[vlc-commits] bin/darwinvlc: fix l10n preferences lookup code

Felix Paul Kühne git at videolan.org
Sun Nov 10 01:13:02 CET 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Nov 10 01:12:54 2013 +0100| [a24db0a78bd552ae26f8e3aab3a3dff8f41e7cbb] | committer: Felix Paul Kühne

bin/darwinvlc: fix l10n preferences lookup code

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a24db0a78bd552ae26f8e3aab3a3dff8f41e7cbb
---

 bin/darwinvlc.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/bin/darwinvlc.c b/bin/darwinvlc.c
index 4b6847a..33bb4f3 100644
--- a/bin/darwinvlc.c
+++ b/bin/darwinvlc.c
@@ -168,23 +168,29 @@ int main( int i_argc, const char *ppsz_argv[] )
             continue;
         }
     }
+    if (lang && strncmp( lang, "auto", 4 )) {
+        char tmp[11];
+        snprintf(tmp, 11, "LANG%s", lang);
+        putenv(tmp);
+    }
 
     if (!lang) {
         CFStringRef language;
         language = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("language"),
                                                           kCFPreferencesCurrentApplication);
         if (language) {
-            if (CFStringGetLength(language) > 0)
-                lang = (char *)CFStringGetCStringPtr(language, kCFStringEncodingUTF8);
+            CFIndex length = CFStringGetLength(language) + 1;
+            if (length > 0) {
+                CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
+                lang = (char *)malloc(maxSize);
+                CFStringGetCString(language, lang, maxSize - 1, kCFStringEncodingUTF8);
+            }
+            char tmp[11];
+            snprintf(tmp, 11, "LANG=%s", lang);
+            putenv(tmp);
             CFRelease(language);
         }
     }
-
-    if (lang && strncmp( lang, "auto", 4 )) {
-        char tmp[11];
-        snprintf(tmp, 11, "LANG%s", lang);
-        putenv(tmp);
-    }
 #endif
 
     ppsz_argv++; i_argc--; /* skip executable path */



More information about the vlc-commits mailing list