1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-23 17:16:18 +02:00
git/gettext.h
Ramsay Jones 642f85faab i18n: avoid parenthesized string as array initializer
The syntax

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

is invalid C.  A parenthesized string is not allowed as an array
initializer.

Some compilers, for example GCC and MSVC, allow this syntax as an
extension, but it is not a portable construct.  tcc does not parse it, for
example.

Remove the parenthesis from the definition of the N_() macro to
fix this.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11 10:33:51 -07:00

41 lines
975 B
C

/*
* Copyright (c) 2010-2011 Ævar Arnfjörð Bjarmason
*
* This is a skeleton no-op implementation of gettext for Git.
* You can replace it with something that uses libintl.h and wraps
* gettext() to try out the translations.
*/
#ifndef GETTEXT_H
#define GETTEXT_H
#if defined(_) || defined(Q_)
#error "namespace conflict: '_' or 'Q_' is pre-defined?"
#endif
#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
#ifdef GETTEXT_POISON
extern int use_gettext_poison(void);
#else
#define use_gettext_poison() 0
#endif
static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
{
return use_gettext_poison() ? "# GETTEXT POISON #" : msgid;
}
static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
const char *Q_(const char *msgid, const char *plu, unsigned long n)
{
if (use_gettext_poison())
return "# GETTEXT POISON #";
return n == 1 ? msgid : plu;
}
/* Mark msgid for translation but do not translate it. */
#define N_(msgid) msgid
#endif