mirror of
https://github.com/mpv-player/mpv
synced 2025-04-06 17:43:02 +00:00
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
This commit is contained in:
parent
b7e160dbe9
commit
35e90f1556
@ -18,7 +18,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef USE_ICONV
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
@ -731,7 +733,7 @@ int generate_tables(font_desc_t *desc, double thickness, double radius)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ICONV
|
||||||
/* decode from 'encoding' to unicode */
|
/* decode from 'encoding' to unicode */
|
||||||
static FT_ULong decode_char(iconv_t *cd, char c) {
|
static FT_ULong decode_char(iconv_t *cd, char c) {
|
||||||
FT_ULong o;
|
FT_ULong o;
|
||||||
@ -830,6 +832,7 @@ static int prepare_charset_unicode(FT_Face face, FT_ULong *charset, FT_ULong *ch
|
|||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static font_desc_t* init_font_desc(void)
|
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++;
|
desc->face_cnt++;
|
||||||
|
|
||||||
|
#ifdef USE_ICONV
|
||||||
if (unicode) {
|
if (unicode) {
|
||||||
charset_size = prepare_charset_unicode(face, my_charset, my_charcodes);
|
charset_size = prepare_charset_unicode(face, my_charset, my_charcodes);
|
||||||
} else {
|
} else {
|
||||||
@ -1030,6 +1034,9 @@ font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height)
|
|||||||
free_font_desc(desc);
|
free_font_desc(desc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
// fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t);
|
// fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t);
|
||||||
|
|
||||||
|
5
mp_msg.c
5
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);
|
msgiconv = iconv_open(mp_msg_charset, MSG_CHARSET);
|
||||||
old_charset = strdup(mp_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);
|
memset(tmp2, 0, MSGSIZE_MAX);
|
||||||
while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1) {
|
while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1) {
|
||||||
if (!inlen || !outlen)
|
if (!inlen || !outlen)
|
||||||
@ -113,6 +117,7 @@ void mp_msg(int mod, int lev, const char *format, ... ){
|
|||||||
tmp[MSGSIZE_MAX-1] = 0;
|
tmp[MSGSIZE_MAX-1] = 0;
|
||||||
tmp[MSGSIZE_MAX-2] = '\n';
|
tmp[MSGSIZE_MAX-2] = '\n';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MSG_USE_COLORS
|
#ifdef MSG_USE_COLORS
|
||||||
|
Loading…
Reference in New Issue
Block a user