Re: [PATCH] parseopt: do not translate empty help string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas Rast <trast@xxxxxxxxxxxxxxx> writes:

> The gettext .po files have a header, but it looks like the translation
> specification for an empty string.  This results in _("") actually
> returning that header.
>
> Prevent parseopt from passing empty strings to gettext when it
> displays help about commands.  In some instances it already did this,
> but git-grep's --or etc. caught another case.
>
> Signed-off-by: Thomas Rast <trast@xxxxxxxxxxxxxxx>
> ---
>  parse-options.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/parse-options.c b/parse-options.c
> index c1c66bd..f95bbb2 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -562,7 +562,8 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
>  			fputc('\n', outfile);
>  			pad = USAGE_OPTS_WIDTH;
>  		}
> -		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", _(opts->help));
> +		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "",
> +			*opts->help ? _(opts->help) : "");
>  	}
>  	fputc('\n', outfile);

Thanks; this is a tricky bit to catch and makes me wonder where else
we have a similar breakage.

Perhaps we would want to do this instead?  I dunno.

 gettext.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git i/gettext.h w/gettext.h
index 57ba8bb..376297b 100644
--- i/gettext.h
+++ w/gettext.h
@@ -44,6 +44,8 @@ extern int use_gettext_poison(void);
 
 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
 {
+	if (!*msgid)
+		return "";
 	return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]