[vlc-commits] darwinvlc: Use FromCFString
Marvin Scholz
git at videolan.org
Sat Oct 20 20:06:13 CEST 2018
vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Mon Oct 8 10:53:50 2018 +0200| [d75d12bee277760353a4b710f1703d3ef3944b32] | committer: Marvin Scholz
darwinvlc: Use FromCFString
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d75d12bee277760353a4b710f1703d3ef3944b32
---
bin/darwinvlc.m | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/bin/darwinvlc.m b/bin/darwinvlc.m
index 3ba5c6547b..826d60a5ae 100644
--- a/bin/darwinvlc.m
+++ b/bin/darwinvlc.m
@@ -27,6 +27,9 @@
#endif
#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_charset.h>
+
#include <stdlib.h>
#include <locale.h>
#include <signal.h>
@@ -244,21 +247,13 @@ int main(int i_argc, const char *ppsz_argv[])
language = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("language"),
kCFPreferencesCurrentApplication);
if (language) {
- CFIndex length = CFStringGetLength(language) + 1;
- if (length > 0) {
- CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
- lang = (char *)malloc(maxSize);
- if(lang) {
- CFStringGetCString(language, lang, maxSize - 1, kCFStringEncodingUTF8);
- if (strncmp( lang, "auto", 4 )) {
- char tmp[11];
- snprintf(tmp, 11, "LANG=%s", lang);
- putenv(tmp);
-
- }
- }
- free(lang);
+ lang = FromCFString(language, kCFStringEncodingUTF8);
+ if (strncmp( lang, "auto", 4 )) {
+ char tmp[11];
+ snprintf(tmp, 11, "LANG=%s", lang);
+ putenv(tmp);
}
+ free(lang);
CFRelease(language);
}
}
More information about the vlc-commits
mailing list