{"thread":{"id":"31296","subject":"[PATCH] parseopt: do not translate empty help string","startedAt":"2012-08-20T18:24:56Z","lastAt":"2012-08-20T23:03:44Z","messageCount":6,"participants":["Thomas Rast","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"197430","messageId":"bcb1f4437760452f967737fddf26dff019d0f0b2.1345487066.git.trast@student.ethz.ch","threadId":"31296","inReplyTo":null,"subject":"[PATCH] parseopt: do not translate empty help string","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-08-20T18:24:56Z","receivedAt":"2012-08-20T18:24:56Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"The gettext .po files have a header, but it looks like the translation\nspecification for an empty string.  This results in _(\"\") actually\nreturning that header.\n\nPrevent parseopt from passing empty strings to gettext when it\ndisplays help about commands.  In some instances it already did this,\nbut git-grep's --or etc. caught another case.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n parse-options.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex c1c66bd..f95bbb2 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -562,7 +562,8 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \t\t\tfputc('\\n', outfile);\n \t\t\tpad = USAGE_OPTS_WIDTH;\n \t\t}\n-\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\", _(opts->help));\n+\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\",\n+\t\t\t*opts->help ? _(opts->help) : \"\");\n \t}\n \tfputc('\\n', outfile);\n \n-- \n1.7.12.rc1.203.gc3c8071\n"},{"id":"197434","messageId":"7vboi5jrn1.fsf@alter.siamese.dyndns.org","threadId":"31296","inReplyTo":"bcb1f4437760452f967737fddf26dff019d0f0b2.1345487066.git.trast@student.ethz.ch","subject":"Re: [PATCH] parseopt: do not translate empty help string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-20T19:21:54Z","receivedAt":"2012-08-20T19:21:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> The gettext .po files have a header, but it looks like the translation\n> specification for an empty string.  This results in _(\"\") actually\n> returning that header.\n>\n> Prevent parseopt from passing empty strings to gettext when it\n> displays help about commands.  In some instances it already did this,\n> but git-grep's --or etc. caught another case.\n>\n> Signed-off-by: Thomas Rast <trast@student.ethz.ch>\n> ---\n>  parse-options.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/parse-options.c b/parse-options.c\n> index c1c66bd..f95bbb2 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -562,7 +562,8 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n>  \t\t\tfputc('\\n', outfile);\n>  \t\t\tpad = USAGE_OPTS_WIDTH;\n>  \t\t}\n> -\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\", _(opts->help));\n> +\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\",\n> +\t\t\t*opts->help ? _(opts->help) : \"\");\n>  \t}\n>  \tfputc('\\n', outfile);\n\nThanks; this is a tricky bit to catch and makes me wonder where else\nwe have a similar breakage.\n\nPerhaps we would want to do this instead?  I dunno.\n\n gettext.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git i/gettext.h w/gettext.h\nindex 57ba8bb..376297b 100644\n--- i/gettext.h\n+++ w/gettext.h\n@@ -44,6 +44,8 @@ extern int use_gettext_poison(void);\n \n static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)\n {\n+\tif (!*msgid)\n+\t\treturn \"\";\n \treturn use_gettext_poison() ? \"# GETTEXT POISON #\" : gettext(msgid);\n }\n \n"},{"id":"197436","messageId":"87obm5jpdy.fsf@thomas.inf.ethz.ch","threadId":"31296","inReplyTo":"7vboi5jrn1.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] parseopt: do not translate empty help string","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-08-20T20:10:33Z","receivedAt":"2012-08-20T20:10:33Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Thomas Rast <trast@student.ethz.ch> writes:\n>\n>> The gettext .po files have a header, but it looks like the translation\n>> specification for an empty string.  This results in _(\"\") actually\n>> returning that header.\n>\n> Thanks; this is a tricky bit to catch and makes me wonder where else\n> we have a similar breakage.\n>\n> Perhaps we would want to do this instead?  I dunno.\n>\n>  gettext.h | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git i/gettext.h w/gettext.h\n> index 57ba8bb..376297b 100644\n> --- i/gettext.h\n> +++ w/gettext.h\n> @@ -44,6 +44,8 @@ extern int use_gettext_poison(void);\n>  \n>  static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)\n>  {\n> +\tif (!*msgid)\n> +\t\treturn \"\";\n>  \treturn use_gettext_poison() ? \"# GETTEXT POISON #\" : gettext(msgid);\n>  }\n\nOh, I forgot that we actually had a wrapper instead of the usual _.\nYes, I think that would be the better solution to guard against this.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"197464","messageId":"7vzk5pi5jn.fsf@alter.siamese.dyndns.org","threadId":"31296","inReplyTo":"87obm5jpdy.fsf@thomas.inf.ethz.ch","subject":"Re: [PATCH] parseopt: do not translate empty help string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-20T22:04:28Z","receivedAt":"2012-08-20T22:04:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Thomas Rast <trast@student.ethz.ch> writes:\n>>\n>>> The gettext .po files have a header, but it looks like the translation\n>>> specification for an empty string.  This results in _(\"\") actually\n>>> returning that header.\n>>\n>> Thanks; this is a tricky bit to catch and makes me wonder where else\n>> we have a similar breakage.\n>>\n>> Perhaps we would want to do this instead?  I dunno.\n>>\n>>  gettext.h | 2 ++\n>>  1 file changed, 2 insertions(+)\n>>\n>> diff --git i/gettext.h w/gettext.h\n>> index 57ba8bb..376297b 100644\n>> --- i/gettext.h\n>> +++ w/gettext.h\n>> @@ -44,6 +44,8 @@ extern int use_gettext_poison(void);\n>>  \n>>  static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)\n>>  {\n>> +\tif (!*msgid)\n>> +\t\treturn \"\";\n>>  \treturn use_gettext_poison() ? \"# GETTEXT POISON #\" : gettext(msgid);\n>>  }\n>\n> Oh, I forgot that we actually had a wrapper instead of the usual _.\n> Yes, I think that would be the better solution to guard against this.\n\nOK, then let's replace the patch text of your commit ;-).\n"},{"id":"197465","messageId":"7vvcgdi5d4.fsf@alter.siamese.dyndns.org","threadId":"31296","inReplyTo":"7vzk5pi5jn.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] parseopt: do not translate empty help string","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-20T22:08:23Z","receivedAt":"2012-08-20T22:08:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> Oh, I forgot that we actually had a wrapper instead of the usual _.\n>> Yes, I think that would be the better solution to guard against this.\n>\n> OK, then let's replace the patch text of your commit ;-).\n\nHe, we need to update the log message a bit, too.\n\n-- >8 --\nFrom: Thomas Rast <trast@student.ethz.ch>\nSubject: [PATCH] gettext: do not translate empty string\n\nThe gettext .po files have a header, but it looks like the translation\nspecification for an empty string.  This results in _(\"\") actually\nreturning that header.\n\nPrevent us from passing empty strings to gettext.  In some places,\nwe run _(opts->help) where opts->help may be an empty string.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n gettext.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/gettext.h b/gettext.h\nindex 57ba8bb..376297b 100644\n--- a/gettext.h\n+++ b/gettext.h\n@@ -44,6 +44,8 @@ extern int use_gettext_poison(void);\n \n static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)\n {\n+\tif (!*msgid)\n+\t\treturn \"\";\n \treturn use_gettext_poison() ? \"# GETTEXT POISON #\" : gettext(msgid);\n }\n \n-- \n1.7.12.124.ga484625\n"},{"id":"197473","messageId":"87harxjhdb.fsf@thomas.inf.ethz.ch","threadId":"31296","inReplyTo":"7vvcgdi5d4.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] parseopt: do not translate empty help string","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2012-08-20T23:03:44Z","receivedAt":"2012-08-20T23:03:44Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>>> Oh, I forgot that we actually had a wrapper instead of the usual _.\n>>> Yes, I think that would be the better solution to guard against this.\n>>\n>> OK, then let's replace the patch text of your commit ;-).\n>\n> He, we need to update the log message a bit, too.\n\nThanks!  But now it's your patch :-)\n\n> -- >8 --\n> From: Thomas Rast <trast@student.ethz.ch>\n> Subject: [PATCH] gettext: do not translate empty string\n>\n> The gettext .po files have a header, but it looks like the translation\n> specification for an empty string.  This results in _(\"\") actually\n> returning that header.\n>\n> Prevent us from passing empty strings to gettext.  In some places,\n          ^^\n\nourselves?  I'm not a native speaker though.\n\n> we run _(opts->help) where opts->help may be an empty string.\n>\n> Signed-off-by: Thomas Rast <trast@student.ethz.ch>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  gettext.h | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/gettext.h b/gettext.h\n> index 57ba8bb..376297b 100644\n> --- a/gettext.h\n> +++ b/gettext.h\n> @@ -44,6 +44,8 @@ extern int use_gettext_poison(void);\n>  \n>  static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)\n>  {\n> +\tif (!*msgid)\n> +\t\treturn \"\";\n>  \treturn use_gettext_poison() ? \"# GETTEXT POISON #\" : gettext(msgid);\n>  }\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}