mp_msg: remove filename_recode

This was intended for translating filenames from filesystem charset to
the terminal charset. Modern sane platforms use UTF-8 for everything,
and on Windows we use unicode APIs, so this is not needed anymore.

Remove filename_recode, all uses of it, options and configure checks
related to terminal output charset, and code that tries to determine
the same.
This commit is contained in:
wm4 2012-07-31 01:35:53 +02:00
parent c78ba1c55c
commit 6e020e66e0
10 changed files with 13 additions and 215 deletions

View File

@ -43,7 +43,6 @@ extern char *lirc_configfile;
extern char *vo_geometry;
extern int stop_xscreensaver;
extern char *mp_msg_charset;
extern int mp_msg_color;
extern int mp_msg_module;
@ -365,9 +364,6 @@ const m_option_t common_opts[] = {
{"msglevel", (void *) msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
{"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"msgmodule", &mp_msg_module, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
#ifdef CONFIG_ICONV
{"msgcharset", &mp_msg_charset, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
#endif
#ifdef CONFIG_PRIORITY
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif

View File

@ -2738,8 +2738,7 @@ static void remove_subtitle_range(MPContext *mpctx, int start, int count)
filename = ass_tracks[idx]->name;
#endif
mp_msg(MSGT_CPLAYER, MSGL_STATUS,
"SUB: Removed subtitle file (%d): %s\n", idx + 1,
filename_recode(filename));
"SUB: Removed subtitle file (%d): %s\n", idx + 1, filename);
sub_free(subd);
subs[idx] = NULL;
#ifdef CONFIG_ASS

32
configure vendored
View File

@ -292,7 +292,6 @@ Optional features:
--enable-termcap use termcap database for key codes [autodetect]
--enable-termios use termios database for key codes [autodetect]
--disable-iconv disable iconv for encoding conversion [autodetect]
--disable-langinfo do not use langinfo [autodetect]
--enable-lirc enable LIRC (remote control) support [autodetect]
--enable-lircc enable LIRCCD (LIRC client daemon) input [autodetect]
--enable-joystick enable joystick support [disable]
@ -394,7 +393,6 @@ Audio output:
Language options:
--enable-translation enable support for translated output [disable]
--charset=charset convert the console messages to this character set
--language-doc=lang language to use for the documentation [en]
--language-man=lang language to use for the man pages [en]
--language-msg=lang extra languages for program messages [all]
@ -475,7 +473,6 @@ _caca=auto
_dvb=auto
_v4l2=auto
_iconv=auto
_langinfo=auto
_ossaudio=auto
_rsound=auto
_pulse=auto
@ -537,7 +534,6 @@ _directfb=auto
#language=en
_shm=auto
_translation=no
_charset="UTF-8"
_libdv=auto
_cdda=auto
_cddb=auto
@ -635,9 +631,6 @@ for ac_option do
--windres=*)
_windres=$(echo $ac_option | cut -d '=' -f 2)
;;
--charset=*)
_charset=$(echo $ac_option | cut -d '=' -f 2)
;;
--language-doc=*)
language_doc=$(echo $ac_option | cut -d '=' -f 2)
;;
@ -716,8 +709,6 @@ for ac_option do
--disable-v4l2) _v4l2=no ;;
--enable-iconv) _iconv=yes ;;
--disable-iconv) _iconv=no ;;
--enable-langinfo) _langinfo=yes ;;
--disable-langinfo) _langinfo=no ;;
--enable-libdv) _libdv=yes ;;
--disable-libdv) _libdv=no ;;
--enable-ossaudio) _ossaudio=yes ;;
@ -1388,19 +1379,6 @@ else
fi
echocheck "langinfo"
if test "$_langinfo" = auto ; then
_langinfo=no
statement_check langinfo.h 'nl_langinfo(CODESET)' && _langinfo=yes
fi
if test "$_langinfo" = yes ; then
def_langinfo='#define HAVE_LANGINFO 1'
else
def_langinfo='#undef HAVE_LANGINFO'
fi
echores "$_langinfo"
echocheck "translation support"
if test "$_translation" = yes; then
def_translation="#define CONFIG_TRANSLATION 1"
@ -3939,13 +3917,6 @@ fi
echores "$_sortsub"
if test "$_charset" != "noconv" ; then
def_charset="#define MSG_CHARSET \"$_charset\""
else
def_charset="#undef MSG_CHARSET"
_charset="UTF-8"
fi
#############################################################################
echocheck "compiler support for noexecstack"
@ -4087,7 +4058,6 @@ export LC_ALL = C
CONFIGURATION = $configuration
CHARSET = $_charset
DOC_LANGS = $language_doc
DOC_LANG_ALL = $doc_lang_all
MAN_LANGS = $language_man
@ -4334,7 +4304,6 @@ $def_winsock2_h
$def_gethostbyname2
$def_gettimeofday
$def_glob
$def_langinfo
$def_lrintf
$def_nanosleep
$def_posix_select
@ -4366,7 +4335,6 @@ $def_restrict_keyword
/* configurable options */
$def_charset
$def_debug
$def_sortsub
$def_stream_cache

View File

@ -30,11 +30,6 @@
#include <libintl.h>
#endif
#ifdef CONFIG_ICONV
#include <iconv.h>
#include <errno.h>
#endif
#include "mp_msg.h"
/* maximum message length of mp_msg */
@ -66,42 +61,6 @@ int mp_msg_level_all = MSGL_STATUS;
int verbose = 0;
int mp_msg_color = 0;
int mp_msg_module = 0;
#ifdef CONFIG_ICONV
char *mp_msg_charset = NULL;
static char *old_charset = NULL;
static iconv_t msgiconv;
#endif
const char* filename_recode(const char* filename)
{
#if !defined(CONFIG_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 (!mp_msg_charset ||
!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, (char **)&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){
#ifdef _WIN32
@ -120,15 +79,6 @@ void mp_msg_init(void){
verbose = atoi(env);
for(i=0;i<MSGT_MAX;i++) mp_msg_levels[i] = -2;
mp_msg_levels[MSGT_IDENTIFY] = -1; // no -identify output by default
#ifdef CONFIG_ICONV
mp_msg_charset = getenv("MPLAYER_CHARSET");
if (!mp_msg_charset)
#ifdef _WIN32
mp_msg_charset = "UTF-8";
#else
mp_msg_charset = get_term_charset();
#endif
#endif
#ifdef CONFIG_TRANSLATION
textdomain("mplayer");
char *localedir = getenv("MPLAYER_LOCALEDIR");
@ -254,47 +204,6 @@ void mp_msg_va(int mod, int lev, const char *format, va_list va)
tmp[MSGSIZE_MAX-2] = '\n';
tmp[MSGSIZE_MAX-1] = 0;
#if defined(CONFIG_ICONV) && defined(MSG_CHARSET)
if (mp_msg_charset && strcasecmp(mp_msg_charset, "noconv"))
{
char tmp2[MSGSIZE_MAX];
size_t inlen = strlen(tmp), outlen = MSGSIZE_MAX;
char *in = tmp, *out = tmp2;
if (!old_charset || strcmp(old_charset, mp_msg_charset))
{
if (old_charset)
{
free(old_charset);
iconv_close(msgiconv);
}
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"
,MSG_CHARSET,mp_msg_charset);
}
else
{
memset(tmp2, 0, MSGSIZE_MAX);
while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1)
{
if (!inlen || !outlen)
break;
*out++ = *in++;
outlen--; inlen--;
}
strncpy(tmp, tmp2, MSGSIZE_MAX);
tmp[MSGSIZE_MAX-1] = 0;
tmp[MSGSIZE_MAX-2] = '\n';
}
}
#endif
/* A status line is normally intended to be overwritten by the next
* status line, and does not end with a '\n'. If we're printing a normal
* line instead after the status one print '\n' to change line. */

View File

@ -140,6 +140,4 @@ void mp_msg(int mod, int lev, const char *format, ... ) PRINTF_ATTRIBUTE(3, 4);
void mp_tmsg(int mod, int lev, const char *format, ... ) PRINTF_ATTRIBUTE(3, 4);
#define mp_dbg mp_msg
const char* filename_recode(const char* filename);
#endif /* MPLAYER_MP_MSG_H */

View File

@ -448,7 +448,7 @@ static void print_file_properties(struct MPContext *mpctx, const char *filename)
double start_pts = MP_NOPTS_VALUE;
double video_start_pts = MP_NOPTS_VALUE;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILENAME=%s\n",
filename_recode(filename));
filename);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_DEMUXER=%s\n",
mpctx->demuxer->desc->name);
if (mpctx->sh_video) {
@ -968,7 +968,7 @@ void add_subtitles(struct MPContext *mpctx, char *filename, float fps,
if (!asst && !subd) {
mp_tmsg(MSGT_CPLAYER, noerr ? MSGL_WARN : MSGL_ERR,
"Cannot load subtitles: %s\n", filename_recode(filename));
"Cannot load subtitles: %s\n", filename);
return;
}
@ -977,11 +977,10 @@ void add_subtitles(struct MPContext *mpctx, char *filename, float fps,
mpctx->track_was_native_ass[mpctx->set_of_sub_size] = is_native_ass;
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
"ID_FILE_SUB_ID=%d\n", mpctx->set_of_sub_size);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n",
filename_recode(filename));
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n", filename);
++mpctx->set_of_sub_size;
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "SUB: Added subtitle file (%d): %s\n",
mpctx->set_of_sub_size, filename_recode(filename));
mpctx->set_of_sub_size, filename);
}
void init_vo_spudec(struct MPContext *mpctx)
@ -3862,8 +3861,7 @@ play_next_file:
vo_control(mpctx->video_out, VOCTRL_RESUME, NULL);
if (mpctx->filename) {
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Playing %s.\n",
filename_recode(mpctx->filename));
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Playing %s.\n", mpctx->filename);
if (use_filename_title && opts->vo_wintitle == NULL)
opts->vo_wintitle = talloc_strdup(NULL,
mp_basename(mpctx->filename));
@ -3875,7 +3873,7 @@ play_next_file:
if ((edl_fd = fopen(edl_output_filename, "w")) == NULL) {
mp_tmsg(MSGT_CPLAYER, MSGL_ERR,
"Can't open EDL file [%s] for writing.\n",
filename_recode(edl_output_filename));
edl_output_filename);
}
}
@ -3885,7 +3883,7 @@ play_next_file:
vo_vobsub = vobsub_open(opts->vobsub_name, spudec_ifo, 1, &vo_spudec);
if (vo_vobsub == NULL)
mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Cannot load subtitles: %s\n",
filename_recode(opts->vobsub_name));
opts->vobsub_name);
} else if (opts->sub_auto && mpctx->filename) {
char **vob = find_vob_subtitles(opts, mpctx->filename);
for (int i = 0; i < MP_TALLOC_ELEMS(vob); i++) {
@ -3932,7 +3930,7 @@ play_next_file:
play_tree_t *entry;
// Handle playlist
mp_msg(MSGT_CPLAYER, MSGL_V, "Parsing playlist %s...\n",
filename_recode(mpctx->filename));
mpctx->filename);
entry = parse_playtree(mpctx->stream, mpctx->mconfig, 0);
mpctx->eof = playtree_add_playlist(mpctx, entry);
goto goto_next_file;
@ -3997,7 +3995,7 @@ goto_enable_cache:
const char *bname;
mp_msg(MSGT_CPLAYER, MSGL_V, "Adding file %s to element entry.\n",
filename_recode(playlist_entry));
playlist_entry);
bname = mp_basename(playlist_entry);
if ((strlen(bname) > 10) && !strncmp(bname, "qt", 2) &&
@ -4072,7 +4070,7 @@ goto_enable_cache:
mp_msg(MSGT_CPLAYER, MSGL_V, "Source files:\n");
for (int i = 0; i < mpctx->num_sources; i++)
mp_msg(MSGT_CPLAYER, MSGL_V, "%d: %s\n", i,
filename_recode(mpctx->sources[i].demuxer->filename));
mpctx->sources[i].demuxer->filename);
mp_msg(MSGT_CPLAYER, MSGL_V, "Timeline parts: (number, start, "
"source_start, source):\n");
for (int i = 0; i < part_count; i++) {

View File

@ -183,43 +183,3 @@ void getch2_disable(void)
if(!getch2_status) return; // already disabled / never enabled
getch2_status=0;
}
#ifdef CONFIG_ICONV
static const struct {
unsigned cp;
char* alias;
} cp_alias[] = {
{ 20127, "ASCII" },
{ 20866, "KOI8-R" },
{ 21866, "KOI8-RU" },
{ 28591, "ISO-8859-1" },
{ 28592, "ISO-8859-2" },
{ 28593, "ISO-8859-3" },
{ 28594, "ISO-8859-4" },
{ 28595, "ISO-8859-5" },
{ 28596, "ISO-8859-6" },
{ 28597, "ISO-8859-7" },
{ 28598, "ISO-8859-8" },
{ 28599, "ISO-8859-9" },
{ 28605, "ISO-8859-15" },
{ 65001, "UTF-8" },
{ 0, NULL }
};
char* get_term_charset(void)
{
char codepage[10];
unsigned i, cpno = GetConsoleOutputCP();
if (!cpno)
cpno = GetACP();
if (!cpno)
return NULL;
for (i = 0; cp_alias[i].cp; i++)
if (cpno == cp_alias[i].cp)
return strdup(cp_alias[i].alias);
snprintf(codepage, sizeof(codepage), "CP%u", cpno);
return strdup(codepage);
}
#endif

View File

@ -50,11 +50,6 @@
#endif
#endif
#if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV)
#include <locale.h>
#include <langinfo.h>
#endif
#include <unistd.h>
#include <fcntl.h>
@ -325,16 +320,3 @@ void getch2_disable(void){
tcsetattr(0,TCSANOW,&tio_orig);
#endif
}
#ifdef CONFIG_ICONV
char* get_term_charset(void)
{
char* charset = NULL;
#ifdef HAVE_LANGINFO
setlocale(LC_CTYPE, "");
charset = strdup(nl_langinfo(CODESET));
setlocale(LC_CTYPE, "C");
#endif
return charset;
}
#endif

View File

@ -49,17 +49,6 @@ void getch2_disable(void);
struct mp_fifo;
bool getch2(struct mp_fifo *fifo);
#ifdef CONFIG_ICONV
/**
* \brief gets the name of the system's terminal character set
* \return a malloced string indicating the system charset
*
* Be warned that this function on many systems is in no way thread-safe
* since it modifies global data
*/
char *get_term_charset(void);
#endif
#if defined(__MINGW32__)
// slave cmd function for Windows
int mp_input_slave_cmd_func(int fd,char* dest,int size);

View File

@ -135,8 +135,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
int num_left = num_sources - 1;
for (int i = 0; i < num_filenames && num_left > 0; i++) {
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Checking file %s\n",
filename_recode(filenames[i]));
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Checking file %s\n", filenames[i]);
int format = 0;
struct stream *s = open_stream(filenames[i], &mpctx->opts, &format);
if (!s)
@ -157,7 +156,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
continue;
if (!memcmp(uid_map[i], d->matroska_data.segment_uid, 16)) {
mp_msg(MSGT_CPLAYER, MSGL_INFO,"Match for source %d: %s\n",
i, filename_recode(d->filename));
i, d->filename);
sources[i].stream = s;
sources[i].demuxer = d;
num_left--;