[vlc-commits] macosx: clean-up string utility

Felix Paul Kühne git at videolan.org
Fri May 16 22:34:56 CEST 2014


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri May 16 22:20:13 2014 +0200| [1fd91c3b1967dd4843de7575c40170435293e62d] | committer: Felix Paul Kühne

macosx: clean-up string utility

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

 modules/gui/macosx/StringUtility.h |    7 ++-----
 modules/gui/macosx/StringUtility.m |   25 +++++++++++++++----------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/modules/gui/macosx/StringUtility.h b/modules/gui/macosx/StringUtility.h
index f941ffb..5e4024e 100644
--- a/modules/gui/macosx/StringUtility.h
+++ b/modules/gui/macosx/StringUtility.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * StringUtility.h: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * Copyright (C) 2002-2014 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
@@ -35,10 +35,7 @@
 #define B64DecNSStr(s) [[VLCStringUtility sharedInstance] b64Decode: s]
 #define B64EncAndFree(s) [[VLCStringUtility sharedInstance] b64EncodeAndFree: s]
 
-inline NSString *toNSStr(const char *str) {
-    return str != NULL ? [NSString stringWithUTF8String:str] : @"";
-}
-
+NSString *toNSStr(const char *str);
 unsigned int CocoaKeyToVLC(unichar i_key);
 
 @interface VLCStringUtility : NSObject
diff --git a/modules/gui/macosx/StringUtility.m b/modules/gui/macosx/StringUtility.m
index 529dee1..68b96ed 100644
--- a/modules/gui/macosx/StringUtility.m
+++ b/modules/gui/macosx/StringUtility.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * StringUtility.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * Copyright (C) 2002-2014 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
@@ -55,24 +55,23 @@ static VLCStringUtility *_o_sharedInstance = nil;
 
 - (NSString *)localizedString:(const char *)psz
 {
-    NSString * o_str = nil;
+    NSString * stringObject = nil;
 
     if (psz != NULL) {
-        o_str = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding];
+        stringObject = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding];
 
-        if (o_str == NULL) {
+        if (stringObject == NULL) {
             msg_Err(VLCIntf, "could not translate: %s", psz);
-            return(@"");
+            return @"";
         }
-    } else {
-        return(@"");
-    }
+    } else
+        return @"";
 
-    return(o_str);
+    return stringObject;
 }
 
 /* i_width is in pixels */
-- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width
+- (NSString *)wrapString:(NSString *)o_in_string toWidth:(int)i_width
 {
     NSMutableString *o_wrapped;
     NSString *o_out_string;
@@ -208,6 +207,12 @@ unsigned int CocoaKeyToVLC(unichar i_key)
     return (unsigned int)i_key;
 }
 
+/* takes a good old const c string and converts it to NSString without UTF8 loss */
+
+NSString *toNSStr(const char *str) {
+    return str != NULL ? [NSString stringWithUTF8String:str] : @"";
+}
+
 /*
  * Converts VLC key string to a prettified version, for hotkey settings.
  * The returned string adapts similar how its done within the cocoa framework when setting this



More information about the vlc-commits mailing list