Enable the compiler to emit a warning for something like [NSString stringWithFormat:UI_STRING("%d files", "label next to file upload button"), @"not an int"] based on %d not matching the NSString parameter.
Created attachment 243817 [details] Add format_arg attributes to UI_STRING and UI_STRING_KEY
Attachment 243817 [details] did not pass style-queue: ERROR: Source/WebKit/mac/Misc/WebLocalizableStrings.h:47: The parameter name "bundle" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebKit/mac/Misc/WebLocalizableStrings.h:54: The parameter name "bundle" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 2 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 243817 [details] Add format_arg attributes to UI_STRING and UI_STRING_KEY View in context: https://bugs.webkit.org/attachment.cgi?id=243817&action=review > Source/WebKit/mac/ChangeLog:9 > + that takes their "string" parameter as a "value" "parameter and has an attribute telling Extra quote here?
Comment on attachment 243817 [details] Add format_arg attributes to UI_STRING and UI_STRING_KEY View in context: https://bugs.webkit.org/attachment.cgi?id=243817&action=review > Source/WebKit/mac/Misc/WebLocalizableStrings.h:52 > +static inline NS_FORMAT_ARGUMENT(3) NSString *WebLocalizedStringWithValue(WebLocalizableStringsBundle *bundle, const char* key, const char* value) > +{ > + return WebLocalizedString(bundle, key); > +} On reflection, I don’t think it’s good for WebLocalizedStringWithValue inlines to be inside extern "C"; I also don’t like the formatting with the #if right up against the functions, but blank lines between the two functions. I’d move WebLocalizedStringWithValue down below. And I’d even consider using a macro for the NS/CF_FORMAT_ARGUMENT so we don’t have to repeat the WebLocalizedStringWithValue function twice.
(In reply to comment #4) > Comment on attachment 243817 [details] > Add format_arg attributes to UI_STRING and UI_STRING_KEY > > View in context: > https://bugs.webkit.org/attachment.cgi?id=243817&action=review > > > Source/WebKit/mac/Misc/WebLocalizableStrings.h:52 > > +static inline NS_FORMAT_ARGUMENT(3) NSString *WebLocalizedStringWithValue(WebLocalizableStringsBundle *bundle, const char* key, const char* value) > > +{ > > + return WebLocalizedString(bundle, key); > > +} > > On reflection, I don’t think it’s good for WebLocalizedStringWithValue > inlines to be inside extern "C"; I also don’t like the formatting with the > #if right up against the functions, but blank lines between the two > functions. I’d move WebLocalizedStringWithValue down below. OK. > And I’d even > consider using a macro for the NS/CF_FORMAT_ARGUMENT so we don’t have to > repeat the WebLocalizedStringWithValue function twice. Wouldn’t we still need to repeat at least the function signature because of the return types being different?
(In reply to comment #5) > > And I’d even > > consider using a macro for the NS/CF_FORMAT_ARGUMENT so we don’t have to > > repeat the WebLocalizedStringWithValue function twice. > > Wouldn’t we still need to repeat at least the function signature because of > the return types being different? Might need a typedef too, yes.
Committed <http://trac.webkit.org/r177825>.