diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 13:17:58 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 13:17:58 +0300 |
commit | e888f1834b88270590b7e04d64c03c75863e4565 (patch) | |
tree | ab679ecbf16dc4f11b90a53f4b1e0084d78c98b0 /intl/libgnuintl.h | |
parent | fae4762eba9ff7bb466a600130e9c90eaac6b0bc (diff) | |
download | egawk-e888f1834b88270590b7e04d64c03c75863e4565.tar.gz egawk-e888f1834b88270590b7e04d64c03c75863e4565.tar.bz2 egawk-e888f1834b88270590b7e04d64c03c75863e4565.zip |
Move to gawk-3.1.2.
Diffstat (limited to 'intl/libgnuintl.h')
-rw-r--r-- | intl/libgnuintl.h | 216 |
1 files changed, 187 insertions, 29 deletions
diff --git a/intl/libgnuintl.h b/intl/libgnuintl.h index 1387e70c..60bc5519 100644 --- a/intl/libgnuintl.h +++ b/intl/libgnuintl.h @@ -36,11 +36,15 @@ implementation of gettext. */ #define __USE_GNU_GETTEXT 1 +/* Provide information about the supported file formats. Returns the + maximum minor revision number supported for a given major revision. */ +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ + ((major) == 0 ? 1 : -1) + /* Resolve a platform specific conflict on DJGPP. GNU gettext takes precedence over _conio_gettext. */ #ifdef __DJGPP__ # undef gettext -# define gettext gettext #endif /* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers @@ -57,78 +61,232 @@ extern "C" { #endif + +/* We redirect the functions to those prefixed with "libintl_". This is + necessary, because some systems define gettext/textdomain/... in the C + library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). + If we used the unprefixed names, there would be cases where the + definition in the C library would override the one in the libintl.so + shared library. Recall that on ELF systems, the symbols are looked + up in the following order: + 1. in the executable, + 2. in the shared libraries specified on the link command line, in order, + 3. in the dependencies of the shared libraries specified on the link + command line, + 4. in the dlopen()ed shared libraries, in the order in which they were + dlopen()ed. + The definition in the C library would override the one in libintl.so if + either + * -lc is given on the link command line and -lintl isn't, or + * -lc is given on the link command line before -lintl, or + * libintl.so is a dependency of a dlopen()ed shared library but not + linked to the executable at link time. + Since Solaris gettext() behaves differently than GNU gettext(), this + would be unacceptable. + + The redirection happens by default through macros in C, so that &gettext + is independent of the compilation unit, but through inline functions in + C++, in order not to interfere with the name mangling of class fields or + class methods called 'gettext'. */ + +/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. + If he doesn't, we choose the method. A third possible method is + _INTL_REDIRECT_ASM, supported only by GCC. */ +#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) +# if __GNUC__ >= 2 && (defined __STDC__ || defined __cplusplus) && !(defined __APPLE_CC__) +# define _INTL_REDIRECT_ASM +# else +# ifdef __cplusplus +# define _INTL_REDIRECT_INLINE +# else +# define _INTL_REDIRECT_MACROS +# endif +# endif +#endif +/* Auxiliary macros. */ +#ifdef _INTL_REDIRECT_ASM +# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) +# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring +# define _INTL_STRINGIFY(prefix) #prefix +#else +# define _INTL_ASM(cname) +#endif + /* Look up MSGID in the current default message catalog for the current LC_MESSAGES locale. If not found, returns MSGID itself (the default text). */ -extern char *gettext _INTL_PARAMS ((const char *__msgid)); +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_gettext (const char *__msgid); +static inline char *gettext (const char *__msgid) +{ + return libintl_gettext (__msgid); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define gettext libintl_gettext +#endif +extern char *gettext _INTL_PARAMS ((const char *__msgid)) + _INTL_ASM (libintl_gettext); +#endif /* Look up MSGID in the DOMAINNAME message catalog for the current LC_MESSAGES locale. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_dgettext (const char *__domainname, const char *__msgid); +static inline char *dgettext (const char *__domainname, const char *__msgid) +{ + return libintl_dgettext (__domainname, __msgid); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dgettext libintl_dgettext +#endif extern char *dgettext _INTL_PARAMS ((const char *__domainname, - const char *__msgid)); + const char *__msgid)) + _INTL_ASM (libintl_dgettext); +#endif /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, + int __category); +static inline char *dcgettext (const char *__domainname, const char *__msgid, + int __category) +{ + return libintl_dcgettext (__domainname, __msgid, __category); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dcgettext libintl_dcgettext +#endif extern char *dcgettext _INTL_PARAMS ((const char *__domainname, const char *__msgid, - int __category)); + int __category)) + _INTL_ASM (libintl_dcgettext); +#endif /* Similar to `gettext' but select the plural form corresponding to the number N. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n); +static inline char *ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n) +{ + return libintl_ngettext (__msgid1, __msgid2, __n); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define ngettext libintl_ngettext +#endif extern char *ngettext _INTL_PARAMS ((const char *__msgid1, const char *__msgid2, - unsigned long int __n)); + unsigned long int __n)) + _INTL_ASM (libintl_ngettext); +#endif /* Similar to `dgettext' but select the plural form corresponding to the number N. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, + const char *__msgid2, unsigned long int __n); +static inline char *dngettext (const char *__domainname, const char *__msgid1, + const char *__msgid2, unsigned long int __n) +{ + return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dngettext libintl_dngettext +#endif extern char *dngettext _INTL_PARAMS ((const char *__domainname, const char *__msgid1, const char *__msgid2, - unsigned long int __n)); + unsigned long int __n)) + _INTL_ASM (libintl_dngettext); +#endif /* Similar to `dcgettext' but select the plural form corresponding to the number N. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_dcngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category); +static inline char *dcngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category) +{ + return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dcngettext libintl_dcngettext +#endif extern char *dcngettext _INTL_PARAMS ((const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n, - int __category)); + int __category)) + _INTL_ASM (libintl_dcngettext); +#endif /* Set the current default message catalog to DOMAINNAME. If DOMAINNAME is null, return the current default. If DOMAINNAME is "", reset to the default of "messages". */ -extern char *textdomain _INTL_PARAMS ((const char *__domainname)); +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_textdomain (const char *__domainname); +static inline char *textdomain (const char *__domainname) +{ + return libintl_textdomain (__domainname); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define textdomain libintl_textdomain +#endif +extern char *textdomain _INTL_PARAMS ((const char *__domainname)) + _INTL_ASM (libintl_textdomain); +#endif /* Specify that the DOMAINNAME message catalog will be found in DIRNAME rather than in the system locale data base. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_bindtextdomain (const char *__domainname, + const char *__dirname); +static inline char *bindtextdomain (const char *__domainname, + const char *__dirname) +{ + return libintl_bindtextdomain (__domainname, __dirname); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define bindtextdomain libintl_bindtextdomain +#endif extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname, - const char *__dirname)); + const char *__dirname)) + _INTL_ASM (libintl_bindtextdomain); +#endif /* Specify the character encoding in which the messages from the DOMAINNAME message catalog will be returned. */ +#ifdef _INTL_REDIRECT_INLINE +extern char *libintl_bind_textdomain_codeset (const char *__domainname, + const char *__codeset); +static inline char *bind_textdomain_codeset (const char *__domainname, + const char *__codeset) +{ + return libintl_bind_textdomain_codeset (__domainname, __codeset); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define bind_textdomain_codeset libintl_bind_textdomain_codeset +#endif extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname, - const char *__codeset)); - - -/* Optimized version of the functions above. */ -#if defined __OPTIMIZED -/* These are macros, but could also be inline functions. */ - -# define gettext(msgid) \ - dgettext (NULL, msgid) - -# define dgettext(domainname, msgid) \ - dcgettext (domainname, msgid, LC_MESSAGES) - -# define ngettext(msgid1, msgid2, n) \ - dngettext (NULL, msgid1, msgid2, n) - -# define dngettext(domainname, msgid1, msgid2, n) \ - dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) - -#endif /* Optimizing. */ + const char *__codeset)) + _INTL_ASM (libintl_bind_textdomain_codeset); +#endif #ifdef __cplusplus |