]> git.saurik.com Git - bison.git/blob - intl/intl-compat.c
* doc/bison.texinfo (Locations): Update @$ stuff.
[bison.git] / intl / intl-compat.c
1 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
2 Library.
3 Copyright (C) 1995, 2000, 2001 Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include "libgnuintl.h"
24 #include "gettextP.h"
25
26 /* @@ end of prolog @@ */
27
28 /* This file redirects the gettext functions (without prefix or suffix) to
29 those defined in the included GNU gettext library (with "__" suffix).
30 It is compiled into libintl when the included GNU gettext library is
31 configured --with-included-gettext.
32
33 This redirection works also in the case that the system C library or
34 the system libintl library contain gettext/textdomain/... functions.
35 If it didn't, we would need to add preprocessor level redirections to
36 libgnuintl.h of the following form:
37
38 # define gettext gettext__
39 # define dgettext dgettext__
40 # define dcgettext dcgettext__
41 # define ngettext ngettext__
42 # define dngettext dngettext__
43 # define dcngettext dcngettext__
44 # define textdomain textdomain__
45 # define bindtextdomain bindtextdomain__
46 # define bind_textdomain_codeset bind_textdomain_codeset__
47
48 How does this redirection work? There are two cases.
49 A. When libintl.a is linked into an executable, it works because
50 functions defined in the executable always override functions in
51 the shared libraries.
52 B. When libintl.so is used, it works because
53 1. those systems defining gettext/textdomain/... in the C library
54 (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are
55 ELF systems and define these symbols as weak, thus explicitly
56 letting other shared libraries override it.
57 2. those systems defining gettext/textdomain/... in a standalone
58 libintl.so library (namely, Solaris 2.3 and newer) have this
59 shared library in /usr/lib, and the linker will search /usr/lib
60 *after* the directory where the GNU gettext library is installed.
61
62 A third case, namely when libintl.a is linked into a shared library
63 whose name is not libintl.so, is not supported. In this case, on
64 Solaris, when -lintl precedes the linker option for the shared library
65 containing GNU gettext, the system's gettext would indeed override
66 the GNU gettext. Anyone doing this kind of stuff must be clever enough
67 to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker
68 command line. */
69
70
71 #undef gettext
72 #undef dgettext
73 #undef dcgettext
74 #undef ngettext
75 #undef dngettext
76 #undef dcngettext
77 #undef textdomain
78 #undef bindtextdomain
79 #undef bind_textdomain_codeset
80
81
82 char *
83 gettext (msgid)
84 const char *msgid;
85 {
86 return gettext__ (msgid);
87 }
88
89
90 char *
91 dgettext (domainname, msgid)
92 const char *domainname;
93 const char *msgid;
94 {
95 return dgettext__ (domainname, msgid);
96 }
97
98
99 char *
100 dcgettext (domainname, msgid, category)
101 const char *domainname;
102 const char *msgid;
103 int category;
104 {
105 return dcgettext__ (domainname, msgid, category);
106 }
107
108
109 char *
110 ngettext (msgid1, msgid2, n)
111 const char *msgid1;
112 const char *msgid2;
113 unsigned long int n;
114 {
115 return ngettext__ (msgid1, msgid2, n);
116 }
117
118
119 char *
120 dngettext (domainname, msgid1, msgid2, n)
121 const char *domainname;
122 const char *msgid1;
123 const char *msgid2;
124 unsigned long int n;
125 {
126 return dngettext__ (domainname, msgid1, msgid2, n);
127 }
128
129
130 char *
131 dcngettext (domainname, msgid1, msgid2, n, category)
132 const char *domainname;
133 const char *msgid1;
134 const char *msgid2;
135 unsigned long int n;
136 int category;
137 {
138 return dcngettext__ (domainname, msgid1, msgid2, n, category);
139 }
140
141
142 char *
143 textdomain (domainname)
144 const char *domainname;
145 {
146 return textdomain__ (domainname);
147 }
148
149
150 char *
151 bindtextdomain (domainname, dirname)
152 const char *domainname;
153 const char *dirname;
154 {
155 return bindtextdomain__ (domainname, dirname);
156 }
157
158
159 char *
160 bind_textdomain_codeset (domainname, codeset)
161 const char *domainname;
162 const char *codeset;
163 {
164 return bind_textdomain_codeset__ (domainname, codeset);
165 }