From 35e90f1556475ee205dee6c253b788ab073133c0 Mon Sep 17 00:00:00 2001 From: albeu Date: Fri, 24 Mar 2006 02:31:29 +0000 Subject: [PATCH] The fix in mp_msg.c avoids a core dump when iconv_open() fails, the other just makes it possible to compile if USE_ICONV is undefined. Patch by Bjorn Sandell (biorn _At_ chalmers _Dot_ se). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17932 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/font_load_ft.c | 9 ++++++++- mp_msg.c | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c index d29ad899a7..2acdce38f5 100644 --- a/libvo/font_load_ft.c +++ b/libvo/font_load_ft.c @@ -18,7 +18,9 @@ #include #include +#ifdef USE_ICONV #include +#endif #include #include FT_FREETYPE_H @@ -731,7 +733,7 @@ int generate_tables(font_desc_t *desc, double thickness, double radius) return 0; } - +#ifdef USE_ICONV /* decode from 'encoding' to unicode */ static FT_ULong decode_char(iconv_t *cd, char c) { FT_ULong o; @@ -830,6 +832,7 @@ static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *ch return i; } +#endif static font_desc_t* init_font_desc(void) { @@ -1015,6 +1018,7 @@ font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height) } desc->face_cnt++; +#ifdef USE_ICONV if (unicode) { charset_size = prepare_charset_unicode(face, my_charset, my_charcodes); } else { @@ -1030,6 +1034,9 @@ font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height) free_font_desc(desc); return NULL; } +#else + return NULL; +#endif // fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t); diff --git a/mp_msg.c b/mp_msg.c index 8439b141d8..5ab75f062c 100644 --- a/mp_msg.c +++ b/mp_msg.c @@ -102,6 +102,10 @@ void mp_msg(int mod, int lev, const char *format, ... ){ msgiconv = iconv_open(mp_msg_charset, MSG_CHARSET); old_charset = strdup(mp_msg_charset); } + if (msgiconv == (iconv_t)(-1)) { + fprintf(stderr,"iconv: conversion from %s to %s unsupported\n" + ,mp_msg_charset,MSG_CHARSET); + }else{ memset(tmp2, 0, MSGSIZE_MAX); while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1) { if (!inlen || !outlen) @@ -112,6 +116,7 @@ void mp_msg(int mod, int lev, const char *format, ... ){ strncpy(tmp, tmp2, MSGSIZE_MAX); tmp[MSGSIZE_MAX-1] = 0; tmp[MSGSIZE_MAX-2] = '\n'; + } } #endif