Changeset 177825 in webkit
- Timestamp:
- Dec 30, 2014 12:43:00 PM (9 years ago)
- Location:
- trunk/Source/WebKit/mac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/mac/ChangeLog
r177817 r177825 1 2014-12-30 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Enable the compiler to check format strings specified with UI_STRING and UI_STRING_KEY 4 https://bugs.webkit.org/show_bug.cgi?id=140003 5 6 Reviewed by Darin Adler. 7 8 * Misc/WebLocalizableStrings.h: Made UI_STRING and UI_STRING_KEY call a new helper function 9 that takes their "string" parameter as a "value" "parameter and has an attribute telling 10 the compiler that if the "value" parameter is a format string then the function returns a 11 modified version of it. The result is that if UI_STRING is used as a format string parameter 12 to some function or method, the compiler will check the format specifiers in the string 13 against the other parameters. 14 1 15 2014-12-29 Dan Bernstein <mitz@apple.com> 2 16 -
trunk/Source/WebKit/mac/Misc/WebLocalizableStrings.h
r165676 r177825 29 29 #if __OBJC__ 30 30 @class NSBundle; 31 #elif __cplusplus 31 typedef NSString *WebLocalizedStringType; 32 #else 33 #if __cplusplus 32 34 class NSBundle; 33 35 #else 34 36 typedef struct NSBundle NSBundle; 37 #endif 38 typedef CFStringRef WebLocalizedStringType; 35 39 #endif 36 40 … … 44 48 #endif 45 49 46 #if __OBJC__ 47 NSString *WebLocalizedString(WebLocalizableStringsBundle *bundle, const char *key); 48 #else 49 CFStringRef WebLocalizedString(WebLocalizableStringsBundle *bundle, const char *key); 50 #endif 50 WebLocalizedStringType WebLocalizedString(WebLocalizableStringsBundle* bundle, const char* key); 51 51 52 52 #if TARGET_OS_IPHONE … … 58 58 #endif 59 59 60 static inline __attribute__((format_arg(3))) WebLocalizedStringType WebLocalizedStringWithValue(WebLocalizableStringsBundle* bundle, const char* key, const char* value) 61 { 62 return WebLocalizedString(bundle, key); 63 } 64 60 65 #ifdef FRAMEWORK_NAME 61 66 … … 64 69 extern WebLocalizableStringsBundle LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME); 65 70 66 #define UI_STRING(string, comment) WebLocalizedString (&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), string)67 #define UI_STRING_KEY(string, key, comment) WebLocalizedString (&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), key)71 #define UI_STRING(string, comment) WebLocalizedStringWithValue(&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), string, string) 72 #define UI_STRING_KEY(string, key, comment) WebLocalizedStringWithValue(&LOCALIZABLE_STRINGS_BUNDLE(FRAMEWORK_NAME), key, string) 68 73 69 74 #else 70 75 71 #define UI_STRING(string, comment) WebLocalizedString (0, string)72 #define UI_STRING_KEY(string, key, comment) WebLocalizedString (0, key)76 #define UI_STRING(string, comment) WebLocalizedStringWithValue(0, string, string) 77 #define UI_STRING_KEY(string, key, comment) WebLocalizedStringWithValue(0, key, string) 73 78 74 79 #endif
Note: See TracChangeset
for help on using the changeset viewer.