From: <ny...@us...> - 2007-02-11 16:59:22
|
Revision: 336 http://svn.sourceforge.net/pmplib/?rev=336&view=rev Author: nyaochi Date: 2007-02-11 08:59:22 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Bug-fix in ucs2init() and ucs2setenc() Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/main.c trunk/pmplib/frontend/easypmp/cui/option.c trunk/pmplib/frontend/easypmp/cui/util.c trunk/pmplib/frontend/easypmp/cui/util.h trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/frontend/easypmp/cui/main.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-11 15:56:15 UTC (rev 335) +++ trunk/pmplib/frontend/easypmp/cui/main.c 2007-02-11 16:59:22 UTC (rev 336) @@ -204,7 +204,8 @@ // Initialize various routines. setlocale(LC_ALL, ""); - console_init(); + ucs2init(); + console_init(); // Initialize option values. option_init(&opt); @@ -356,7 +357,10 @@ // Enumerate music files for database and playlist modes. memset(&musics, 0, sizeof(musics)); if ((opt.verb & MODE_DATABASE) || (opt.verb & MODE_PLAYLIST)) { - fprintf(fpo, "Enumerating music files\n"); + fprintf(fpo, "Enumerating music files in "); + fputucs2str_path(fpo, pmp->info.path_to_root); + fputucs2str_path(fpo, pmp->info.path_to_music); + fprintf(fpo, "\n"); easypmp_enumerate_music(&musics, pmp, &opt, easypmp_enumerate_progress, NULL); console_clearln(fpo); fprintf(fpo, " %d music files were found\n", musics.num_elements); @@ -366,7 +370,14 @@ // Enumerate playlist files for playlist mode. memset(&playlists, 0, sizeof(playlists)); if (opt.verb & MODE_PLAYLIST) { - fprintf(fpe, "Enumerating playlist files\n"); + fprintf(fpe, "Enumerating playlist files in "); + if (opt.path_to_playlist_source) { + fprints(fpo, "%s", opt.path_to_playlist_source); + } else { + fputucs2str_path(fpo, pmp->info.path_to_root); + fputucs2str_path(fpo, pmp->info.path_to_playlist); + } + fprintf(fpo, "\n"); easypmp_enumerate_playlist(&playlists, pmp, &opt, easypmp_enumerate_progress, NULL); console_clearln(fpo); fprintf(fpo, " %d playlist files were found\n", playlists.num_elements); Modified: trunk/pmplib/frontend/easypmp/cui/option.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/option.c 2007-02-11 15:56:15 UTC (rev 335) +++ trunk/pmplib/frontend/easypmp/cui/option.c 2007-02-11 16:59:22 UTC (rev 336) @@ -78,9 +78,6 @@ fprintf(fp, " -r, --reconvert Discard the existing playlist files and reconvert\n"); fprintf(fp, " -f, --find-missing Correct playlists with corrupt references to media files\n"); fprintf(fp, " -i, --ignore-missing Continue a conversion even if a media file is missing\n"); -#ifdef HAVE_JSAPI_H - fprintf(fp, " -j, --jspl Enable JavaScript playlist (JSPL)\n"); -#endif fprintf(fp, "\n"); fprintf(fp, "Player options:\n"); fprintf(fp, " -l, --list-device Show the list of supported devices and exit\n"); Modified: trunk/pmplib/frontend/easypmp/cui/util.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/util.c 2007-02-11 15:56:15 UTC (rev 335) +++ trunk/pmplib/frontend/easypmp/cui/util.c 2007-02-11 16:59:22 UTC (rev 336) @@ -22,15 +22,6 @@ /* $Id$ */ -/** - * @file - * Utility functions for the easypmp command line program (mostly - * display related). - * - * @addtogroup cui - * @{ - */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif/*HAVE_CONFIG_H*/ @@ -103,4 +94,17 @@ } } -/** @} */ +void fputucs2str_path(FILE *fp, const ucs2char_t* str) +{ + while (*str) { + ucs2char_t c = *str; + if (c == 0x005C) { + c = PATHCHAR; + } + if (c == 0x002F) { + c = PATHCHAR; + } + fputucs2c(c, fp); + str++; + } +} Modified: trunk/pmplib/frontend/easypmp/cui/util.h =================================================================== --- trunk/pmplib/frontend/easypmp/cui/util.h 2007-02-11 15:56:15 UTC (rev 335) +++ trunk/pmplib/frontend/easypmp/cui/util.h 2007-02-11 16:59:22 UTC (rev 336) @@ -35,6 +35,7 @@ void clear_line(FILE *fp); void fprints(FILE *fp, const char *format, const ucs2char_t* value); void fprints_fixed(FILE *fp, const char *format, const ucs2char_t* value, size_t length); +void fputucs2str_path(FILE *fp, const ucs2char_t* str); /** @} */ Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-11 15:56:15 UTC (rev 335) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-02-11 16:59:22 UTC (rev 336) @@ -65,18 +65,6 @@ static char g_encoding[128]; static char g_ucs2encoding[128]; -static char *get_default_encoding() -{ - const char *encoding = getenv("CHARSET"); - -#ifdef HAVE_LANGINFO_CODESET - if (!encoding) { - encoding = nl_langinfo(CODESET); - } -#endif - return encoding ? strdup(encoding) : strdup(MBS_CHARSET); -} - static void print_ucs2(const ucs2char_t* str) { while (*str) { @@ -102,7 +90,18 @@ int ucs2init() { - strcpy(g_encoding, MBS_CHARSET); + ucs2conv_t conv; + const char *encoding = getenv("CHARSET"); + +#ifdef HAVE_LANGINFO_CODESET + if (!encoding) { + encoding = nl_langinfo(CODESET); + } +#endif + + strcpy(g_encoding, encoding ? encoding : MBS_CHARSET); + strcpy(g_ucs2encoding, get_ucs2encoding()); + return ucs2check(&conv); } static int ucs2check(ucs2conv_t* conv) @@ -142,8 +141,9 @@ { int ret = 0; ucs2conv_t conv; + memset(g_encoding, 0, sizeof(g_encoding)); strncpy(g_encoding, encoding, sizeof(g_encoding)); - strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); + strcpy(g_ucs2encoding, get_ucs2encoding()); return ucs2check(&conv); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |