From: <ny...@us...> - 2006-07-27 16:07:55
|
Revision: 132 Author: nyaochi Date: 2006-07-27 09:07:48 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=132&view=rev Log Message: ----------- Fix for stripping preceding words in artist names: - We must not call any string conversion routine from the option parser since the character encoding has not been decided yet. - The previous implementation could not parse CSV values correctly. Modified Paths: -------------- trunk/frontend/easypmp/common/database.c trunk/frontend/easypmp/common/easypmp.h trunk/frontend/easypmp/cui/main.c trunk/frontend/easypmp/cui/option.c Modified: trunk/frontend/easypmp/common/database.c =================================================================== --- trunk/frontend/easypmp/common/database.c 2006-07-26 15:11:46 UTC (rev 131) +++ trunk/frontend/easypmp/common/database.c 2006-07-27 16:07:48 UTC (rev 132) @@ -429,11 +429,10 @@ memset(opt->strip_words[i], 0, sizeof(ucs2char_t) * (length+1)); ucs2ncpy(opt->strip_words[i], p, length); opt->strip_words[i][length] = 0; - if (!*q) { - break; - } else { + if (*q) { p = q+1; } + break; } q++; } Modified: trunk/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/frontend/easypmp/common/easypmp.h 2006-07-26 15:11:46 UTC (rev 131) +++ trunk/frontend/easypmp/common/easypmp.h 2006-07-27 16:07:48 UTC (rev 132) @@ -91,6 +91,7 @@ char model[128]; char *system_encoding; char *music_encoding; + char *mbs_strip_words; ucs2char_t** strip_words; int num_strip_words; } option_t; Modified: trunk/frontend/easypmp/cui/main.c =================================================================== --- trunk/frontend/easypmp/cui/main.c 2006-07-26 15:11:46 UTC (rev 131) +++ trunk/frontend/easypmp/cui/main.c 2006-07-27 16:07:48 UTC (rev 132) @@ -233,6 +233,13 @@ } #endif/*_WIN32*/ + /* Set words to be stripped from artist names. */ + if (opt.mbs_strip_words) { + ucs2char_t* ucs2str = mbsdupucs2(opt.mbs_strip_words); + easypmp_set_strip_words(&opt, ucs2str); + ucs2free(ucs2str); + } + /* Obtain the path to root directory (path_to_root) from the command line if any. */ if (used_args < argc) { size_t length = strlen(argv[used_args]); Modified: trunk/frontend/easypmp/cui/option.c =================================================================== --- trunk/frontend/easypmp/cui/option.c 2006-07-26 15:11:46 UTC (rev 131) +++ trunk/frontend/easypmp/cui/option.c 2006-07-27 16:07:48 UTC (rev 132) @@ -99,12 +99,6 @@ fprintf(fp, " -h, --help Show this help message and exit\n"); } -static void set_strip_words(option_t* opt, const char *str) -{ - ucs2char_t* ucs2str = mbsdupucs2(str); - easypmp_set_strip_words(opt, ucs2str); -} - static char *get_default_encoding() { const char *encoding = getenv("CHARSET"); @@ -123,9 +117,9 @@ // Set default values here. opt->media_info_source |= (GMIF_TAG | GMIF_STRIP_ARTIST); - set_strip_words(opt, "the "); opt->system_encoding = get_default_encoding(); opt->music_encoding = get_default_encoding(); + opt->mbs_strip_words = strdup("the "); } void option_finish(option_t* opt) @@ -145,7 +139,11 @@ { int used_args = 0; - /* Parse the command-line arguments. */ + /* + * Parse the command-line arguments. + * We must not use the charaset conversion routine from this function + * since the character encoding has not been decided at this moment. + */ for (;;) { int this_option_optind = optind ? optind : 1; int option_index = 0; @@ -210,7 +208,8 @@ opt->repr_level = atoi(optarg); break; case 't': - set_strip_words(opt, optarg); + free(opt->mbs_strip_words); + opt->mbs_strip_words = strdup(optarg); break; case 'p': opt->verb |= (MODE_PLAYLIST | MODE_PLAYLIST_PLAYLIST); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |