Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 24 Jun 2014 13:02:31 UTC Commit: 2490df9b45a2b5c3707436971a8bb5f3538fc006 https://github.com/geany/geany/commit/2490df9b45a2b5c3707436971a8bb5f3538fc0...
Log Message: ----------- Avoid passing non-literals to string formatting functions
Having a string literal allows the compiler to check the arguments match the format, so avoid passing non-literal whenever possible.
Modified Paths: -------------- src/filetypes.c
Modified: src/filetypes.c 14 lines changed, 5 insertions(+), 9 deletions(-) =================================================================== @@ -87,21 +87,17 @@ enum TitleType /* Save adding many translation strings if the filetype name doesn't need translating */ static gchar *filetype_make_title(const char *name, enum TitleType type) { - const gchar *fmt = NULL; - g_return_val_if_fail(name != NULL, NULL);
switch (type) { - case TITLE_SOURCE_FILE: fmt = _("%s source file"); break; - case TITLE_FILE: fmt = _("%s file"); break; - case TITLE_SCRIPT: fmt = _("%s script"); break; - case TITLE_DOCUMENT: fmt = _("%s document"); break; + case TITLE_SOURCE_FILE: return g_strdup_printf(_("%s source file"), name); + case TITLE_FILE: return g_strdup_printf(_("%s file"), name); + case TITLE_SCRIPT: return g_strdup_printf(_("%s script"), name); + case TITLE_DOCUMENT: return g_strdup_printf(_("%s document"), name); case TITLE_NONE: /* fall through */ - default: fmt = "%s"; break; + default: return g_strdup(name); } - - return g_strdup_printf(fmt, name); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).