From 4c1eb9225d5a741e1234d48eb38a8df3da908259 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sun, 21 Mar 2004 21:32:23 +0000 Subject: add aac_decode.[ch] and start working on it also, if locale is C or POSIX, set fs charset to iso-8859-1 git-svn-id: https://svn.musicpd.org/mpd/trunk@347 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/path.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index 5a73baa86..e209b671d 100644 --- a/src/path.c +++ b/src/path.c @@ -87,40 +87,52 @@ char * getFsCharset() { } void initPaths() { -#ifdef HAVE_LOCALE -#ifdef HAVE_LANGINFO - char * originalLocale; -#endif -#endif char * charset = NULL; + char * originalLocale; if(getConf()[CONF_FS_CHARSET]) { charset = strdup(getConf()[CONF_FS_CHARSET]); } #ifdef HAVE_LOCALE #ifdef HAVE_LANGINFO - else if((originalLocale = setlocale(LC_CTYPE,""))) { + else if((originalLocale = setlocale(LC_CTYPE,NULL))) { char * temp; + char * currentLocale; + originalLocale = strdup(originalLocale); - if((temp = nl_langinfo(CODESET))) { - charset = strdup(temp); + if(!(currentLocale = setlocale(LC_CTYPE,""))) { + ERROR("problems setting current locale with " + "setlocale()\n"); } - else ERROR("problems getting charset for locale\n"); - if(!setlocale(LC_CTYPE,originalLocale)) { - ERROR("problems resetting locale with setlocale()\n"); + else { + if(strcmp(currentLocale,"C")==0 || + strcmp(currentLocale,"POSIX")==0) + { + ERROR("current locale is \"%s\"\n", + currentLocale); + } + else if((temp = nl_langinfo(CODESET))) { + charset = strdup(temp); + } + else ERROR("problems getting charset for locale\n"); + if(!setlocale(LC_CTYPE,originalLocale)) { + ERROR("problems resetting locale with setlocale()\n"); + } } + + free(originalLocale); } + else ERROR("problems getting locale with setlocale()\n"); #endif #endif - else ERROR("problems getting locale with setlocale()\n"); if(charset) { setFsCharset(charset); free(charset); } else { - ERROR("setting filesystem charset to UTF-8\n"); - setFsCharset("UTF-8"); + ERROR("setting filesystem charset to ISO-8859-1\n"); + setFsCharset("ISO-8859-1"); } } -- cgit v1.2.3