git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 6/9] gettext.h: Avoid using a non-standard C construct
@ 2011-04-07 18:41 Ramsay Jones
  2011-04-07 22:10 ` Jonathan Nieder
  0 siblings, 1 reply; 5+ messages in thread
From: Ramsay Jones @ 2011-04-07 18:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GIT Mailing-list, bebarino


In particular, standard C does not allow a parenthesized string
as an array initializer. Some compilers, for example GCC and MSVC,
allow this syntax as an extension, but it is (obviously) not a
portable construct.

In order to avoid such a construct, for example while initialising
the array 'ignore_error' (builtin/add.c line 309), we simply
remove the parenthesis from the definition of the N_() macro.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

For example, tcc can not parse this syntax.

Note that sparse issues warnings like the following:
    builtin/add.c:309:1: warning: too long initializer-string for \
        array of char
which is actually a bug in sparse that is tickled by a parenthesized
string initializer (it doesn't determine the correct size of the
string). Again I have a patch ...

 gettext.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gettext.h b/gettext.h
index 1b253b7..24d9182 100644
--- a/gettext.h
+++ b/gettext.h
@@ -35,6 +35,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
 }
 
 /* Mark msgid for translation but do not translate it. */
-#define N_(msgid) (msgid)
+#define N_(msgid) msgid
 
 #endif
-- 
1.7.4

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

* Re: [PATCH 6/9] gettext.h: Avoid using a non-standard C construct
  2011-04-07 18:41 [PATCH 6/9] gettext.h: Avoid using a non-standard C construct Ramsay Jones
@ 2011-04-07 22:10 ` Jonathan Nieder
  2011-04-10 12:54   ` Ævar Arnfjörð Bjarmason
  2011-04-11 17:15   ` Ramsay Jones
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Nieder @ 2011-04-07 22:10 UTC (permalink / raw)
  To: Ramsay Jones
  Cc: Junio C Hamano, GIT Mailing-list, bebarino,
	Ævar Arnfjörð Bjarmason

Hi,

Ramsay Jones wrote:

> +++ b/gettext.h
> @@ -35,6 +35,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
[...]
> -#define N_(msgid) (msgid)
> +#define N_(msgid) msgid

Good catch.  Thanks!

> In particular, standard C does not allow a parenthesized string
> as an array initializer.

The subject line seems unnecessarily vague.  Why not:

	i18n: avoid parenthesized string as array initializer

	The syntax

		static const char ignore_error[] = ("something");

	is invalid C.  GCC and MSVC can parse it, but for example
	tcc cannot.  So remove the parenthesis from the definition
	of the N_() macro.

	Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
	Acked-by: Jonathan Nieder <jrnieder@gmail.com>

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

* Re: [PATCH 6/9] gettext.h: Avoid using a non-standard C construct
  2011-04-07 22:10 ` Jonathan Nieder
@ 2011-04-10 12:54   ` Ævar Arnfjörð Bjarmason
  2011-04-11 17:15   ` Ramsay Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2011-04-10 12:54 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Ramsay Jones, Junio C Hamano, GIT Mailing-list, bebarino

On Fri, Apr 8, 2011 at 00:10, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi,
>
> Ramsay Jones wrote:
>
>> +++ b/gettext.h
>> @@ -35,6 +35,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
> [...]
>> -#define N_(msgid) (msgid)
>> +#define N_(msgid) msgid
>
> Good catch.  Thanks!
>
>> In particular, standard C does not allow a parenthesized string
>> as an array initializer.
>
> The subject line seems unnecessarily vague.  Why not:
>
>        i18n: avoid parenthesized string as array initializer
>
>        The syntax
>
>                static const char ignore_error[] = ("something");
>
>        is invalid C.  GCC and MSVC can parse it, but for example
>        tcc cannot.  So remove the parenthesis from the definition
>        of the N_() macro.
>
>        Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>        Acked-by: Jonathan Nieder <jrnieder@gmail.com>

This looks good to me with this commit message:

Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

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

* Re: [PATCH 6/9] gettext.h: Avoid using a non-standard C construct
  2011-04-07 22:10 ` Jonathan Nieder
  2011-04-10 12:54   ` Ævar Arnfjörð Bjarmason
@ 2011-04-11 17:15   ` Ramsay Jones
  2011-04-11 20:13     ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Ramsay Jones @ 2011-04-11 17:15 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Junio C Hamano, GIT Mailing-list, bebarino,
	Ævar Arnfjörð Bjarmason

Jonathan Nieder wrote:
>> +++ b/gettext.h
>> @@ -35,6 +35,6 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n)
> [...]
>> -#define N_(msgid) (msgid)
>> +#define N_(msgid) msgid
> 
> Good catch.  Thanks!
> 
>> In particular, standard C does not allow a parenthesized string
>> as an array initializer.
> 
> The subject line seems unnecessarily vague.  Why not:
> 
> 	i18n: avoid parenthesized string as array initializer
> 
> 	The syntax
> 
> 		static const char ignore_error[] = ("something");
> 
> 	is invalid C.  GCC and MSVC can parse it, but for example
> 	tcc cannot.  So remove the parenthesis from the definition
> 	of the N_() macro.
> 
> 	Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> 	Acked-by: Jonathan Nieder <jrnieder@gmail.com>
> 

Sounds good to me. I'll re-roll and use your message verbatim.

Thanks!

ATB,
Ramsay Jones

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

* Re: [PATCH 6/9] gettext.h: Avoid using a non-standard C construct
  2011-04-11 17:15   ` Ramsay Jones
@ 2011-04-11 20:13     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2011-04-11 20:13 UTC (permalink / raw)
  To: Ramsay Jones
  Cc: Jonathan Nieder, GIT Mailing-list, bebarino,
	Ævar Arnfjörð Bjarmason

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:

>> 	Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
>> 	Acked-by: Jonathan Nieder <jrnieder@gmail.com>
>> 
>
> Sounds good to me. I'll re-roll and use your message verbatim.

Thanks, all.  No need to resend, as I'll be queuing what we got in 'pu'
after amending it.

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

end of thread, other threads:[~2011-04-11 20:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-07 18:41 [PATCH 6/9] gettext.h: Avoid using a non-standard C construct Ramsay Jones
2011-04-07 22:10 ` Jonathan Nieder
2011-04-10 12:54   ` Ævar Arnfjörð Bjarmason
2011-04-11 17:15   ` Ramsay Jones
2011-04-11 20:13     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).