All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parseopt: do not translate empty help string
@ 2012-08-20 18:24 Thomas Rast
  2012-08-20 19:21 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Rast @ 2012-08-20 18:24 UTC (permalink / raw
  To: git; +Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano

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@student.ethz.ch>
---
 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);
 
-- 
1.7.12.rc1.203.gc3c8071

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] parseopt: do not translate empty help string
  2012-08-20 18:24 [PATCH] parseopt: do not translate empty help string Thomas Rast
@ 2012-08-20 19:21 ` Junio C Hamano
  2012-08-20 20:10   ` Thomas Rast
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2012-08-20 19:21 UTC (permalink / raw
  To: Thomas Rast; +Cc: git, Nguyễn Thái Ngọc Duy

Thomas Rast <trast@student.ethz.ch> 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@student.ethz.ch>
> ---
>  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);
 }
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] parseopt: do not translate empty help string
  2012-08-20 19:21 ` Junio C Hamano
@ 2012-08-20 20:10   ` Thomas Rast
  2012-08-20 22:04     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Rast @ 2012-08-20 20:10 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Nguyễn Thái Ngọc Duy

Junio C Hamano <gitster@pobox.com> writes:

> Thomas Rast <trast@student.ethz.ch> 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.
>
> 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);
>  }

Oh, I forgot that we actually had a wrapper instead of the usual _.
Yes, I think that would be the better solution to guard against this.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] parseopt: do not translate empty help string
  2012-08-20 20:10   ` Thomas Rast
@ 2012-08-20 22:04     ` Junio C Hamano
  2012-08-20 22:08       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2012-08-20 22:04 UTC (permalink / raw
  To: Thomas Rast; +Cc: git, Nguyễn Thái Ngọc Duy

Thomas Rast <trast@student.ethz.ch> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> Thomas Rast <trast@student.ethz.ch> 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.
>>
>> 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);
>>  }
>
> Oh, I forgot that we actually had a wrapper instead of the usual _.
> Yes, I think that would be the better solution to guard against this.

OK, then let's replace the patch text of your commit ;-).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] parseopt: do not translate empty help string
  2012-08-20 22:04     ` Junio C Hamano
@ 2012-08-20 22:08       ` Junio C Hamano
  2012-08-20 23:03         ` Thomas Rast
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2012-08-20 22:08 UTC (permalink / raw
  To: Thomas Rast; +Cc: git, Nguyễn Thái Ngọc Duy

Junio C Hamano <gitster@pobox.com> writes:

>> Oh, I forgot that we actually had a wrapper instead of the usual _.
>> Yes, I think that would be the better solution to guard against this.
>
> OK, then let's replace the patch text of your commit ;-).

He, we need to update the log message a bit, too.

-- >8 --
From: Thomas Rast <trast@student.ethz.ch>
Subject: [PATCH] gettext: do not translate empty string

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 us from passing empty strings to gettext.  In some places,
we run _(opts->help) where opts->help may be an empty string.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 gettext.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gettext.h b/gettext.h
index 57ba8bb..376297b 100644
--- a/gettext.h
+++ b/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);
 }
 
-- 
1.7.12.124.ga484625

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] parseopt: do not translate empty help string
  2012-08-20 22:08       ` Junio C Hamano
@ 2012-08-20 23:03         ` Thomas Rast
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Rast @ 2012-08-20 23:03 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Thomas Rast, git, Nguyễn Thái Ngọc Duy

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>>> Oh, I forgot that we actually had a wrapper instead of the usual _.
>>> Yes, I think that would be the better solution to guard against this.
>>
>> OK, then let's replace the patch text of your commit ;-).
>
> He, we need to update the log message a bit, too.

Thanks!  But now it's your patch :-)

> -- >8 --
> From: Thomas Rast <trast@student.ethz.ch>
> Subject: [PATCH] gettext: do not translate empty string
>
> 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 us from passing empty strings to gettext.  In some places,
          ^^

ourselves?  I'm not a native speaker though.

> we run _(opts->help) where opts->help may be an empty string.
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  gettext.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gettext.h b/gettext.h
> index 57ba8bb..376297b 100644
> --- a/gettext.h
> +++ b/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);
>  }

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-20 23:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20 18:24 [PATCH] parseopt: do not translate empty help string Thomas Rast
2012-08-20 19:21 ` Junio C Hamano
2012-08-20 20:10   ` Thomas Rast
2012-08-20 22:04     ` Junio C Hamano
2012-08-20 22:08       ` Junio C Hamano
2012-08-20 23:03         ` Thomas Rast

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.