2009-10-15 Jim Blandy <jimb@red-bean.com>

* libgnuintl.h (_INTL_MAY_RETURN_STRING_ARG, gettext, dgettext)
	(dcgettext, ngettext, dngettext, dcngettext): Backport changes
	from current gettext to provide GCC format_arg attributes.

From-SVN: r152842
This commit is contained in:
Jim Blandy 2009-10-15 08:56:02 +00:00 committed by Tristan Gingold
parent 23503efce3
commit dda4416508
2 changed files with 39 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2009-10-15 Jim Blandy <jimb@red-bean.com>
* libgnuintl.h (_INTL_MAY_RETURN_STRING_ARG, gettext, dgettext)
(dcgettext, ngettext, dngettext, dcngettext): Backport changes
from current gettext to provide GCC format_arg attributes.
2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> 2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* configure.ac (AC_PREREQ): Bump to 2.64. * configure.ac (AC_PREREQ): Bump to 2.64.

View File

@ -112,11 +112,21 @@ extern "C" {
# define _INTL_ASM(cname) # define _INTL_ASM(cname)
#endif #endif
/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
its n-th argument literally. This enables GCC to warn for example about
printf (gettext ("foo %y")). */
#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
#else
# define _INTL_MAY_RETURN_STRING_ARG(n)
#endif
/* Look up MSGID in the current default message catalog for the current /* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */ text). */
#ifdef _INTL_REDIRECT_INLINE #ifdef _INTL_REDIRECT_INLINE
extern char *libintl_gettext (const char *__msgid); extern char *libintl_gettext (const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (1);
static inline char *gettext (const char *__msgid) static inline char *gettext (const char *__msgid)
{ {
return libintl_gettext (__msgid); return libintl_gettext (__msgid);
@ -126,13 +136,15 @@ static inline char *gettext (const char *__msgid)
# define gettext libintl_gettext # define gettext libintl_gettext
#endif #endif
extern char *gettext _INTL_PARAMS ((const char *__msgid)) extern char *gettext _INTL_PARAMS ((const char *__msgid))
_INTL_ASM (libintl_gettext); _INTL_ASM (libintl_gettext)
_INTL_MAY_RETURN_STRING_ARG (1);
#endif #endif
/* Look up MSGID in the DOMAINNAME message catalog for the current /* Look up MSGID in the DOMAINNAME message catalog for the current
LC_MESSAGES locale. */ LC_MESSAGES locale. */
#ifdef _INTL_REDIRECT_INLINE #ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dgettext (const char *__domainname, const char *__msgid); extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (2);
static inline char *dgettext (const char *__domainname, const char *__msgid) static inline char *dgettext (const char *__domainname, const char *__msgid)
{ {
return libintl_dgettext (__domainname, __msgid); return libintl_dgettext (__domainname, __msgid);
@ -143,14 +155,16 @@ static inline char *dgettext (const char *__domainname, const char *__msgid)
#endif #endif
extern char *dgettext _INTL_PARAMS ((const char *__domainname, extern char *dgettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid)) const char *__msgid))
_INTL_ASM (libintl_dgettext); _INTL_ASM (libintl_dgettext)
_INTL_MAY_RETURN_STRING_ARG (2);
#endif #endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */ locale. */
#ifdef _INTL_REDIRECT_INLINE #ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
int __category); int __category)
_INTL_MAY_RETURN_STRING_ARG (2);
static inline char *dcgettext (const char *__domainname, const char *__msgid, static inline char *dcgettext (const char *__domainname, const char *__msgid,
int __category) int __category)
{ {
@ -163,7 +177,8 @@ static inline char *dcgettext (const char *__domainname, const char *__msgid,
extern char *dcgettext _INTL_PARAMS ((const char *__domainname, extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid, const char *__msgid,
int __category)) int __category))
_INTL_ASM (libintl_dcgettext); _INTL_ASM (libintl_dcgettext)
_INTL_MAY_RETURN_STRING_ARG (2);
#endif #endif
@ -171,7 +186,8 @@ extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
number N. */ number N. */
#ifdef _INTL_REDIRECT_INLINE #ifdef _INTL_REDIRECT_INLINE
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n); unsigned long int __n)
_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
static inline char *ngettext (const char *__msgid1, const char *__msgid2, static inline char *ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n) unsigned long int __n)
{ {
@ -184,14 +200,16 @@ static inline char *ngettext (const char *__msgid1, const char *__msgid2,
extern char *ngettext _INTL_PARAMS ((const char *__msgid1, extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
const char *__msgid2, const char *__msgid2,
unsigned long int __n)) unsigned long int __n))
_INTL_ASM (libintl_ngettext); _INTL_ASM (libintl_ngettext)
_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
#endif #endif
/* Similar to `dgettext' but select the plural form corresponding to the /* Similar to `dgettext' but select the plural form corresponding to the
number N. */ number N. */
#ifdef _INTL_REDIRECT_INLINE #ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
const char *__msgid2, unsigned long int __n); const char *__msgid2, unsigned long int __n)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
static inline char *dngettext (const char *__domainname, const char *__msgid1, static inline char *dngettext (const char *__domainname, const char *__msgid1,
const char *__msgid2, unsigned long int __n) const char *__msgid2, unsigned long int __n)
{ {
@ -205,7 +223,8 @@ extern char *dngettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid1,
const char *__msgid2, const char *__msgid2,
unsigned long int __n)) unsigned long int __n))
_INTL_ASM (libintl_dngettext); _INTL_ASM (libintl_dngettext)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
#endif #endif
/* Similar to `dcgettext' but select the plural form corresponding to the /* Similar to `dcgettext' but select the plural form corresponding to the
@ -213,7 +232,8 @@ extern char *dngettext _INTL_PARAMS ((const char *__domainname,
#ifdef _INTL_REDIRECT_INLINE #ifdef _INTL_REDIRECT_INLINE
extern char *libintl_dcngettext (const char *__domainname, extern char *libintl_dcngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2, const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category); unsigned long int __n, int __category)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
static inline char *dcngettext (const char *__domainname, static inline char *dcngettext (const char *__domainname,
const char *__msgid1, const char *__msgid2, const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category) unsigned long int __n, int __category)
@ -229,7 +249,8 @@ extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid2, const char *__msgid2,
unsigned long int __n, unsigned long int __n,
int __category)) int __category))
_INTL_ASM (libintl_dcngettext); _INTL_ASM (libintl_dcngettext)
_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
#endif #endif