3 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
5 Copyright (C) 1995, 2000, 2001 Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published
9 by the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 #include "libgnuintl.h"
29 /* @@ end of prolog @@ */
31 /* This file redirects the gettext functions (without prefix or suffix) to
32 those defined in the included GNU gettext library (with "__" suffix).
33 It is compiled into libintl when the included GNU gettext library is
34 configured --with-included-gettext.
36 This redirection works also in the case that the system C library or
37 the system libintl library contain gettext/textdomain/... functions.
38 If it didn't, we would need to add preprocessor level redirections to
39 libgnuintl.h of the following form:
41 # define gettext gettext__
42 # define dgettext dgettext__
43 # define dcgettext dcgettext__
44 # define ngettext ngettext__
45 # define dngettext dngettext__
46 # define dcngettext dcngettext__
47 # define textdomain textdomain__
48 # define bindtextdomain bindtextdomain__
49 # define bind_textdomain_codeset bind_textdomain_codeset__
51 How does this redirection work? There are two cases.
52 A. When libintl.a is linked into an executable, it works because
53 functions defined in the executable always override functions in
55 B. When libintl.so is used, it works because
56 1. those systems defining gettext/textdomain/... in the C library
57 (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are
58 ELF systems and define these symbols as weak, thus explicitly
59 letting other shared libraries override it.
60 2. those systems defining gettext/textdomain/... in a standalone
61 libintl.so library (namely, Solaris 2.3 and newer) have this
62 shared library in /usr/lib, and the linker will search /usr/lib
63 *after* the directory where the GNU gettext library is installed.
65 A third case, namely when libintl.a is linked into a shared library
66 whose name is not libintl.so, is not supported. In this case, on
67 Solaris, when -lintl precedes the linker option for the shared library
68 containing GNU gettext, the system's gettext would indeed override
69 the GNU gettext. Anyone doing this kind of stuff must be clever enough
70 to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker
82 #undef bind_textdomain_codeset
89 return gettext__ (msgid
);
94 dgettext (domainname
, msgid
)
95 const char *domainname
;
98 return dgettext__ (domainname
, msgid
);
103 dcgettext (domainname
, msgid
, category
)
104 const char *domainname
;
108 return dcgettext__ (domainname
, msgid
, category
);
113 ngettext (msgid1
, msgid2
, n
)
118 return ngettext__ (msgid1
, msgid2
, n
);
123 dngettext (domainname
, msgid1
, msgid2
, n
)
124 const char *domainname
;
129 return dngettext__ (domainname
, msgid1
, msgid2
, n
);
134 dcngettext (domainname
, msgid1
, msgid2
, n
, category
)
135 const char *domainname
;
141 return dcngettext__ (domainname
, msgid1
, msgid2
, n
, category
);
146 textdomain (domainname
)
147 const char *domainname
;
149 return textdomain__ (domainname
);
154 bindtextdomain (domainname
, dirname
)
155 const char *domainname
;
158 return bindtextdomain__ (domainname
, dirname
);
163 bind_textdomain_codeset (domainname
, codeset
)
164 const char *domainname
;
167 return bind_textdomain_codeset__ (domainname
, codeset
);