[MPlayer-cvslog] r22020 - in trunk: mp_msg.c mp_msg.h mplayer.c
gpoirier
subversion at mplayerhq.hu
Fri Jan 26 10:57:09 CET 2007
Author: gpoirier
Date: Fri Jan 26 10:57:09 2007
New Revision: 22020
Modified:
trunk/mp_msg.c
trunk/mp_msg.h
trunk/mplayer.c
Log:
filename double-conversion, especially usefull for CJK users :-)
Patch by Zuxy Meng <zuxy.meng at gmail.com>
date: Oct 25, 2006 2:20 AM
subject: [MPlayer-dev-eng] [PATCH] Filename double-conversion
Modified: trunk/mp_msg.c
==============================================================================
--- trunk/mp_msg.c (original)
+++ trunk/mp_msg.c Fri Jan 26 10:57:09 2007
@@ -14,6 +14,7 @@
#endif
#ifdef USE_ICONV
#include <iconv.h>
+#include <errno.h>
#endif
#if defined(FOR_MENCODER) || defined(CODECS2HTML)
@@ -38,6 +39,36 @@
static iconv_t msgiconv;
#endif
+const char* filename_recode(const char* filename)
+{
+#if !defined(USE_ICONV) || !defined(MSG_CHARSET)
+ return filename;
+#else
+ static iconv_t inv_msgiconv = (iconv_t)(-1);
+ static char recoded_filename[MSGSIZE_MAX];
+ size_t filename_len, max_path;
+ char* precoded;
+ if (!strcasecmp(mp_msg_charset, MSG_CHARSET) ||
+ !strcasecmp(mp_msg_charset, "noconv"))
+ return filename;
+ if (inv_msgiconv == (iconv_t)(-1)) {
+ inv_msgiconv = iconv_open(MSG_CHARSET, mp_msg_charset);
+ if (inv_msgiconv == (iconv_t)(-1))
+ return filename;
+ }
+ filename_len = strlen(filename);
+ max_path = MSGSIZE_MAX - 4;
+ precoded = recoded_filename;
+ if (iconv(inv_msgiconv, &filename, &filename_len,
+ &precoded, &max_path) == (size_t)(-1) && errno == E2BIG) {
+ precoded[0] = precoded[1] = precoded[2] = '.';
+ precoded += 3;
+ }
+ *precoded = '\0';
+ return recoded_filename;
+#endif
+}
+
void mp_msg_init(void){
int i;
char *env = getenv("MPLAYER_VERBOSE");
Modified: trunk/mp_msg.h
==============================================================================
--- trunk/mp_msg.h (original)
+++ trunk/mp_msg.h Fri Jan 26 10:57:09 2007
@@ -132,6 +132,7 @@
# endif
#endif
+const char* filename_recode(const char* filename);
#endif
#endif
Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c (original)
+++ trunk/mplayer.c Fri Jan 26 10:57:09 2007
@@ -995,7 +995,8 @@
#else
if(!subd && !silent)
#endif
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub, filename);
+ mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub,
+ filename_recode(filename));
#ifdef USE_ASS
if (!asst && !subd) return;
@@ -1005,9 +1006,11 @@
#endif
set_of_subtitles[set_of_sub_size] = subd;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_ID=%d\n", set_of_sub_size);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n", filename);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n",
+ filename_recode(filename));
++set_of_sub_size;
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, set_of_sub_size, filename);
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, set_of_sub_size,
+ filename_recode(filename));
}
// FIXME: if/when the GUI calls this, global sub numbering gets (potentially) broken.
@@ -3824,7 +3827,8 @@
#ifdef HAVE_BITMAP_FONT
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
- if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+ if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,
+ filename_recode(font_name));
} else {
// try default:
vo_font=read_font_desc( mem_ptr=get_path("font/font.desc"),font_factor,verbose>1);
@@ -4076,7 +4080,9 @@
}
//---------------------------------------------------------------------------
- if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);
+ if(filename)
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing,
+ filename_recode(filename));
if (edl_filename) {
if (edl_records) free_edl(edl_records);
@@ -4087,7 +4093,7 @@
if ((edl_fd = fopen(edl_output_filename, "w")) == NULL)
{
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite,
- edl_output_filename);
+ filename_recode(edl_output_filename));
}
}
@@ -4097,7 +4103,8 @@
if (vobsub_name){
vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec);
if(vo_vobsub==NULL)
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name);
+ mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,
+ filename_recode(vobsub_name));
}else if(sub_auto && filename && (strlen(filename)>=5)){
/* try to autodetect vobsub from movie filename ::atmos */
char *buf = malloc((strlen(filename)-3)),*psub;
@@ -4164,7 +4171,8 @@
play_tree_t* entry;
// Handle playlist
current_module="handle_playlist";
- mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",filename);
+ mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",
+ filename_recode(filename));
entry = parse_playtree(stream,0);
eof=playtree_add_playlist(entry);
goto goto_next_file;
@@ -4257,7 +4265,8 @@
{
char *temp, *bname;
- mp_msg(MSGT_CPLAYER,MSGL_V,"Adding file %s to element entry.\n",playlist_entry);
+ mp_msg(MSGT_CPLAYER,MSGL_V,"Adding file %s to element entry.\n",
+ filename_recode(playlist_entry));
bname=mp_basename(playlist_entry);
if ((strlen(bname)>10) && !strncmp(bname,"qt",2) && !strncmp(bname+3,"gateQT",6))
@@ -4511,7 +4520,8 @@
}
}
- mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n", filename);
+ mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n",
+ filename_recode(filename));
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_DEMUXER=%s\n", demuxer->desc->name);
if (sh_video) {
/* Assume FOURCC if all bytes >= 0x20 (' ') */
@@ -5253,7 +5263,8 @@
if (v < 0) {
for (v = 0; v < set_of_sub_size; ++v) {
subd = set_of_subtitles[v];
- mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename);
+ mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
+ filename_recode(subd->filename));
sub_free(subd);
set_of_subtitles[v] = NULL;
}
@@ -5270,7 +5281,8 @@
}
else if (v < set_of_sub_size) {
subd = set_of_subtitles[v];
- mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename);
+ mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
+ filename_recode(subd->filename));
sub_free(subd);
if (set_of_sub_pos == v) {
global_sub_pos = -2;
More information about the MPlayer-cvslog
mailing list