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

Felix Paul Kühne git at videolan.org
Sun Nov 10 11:09:55 CET 2013


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

bin/darwinvlc: fix l10n preferences lookup code

(cherry picked from commit a24db0a78bd552ae26f8e3aab3a3dff8f41e7cbb)

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

 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