summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2002-06-03 12:28:14 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:08:35 +0200
commit0c71aa742bcb51a7a1552d846f36d0484feeeac2 (patch)
tree43bb63cc719429228a352681f5d4f82e11e1042a
parentc3608e1634c7f344183d7bc507e023f17252955f (diff)
downloadexternal_gettext-0c71aa742bcb51a7a1552d846f36d0484feeeac2.zip
external_gettext-0c71aa742bcb51a7a1552d846f36d0484feeeac2.tar.gz
external_gettext-0c71aa742bcb51a7a1552d846f36d0484feeeac2.tar.bz2
Make redirection work better in C++ and with gcc.
-rw-r--r--intl/ChangeLog7
-rw-r--r--intl/libgnuintl.h178
2 files changed, 166 insertions, 19 deletions
diff --git a/intl/ChangeLog b/intl/ChangeLog
index 3422722..35ff7f8 100644
--- a/intl/ChangeLog
+++ b/intl/ChangeLog
@@ -1,3 +1,10 @@
+2002-05-30 Bruno Haible <bruno@clisp.org>
+
+ * libgnuintl.h (_INTL_REDIRECT_ASM, _INTL_REDIRECT_INLINE,
+ _INTL_REDIRECT_MACROS, _INTL_ASM, _INTL_ASMNAME, _INTL_STRINGIFY):
+ New macros. Use them instead of plain preprocessor level indirection
+ when appropriate.
+
2002-05-28 Bruno Haible <bruno@clisp.org>
* localename.c (LANG_SORBIAN): Provide a default value, for mingw32.
diff --git a/intl/libgnuintl.h b/intl/libgnuintl.h
index ad2aebc..bbb3361 100644
--- a/intl/libgnuintl.h
+++ b/intl/libgnuintl.h
@@ -77,71 +77,211 @@ extern "C" {
* 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. */
+ 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)
+# 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). */
-#define gettext libintl_gettext
-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. */
-#define dgettext libintl_dgettext
+#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. */
-#define dcgettext libintl_dcgettext
+#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. */
-#define ngettext libintl_ngettext
+#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. */
-#define dngettext libintl_dngettext
+#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. */
-#define dcngettext libintl_dcngettext
+#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". */
-#define textdomain libintl_textdomain
-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. */
-#define bindtextdomain libintl_bindtextdomain
+#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. */
-#define bind_textdomain_codeset libintl_bind_textdomain_codeset
+#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));
+ const char *__codeset))
+ _INTL_ASM (libintl_bind_textdomain_codeset);
+#endif
#ifdef __cplusplus