diff options
author | Khem Raj <raj.khem@gmail.com> | 2019-12-07 00:57:23 -0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2019-12-08 23:00:57 -0800 |
commit | c55a5670227fd02385350493b53dba79f3d21fe4 (patch) | |
tree | c5b33f4653ec104f8463586521e2326686f2b446 /meta-oe | |
parent | 53e62e4e57c701dd546a2e27d8b72b7a4698551a (diff) | |
download | meta-openembedded-c55a5670227fd02385350493b53dba79f3d21fe4.tar.gz |
libnih: Fix build with latest gettext
Run gettextize and fix up the resulting problems so that it builds
Fixes
| make[2]: *** No rule to make target 'libgnuintl.@INTL_LIBTOOL_SUFFIX_PREFIX@a', needed by 'all-no-yes'. Stop.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe')
-rw-r--r-- | meta-oe/recipes-support/libnih/libnih-1.0.3/0001-Update-autotool-files-also-make-it-work-with-latest-.patch | 24310 | ||||
-rw-r--r-- | meta-oe/recipes-support/libnih/libnih_1.0.3.bb | 8 |
2 files changed, 24314 insertions, 4 deletions
diff --git a/meta-oe/recipes-support/libnih/libnih-1.0.3/0001-Update-autotool-files-also-make-it-work-with-latest-.patch b/meta-oe/recipes-support/libnih/libnih-1.0.3/0001-Update-autotool-files-also-make-it-work-with-latest-.patch new file mode 100644 index 000000000..2c857c26f --- /dev/null +++ b/meta-oe/recipes-support/libnih/libnih-1.0.3/0001-Update-autotool-files-also-make-it-work-with-latest-.patch | |||
@@ -0,0 +1,24310 @@ | |||
1 | From 0f1cc1bc615807e81fd2709d4177ca41168446c0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 7 Dec 2019 00:45:23 -0800 | ||
4 | Subject: [PATCH] Update autotool files, also make it work with latest gettext | ||
5 | |||
6 | Upstream-Status: Inappropriate [Dead upstream] | ||
7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
8 | --- | ||
9 | ABOUT-NLS | 1069 +-- | ||
10 | ChangeLog | 7 + | ||
11 | Makefile.am | 2 +- | ||
12 | configure.ac | 6 +- | ||
13 | intl/ChangeLog | 4 - | ||
14 | intl/Makefile.in | 587 -- | ||
15 | intl/VERSION | 1 - | ||
16 | intl/bindtextdom.c | 340 - | ||
17 | intl/config.charset | 640 -- | ||
18 | intl/dcgettext.c | 56 - | ||
19 | intl/dcigettext.c | 1689 ----- | ||
20 | intl/dcngettext.c | 57 - | ||
21 | intl/dgettext.c | 58 - | ||
22 | intl/dngettext.c | 59 - | ||
23 | intl/eval-plural.h | 108 - | ||
24 | intl/explodename.c | 135 - | ||
25 | intl/export.h | 6 - | ||
26 | intl/finddomain.c | 212 - | ||
27 | intl/gettext.c | 63 - | ||
28 | intl/gettextP.h | 297 - | ||
29 | intl/gmo.h | 152 - | ||
30 | intl/hash-string.c | 51 - | ||
31 | intl/hash-string.h | 36 - | ||
32 | intl/intl-compat.c | 133 - | ||
33 | intl/intl-exports.c | 36 - | ||
34 | intl/l10nflist.c | 400 -- | ||
35 | intl/langprefs.c | 130 - | ||
36 | intl/libgnuintl.h.in | 419 -- | ||
37 | intl/libintl.rc | 38 - | ||
38 | intl/loadinfo.h | 132 - | ||
39 | intl/loadmsgcat.c | 1336 ---- | ||
40 | intl/localcharset.c | 461 -- | ||
41 | intl/localcharset.h | 42 - | ||
42 | intl/locale.alias | 77 - | ||
43 | intl/localealias.c | 439 -- | ||
44 | intl/localename.c | 1507 ---- | ||
45 | intl/lock.c | 922 --- | ||
46 | intl/lock.h | 1105 --- | ||
47 | intl/log.c | 116 - | ||
48 | intl/ngettext.c | 65 - | ||
49 | intl/os2compat.c | 98 - | ||
50 | intl/os2compat.h | 46 - | ||
51 | intl/osdep.c | 26 - | ||
52 | intl/plural-exp.c | 155 - | ||
53 | intl/plural-exp.h | 129 - | ||
54 | intl/plural.c | 1981 ------ | ||
55 | intl/plural.y | 385 -- | ||
56 | intl/printf-args.c | 188 - | ||
57 | intl/printf-args.h | 155 - | ||
58 | intl/printf-parse.c | 590 -- | ||
59 | intl/printf-parse.h | 75 - | ||
60 | intl/printf.c | 427 -- | ||
61 | intl/ref-add.sin | 31 - | ||
62 | intl/ref-del.sin | 26 - | ||
63 | intl/relocatable.c | 468 -- | ||
64 | intl/relocatable.h | 79 - | ||
65 | intl/textdomain.c | 127 - | ||
66 | intl/tsearch.c | 684 -- | ||
67 | intl/tsearch.h | 83 - | ||
68 | intl/vasnprintf.c | 4677 ------------- | ||
69 | intl/vasnprintf.h | 78 - | ||
70 | intl/vasnwprintf.h | 46 - | ||
71 | intl/version.c | 26 - | ||
72 | intl/wprintf-parse.h | 75 - | ||
73 | intl/xsize.h | 109 - | ||
74 | m4/intlmacosx.m4 | 55 +- | ||
75 | po/ChangeLog | 8 + | ||
76 | po/Rules-quot | 19 +- | ||
77 | po/en@boldquot.header | 2 +- | ||
78 | po/en@quot.header | 2 +- | ||
79 | po/insert-header.sin | 5 + | ||
80 | po/remove-potcdate.sin | 8 +- | ||
81 | 74 files changed, 1335 insertions(+), 38646 deletions(-) | ||
82 | delete mode 100644 intl/ChangeLog | ||
83 | delete mode 100644 intl/Makefile.in | ||
84 | delete mode 100644 intl/VERSION | ||
85 | delete mode 100644 intl/bindtextdom.c | ||
86 | delete mode 100755 intl/config.charset | ||
87 | delete mode 100644 intl/dcgettext.c | ||
88 | delete mode 100644 intl/dcigettext.c | ||
89 | delete mode 100644 intl/dcngettext.c | ||
90 | delete mode 100644 intl/dgettext.c | ||
91 | delete mode 100644 intl/dngettext.c | ||
92 | delete mode 100644 intl/eval-plural.h | ||
93 | delete mode 100644 intl/explodename.c | ||
94 | delete mode 100644 intl/export.h | ||
95 | delete mode 100644 intl/finddomain.c | ||
96 | delete mode 100644 intl/gettext.c | ||
97 | delete mode 100644 intl/gettextP.h | ||
98 | delete mode 100644 intl/gmo.h | ||
99 | delete mode 100644 intl/hash-string.c | ||
100 | delete mode 100644 intl/hash-string.h | ||
101 | delete mode 100644 intl/intl-compat.c | ||
102 | delete mode 100644 intl/intl-exports.c | ||
103 | delete mode 100644 intl/l10nflist.c | ||
104 | delete mode 100644 intl/langprefs.c | ||
105 | delete mode 100644 intl/libgnuintl.h.in | ||
106 | delete mode 100644 intl/libintl.rc | ||
107 | delete mode 100644 intl/loadinfo.h | ||
108 | delete mode 100644 intl/loadmsgcat.c | ||
109 | delete mode 100644 intl/localcharset.c | ||
110 | delete mode 100644 intl/localcharset.h | ||
111 | delete mode 100644 intl/locale.alias | ||
112 | delete mode 100644 intl/localealias.c | ||
113 | delete mode 100644 intl/localename.c | ||
114 | delete mode 100644 intl/lock.c | ||
115 | delete mode 100644 intl/lock.h | ||
116 | delete mode 100644 intl/log.c | ||
117 | delete mode 100644 intl/ngettext.c | ||
118 | delete mode 100644 intl/os2compat.c | ||
119 | delete mode 100644 intl/os2compat.h | ||
120 | delete mode 100644 intl/osdep.c | ||
121 | delete mode 100644 intl/plural-exp.c | ||
122 | delete mode 100644 intl/plural-exp.h | ||
123 | delete mode 100644 intl/plural.c | ||
124 | delete mode 100644 intl/plural.y | ||
125 | delete mode 100644 intl/printf-args.c | ||
126 | delete mode 100644 intl/printf-args.h | ||
127 | delete mode 100644 intl/printf-parse.c | ||
128 | delete mode 100644 intl/printf-parse.h | ||
129 | delete mode 100644 intl/printf.c | ||
130 | delete mode 100644 intl/ref-add.sin | ||
131 | delete mode 100644 intl/ref-del.sin | ||
132 | delete mode 100644 intl/relocatable.c | ||
133 | delete mode 100644 intl/relocatable.h | ||
134 | delete mode 100644 intl/textdomain.c | ||
135 | delete mode 100644 intl/tsearch.c | ||
136 | delete mode 100644 intl/tsearch.h | ||
137 | delete mode 100644 intl/vasnprintf.c | ||
138 | delete mode 100644 intl/vasnprintf.h | ||
139 | delete mode 100644 intl/vasnwprintf.h | ||
140 | delete mode 100644 intl/version.c | ||
141 | delete mode 100644 intl/wprintf-parse.h | ||
142 | delete mode 100644 intl/xsize.h | ||
143 | |||
144 | --- a/ABOUT-NLS | ||
145 | +++ b/ABOUT-NLS | ||
146 | @@ -1,1068 +1 @@ | ||
147 | -1 Notes on the Free Translation Project | ||
148 | -*************************************** | ||
149 | - | ||
150 | -Free software is going international! The Free Translation Project is | ||
151 | -a way to get maintainers of free software, translators, and users all | ||
152 | -together, so that free software will gradually become able to speak many | ||
153 | -languages. A few packages already provide translations for their | ||
154 | -messages. | ||
155 | - | ||
156 | - If you found this `ABOUT-NLS' file inside a distribution, you may | ||
157 | -assume that the distributed package does use GNU `gettext' internally, | ||
158 | -itself available at your nearest GNU archive site. But you do _not_ | ||
159 | -need to install GNU `gettext' prior to configuring, installing or using | ||
160 | -this package with messages translated. | ||
161 | - | ||
162 | - Installers will find here some useful hints. These notes also | ||
163 | -explain how users should proceed for getting the programs to use the | ||
164 | -available translations. They tell how people wanting to contribute and | ||
165 | -work on translations can contact the appropriate team. | ||
166 | - | ||
167 | - When reporting bugs in the `intl/' directory or bugs which may be | ||
168 | -related to internationalization, you should tell about the version of | ||
169 | -`gettext' which is used. The information can be found in the | ||
170 | -`intl/VERSION' file, in internationalized packages. | ||
171 | - | ||
172 | -1.1 Quick configuration advice | ||
173 | -============================== | ||
174 | - | ||
175 | -If you want to exploit the full power of internationalization, you | ||
176 | -should configure it using | ||
177 | - | ||
178 | - ./configure --with-included-gettext | ||
179 | - | ||
180 | -to force usage of internationalizing routines provided within this | ||
181 | -package, despite the existence of internationalizing capabilities in the | ||
182 | -operating system where this package is being installed. So far, only | ||
183 | -the `gettext' implementation in the GNU C library version 2 provides as | ||
184 | -many features (such as locale alias, message inheritance, automatic | ||
185 | -charset conversion or plural form handling) as the implementation here. | ||
186 | -It is also not possible to offer this additional functionality on top | ||
187 | -of a `catgets' implementation. Future versions of GNU `gettext' will | ||
188 | -very likely convey even more functionality. So it might be a good idea | ||
189 | -to change to GNU `gettext' as soon as possible. | ||
190 | - | ||
191 | - So you need _not_ provide this option if you are using GNU libc 2 or | ||
192 | -you have installed a recent copy of the GNU gettext package with the | ||
193 | -included `libintl'. | ||
194 | - | ||
195 | -1.2 INSTALL Matters | ||
196 | -=================== | ||
197 | - | ||
198 | -Some packages are "localizable" when properly installed; the programs | ||
199 | -they contain can be made to speak your own native language. Most such | ||
200 | -packages use GNU `gettext'. Other packages have their own ways to | ||
201 | -internationalization, predating GNU `gettext'. | ||
202 | - | ||
203 | - By default, this package will be installed to allow translation of | ||
204 | -messages. It will automatically detect whether the system already | ||
205 | -provides the GNU `gettext' functions. If not, the included GNU | ||
206 | -`gettext' library will be used. This library is wholly contained | ||
207 | -within this package, usually in the `intl/' subdirectory, so prior | ||
208 | -installation of the GNU `gettext' package is _not_ required. | ||
209 | -Installers may use special options at configuration time for changing | ||
210 | -the default behaviour. The commands: | ||
211 | - | ||
212 | - ./configure --with-included-gettext | ||
213 | - ./configure --disable-nls | ||
214 | - | ||
215 | -will, respectively, bypass any pre-existing `gettext' to use the | ||
216 | -internationalizing routines provided within this package, or else, | ||
217 | -_totally_ disable translation of messages. | ||
218 | - | ||
219 | - When you already have GNU `gettext' installed on your system and run | ||
220 | -configure without an option for your new package, `configure' will | ||
221 | -probably detect the previously built and installed `libintl.a' file and | ||
222 | -will decide to use this. This might not be desirable. You should use | ||
223 | -the more recent version of the GNU `gettext' library. I.e. if the file | ||
224 | -`intl/VERSION' shows that the library which comes with this package is | ||
225 | -more recent, you should use | ||
226 | - | ||
227 | - ./configure --with-included-gettext | ||
228 | - | ||
229 | -to prevent auto-detection. | ||
230 | - | ||
231 | - The configuration process will not test for the `catgets' function | ||
232 | -and therefore it will not be used. The reason is that even an | ||
233 | -emulation of `gettext' on top of `catgets' could not provide all the | ||
234 | -extensions of the GNU `gettext' library. | ||
235 | - | ||
236 | - Internationalized packages usually have many `po/LL.po' files, where | ||
237 | -LL gives an ISO 639 two-letter code identifying the language. Unless | ||
238 | -translations have been forbidden at `configure' time by using the | ||
239 | -`--disable-nls' switch, all available translations are installed | ||
240 | -together with the package. However, the environment variable `LINGUAS' | ||
241 | -may be set, prior to configuration, to limit the installed set. | ||
242 | -`LINGUAS' should then contain a space separated list of two-letter | ||
243 | -codes, stating which languages are allowed. | ||
244 | - | ||
245 | -1.3 Using This Package | ||
246 | -====================== | ||
247 | - | ||
248 | -As a user, if your language has been installed for this package, you | ||
249 | -only have to set the `LANG' environment variable to the appropriate | ||
250 | -`LL_CC' combination. If you happen to have the `LC_ALL' or some other | ||
251 | -`LC_xxx' environment variables set, you should unset them before | ||
252 | -setting `LANG', otherwise the setting of `LANG' will not have the | ||
253 | -desired effect. Here `LL' is an ISO 639 two-letter language code, and | ||
254 | -`CC' is an ISO 3166 two-letter country code. For example, let's | ||
255 | -suppose that you speak German and live in Germany. At the shell | ||
256 | -prompt, merely execute `setenv LANG de_DE' (in `csh'), | ||
257 | -`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). | ||
258 | -This can be done from your `.login' or `.profile' file, once and for | ||
259 | -all. | ||
260 | - | ||
261 | - You might think that the country code specification is redundant. | ||
262 | -But in fact, some languages have dialects in different countries. For | ||
263 | -example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The | ||
264 | -country code serves to distinguish the dialects. | ||
265 | - | ||
266 | - The locale naming convention of `LL_CC', with `LL' denoting the | ||
267 | -language and `CC' denoting the country, is the one use on systems based | ||
268 | -on GNU libc. On other systems, some variations of this scheme are | ||
269 | -used, such as `LL' or `LL_CC.ENCODING'. You can get the list of | ||
270 | -locales supported by your system for your language by running the | ||
271 | -command `locale -a | grep '^LL''. | ||
272 | - | ||
273 | - Not all programs have translations for all languages. By default, an | ||
274 | -English message is shown in place of a nonexistent translation. If you | ||
275 | -understand other languages, you can set up a priority list of languages. | ||
276 | -This is done through a different environment variable, called | ||
277 | -`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' | ||
278 | -for the purpose of message handling, but you still need to have `LANG' | ||
279 | -set to the primary language; this is required by other parts of the | ||
280 | -system libraries. For example, some Swedish users who would rather | ||
281 | -read translations in German than English for when Swedish is not | ||
282 | -available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. | ||
283 | - | ||
284 | - Special advice for Norwegian users: The language code for Norwegian | ||
285 | -bokma*l changed from `no' to `nb' recently (in 2003). During the | ||
286 | -transition period, while some message catalogs for this language are | ||
287 | -installed under `nb' and some older ones under `no', it's recommended | ||
288 | -for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and | ||
289 | -older translations are used. | ||
290 | - | ||
291 | - In the `LANGUAGE' environment variable, but not in the `LANG' | ||
292 | -environment variable, `LL_CC' combinations can be abbreviated as `LL' | ||
293 | -to denote the language's main dialect. For example, `de' is equivalent | ||
294 | -to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' | ||
295 | -(Portuguese as spoken in Portugal) in this context. | ||
296 | - | ||
297 | -1.4 Translating Teams | ||
298 | -===================== | ||
299 | - | ||
300 | -For the Free Translation Project to be a success, we need interested | ||
301 | -people who like their own language and write it well, and who are also | ||
302 | -able to synergize with other translators speaking the same language. | ||
303 | -Each translation team has its own mailing list. The up-to-date list of | ||
304 | -teams can be found at the Free Translation Project's homepage, | ||
305 | -`http://translationproject.org/', in the "Teams" area. | ||
306 | - | ||
307 | - If you'd like to volunteer to _work_ at translating messages, you | ||
308 | -should become a member of the translating team for your own language. | ||
309 | -The subscribing address is _not_ the same as the list itself, it has | ||
310 | -`-request' appended. For example, speakers of Swedish can send a | ||
311 | -message to `sv-request@li.org', having this message body: | ||
312 | - | ||
313 | - subscribe | ||
314 | - | ||
315 | - Keep in mind that team members are expected to participate | ||
316 | -_actively_ in translations, or at solving translational difficulties, | ||
317 | -rather than merely lurking around. If your team does not exist yet and | ||
318 | -you want to start one, or if you are unsure about what to do or how to | ||
319 | -get started, please write to `coordinator@translationproject.org' to | ||
320 | -reach the coordinator for all translator teams. | ||
321 | - | ||
322 | - The English team is special. It works at improving and uniformizing | ||
323 | -the terminology in use. Proven linguistic skills are praised more than | ||
324 | -programming skills, here. | ||
325 | - | ||
326 | -1.5 Available Packages | ||
327 | -====================== | ||
328 | - | ||
329 | -Languages are not equally supported in all packages. The following | ||
330 | -matrix shows the current state of internationalization, as of November | ||
331 | -2007. The matrix shows, in regard of each package, for which languages | ||
332 | -PO files have been submitted to translation coordination, with a | ||
333 | -translation percentage of at least 50%. | ||
334 | - | ||
335 | - Ready PO files af am ar az be bg bs ca cs cy da de el en en_GB eo | ||
336 | - +----------------------------------------------------+ | ||
337 | - Compendium | [] [] [] [] | | ||
338 | - a2ps | [] [] [] [] [] | | ||
339 | - aegis | () | | ||
340 | - ant-phone | () | | ||
341 | - anubis | [] | | ||
342 | - ap-utils | | | ||
343 | - aspell | [] [] [] [] [] | | ||
344 | - bash | [] | | ||
345 | - bfd | | | ||
346 | - bibshelf | [] | | ||
347 | - binutils | | | ||
348 | - bison | [] [] | | ||
349 | - bison-runtime | [] | | ||
350 | - bluez-pin | [] [] [] [] [] | | ||
351 | - cflow | [] | | ||
352 | - clisp | [] [] [] | | ||
353 | - console-tools | [] [] | | ||
354 | - coreutils | [] [] [] [] | | ||
355 | - cpio | | | ||
356 | - cpplib | [] [] [] | | ||
357 | - cryptonit | [] | | ||
358 | - dialog | | | ||
359 | - diffutils | [] [] [] [] [] [] | | ||
360 | - doodle | [] | | ||
361 | - e2fsprogs | [] [] | | ||
362 | - enscript | [] [] [] [] | | ||
363 | - fetchmail | [] [] () [] [] | | ||
364 | - findutils | [] | | ||
365 | - findutils_stable | [] [] [] | | ||
366 | - flex | [] [] [] | | ||
367 | - fslint | | | ||
368 | - gas | | | ||
369 | - gawk | [] [] [] | | ||
370 | - gcal | [] | | ||
371 | - gcc | [] | | ||
372 | - gettext-examples | [] [] [] [] [] | | ||
373 | - gettext-runtime | [] [] [] [] [] | | ||
374 | - gettext-tools | [] [] | | ||
375 | - gip | [] | | ||
376 | - gliv | [] [] | | ||
377 | - glunarclock | [] | | ||
378 | - gmult | [] [] | | ||
379 | - gnubiff | () | | ||
380 | - gnucash | [] [] () () [] | | ||
381 | - gnuedu | | | ||
382 | - gnulib | [] | | ||
383 | - gnunet | | | ||
384 | - gnunet-gtk | | | ||
385 | - gnutls | [] | | ||
386 | - gpe-aerial | [] [] | | ||
387 | - gpe-beam | [] [] | | ||
388 | - gpe-calendar | | | ||
389 | - gpe-clock | [] [] | | ||
390 | - gpe-conf | [] [] | | ||
391 | - gpe-contacts | | | ||
392 | - gpe-edit | [] | | ||
393 | - gpe-filemanager | | | ||
394 | - gpe-go | [] | | ||
395 | - gpe-login | [] [] | | ||
396 | - gpe-ownerinfo | [] [] | | ||
397 | - gpe-package | | | ||
398 | - gpe-sketchbook | [] [] | | ||
399 | - gpe-su | [] [] | | ||
400 | - gpe-taskmanager | [] [] | | ||
401 | - gpe-timesheet | [] | | ||
402 | - gpe-today | [] [] | | ||
403 | - gpe-todo | | | ||
404 | - gphoto2 | [] [] [] [] | | ||
405 | - gprof | [] [] | | ||
406 | - gpsdrive | | | ||
407 | - gramadoir | [] [] | | ||
408 | - grep | [] [] | | ||
409 | - gretl | () | | ||
410 | - gsasl | | | ||
411 | - gss | | | ||
412 | - gst-plugins-bad | [] [] | | ||
413 | - gst-plugins-base | [] [] | | ||
414 | - gst-plugins-good | [] [] [] | | ||
415 | - gst-plugins-ugly | [] [] | | ||
416 | - gstreamer | [] [] [] [] [] [] [] | | ||
417 | - gtick | () | | ||
418 | - gtkam | [] [] [] [] | | ||
419 | - gtkorphan | [] [] | | ||
420 | - gtkspell | [] [] [] [] | | ||
421 | - gutenprint | [] | | ||
422 | - hello | [] [] [] [] [] | | ||
423 | - herrie | [] | | ||
424 | - hylafax | | | ||
425 | - idutils | [] [] | | ||
426 | - indent | [] [] [] [] | | ||
427 | - iso_15924 | | | ||
428 | - iso_3166 | [] [] [] [] [] [] [] [] [] [] [] | | ||
429 | - iso_3166_2 | | | ||
430 | - iso_4217 | [] [] [] | | ||
431 | - iso_639 | [] [] [] [] | | ||
432 | - jpilot | [] | | ||
433 | - jtag | | | ||
434 | - jwhois | | | ||
435 | - kbd | [] [] [] [] | | ||
436 | - keytouch | [] [] | | ||
437 | - keytouch-editor | [] | | ||
438 | - keytouch-keyboa... | [] | | ||
439 | - latrine | () | | ||
440 | - ld | [] | | ||
441 | - leafpad | [] [] [] [] [] | | ||
442 | - libc | [] [] [] [] | | ||
443 | - libexif | [] | | ||
444 | - libextractor | [] | | ||
445 | - libgpewidget | [] [] [] | | ||
446 | - libgpg-error | [] | | ||
447 | - libgphoto2 | [] [] | | ||
448 | - libgphoto2_port | [] [] | | ||
449 | - libgsasl | | | ||
450 | - libiconv | [] [] | | ||
451 | - libidn | [] [] [] | | ||
452 | - lifelines | [] () | | ||
453 | - lilypond | [] | | ||
454 | - lingoteach | | | ||
455 | - lprng | | | ||
456 | - lynx | [] [] [] [] | | ||
457 | - m4 | [] [] [] [] | | ||
458 | - mailfromd | | | ||
459 | - mailutils | [] | | ||
460 | - make | [] [] | | ||
461 | - man-db | [] [] [] | | ||
462 | - minicom | [] [] [] | | ||
463 | - nano | [] [] [] | | ||
464 | - opcodes | [] | | ||
465 | - parted | [] [] | | ||
466 | - pilot-qof | | | ||
467 | - popt | [] [] [] | | ||
468 | - psmisc | [] | | ||
469 | - pwdutils | | | ||
470 | - qof | | | ||
471 | - radius | [] | | ||
472 | - recode | [] [] [] [] [] [] | | ||
473 | - rpm | [] | | ||
474 | - screem | | | ||
475 | - scrollkeeper | [] [] [] [] [] [] [] [] | | ||
476 | - sed | [] [] [] | | ||
477 | - shared-mime-info | [] [] [] [] () [] [] [] | | ||
478 | - sharutils | [] [] [] [] [] [] | | ||
479 | - shishi | | | ||
480 | - skencil | [] () | | ||
481 | - solfege | | | ||
482 | - soundtracker | [] [] | | ||
483 | - sp | [] | | ||
484 | - system-tools-ba... | [] [] [] [] [] [] [] [] [] | | ||
485 | - tar | [] [] | | ||
486 | - texinfo | [] [] [] | | ||
487 | - tin | () () | | ||
488 | - tuxpaint | [] [] [] [] [] [] | | ||
489 | - unicode-han-tra... | | | ||
490 | - unicode-transla... | | | ||
491 | - util-linux | [] [] [] [] | | ||
492 | - util-linux-ng | [] [] [] [] | | ||
493 | - vorbis-tools | [] | | ||
494 | - wastesedge | () | | ||
495 | - wdiff | [] [] [] [] | | ||
496 | - wget | [] [] [] | | ||
497 | - xchat | [] [] [] [] [] [] [] | | ||
498 | - xkeyboard-config | [] | | ||
499 | - xpad | [] [] [] | | ||
500 | - +----------------------------------------------------+ | ||
501 | - af am ar az be bg bs ca cs cy da de el en en_GB eo | ||
502 | - 6 0 2 1 8 26 2 40 48 2 56 88 15 1 15 18 | ||
503 | - | ||
504 | - es et eu fa fi fr ga gl gu he hi hr hu id is it | ||
505 | - +--------------------------------------------------+ | ||
506 | - Compendium | [] [] [] [] [] | | ||
507 | - a2ps | [] [] [] () | | ||
508 | - aegis | | | ||
509 | - ant-phone | [] | | ||
510 | - anubis | [] | | ||
511 | - ap-utils | [] [] | | ||
512 | - aspell | [] [] [] | | ||
513 | - bash | [] | | ||
514 | - bfd | [] [] | | ||
515 | - bibshelf | [] [] [] | | ||
516 | - binutils | [] [] [] | | ||
517 | - bison | [] [] [] [] [] [] | | ||
518 | - bison-runtime | [] [] [] [] [] | | ||
519 | - bluez-pin | [] [] [] [] [] | | ||
520 | - cflow | [] | | ||
521 | - clisp | [] [] | | ||
522 | - console-tools | | | ||
523 | - coreutils | [] [] [] [] [] [] | | ||
524 | - cpio | [] [] [] | | ||
525 | - cpplib | [] [] | | ||
526 | - cryptonit | [] | | ||
527 | - dialog | [] [] [] | | ||
528 | - diffutils | [] [] [] [] [] [] [] [] [] | | ||
529 | - doodle | [] [] | | ||
530 | - e2fsprogs | [] [] [] | | ||
531 | - enscript | [] [] [] | | ||
532 | - fetchmail | [] | | ||
533 | - findutils | [] [] [] | | ||
534 | - findutils_stable | [] [] [] [] | | ||
535 | - flex | [] [] [] | | ||
536 | - fslint | | | ||
537 | - gas | [] [] | | ||
538 | - gawk | [] [] [] [] () | | ||
539 | - gcal | [] [] | | ||
540 | - gcc | [] | | ||
541 | - gettext-examples | [] [] [] [] [] [] [] | | ||
542 | - gettext-runtime | [] [] [] [] [] [] | | ||
543 | - gettext-tools | [] [] [] [] | | ||
544 | - gip | [] [] [] [] | | ||
545 | - gliv | () | | ||
546 | - glunarclock | [] [] [] | | ||
547 | - gmult | [] [] [] | | ||
548 | - gnubiff | () () | | ||
549 | - gnucash | () () () | | ||
550 | - gnuedu | [] | | ||
551 | - gnulib | [] [] [] | | ||
552 | - gnunet | | | ||
553 | - gnunet-gtk | | | ||
554 | - gnutls | | | ||
555 | - gpe-aerial | [] [] | | ||
556 | - gpe-beam | [] [] | | ||
557 | - gpe-calendar | | | ||
558 | - gpe-clock | [] [] [] [] | | ||
559 | - gpe-conf | [] | | ||
560 | - gpe-contacts | [] [] | | ||
561 | - gpe-edit | [] [] [] [] | | ||
562 | - gpe-filemanager | [] | | ||
563 | - gpe-go | [] [] [] | | ||
564 | - gpe-login | [] [] [] | | ||
565 | - gpe-ownerinfo | [] [] [] [] [] | | ||
566 | - gpe-package | [] | | ||
567 | - gpe-sketchbook | [] [] | | ||
568 | - gpe-su | [] [] [] [] | | ||
569 | - gpe-taskmanager | [] [] [] | | ||
570 | - gpe-timesheet | [] [] [] [] | | ||
571 | - gpe-today | [] [] [] [] | | ||
572 | - gpe-todo | [] | | ||
573 | - gphoto2 | [] [] [] [] [] | | ||
574 | - gprof | [] [] [] [] [] | | ||
575 | - gpsdrive | [] | | ||
576 | - gramadoir | [] [] | | ||
577 | - grep | [] [] [] | | ||
578 | - gretl | [] [] [] () | | ||
579 | - gsasl | [] [] | | ||
580 | - gss | [] [] | | ||
581 | - gst-plugins-bad | [] [] [] [] | | ||
582 | - gst-plugins-base | [] [] [] [] | | ||
583 | - gst-plugins-good | [] [] [] [] [] | | ||
584 | - gst-plugins-ugly | [] [] [] [] | | ||
585 | - gstreamer | [] [] [] | | ||
586 | - gtick | [] [] [] | | ||
587 | - gtkam | [] [] [] [] | | ||
588 | - gtkorphan | [] [] | | ||
589 | - gtkspell | [] [] [] [] [] [] [] | | ||
590 | - gutenprint | [] | | ||
591 | - hello | [] [] [] [] [] [] [] [] [] [] [] [] [] | | ||
592 | - herrie | [] | | ||
593 | - hylafax | | | ||
594 | - idutils | [] [] [] [] [] | | ||
595 | - indent | [] [] [] [] [] [] [] [] [] [] | | ||
596 | - iso_15924 | [] | | ||
597 | - iso_3166 | [] [] [] [] [] [] [] [] [] [] [] [] [] | | ||
598 | - iso_3166_2 | [] | | ||
599 | - iso_4217 | [] [] [] [] [] [] | | ||
600 | - iso_639 | [] [] [] [] [] [] | | ||
601 | - jpilot | [] [] | | ||
602 | - jtag | [] | | ||
603 | - jwhois | [] [] [] [] [] | | ||
604 | - kbd | [] [] | | ||
605 | - keytouch | [] [] [] | | ||
606 | - keytouch-editor | [] | | ||
607 | - keytouch-keyboa... | [] [] | | ||
608 | - latrine | [] [] | | ||
609 | - ld | [] [] [] [] | | ||
610 | - leafpad | [] [] [] [] [] [] | | ||
611 | - libc | [] [] [] [] [] | | ||
612 | - libexif | [] | | ||
613 | - libextractor | [] | | ||
614 | - libgpewidget | [] [] [] [] [] | | ||
615 | - libgpg-error | [] | | ||
616 | - libgphoto2 | [] [] [] | | ||
617 | - libgphoto2_port | [] [] | | ||
618 | - libgsasl | [] [] | | ||
619 | - libiconv | [] [] [] | | ||
620 | - libidn | [] [] | | ||
621 | - lifelines | () | | ||
622 | - lilypond | [] [] [] | | ||
623 | - lingoteach | [] [] [] | | ||
624 | - lprng | | | ||
625 | - lynx | [] [] [] | | ||
626 | - m4 | [] [] [] [] | | ||
627 | - mailfromd | | | ||
628 | - mailutils | [] [] | | ||
629 | - make | [] [] [] [] [] [] [] [] | | ||
630 | - man-db | [] | | ||
631 | - minicom | [] [] [] [] | | ||
632 | - nano | [] [] [] [] [] [] [] | | ||
633 | - opcodes | [] [] [] [] | | ||
634 | - parted | [] [] [] | | ||
635 | - pilot-qof | | | ||
636 | - popt | [] [] [] [] | | ||
637 | - psmisc | [] [] | | ||
638 | - pwdutils | | | ||
639 | - qof | [] | | ||
640 | - radius | [] [] | | ||
641 | - recode | [] [] [] [] [] [] [] [] | | ||
642 | - rpm | [] [] | | ||
643 | - screem | | | ||
644 | - scrollkeeper | [] [] [] | | ||
645 | - sed | [] [] [] [] [] | | ||
646 | - shared-mime-info | [] [] [] [] [] [] | | ||
647 | - sharutils | [] [] [] [] [] [] [] [] | | ||
648 | - shishi | [] | | ||
649 | - skencil | [] [] | | ||
650 | - solfege | [] | | ||
651 | - soundtracker | [] [] [] | | ||
652 | - sp | [] | | ||
653 | - system-tools-ba... | [] [] [] [] [] [] [] [] [] | | ||
654 | - tar | [] [] [] [] [] | | ||
655 | - texinfo | [] [] [] | | ||
656 | - tin | [] () | | ||
657 | - tuxpaint | [] [] | | ||
658 | - unicode-han-tra... | | | ||
659 | - unicode-transla... | [] [] | | ||
660 | - util-linux | [] [] [] [] [] [] [] | | ||
661 | - util-linux-ng | [] [] [] [] [] [] [] | | ||
662 | - vorbis-tools | | | ||
663 | - wastesedge | () | | ||
664 | - wdiff | [] [] [] [] [] [] [] [] | | ||
665 | - wget | [] [] [] [] [] [] [] [] | | ||
666 | - xchat | [] [] [] [] [] [] [] | | ||
667 | - xkeyboard-config | [] [] [] [] | | ||
668 | - xpad | [] [] [] | | ||
669 | - +--------------------------------------------------+ | ||
670 | - es et eu fa fi fr ga gl gu he hi hr hu id is it | ||
671 | - 85 22 14 2 48 101 61 12 2 8 2 6 53 29 1 52 | ||
672 | - | ||
673 | - ja ka ko ku ky lg lt lv mk mn ms mt nb ne nl nn | ||
674 | - +--------------------------------------------------+ | ||
675 | - Compendium | [] | | ||
676 | - a2ps | () [] [] | | ||
677 | - aegis | () | | ||
678 | - ant-phone | [] | | ||
679 | - anubis | [] [] [] | | ||
680 | - ap-utils | [] | | ||
681 | - aspell | [] [] | | ||
682 | - bash | [] | | ||
683 | - bfd | | | ||
684 | - bibshelf | [] | | ||
685 | - binutils | | | ||
686 | - bison | [] [] [] | | ||
687 | - bison-runtime | [] [] [] | | ||
688 | - bluez-pin | [] [] [] | | ||
689 | - cflow | | | ||
690 | - clisp | [] | | ||
691 | - console-tools | | | ||
692 | - coreutils | [] | | ||
693 | - cpio | [] | | ||
694 | - cpplib | [] | | ||
695 | - cryptonit | [] | | ||
696 | - dialog | [] [] | | ||
697 | - diffutils | [] [] [] | | ||
698 | - doodle | | | ||
699 | - e2fsprogs | [] | | ||
700 | - enscript | [] | | ||
701 | - fetchmail | [] [] | | ||
702 | - findutils | [] | | ||
703 | - findutils_stable | [] | | ||
704 | - flex | [] [] | | ||
705 | - fslint | | | ||
706 | - gas | | | ||
707 | - gawk | [] [] | | ||
708 | - gcal | | | ||
709 | - gcc | | | ||
710 | - gettext-examples | [] [] [] | | ||
711 | - gettext-runtime | [] [] [] | | ||
712 | - gettext-tools | [] [] | | ||
713 | - gip | [] [] | | ||
714 | - gliv | [] | | ||
715 | - glunarclock | [] [] | | ||
716 | - gmult | [] [] [] | | ||
717 | - gnubiff | | | ||
718 | - gnucash | () () () | | ||
719 | - gnuedu | | | ||
720 | - gnulib | [] [] | | ||
721 | - gnunet | | | ||
722 | - gnunet-gtk | | | ||
723 | - gnutls | [] | | ||
724 | - gpe-aerial | [] | | ||
725 | - gpe-beam | [] | | ||
726 | - gpe-calendar | [] | | ||
727 | - gpe-clock | [] [] [] | | ||
728 | - gpe-conf | [] [] [] | | ||
729 | - gpe-contacts | [] | | ||
730 | - gpe-edit | [] [] [] | | ||
731 | - gpe-filemanager | [] [] | | ||
732 | - gpe-go | [] [] [] | | ||
733 | - gpe-login | [] [] [] | | ||
734 | - gpe-ownerinfo | [] [] | | ||
735 | - gpe-package | [] [] | | ||
736 | - gpe-sketchbook | [] [] | | ||
737 | - gpe-su | [] [] [] | | ||
738 | - gpe-taskmanager | [] [] [] [] | | ||
739 | - gpe-timesheet | [] | | ||
740 | - gpe-today | [] [] | | ||
741 | - gpe-todo | [] | | ||
742 | - gphoto2 | [] [] | | ||
743 | - gprof | [] | | ||
744 | - gpsdrive | [] | | ||
745 | - gramadoir | () | | ||
746 | - grep | [] [] | | ||
747 | - gretl | | | ||
748 | - gsasl | [] | | ||
749 | - gss | | | ||
750 | - gst-plugins-bad | [] | | ||
751 | - gst-plugins-base | [] | | ||
752 | - gst-plugins-good | [] | | ||
753 | - gst-plugins-ugly | [] | | ||
754 | - gstreamer | [] | | ||
755 | - gtick | [] | | ||
756 | - gtkam | [] [] | | ||
757 | - gtkorphan | [] | | ||
758 | - gtkspell | [] [] | | ||
759 | - gutenprint | [] | | ||
760 | - hello | [] [] [] [] [] [] [] | | ||
761 | - herrie | [] | | ||
762 | - hylafax | | | ||
763 | - idutils | [] | | ||
764 | - indent | [] [] | | ||
765 | - iso_15924 | [] | | ||
766 | - iso_3166 | [] [] [] [] [] [] [] [] | | ||
767 | - iso_3166_2 | [] | | ||
768 | - iso_4217 | [] [] [] | | ||
769 | - iso_639 | [] [] [] [] | | ||
770 | - jpilot | () () | | ||
771 | - jtag | | | ||
772 | - jwhois | [] | | ||
773 | - kbd | [] | | ||
774 | - keytouch | [] | | ||
775 | - keytouch-editor | [] | | ||
776 | - keytouch-keyboa... | | | ||
777 | - latrine | [] | | ||
778 | - ld | | | ||
779 | - leafpad | [] [] | | ||
780 | - libc | [] [] [] | | ||
781 | - libexif | | | ||
782 | - libextractor | | | ||
783 | - libgpewidget | [] | | ||
784 | - libgpg-error | | | ||
785 | - libgphoto2 | [] | | ||
786 | - libgphoto2_port | [] | | ||
787 | - libgsasl | [] | | ||
788 | - libiconv | [] | | ||
789 | - libidn | [] [] | | ||
790 | - lifelines | [] | | ||
791 | - lilypond | [] | | ||
792 | - lingoteach | [] | | ||
793 | - lprng | | | ||
794 | - lynx | [] [] | | ||
795 | - m4 | [] [] | | ||
796 | - mailfromd | | | ||
797 | - mailutils | | | ||
798 | - make | [] [] [] | | ||
799 | - man-db | | | ||
800 | - minicom | [] | | ||
801 | - nano | [] [] [] | | ||
802 | - opcodes | [] | | ||
803 | - parted | [] [] | | ||
804 | - pilot-qof | | | ||
805 | - popt | [] [] [] | | ||
806 | - psmisc | [] [] [] | | ||
807 | - pwdutils | | | ||
808 | - qof | | | ||
809 | - radius | | | ||
810 | - recode | [] | | ||
811 | - rpm | [] [] | | ||
812 | - screem | [] | | ||
813 | - scrollkeeper | [] [] [] [] | | ||
814 | - sed | [] [] | | ||
815 | - shared-mime-info | [] [] [] [] [] [] [] | | ||
816 | - sharutils | [] [] | | ||
817 | - shishi | | | ||
818 | - skencil | | | ||
819 | - solfege | () () | | ||
820 | - soundtracker | | | ||
821 | - sp | () | | ||
822 | - system-tools-ba... | [] [] [] [] | | ||
823 | - tar | [] [] [] | | ||
824 | - texinfo | [] [] | | ||
825 | - tin | | | ||
826 | - tuxpaint | () [] [] | | ||
827 | - unicode-han-tra... | | | ||
828 | - unicode-transla... | | | ||
829 | - util-linux | [] [] | | ||
830 | - util-linux-ng | [] [] | | ||
831 | - vorbis-tools | | | ||
832 | - wastesedge | [] | | ||
833 | - wdiff | [] [] | | ||
834 | - wget | [] [] | | ||
835 | - xchat | [] [] [] [] | | ||
836 | - xkeyboard-config | [] [] [] | | ||
837 | - xpad | [] [] [] | | ||
838 | - +--------------------------------------------------+ | ||
839 | - ja ka ko ku ky lg lt lv mk mn ms mt nb ne nl nn | ||
840 | - 51 2 25 3 2 0 6 0 2 2 20 0 11 1 103 6 | ||
841 | - | ||
842 | - or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta | ||
843 | - +--------------------------------------------------+ | ||
844 | - Compendium | [] [] [] [] [] | | ||
845 | - a2ps | () [] [] [] [] [] [] | | ||
846 | - aegis | () () | | ||
847 | - ant-phone | [] [] | | ||
848 | - anubis | [] [] [] | | ||
849 | - ap-utils | () | | ||
850 | - aspell | [] [] [] | | ||
851 | - bash | [] [] | | ||
852 | - bfd | | | ||
853 | - bibshelf | [] | | ||
854 | - binutils | [] [] | | ||
855 | - bison | [] [] [] [] [] | | ||
856 | - bison-runtime | [] [] [] [] [] | | ||
857 | - bluez-pin | [] [] [] [] [] [] [] [] [] | | ||
858 | - cflow | [] | | ||
859 | - clisp | [] | | ||
860 | - console-tools | [] | | ||
861 | - coreutils | [] [] [] [] | | ||
862 | - cpio | [] [] [] | | ||
863 | - cpplib | [] | | ||
864 | - cryptonit | [] [] | | ||
865 | - dialog | [] | | ||
866 | - diffutils | [] [] [] [] [] [] | | ||
867 | - doodle | [] [] | | ||
868 | - e2fsprogs | [] [] | | ||
869 | - enscript | [] [] [] [] [] | | ||
870 | - fetchmail | [] [] [] | | ||
871 | - findutils | [] [] [] | | ||
872 | - findutils_stable | [] [] [] [] [] [] | | ||
873 | - flex | [] [] [] [] [] | | ||
874 | - fslint | [] | | ||
875 | - gas | | | ||
876 | - gawk | [] [] [] [] | | ||
877 | - gcal | [] | | ||
878 | - gcc | [] [] | | ||
879 | - gettext-examples | [] [] [] [] [] [] [] [] | | ||
880 | - gettext-runtime | [] [] [] [] [] [] [] [] | | ||
881 | - gettext-tools | [] [] [] [] [] [] [] | | ||
882 | - gip | [] [] [] [] | | ||
883 | - gliv | [] [] [] [] [] [] | | ||
884 | - glunarclock | [] [] [] [] [] [] | | ||
885 | - gmult | [] [] [] [] | | ||
886 | - gnubiff | () [] | | ||
887 | - gnucash | () [] | | ||
888 | - gnuedu | | | ||
889 | - gnulib | [] [] [] | | ||
890 | - gnunet | | | ||
891 | - gnunet-gtk | [] | | ||
892 | - gnutls | [] [] | | ||
893 | - gpe-aerial | [] [] [] [] [] [] [] | | ||
894 | - gpe-beam | [] [] [] [] [] [] [] | | ||
895 | - gpe-calendar | [] [] [] [] | | ||
896 | - gpe-clock | [] [] [] [] [] [] [] [] | | ||
897 | - gpe-conf | [] [] [] [] [] [] [] | | ||
898 | - gpe-contacts | [] [] [] [] [] | | ||
899 | - gpe-edit | [] [] [] [] [] [] [] [] [] | | ||
900 | - gpe-filemanager | [] [] | | ||
901 | - gpe-go | [] [] [] [] [] [] [] [] | | ||
902 | - gpe-login | [] [] [] [] [] [] [] [] | | ||
903 | - gpe-ownerinfo | [] [] [] [] [] [] [] [] | | ||
904 | - gpe-package | [] [] | | ||
905 | - gpe-sketchbook | [] [] [] [] [] [] [] [] | | ||
906 | - gpe-su | [] [] [] [] [] [] [] [] | | ||
907 | - gpe-taskmanager | [] [] [] [] [] [] [] [] | | ||
908 | - gpe-timesheet | [] [] [] [] [] [] [] [] | | ||
909 | - gpe-today | [] [] [] [] [] [] [] [] | | ||
910 | - gpe-todo | [] [] [] [] | | ||
911 | - gphoto2 | [] [] [] [] [] [] | | ||
912 | - gprof | [] [] [] | | ||
913 | - gpsdrive | [] [] | | ||
914 | - gramadoir | [] [] | | ||
915 | - grep | [] [] [] [] | | ||
916 | - gretl | [] [] [] | | ||
917 | - gsasl | [] [] [] | | ||
918 | - gss | [] [] [] [] | | ||
919 | - gst-plugins-bad | [] [] [] | | ||
920 | - gst-plugins-base | [] [] | | ||
921 | - gst-plugins-good | [] [] | | ||
922 | - gst-plugins-ugly | [] [] [] | | ||
923 | - gstreamer | [] [] [] [] | | ||
924 | - gtick | [] | | ||
925 | - gtkam | [] [] [] [] [] | | ||
926 | - gtkorphan | [] | | ||
927 | - gtkspell | [] [] [] [] [] [] [] [] | | ||
928 | - gutenprint | [] | | ||
929 | - hello | [] [] [] [] [] [] [] [] | | ||
930 | - herrie | [] [] [] | | ||
931 | - hylafax | | | ||
932 | - idutils | [] [] [] [] [] | | ||
933 | - indent | [] [] [] [] [] [] [] | | ||
934 | - iso_15924 | | | ||
935 | - iso_3166 | [] [] [] [] [] [] [] [] [] [] [] [] [] | | ||
936 | - iso_3166_2 | | | ||
937 | - iso_4217 | [] [] [] [] [] [] [] | | ||
938 | - iso_639 | [] [] [] [] [] [] [] | | ||
939 | - jpilot | | | ||
940 | - jtag | [] | | ||
941 | - jwhois | [] [] [] [] | | ||
942 | - kbd | [] [] [] | | ||
943 | - keytouch | [] | | ||
944 | - keytouch-editor | [] | | ||
945 | - keytouch-keyboa... | [] | | ||
946 | - latrine | | | ||
947 | - ld | [] | | ||
948 | - leafpad | [] [] [] [] [] [] | | ||
949 | - libc | [] [] [] [] | | ||
950 | - libexif | [] [] | | ||
951 | - libextractor | [] [] | | ||
952 | - libgpewidget | [] [] [] [] [] [] [] [] | | ||
953 | - libgpg-error | [] [] [] | | ||
954 | - libgphoto2 | [] | | ||
955 | - libgphoto2_port | [] [] [] | | ||
956 | - libgsasl | [] [] [] [] | | ||
957 | - libiconv | [] [] [] | | ||
958 | - libidn | [] [] () | | ||
959 | - lifelines | [] [] | | ||
960 | - lilypond | | | ||
961 | - lingoteach | [] | | ||
962 | - lprng | [] | | ||
963 | - lynx | [] [] [] | | ||
964 | - m4 | [] [] [] [] [] | | ||
965 | - mailfromd | [] | | ||
966 | - mailutils | [] [] [] | | ||
967 | - make | [] [] [] [] | | ||
968 | - man-db | [] [] [] [] | | ||
969 | - minicom | [] [] [] [] [] | | ||
970 | - nano | [] [] [] [] | | ||
971 | - opcodes | [] [] | | ||
972 | - parted | [] | | ||
973 | - pilot-qof | | | ||
974 | - popt | [] [] [] [] | | ||
975 | - psmisc | [] [] | | ||
976 | - pwdutils | [] [] | | ||
977 | - qof | [] [] | | ||
978 | - radius | [] [] | | ||
979 | - recode | [] [] [] [] [] [] [] | | ||
980 | - rpm | [] [] [] [] | | ||
981 | - screem | | | ||
982 | - scrollkeeper | [] [] [] [] [] [] [] | | ||
983 | - sed | [] [] [] [] [] [] [] [] [] | | ||
984 | - shared-mime-info | [] [] [] [] [] [] | | ||
985 | - sharutils | [] [] [] [] | | ||
986 | - shishi | [] | | ||
987 | - skencil | [] [] [] | | ||
988 | - solfege | [] | | ||
989 | - soundtracker | [] [] | | ||
990 | - sp | | | ||
991 | - system-tools-ba... | [] [] [] [] [] [] [] [] [] | | ||
992 | - tar | [] [] [] [] | | ||
993 | - texinfo | [] [] [] [] | | ||
994 | - tin | () | | ||
995 | - tuxpaint | [] [] [] [] [] [] | | ||
996 | - unicode-han-tra... | | | ||
997 | - unicode-transla... | | | ||
998 | - util-linux | [] [] [] [] | | ||
999 | - util-linux-ng | [] [] [] [] | | ||
1000 | - vorbis-tools | [] | | ||
1001 | - wastesedge | | | ||
1002 | - wdiff | [] [] [] [] [] [] [] | | ||
1003 | - wget | [] [] [] [] | | ||
1004 | - xchat | [] [] [] [] [] [] [] | | ||
1005 | - xkeyboard-config | [] [] [] | | ||
1006 | - xpad | [] [] [] | | ||
1007 | - +--------------------------------------------------+ | ||
1008 | - or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta | ||
1009 | - 0 5 77 31 53 4 58 72 3 45 46 9 45 122 3 | ||
1010 | - | ||
1011 | - tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu | ||
1012 | - +---------------------------------------------------+ | ||
1013 | - Compendium | [] [] [] [] | 19 | ||
1014 | - a2ps | [] [] [] | 19 | ||
1015 | - aegis | [] | 1 | ||
1016 | - ant-phone | [] [] | 6 | ||
1017 | - anubis | [] [] [] | 11 | ||
1018 | - ap-utils | () [] | 4 | ||
1019 | - aspell | [] [] [] | 16 | ||
1020 | - bash | [] | 6 | ||
1021 | - bfd | | 2 | ||
1022 | - bibshelf | [] | 7 | ||
1023 | - binutils | [] [] [] [] | 9 | ||
1024 | - bison | [] [] [] [] | 20 | ||
1025 | - bison-runtime | [] [] [] [] | 18 | ||
1026 | - bluez-pin | [] [] [] [] [] [] | 28 | ||
1027 | - cflow | [] [] | 5 | ||
1028 | - clisp | | 9 | ||
1029 | - console-tools | [] [] | 5 | ||
1030 | - coreutils | [] [] [] | 18 | ||
1031 | - cpio | [] [] [] [] | 11 | ||
1032 | - cpplib | [] [] [] [] [] | 12 | ||
1033 | - cryptonit | [] | 6 | ||
1034 | - dialog | [] [] [] | 9 | ||
1035 | - diffutils | [] [] [] [] [] | 29 | ||
1036 | - doodle | [] | 6 | ||
1037 | - e2fsprogs | [] [] | 10 | ||
1038 | - enscript | [] [] [] | 16 | ||
1039 | - fetchmail | [] [] | 12 | ||
1040 | - findutils | [] [] [] | 11 | ||
1041 | - findutils_stable | [] [] [] [] | 18 | ||
1042 | - flex | [] [] | 15 | ||
1043 | - fslint | [] | 2 | ||
1044 | - gas | [] | 3 | ||
1045 | - gawk | [] [] [] | 16 | ||
1046 | - gcal | [] | 5 | ||
1047 | - gcc | [] [] [] | 7 | ||
1048 | - gettext-examples | [] [] [] [] [] [] | 29 | ||
1049 | - gettext-runtime | [] [] [] [] [] [] | 28 | ||
1050 | - gettext-tools | [] [] [] [] [] | 20 | ||
1051 | - gip | [] [] | 13 | ||
1052 | - gliv | [] [] | 11 | ||
1053 | - glunarclock | [] [] [] | 15 | ||
1054 | - gmult | [] [] [] [] | 16 | ||
1055 | - gnubiff | [] | 2 | ||
1056 | - gnucash | () [] | 5 | ||
1057 | - gnuedu | [] | 2 | ||
1058 | - gnulib | [] | 10 | ||
1059 | - gnunet | | 0 | ||
1060 | - gnunet-gtk | [] [] | 3 | ||
1061 | - gnutls | | 4 | ||
1062 | - gpe-aerial | [] [] | 14 | ||
1063 | - gpe-beam | [] [] | 14 | ||
1064 | - gpe-calendar | [] [] | 7 | ||
1065 | - gpe-clock | [] [] [] [] | 21 | ||
1066 | - gpe-conf | [] [] [] | 16 | ||
1067 | - gpe-contacts | [] [] | 10 | ||
1068 | - gpe-edit | [] [] [] [] [] | 22 | ||
1069 | - gpe-filemanager | [] [] | 7 | ||
1070 | - gpe-go | [] [] [] [] | 19 | ||
1071 | - gpe-login | [] [] [] [] [] | 21 | ||
1072 | - gpe-ownerinfo | [] [] [] [] | 21 | ||
1073 | - gpe-package | [] | 6 | ||
1074 | - gpe-sketchbook | [] [] | 16 | ||
1075 | - gpe-su | [] [] [] [] | 21 | ||
1076 | - gpe-taskmanager | [] [] [] [] | 21 | ||
1077 | - gpe-timesheet | [] [] [] [] | 18 | ||
1078 | - gpe-today | [] [] [] [] [] | 21 | ||
1079 | - gpe-todo | [] [] | 8 | ||
1080 | - gphoto2 | [] [] [] [] | 21 | ||
1081 | - gprof | [] [] | 13 | ||
1082 | - gpsdrive | [] | 5 | ||
1083 | - gramadoir | [] | 7 | ||
1084 | - grep | [] | 12 | ||
1085 | - gretl | | 6 | ||
1086 | - gsasl | [] [] [] | 9 | ||
1087 | - gss | [] | 7 | ||
1088 | - gst-plugins-bad | [] [] [] | 13 | ||
1089 | - gst-plugins-base | [] [] | 11 | ||
1090 | - gst-plugins-good | [] [] [] [] [] | 16 | ||
1091 | - gst-plugins-ugly | [] [] [] | 13 | ||
1092 | - gstreamer | [] [] [] | 18 | ||
1093 | - gtick | [] [] | 7 | ||
1094 | - gtkam | [] | 16 | ||
1095 | - gtkorphan | [] | 7 | ||
1096 | - gtkspell | [] [] [] [] [] [] | 27 | ||
1097 | - gutenprint | | 4 | ||
1098 | - hello | [] [] [] [] [] | 38 | ||
1099 | - herrie | [] [] | 8 | ||
1100 | - hylafax | | 0 | ||
1101 | - idutils | [] [] | 15 | ||
1102 | - indent | [] [] [] [] [] | 28 | ||
1103 | - iso_15924 | [] [] | 4 | ||
1104 | - iso_3166 | [] [] [] [] [] [] [] [] [] | 54 | ||
1105 | - iso_3166_2 | [] [] | 4 | ||
1106 | - iso_4217 | [] [] [] [] [] | 24 | ||
1107 | - iso_639 | [] [] [] [] [] | 26 | ||
1108 | - jpilot | [] [] [] [] | 7 | ||
1109 | - jtag | [] | 3 | ||
1110 | - jwhois | [] [] [] | 13 | ||
1111 | - kbd | [] [] [] | 13 | ||
1112 | - keytouch | [] | 8 | ||
1113 | - keytouch-editor | [] | 5 | ||
1114 | - keytouch-keyboa... | [] | 5 | ||
1115 | - latrine | [] [] | 5 | ||
1116 | - ld | [] [] [] [] | 10 | ||
1117 | - leafpad | [] [] [] [] [] | 24 | ||
1118 | - libc | [] [] [] | 19 | ||
1119 | - libexif | [] | 5 | ||
1120 | - libextractor | [] | 5 | ||
1121 | - libgpewidget | [] [] [] | 20 | ||
1122 | - libgpg-error | [] | 6 | ||
1123 | - libgphoto2 | [] [] | 9 | ||
1124 | - libgphoto2_port | [] [] [] | 11 | ||
1125 | - libgsasl | [] | 8 | ||
1126 | - libiconv | [] [] | 11 | ||
1127 | - libidn | [] [] | 11 | ||
1128 | - lifelines | | 4 | ||
1129 | - lilypond | [] | 6 | ||
1130 | - lingoteach | [] | 6 | ||
1131 | - lprng | [] | 2 | ||
1132 | - lynx | [] [] [] | 15 | ||
1133 | - m4 | [] [] [] | 18 | ||
1134 | - mailfromd | [] [] | 3 | ||
1135 | - mailutils | [] [] | 8 | ||
1136 | - make | [] [] [] | 20 | ||
1137 | - man-db | [] | 9 | ||
1138 | - minicom | [] | 14 | ||
1139 | - nano | [] [] [] | 20 | ||
1140 | - opcodes | [] [] | 10 | ||
1141 | - parted | [] [] [] | 11 | ||
1142 | - pilot-qof | [] | 1 | ||
1143 | - popt | [] [] [] [] | 18 | ||
1144 | - psmisc | [] [] | 10 | ||
1145 | - pwdutils | [] | 3 | ||
1146 | - qof | [] | 4 | ||
1147 | - radius | [] [] | 7 | ||
1148 | - recode | [] [] [] | 25 | ||
1149 | - rpm | [] [] [] [] | 13 | ||
1150 | - screem | [] | 2 | ||
1151 | - scrollkeeper | [] [] [] [] | 26 | ||
1152 | - sed | [] [] [] [] | 23 | ||
1153 | - shared-mime-info | [] [] [] | 29 | ||
1154 | - sharutils | [] [] [] | 23 | ||
1155 | - shishi | [] | 3 | ||
1156 | - skencil | [] | 7 | ||
1157 | - solfege | [] | 3 | ||
1158 | - soundtracker | [] [] | 9 | ||
1159 | - sp | [] | 3 | ||
1160 | - system-tools-ba... | [] [] [] [] [] [] [] | 38 | ||
1161 | - tar | [] [] [] | 17 | ||
1162 | - texinfo | [] [] [] | 15 | ||
1163 | - tin | | 1 | ||
1164 | - tuxpaint | [] [] [] | 19 | ||
1165 | - unicode-han-tra... | | 0 | ||
1166 | - unicode-transla... | | 2 | ||
1167 | - util-linux | [] [] [] | 20 | ||
1168 | - util-linux-ng | [] [] [] | 20 | ||
1169 | - vorbis-tools | [] [] | 4 | ||
1170 | - wastesedge | | 1 | ||
1171 | - wdiff | [] [] | 23 | ||
1172 | - wget | [] [] [] | 20 | ||
1173 | - xchat | [] [] [] [] | 29 | ||
1174 | - xkeyboard-config | [] [] [] | 14 | ||
1175 | - xpad | [] [] [] | 15 | ||
1176 | - +---------------------------------------------------+ | ||
1177 | - 76 teams tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu | ||
1178 | - 163 domains 0 3 1 74 51 0 143 21 1 57 7 45 0 2036 | ||
1179 | - | ||
1180 | - Some counters in the preceding matrix are higher than the number of | ||
1181 | -visible blocks let us expect. This is because a few extra PO files are | ||
1182 | -used for implementing regional variants of languages, or language | ||
1183 | -dialects. | ||
1184 | - | ||
1185 | - For a PO file in the matrix above to be effective, the package to | ||
1186 | -which it applies should also have been internationalized and | ||
1187 | -distributed as such by its maintainer. There might be an observable | ||
1188 | -lag between the mere existence a PO file and its wide availability in a | ||
1189 | -distribution. | ||
1190 | - | ||
1191 | - If November 2007 seems to be old, you may fetch a more recent copy | ||
1192 | -of this `ABOUT-NLS' file on most GNU archive sites. The most | ||
1193 | -up-to-date matrix with full percentage details can be found at | ||
1194 | -`http://translationproject.org/extra/matrix.html'. | ||
1195 | - | ||
1196 | -1.6 Using `gettext' in new packages | ||
1197 | -=================================== | ||
1198 | - | ||
1199 | -If you are writing a freely available program and want to | ||
1200 | -internationalize it you are welcome to use GNU `gettext' in your | ||
1201 | -package. Of course you have to respect the GNU Library General Public | ||
1202 | -License which covers the use of the GNU `gettext' library. This means | ||
1203 | -in particular that even non-free programs can use `libintl' as a shared | ||
1204 | -library, whereas only free software can use `libintl' as a static | ||
1205 | -library or use modified versions of `libintl'. | ||
1206 | - | ||
1207 | - Once the sources are changed appropriately and the setup can handle | ||
1208 | -the use of `gettext' the only thing missing are the translations. The | ||
1209 | -Free Translation Project is also available for packages which are not | ||
1210 | -developed inside the GNU project. Therefore the information given above | ||
1211 | -applies also for every other Free Software Project. Contact | ||
1212 | -`coordinator@translationproject.org' to make the `.pot' files available | ||
1213 | -to the translation teams. | ||
1214 | - | ||
1215 | +<https://www.gnu.org/software/gettext/manual/html_node/Users.html> | ||
1216 | --- a/ChangeLog | ||
1217 | +++ b/ChangeLog | ||
1218 | @@ -1,3 +1,10 @@ | ||
1219 | +2019-12-07 gettextize <bug-gnu-gettext@gnu.org> | ||
1220 | + | ||
1221 | + * m4/intlmacosx.m4: Upgrade to gettext-0.20.1. | ||
1222 | + * Makefile.am (SUBDIRS): Remove intl. | ||
1223 | + * configure.ac (AC_CONFIG_FILES): Remove intl/Makefile. | ||
1224 | + (AM_GNU_GETTEXT_VERSION): Bump to 0.20. | ||
1225 | + | ||
1226 | 2013-03-13 Steve Langasek <steve.langasek@ubuntu.com> | ||
1227 | |||
1228 | * nih/watch.c (nih_watch_walk_filter): New NihFileFilter function | ||
1229 | --- a/Makefile.am | ||
1230 | +++ b/Makefile.am | ||
1231 | @@ -1,6 +1,6 @@ | ||
1232 | ## Process this file with automake to produce Makefile.in | ||
1233 | |||
1234 | -SUBDIRS = m4 intl nih nih-dbus nih-dbus-tool po | ||
1235 | +SUBDIRS = m4 nih nih-dbus nih-dbus-tool po | ||
1236 | |||
1237 | EXTRA_DIST = HACKING | ||
1238 | |||
1239 | --- a/configure.ac | ||
1240 | +++ b/configure.ac | ||
1241 | @@ -15,8 +15,8 @@ AM_MAINTAINER_MODE([enable]) | ||
1242 | LT_PREREQ(2.2.4) | ||
1243 | LT_INIT | ||
1244 | |||
1245 | -AM_GNU_GETTEXT_VERSION([0.17]) | ||
1246 | -AM_GNU_GETTEXT() | ||
1247 | +AM_GNU_GETTEXT_VERSION([0.20]) | ||
1248 | +AM_GNU_GETTEXT([external]) | ||
1249 | |||
1250 | # Checks for programs. | ||
1251 | AC_PROG_CC | ||
1252 | @@ -58,7 +58,7 @@ AS_IF([test "$cross_compiling" = "yes"], | ||
1253 | AC_SUBST([NIH_DBUS_TOOL], ["\${top_builddir}/nih-dbus-tool/nih-dbus-tool"])])], | ||
1254 | [AC_SUBST([NIH_DBUS_TOOL], ["\${top_builddir}/nih-dbus-tool/nih-dbus-tool"])]) | ||
1255 | |||
1256 | -AC_CONFIG_FILES([ Makefile m4/Makefile intl/Makefile | ||
1257 | +AC_CONFIG_FILES([ Makefile m4/Makefile | ||
1258 | nih/Makefile nih/libnih.pc | ||
1259 | nih-dbus/Makefile nih-dbus/libnih-dbus.pc | ||
1260 | nih-dbus-tool/Makefile | ||
1261 | --- a/intl/ChangeLog | ||
1262 | +++ /dev/null | ||
1263 | @@ -1,4 +0,0 @@ | ||
1264 | -2007-11-07 GNU <bug-gnu-gettext@gnu.org> | ||
1265 | - | ||
1266 | - * Version 0.17 released. | ||
1267 | - | ||
1268 | --- a/intl/Makefile.in | ||
1269 | +++ /dev/null | ||
1270 | @@ -1,587 +0,0 @@ | ||
1271 | -# Makefile for directory with message catalog handling library of GNU gettext | ||
1272 | -# Copyright (C) 1995-1998, 2000-2007 Free Software Foundation, Inc. | ||
1273 | -# | ||
1274 | -# This program is free software; you can redistribute it and/or modify it | ||
1275 | -# under the terms of the GNU Library General Public License as published | ||
1276 | -# by the Free Software Foundation; either version 2, or (at your option) | ||
1277 | -# any later version. | ||
1278 | -# | ||
1279 | -# This program is distributed in the hope that it will be useful, | ||
1280 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1281 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1282 | -# Library General Public License for more details. | ||
1283 | -# | ||
1284 | -# You should have received a copy of the GNU Library General Public | ||
1285 | -# License along with this program; if not, write to the Free Software | ||
1286 | -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
1287 | -# USA. | ||
1288 | - | ||
1289 | -PACKAGE = @PACKAGE@ | ||
1290 | -VERSION = @VERSION@ | ||
1291 | - | ||
1292 | -SHELL = /bin/sh | ||
1293 | - | ||
1294 | -srcdir = @srcdir@ | ||
1295 | -top_srcdir = @top_srcdir@ | ||
1296 | -top_builddir = .. | ||
1297 | - | ||
1298 | -# The VPATH variables allows builds with $builddir != $srcdir, assuming a | ||
1299 | -# 'make' program that supports VPATH (such as GNU make). This line is removed | ||
1300 | -# by autoconf automatically when "$(srcdir)" = ".". | ||
1301 | -# In this directory, the VPATH handling is particular: | ||
1302 | -# 1. If INTL_LIBTOOL_SUFFIX_PREFIX is 'l' (indicating a build with libtool), | ||
1303 | -# the .c -> .lo rules carefully use $(srcdir), so that VPATH can be omitted. | ||
1304 | -# 2. If PACKAGE = gettext-tools, VPATH _must_ be omitted, because otherwise | ||
1305 | -# 'make' does the wrong thing if GNU gettext was configured with | ||
1306 | -# "./configure --srcdir=`pwd`", namely it gets confused by the .lo and .la | ||
1307 | -# files it finds in srcdir = ../../gettext-runtime/intl. | ||
1308 | -VPATH = $(srcdir) | ||
1309 | - | ||
1310 | -prefix = @prefix@ | ||
1311 | -exec_prefix = @exec_prefix@ | ||
1312 | -transform = @program_transform_name@ | ||
1313 | -libdir = @libdir@ | ||
1314 | -includedir = @includedir@ | ||
1315 | -datarootdir = @datarootdir@ | ||
1316 | -datadir = @datadir@ | ||
1317 | -localedir = $(datadir)/locale | ||
1318 | -gettextsrcdir = $(datadir)/gettext/intl | ||
1319 | -aliaspath = $(localedir) | ||
1320 | -subdir = intl | ||
1321 | - | ||
1322 | -INSTALL = @INSTALL@ | ||
1323 | -INSTALL_DATA = @INSTALL_DATA@ | ||
1324 | - | ||
1325 | -# We use $(mkdir_p). | ||
1326 | -# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as | ||
1327 | -# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, | ||
1328 | -# @install_sh@ does not start with $(SHELL), so we add it. | ||
1329 | -# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined | ||
1330 | -# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake | ||
1331 | -# versions, $(mkinstalldirs) and $(install_sh) are unused. | ||
1332 | -mkinstalldirs = $(SHELL) @install_sh@ -d | ||
1333 | -install_sh = $(SHELL) @install_sh@ | ||
1334 | -MKDIR_P = @MKDIR_P@ | ||
1335 | -mkdir_p = @mkdir_p@ | ||
1336 | - | ||
1337 | -l = @INTL_LIBTOOL_SUFFIX_PREFIX@ | ||
1338 | - | ||
1339 | -AR = ar | ||
1340 | -CC = @CC@ | ||
1341 | -LIBTOOL = @LIBTOOL@ | ||
1342 | -RANLIB = @RANLIB@ | ||
1343 | -YACC = @INTLBISON@ -y -d | ||
1344 | -YFLAGS = --name-prefix=__gettext | ||
1345 | -WINDRES = @WINDRES@ | ||
1346 | - | ||
1347 | -# -DBUILDING_LIBINTL: Change expansion of LIBINTL_DLL_EXPORTED macro. | ||
1348 | -# -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro. | ||
1349 | -DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ | ||
1350 | --DLIBDIR=\"$(libdir)\" -DBUILDING_LIBINTL -DBUILDING_DLL -DIN_LIBINTL \ | ||
1351 | --DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\" -DNO_XMALLOC \ | ||
1352 | --Dset_relocation_prefix=libintl_set_relocation_prefix \ | ||
1353 | --Drelocate=libintl_relocate \ | ||
1354 | --DDEPENDS_ON_LIBICONV=1 @DEFS@ | ||
1355 | -CPPFLAGS = @CPPFLAGS@ | ||
1356 | -CFLAGS = @CFLAGS@ @CFLAG_VISIBILITY@ | ||
1357 | -LDFLAGS = @LDFLAGS@ $(LDFLAGS_@WOE32DLL@) | ||
1358 | -LDFLAGS_yes = -Wl,--export-all-symbols | ||
1359 | -LDFLAGS_no = | ||
1360 | -LIBS = @LIBS@ | ||
1361 | - | ||
1362 | -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) | ||
1363 | - | ||
1364 | -HEADERS = \ | ||
1365 | - gmo.h \ | ||
1366 | - gettextP.h \ | ||
1367 | - hash-string.h \ | ||
1368 | - loadinfo.h \ | ||
1369 | - plural-exp.h \ | ||
1370 | - eval-plural.h \ | ||
1371 | - localcharset.h \ | ||
1372 | - lock.h \ | ||
1373 | - relocatable.h \ | ||
1374 | - tsearch.h tsearch.c \ | ||
1375 | - xsize.h \ | ||
1376 | - printf-args.h printf-args.c \ | ||
1377 | - printf-parse.h wprintf-parse.h printf-parse.c \ | ||
1378 | - vasnprintf.h vasnwprintf.h vasnprintf.c \ | ||
1379 | - os2compat.h \ | ||
1380 | - libgnuintl.h.in | ||
1381 | -SOURCES = \ | ||
1382 | - bindtextdom.c \ | ||
1383 | - dcgettext.c \ | ||
1384 | - dgettext.c \ | ||
1385 | - gettext.c \ | ||
1386 | - finddomain.c \ | ||
1387 | - hash-string.c \ | ||
1388 | - loadmsgcat.c \ | ||
1389 | - localealias.c \ | ||
1390 | - textdomain.c \ | ||
1391 | - l10nflist.c \ | ||
1392 | - explodename.c \ | ||
1393 | - dcigettext.c \ | ||
1394 | - dcngettext.c \ | ||
1395 | - dngettext.c \ | ||
1396 | - ngettext.c \ | ||
1397 | - plural.y \ | ||
1398 | - plural-exp.c \ | ||
1399 | - localcharset.c \ | ||
1400 | - lock.c \ | ||
1401 | - relocatable.c \ | ||
1402 | - langprefs.c \ | ||
1403 | - localename.c \ | ||
1404 | - log.c \ | ||
1405 | - printf.c \ | ||
1406 | - version.c \ | ||
1407 | - osdep.c \ | ||
1408 | - os2compat.c \ | ||
1409 | - intl-exports.c \ | ||
1410 | - intl-compat.c | ||
1411 | -OBJECTS = \ | ||
1412 | - bindtextdom.$lo \ | ||
1413 | - dcgettext.$lo \ | ||
1414 | - dgettext.$lo \ | ||
1415 | - gettext.$lo \ | ||
1416 | - finddomain.$lo \ | ||
1417 | - hash-string.$lo \ | ||
1418 | - loadmsgcat.$lo \ | ||
1419 | - localealias.$lo \ | ||
1420 | - textdomain.$lo \ | ||
1421 | - l10nflist.$lo \ | ||
1422 | - explodename.$lo \ | ||
1423 | - dcigettext.$lo \ | ||
1424 | - dcngettext.$lo \ | ||
1425 | - dngettext.$lo \ | ||
1426 | - ngettext.$lo \ | ||
1427 | - plural.$lo \ | ||
1428 | - plural-exp.$lo \ | ||
1429 | - localcharset.$lo \ | ||
1430 | - lock.$lo \ | ||
1431 | - relocatable.$lo \ | ||
1432 | - langprefs.$lo \ | ||
1433 | - localename.$lo \ | ||
1434 | - log.$lo \ | ||
1435 | - printf.$lo \ | ||
1436 | - version.$lo \ | ||
1437 | - osdep.$lo \ | ||
1438 | - intl-compat.$lo | ||
1439 | -OBJECTS_RES_yes = libintl.res | ||
1440 | -OBJECTS_RES_no = | ||
1441 | -DISTFILES.common = Makefile.in \ | ||
1442 | -config.charset locale.alias ref-add.sin ref-del.sin export.h libintl.rc \ | ||
1443 | -$(HEADERS) $(SOURCES) | ||
1444 | -DISTFILES.generated = plural.c | ||
1445 | -DISTFILES.normal = VERSION | ||
1446 | -DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc README.woe32 | ||
1447 | -DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \ | ||
1448 | -COPYING.LIB-2 gettext.h libgettext.h plural-eval.c libgnuintl.h \ | ||
1449 | -libgnuintl.h_vms Makefile.vms libgnuintl.h.msvc-static \ | ||
1450 | -libgnuintl.h.msvc-shared Makefile.msvc | ||
1451 | - | ||
1452 | -all: all-@USE_INCLUDED_LIBINTL@ | ||
1453 | -all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed | ||
1454 | -all-no: all-no-@BUILD_INCLUDED_LIBINTL@ | ||
1455 | -all-no-yes: libgnuintl.$la | ||
1456 | -all-no-no: | ||
1457 | - | ||
1458 | -libintl.a libgnuintl.a: $(OBJECTS) | ||
1459 | - rm -f $@ | ||
1460 | - $(AR) cru $@ $(OBJECTS) | ||
1461 | - $(RANLIB) $@ | ||
1462 | - | ||
1463 | -libintl.la libgnuintl.la: $(OBJECTS) $(OBJECTS_RES_@WOE32@) | ||
1464 | - $(LIBTOOL) --mode=link \ | ||
1465 | - $(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \ | ||
1466 | - $(OBJECTS) @LTLIBICONV@ @INTL_MACOSX_LIBS@ $(LIBS) @LTLIBTHREAD@ @LTLIBC@ \ | ||
1467 | - $(OBJECTS_RES_@WOE32@) \ | ||
1468 | - -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \ | ||
1469 | - -rpath $(libdir) \ | ||
1470 | - -no-undefined | ||
1471 | - | ||
1472 | -# Libtool's library version information for libintl. | ||
1473 | -# Before making a gettext release, the gettext maintainer must change this | ||
1474 | -# according to the libtool documentation, section "Library interface versions". | ||
1475 | -# Maintainers of other packages that include the intl directory must *not* | ||
1476 | -# change these values. | ||
1477 | -LTV_CURRENT=8 | ||
1478 | -LTV_REVISION=2 | ||
1479 | -LTV_AGE=0 | ||
1480 | - | ||
1481 | -.SUFFIXES: | ||
1482 | -.SUFFIXES: .c .y .o .lo .sin .sed | ||
1483 | - | ||
1484 | -.c.o: | ||
1485 | - $(COMPILE) $< | ||
1486 | - | ||
1487 | -.y.c: | ||
1488 | - $(YACC) $(YFLAGS) --output $@ $< | ||
1489 | - rm -f $*.h | ||
1490 | - | ||
1491 | -bindtextdom.lo: $(srcdir)/bindtextdom.c | ||
1492 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/bindtextdom.c | ||
1493 | -dcgettext.lo: $(srcdir)/dcgettext.c | ||
1494 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dcgettext.c | ||
1495 | -dgettext.lo: $(srcdir)/dgettext.c | ||
1496 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dgettext.c | ||
1497 | -gettext.lo: $(srcdir)/gettext.c | ||
1498 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/gettext.c | ||
1499 | -finddomain.lo: $(srcdir)/finddomain.c | ||
1500 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/finddomain.c | ||
1501 | -hash-string.lo: $(srcdir)/hash-string.c | ||
1502 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/hash-string.c | ||
1503 | -loadmsgcat.lo: $(srcdir)/loadmsgcat.c | ||
1504 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/loadmsgcat.c | ||
1505 | -localealias.lo: $(srcdir)/localealias.c | ||
1506 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localealias.c | ||
1507 | -textdomain.lo: $(srcdir)/textdomain.c | ||
1508 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/textdomain.c | ||
1509 | -l10nflist.lo: $(srcdir)/l10nflist.c | ||
1510 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/l10nflist.c | ||
1511 | -explodename.lo: $(srcdir)/explodename.c | ||
1512 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/explodename.c | ||
1513 | -dcigettext.lo: $(srcdir)/dcigettext.c | ||
1514 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dcigettext.c | ||
1515 | -dcngettext.lo: $(srcdir)/dcngettext.c | ||
1516 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dcngettext.c | ||
1517 | -dngettext.lo: $(srcdir)/dngettext.c | ||
1518 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dngettext.c | ||
1519 | -ngettext.lo: $(srcdir)/ngettext.c | ||
1520 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/ngettext.c | ||
1521 | -plural.lo: $(srcdir)/plural.c | ||
1522 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural.c | ||
1523 | -plural-exp.lo: $(srcdir)/plural-exp.c | ||
1524 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c | ||
1525 | -localcharset.lo: $(srcdir)/localcharset.c | ||
1526 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c | ||
1527 | -lock.lo: $(srcdir)/lock.c | ||
1528 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/lock.c | ||
1529 | -relocatable.lo: $(srcdir)/relocatable.c | ||
1530 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/relocatable.c | ||
1531 | -langprefs.lo: $(srcdir)/langprefs.c | ||
1532 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/langprefs.c | ||
1533 | -localename.lo: $(srcdir)/localename.c | ||
1534 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localename.c | ||
1535 | -log.lo: $(srcdir)/log.c | ||
1536 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/log.c | ||
1537 | -printf.lo: $(srcdir)/printf.c | ||
1538 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/printf.c | ||
1539 | -version.lo: $(srcdir)/version.c | ||
1540 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/version.c | ||
1541 | -osdep.lo: $(srcdir)/osdep.c | ||
1542 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/osdep.c | ||
1543 | -intl-compat.lo: $(srcdir)/intl-compat.c | ||
1544 | - $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/intl-compat.c | ||
1545 | - | ||
1546 | -# This rule is executed only on Woe32 systems. | ||
1547 | -# The following sed expressions come from the windres-options script. They are | ||
1548 | -# inlined here, so that they can be written in a Makefile without requiring a | ||
1549 | -# temporary file. They must contain literal newlines rather than semicolons, | ||
1550 | -# so that they work with the sed-3.02 that is shipped with MSYS. We can use | ||
1551 | -# GNU bash's $'\n' syntax to obtain such a newline. | ||
1552 | -libintl.res: $(srcdir)/libintl.rc | ||
1553 | - nl=$$'\n'; \ | ||
1554 | - sed_extract_major='/^[0-9]/{'$${nl}'s/^\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \ | ||
1555 | - sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{'$${nl}'s/^[0-9]*[.]\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \ | ||
1556 | - sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{'$${nl}'s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p'$${nl}q$${nl}'}'$${nl}'c\'$${nl}0$${nl}q; \ | ||
1557 | - $(WINDRES) \ | ||
1558 | - "-DPACKAGE_VERSION_STRING=\\\"$(VERSION)\\\"" \ | ||
1559 | - "-DPACKAGE_VERSION_MAJOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_major"` \ | ||
1560 | - "-DPACKAGE_VERSION_MINOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_minor"` \ | ||
1561 | - "-DPACKAGE_VERSION_SUBMINOR="`echo '$(VERSION)' | sed -n -e "$$sed_extract_subminor"` \ | ||
1562 | - -i $(srcdir)/libintl.rc -o libintl.res --output-format=coff | ||
1563 | - | ||
1564 | -ref-add.sed: $(srcdir)/ref-add.sin | ||
1565 | - sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-add.sin > t-ref-add.sed | ||
1566 | - mv t-ref-add.sed ref-add.sed | ||
1567 | -ref-del.sed: $(srcdir)/ref-del.sin | ||
1568 | - sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-del.sin > t-ref-del.sed | ||
1569 | - mv t-ref-del.sed ref-del.sed | ||
1570 | - | ||
1571 | -INCLUDES = -I. -I$(srcdir) -I.. | ||
1572 | - | ||
1573 | -libgnuintl.h: $(srcdir)/libgnuintl.h.in | ||
1574 | - sed -e '/IN_LIBGLOCALE/d' \ | ||
1575 | - -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \ | ||
1576 | - -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ | ||
1577 | - -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ | ||
1578 | - -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ | ||
1579 | - < $(srcdir)/libgnuintl.h.in \ | ||
1580 | - | if test '@WOE32DLL@' = yes; then \ | ||
1581 | - sed -e 's/extern \([^()]*\);/extern __declspec (dllimport) \1;/'; \ | ||
1582 | - else \ | ||
1583 | - cat; \ | ||
1584 | - fi \ | ||
1585 | - | sed -e 's/extern \([^"]\)/extern LIBINTL_DLL_EXPORTED \1/' \ | ||
1586 | - -e "/#define _LIBINTL_H/r $(srcdir)/export.h" \ | ||
1587 | - | sed -e 's,@''HAVE_VISIBILITY''@,@HAVE_VISIBILITY@,g' \ | ||
1588 | - > libgnuintl.h | ||
1589 | - | ||
1590 | -libintl.h: $(srcdir)/libgnuintl.h.in | ||
1591 | - sed -e '/IN_LIBGLOCALE/d' \ | ||
1592 | - -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \ | ||
1593 | - -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ | ||
1594 | - -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ | ||
1595 | - -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ | ||
1596 | - < $(srcdir)/libgnuintl.h.in > libintl.h | ||
1597 | - | ||
1598 | -charset.alias: $(srcdir)/config.charset | ||
1599 | - $(SHELL) $(srcdir)/config.charset '@host@' > t-$@ | ||
1600 | - mv t-$@ $@ | ||
1601 | - | ||
1602 | -check: all | ||
1603 | - | ||
1604 | -# We must not install the libintl.h/libintl.a files if we are on a | ||
1605 | -# system which has the GNU gettext() function in its C library or in a | ||
1606 | -# separate library. | ||
1607 | -# If you want to use the one which comes with this version of the | ||
1608 | -# package, you have to use `configure --with-included-gettext'. | ||
1609 | -install: install-exec install-data | ||
1610 | -install-exec: all | ||
1611 | - if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \ | ||
1612 | - && test '@USE_INCLUDED_LIBINTL@' = yes; then \ | ||
1613 | - $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ | ||
1614 | - $(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \ | ||
1615 | - $(LIBTOOL) --mode=install \ | ||
1616 | - $(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \ | ||
1617 | - if test "@RELOCATABLE@" = yes; then \ | ||
1618 | - dependencies=`sed -n -e 's,^dependency_libs=\(.*\),\1,p' < $(DESTDIR)$(libdir)/libintl.la | sed -e "s,^',," -e "s,'\$$,,"`; \ | ||
1619 | - if test -n "$$dependencies"; then \ | ||
1620 | - rm -f $(DESTDIR)$(libdir)/libintl.la; \ | ||
1621 | - fi; \ | ||
1622 | - fi; \ | ||
1623 | - else \ | ||
1624 | - : ; \ | ||
1625 | - fi | ||
1626 | - if test "$(PACKAGE)" = "gettext-tools" \ | ||
1627 | - && test '@USE_INCLUDED_LIBINTL@' = no \ | ||
1628 | - && test @GLIBC2@ != no; then \ | ||
1629 | - $(mkdir_p) $(DESTDIR)$(libdir); \ | ||
1630 | - $(LIBTOOL) --mode=install \ | ||
1631 | - $(INSTALL_DATA) libgnuintl.$la $(DESTDIR)$(libdir)/libgnuintl.$la; \ | ||
1632 | - rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \ | ||
1633 | - $(INSTALL_DATA) $(DESTDIR)$(libdir)/libgnuintl.so $(DESTDIR)$(libdir)/preloadable_libintl.so; \ | ||
1634 | - $(LIBTOOL) --mode=uninstall \ | ||
1635 | - rm -f $(DESTDIR)$(libdir)/libgnuintl.$la; \ | ||
1636 | - else \ | ||
1637 | - : ; \ | ||
1638 | - fi | ||
1639 | - if test '@USE_INCLUDED_LIBINTL@' = yes; then \ | ||
1640 | - test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \ | ||
1641 | - temp=$(DESTDIR)$(libdir)/t-charset.alias; \ | ||
1642 | - dest=$(DESTDIR)$(libdir)/charset.alias; \ | ||
1643 | - if test -f $(DESTDIR)$(libdir)/charset.alias; then \ | ||
1644 | - orig=$(DESTDIR)$(libdir)/charset.alias; \ | ||
1645 | - sed -f ref-add.sed $$orig > $$temp; \ | ||
1646 | - $(INSTALL_DATA) $$temp $$dest; \ | ||
1647 | - rm -f $$temp; \ | ||
1648 | - else \ | ||
1649 | - if test @GLIBC21@ = no; then \ | ||
1650 | - orig=charset.alias; \ | ||
1651 | - sed -f ref-add.sed $$orig > $$temp; \ | ||
1652 | - $(INSTALL_DATA) $$temp $$dest; \ | ||
1653 | - rm -f $$temp; \ | ||
1654 | - fi; \ | ||
1655 | - fi; \ | ||
1656 | - $(mkdir_p) $(DESTDIR)$(localedir); \ | ||
1657 | - test -f $(DESTDIR)$(localedir)/locale.alias \ | ||
1658 | - && orig=$(DESTDIR)$(localedir)/locale.alias \ | ||
1659 | - || orig=$(srcdir)/locale.alias; \ | ||
1660 | - temp=$(DESTDIR)$(localedir)/t-locale.alias; \ | ||
1661 | - dest=$(DESTDIR)$(localedir)/locale.alias; \ | ||
1662 | - sed -f ref-add.sed $$orig > $$temp; \ | ||
1663 | - $(INSTALL_DATA) $$temp $$dest; \ | ||
1664 | - rm -f $$temp; \ | ||
1665 | - else \ | ||
1666 | - : ; \ | ||
1667 | - fi | ||
1668 | -install-data: all | ||
1669 | - if test "$(PACKAGE)" = "gettext-tools"; then \ | ||
1670 | - $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ | ||
1671 | - $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \ | ||
1672 | - $(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \ | ||
1673 | - dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \ | ||
1674 | - for file in $$dists; do \ | ||
1675 | - $(INSTALL_DATA) $(srcdir)/$$file \ | ||
1676 | - $(DESTDIR)$(gettextsrcdir)/$$file; \ | ||
1677 | - done; \ | ||
1678 | - chmod a+x $(DESTDIR)$(gettextsrcdir)/config.charset; \ | ||
1679 | - dists="$(DISTFILES.generated)"; \ | ||
1680 | - for file in $$dists; do \ | ||
1681 | - if test -f $$file; then dir=.; else dir=$(srcdir); fi; \ | ||
1682 | - $(INSTALL_DATA) $$dir/$$file \ | ||
1683 | - $(DESTDIR)$(gettextsrcdir)/$$file; \ | ||
1684 | - done; \ | ||
1685 | - dists="$(DISTFILES.obsolete)"; \ | ||
1686 | - for file in $$dists; do \ | ||
1687 | - rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ | ||
1688 | - done; \ | ||
1689 | - else \ | ||
1690 | - : ; \ | ||
1691 | - fi | ||
1692 | - | ||
1693 | -install-strip: install | ||
1694 | - | ||
1695 | -install-dvi install-html install-info install-ps install-pdf: | ||
1696 | - | ||
1697 | -installdirs: | ||
1698 | - if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \ | ||
1699 | - && test '@USE_INCLUDED_LIBINTL@' = yes; then \ | ||
1700 | - $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ | ||
1701 | - else \ | ||
1702 | - : ; \ | ||
1703 | - fi | ||
1704 | - if test "$(PACKAGE)" = "gettext-tools" \ | ||
1705 | - && test '@USE_INCLUDED_LIBINTL@' = no \ | ||
1706 | - && test @GLIBC2@ != no; then \ | ||
1707 | - $(mkdir_p) $(DESTDIR)$(libdir); \ | ||
1708 | - else \ | ||
1709 | - : ; \ | ||
1710 | - fi | ||
1711 | - if test '@USE_INCLUDED_LIBINTL@' = yes; then \ | ||
1712 | - test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \ | ||
1713 | - $(mkdir_p) $(DESTDIR)$(localedir); \ | ||
1714 | - else \ | ||
1715 | - : ; \ | ||
1716 | - fi | ||
1717 | - if test "$(PACKAGE)" = "gettext-tools"; then \ | ||
1718 | - $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ | ||
1719 | - else \ | ||
1720 | - : ; \ | ||
1721 | - fi | ||
1722 | - | ||
1723 | -# Define this as empty until I found a useful application. | ||
1724 | -installcheck: | ||
1725 | - | ||
1726 | -uninstall: | ||
1727 | - if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \ | ||
1728 | - && test '@USE_INCLUDED_LIBINTL@' = yes; then \ | ||
1729 | - rm -f $(DESTDIR)$(includedir)/libintl.h; \ | ||
1730 | - $(LIBTOOL) --mode=uninstall \ | ||
1731 | - rm -f $(DESTDIR)$(libdir)/libintl.$la; \ | ||
1732 | - else \ | ||
1733 | - : ; \ | ||
1734 | - fi | ||
1735 | - if test "$(PACKAGE)" = "gettext-tools" \ | ||
1736 | - && test '@USE_INCLUDED_LIBINTL@' = no \ | ||
1737 | - && test @GLIBC2@ != no; then \ | ||
1738 | - rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \ | ||
1739 | - else \ | ||
1740 | - : ; \ | ||
1741 | - fi | ||
1742 | - if test '@USE_INCLUDED_LIBINTL@' = yes; then \ | ||
1743 | - if test -f $(DESTDIR)$(libdir)/charset.alias; then \ | ||
1744 | - temp=$(DESTDIR)$(libdir)/t-charset.alias; \ | ||
1745 | - dest=$(DESTDIR)$(libdir)/charset.alias; \ | ||
1746 | - sed -f ref-del.sed $$dest > $$temp; \ | ||
1747 | - if grep '^# Packages using this file: $$' $$temp > /dev/null; then \ | ||
1748 | - rm -f $$dest; \ | ||
1749 | - else \ | ||
1750 | - $(INSTALL_DATA) $$temp $$dest; \ | ||
1751 | - fi; \ | ||
1752 | - rm -f $$temp; \ | ||
1753 | - fi; \ | ||
1754 | - if test -f $(DESTDIR)$(localedir)/locale.alias; then \ | ||
1755 | - temp=$(DESTDIR)$(localedir)/t-locale.alias; \ | ||
1756 | - dest=$(DESTDIR)$(localedir)/locale.alias; \ | ||
1757 | - sed -f ref-del.sed $$dest > $$temp; \ | ||
1758 | - if grep '^# Packages using this file: $$' $$temp > /dev/null; then \ | ||
1759 | - rm -f $$dest; \ | ||
1760 | - else \ | ||
1761 | - $(INSTALL_DATA) $$temp $$dest; \ | ||
1762 | - fi; \ | ||
1763 | - rm -f $$temp; \ | ||
1764 | - fi; \ | ||
1765 | - else \ | ||
1766 | - : ; \ | ||
1767 | - fi | ||
1768 | - if test "$(PACKAGE)" = "gettext-tools"; then \ | ||
1769 | - for file in VERSION ChangeLog COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common) $(DISTFILES.generated); do \ | ||
1770 | - rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ | ||
1771 | - done; \ | ||
1772 | - else \ | ||
1773 | - : ; \ | ||
1774 | - fi | ||
1775 | - | ||
1776 | -info dvi ps pdf html: | ||
1777 | - | ||
1778 | -$(OBJECTS): ../config.h libgnuintl.h | ||
1779 | -bindtextdom.$lo dcgettext.$lo dcigettext.$lo dcngettext.$lo dgettext.$lo dngettext.$lo finddomain.$lo gettext.$lo intl-compat.$lo loadmsgcat.$lo localealias.$lo ngettext.$lo textdomain.$lo: $(srcdir)/gettextP.h $(srcdir)/gmo.h $(srcdir)/loadinfo.h | ||
1780 | -hash-string.$lo dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h | ||
1781 | -explodename.$lo l10nflist.$lo: $(srcdir)/loadinfo.h | ||
1782 | -dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: $(srcdir)/plural-exp.h | ||
1783 | -dcigettext.$lo: $(srcdir)/eval-plural.h | ||
1784 | -localcharset.$lo: $(srcdir)/localcharset.h | ||
1785 | -bindtextdom.$lo dcigettext.$lo finddomain.$lo loadmsgcat.$lo localealias.$lo lock.$lo log.$lo: $(srcdir)/lock.h | ||
1786 | -localealias.$lo localcharset.$lo relocatable.$lo: $(srcdir)/relocatable.h | ||
1787 | -printf.$lo: $(srcdir)/printf-args.h $(srcdir)/printf-args.c $(srcdir)/printf-parse.h $(srcdir)/wprintf-parse.h $(srcdir)/xsize.h $(srcdir)/printf-parse.c $(srcdir)/vasnprintf.h $(srcdir)/vasnwprintf.h $(srcdir)/vasnprintf.c | ||
1788 | - | ||
1789 | -# A bison-2.1 generated plural.c includes <libintl.h> if ENABLE_NLS. | ||
1790 | -PLURAL_DEPS_yes = libintl.h | ||
1791 | -PLURAL_DEPS_no = | ||
1792 | -plural.$lo: $(PLURAL_DEPS_@USE_INCLUDED_LIBINTL@) | ||
1793 | - | ||
1794 | -tags: TAGS | ||
1795 | - | ||
1796 | -TAGS: $(HEADERS) $(SOURCES) | ||
1797 | - here=`pwd`; cd $(srcdir) && etags -o $$here/TAGS $(HEADERS) $(SOURCES) | ||
1798 | - | ||
1799 | -ctags: CTAGS | ||
1800 | - | ||
1801 | -CTAGS: $(HEADERS) $(SOURCES) | ||
1802 | - here=`pwd`; cd $(srcdir) && ctags -o $$here/CTAGS $(HEADERS) $(SOURCES) | ||
1803 | - | ||
1804 | -id: ID | ||
1805 | - | ||
1806 | -ID: $(HEADERS) $(SOURCES) | ||
1807 | - here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES) | ||
1808 | - | ||
1809 | - | ||
1810 | -mostlyclean: | ||
1811 | - rm -f *.a *.la *.o *.obj *.lo libintl.res core core.* | ||
1812 | - rm -f libgnuintl.h libintl.h charset.alias ref-add.sed ref-del.sed | ||
1813 | - rm -f -r .libs _libs | ||
1814 | - | ||
1815 | -clean: mostlyclean | ||
1816 | - | ||
1817 | -distclean: clean | ||
1818 | - rm -f Makefile ID TAGS | ||
1819 | - if test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; then \ | ||
1820 | - rm -f ChangeLog.inst $(DISTFILES.normal); \ | ||
1821 | - else \ | ||
1822 | - : ; \ | ||
1823 | - fi | ||
1824 | - | ||
1825 | -maintainer-clean: distclean | ||
1826 | - @echo "This command is intended for maintainers to use;" | ||
1827 | - @echo "it deletes files that may require special tools to rebuild." | ||
1828 | - | ||
1829 | - | ||
1830 | -# GNU gettext needs not contain the file `VERSION' but contains some | ||
1831 | -# other files which should not be distributed in other packages. | ||
1832 | -distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) | ||
1833 | -dist distdir: Makefile | ||
1834 | - if test "$(PACKAGE)" = "gettext-tools"; then \ | ||
1835 | - : ; \ | ||
1836 | - else \ | ||
1837 | - if test "$(PACKAGE)" = "gettext-runtime"; then \ | ||
1838 | - additional="$(DISTFILES.gettext)"; \ | ||
1839 | - else \ | ||
1840 | - additional="$(DISTFILES.normal)"; \ | ||
1841 | - fi; \ | ||
1842 | - $(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \ | ||
1843 | - for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) $$additional; do \ | ||
1844 | - if test -f $$file; then dir=.; else dir=$(srcdir); fi; \ | ||
1845 | - cp -p $$dir/$$file $(distdir) || test $$file = Makefile.in || exit 1; \ | ||
1846 | - done; \ | ||
1847 | - fi | ||
1848 | - | ||
1849 | -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status | ||
1850 | - cd $(top_builddir) && $(SHELL) ./config.status | ||
1851 | -# This would be more efficient, but doesn't work any more with autoconf-2.57, | ||
1852 | -# when AC_CONFIG_FILES([intl/Makefile:somedir/Makefile.in]) is used. | ||
1853 | -# cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ | ||
1854 | - | ||
1855 | -# Tell versions [3.59,3.63) of GNU make not to export all variables. | ||
1856 | -# Otherwise a system limit (for SysV at least) may be exceeded. | ||
1857 | -.NOEXPORT: | ||
1858 | --- a/intl/VERSION | ||
1859 | +++ /dev/null | ||
1860 | @@ -1 +0,0 @@ | ||
1861 | -GNU gettext library from gettext-0.17 | ||
1862 | --- a/intl/bindtextdom.c | ||
1863 | +++ /dev/null | ||
1864 | @@ -1,340 +0,0 @@ | ||
1865 | -/* Implementation of the bindtextdomain(3) function | ||
1866 | - Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc. | ||
1867 | - | ||
1868 | - This program is free software; you can redistribute it and/or modify it | ||
1869 | - under the terms of the GNU Library General Public License as published | ||
1870 | - by the Free Software Foundation; either version 2, or (at your option) | ||
1871 | - any later version. | ||
1872 | - | ||
1873 | - This program is distributed in the hope that it will be useful, | ||
1874 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1875 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1876 | - Library General Public License for more details. | ||
1877 | - | ||
1878 | - You should have received a copy of the GNU Library General Public | ||
1879 | - License along with this program; if not, write to the Free Software | ||
1880 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
1881 | - USA. */ | ||
1882 | - | ||
1883 | -#ifdef HAVE_CONFIG_H | ||
1884 | -# include <config.h> | ||
1885 | -#endif | ||
1886 | - | ||
1887 | -#include <stddef.h> | ||
1888 | -#include <stdlib.h> | ||
1889 | -#include <string.h> | ||
1890 | - | ||
1891 | -#include "gettextP.h" | ||
1892 | -#ifdef _LIBC | ||
1893 | -# include <libintl.h> | ||
1894 | -#else | ||
1895 | -# include "libgnuintl.h" | ||
1896 | -#endif | ||
1897 | - | ||
1898 | -/* Handle multi-threaded applications. */ | ||
1899 | -#ifdef _LIBC | ||
1900 | -# include <bits/libc-lock.h> | ||
1901 | -# define gl_rwlock_define __libc_rwlock_define | ||
1902 | -# define gl_rwlock_wrlock __libc_rwlock_wrlock | ||
1903 | -# define gl_rwlock_unlock __libc_rwlock_unlock | ||
1904 | -#else | ||
1905 | -# include "lock.h" | ||
1906 | -#endif | ||
1907 | - | ||
1908 | -/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */ | ||
1909 | -#ifndef offsetof | ||
1910 | -# define offsetof(type,ident) ((size_t)&(((type*)0)->ident)) | ||
1911 | -#endif | ||
1912 | - | ||
1913 | -/* @@ end of prolog @@ */ | ||
1914 | - | ||
1915 | -/* Lock variable to protect the global data in the gettext implementation. */ | ||
1916 | -gl_rwlock_define (extern, _nl_state_lock attribute_hidden) | ||
1917 | - | ||
1918 | - | ||
1919 | -/* Names for the libintl functions are a problem. They must not clash | ||
1920 | - with existing names and they should follow ANSI C. But this source | ||
1921 | - code is also used in GNU C Library where the names have a __ | ||
1922 | - prefix. So we have to make a difference here. */ | ||
1923 | -#ifdef _LIBC | ||
1924 | -# define BINDTEXTDOMAIN __bindtextdomain | ||
1925 | -# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset | ||
1926 | -# ifndef strdup | ||
1927 | -# define strdup(str) __strdup (str) | ||
1928 | -# endif | ||
1929 | -#else | ||
1930 | -# define BINDTEXTDOMAIN libintl_bindtextdomain | ||
1931 | -# define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset | ||
1932 | -#endif | ||
1933 | - | ||
1934 | -/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP | ||
1935 | - to be used for the DOMAINNAME message catalog. | ||
1936 | - If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not | ||
1937 | - modified, only the current value is returned. | ||
1938 | - If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither | ||
1939 | - modified nor returned. */ | ||
1940 | -static void | ||
1941 | -set_binding_values (const char *domainname, | ||
1942 | - const char **dirnamep, const char **codesetp) | ||
1943 | -{ | ||
1944 | - struct binding *binding; | ||
1945 | - int modified; | ||
1946 | - | ||
1947 | - /* Some sanity checks. */ | ||
1948 | - if (domainname == NULL || domainname[0] == '\0') | ||
1949 | - { | ||
1950 | - if (dirnamep) | ||
1951 | - *dirnamep = NULL; | ||
1952 | - if (codesetp) | ||
1953 | - *codesetp = NULL; | ||
1954 | - return; | ||
1955 | - } | ||
1956 | - | ||
1957 | - gl_rwlock_wrlock (_nl_state_lock); | ||
1958 | - | ||
1959 | - modified = 0; | ||
1960 | - | ||
1961 | - for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) | ||
1962 | - { | ||
1963 | - int compare = strcmp (domainname, binding->domainname); | ||
1964 | - if (compare == 0) | ||
1965 | - /* We found it! */ | ||
1966 | - break; | ||
1967 | - if (compare < 0) | ||
1968 | - { | ||
1969 | - /* It is not in the list. */ | ||
1970 | - binding = NULL; | ||
1971 | - break; | ||
1972 | - } | ||
1973 | - } | ||
1974 | - | ||
1975 | - if (binding != NULL) | ||
1976 | - { | ||
1977 | - if (dirnamep) | ||
1978 | - { | ||
1979 | - const char *dirname = *dirnamep; | ||
1980 | - | ||
1981 | - if (dirname == NULL) | ||
1982 | - /* The current binding has be to returned. */ | ||
1983 | - *dirnamep = binding->dirname; | ||
1984 | - else | ||
1985 | - { | ||
1986 | - /* The domain is already bound. If the new value and the old | ||
1987 | - one are equal we simply do nothing. Otherwise replace the | ||
1988 | - old binding. */ | ||
1989 | - char *result = binding->dirname; | ||
1990 | - if (strcmp (dirname, result) != 0) | ||
1991 | - { | ||
1992 | - if (strcmp (dirname, _nl_default_dirname) == 0) | ||
1993 | - result = (char *) _nl_default_dirname; | ||
1994 | - else | ||
1995 | - { | ||
1996 | -#if defined _LIBC || defined HAVE_STRDUP | ||
1997 | - result = strdup (dirname); | ||
1998 | -#else | ||
1999 | - size_t len = strlen (dirname) + 1; | ||
2000 | - result = (char *) malloc (len); | ||
2001 | - if (__builtin_expect (result != NULL, 1)) | ||
2002 | - memcpy (result, dirname, len); | ||
2003 | -#endif | ||
2004 | - } | ||
2005 | - | ||
2006 | - if (__builtin_expect (result != NULL, 1)) | ||
2007 | - { | ||
2008 | - if (binding->dirname != _nl_default_dirname) | ||
2009 | - free (binding->dirname); | ||
2010 | - | ||
2011 | - binding->dirname = result; | ||
2012 | - modified = 1; | ||
2013 | - } | ||
2014 | - } | ||
2015 | - *dirnamep = result; | ||
2016 | - } | ||
2017 | - } | ||
2018 | - | ||
2019 | - if (codesetp) | ||
2020 | - { | ||
2021 | - const char *codeset = *codesetp; | ||
2022 | - | ||
2023 | - if (codeset == NULL) | ||
2024 | - /* The current binding has be to returned. */ | ||
2025 | - *codesetp = binding->codeset; | ||
2026 | - else | ||
2027 | - { | ||
2028 | - /* The domain is already bound. If the new value and the old | ||
2029 | - one are equal we simply do nothing. Otherwise replace the | ||
2030 | - old binding. */ | ||
2031 | - char *result = binding->codeset; | ||
2032 | - if (result == NULL || strcmp (codeset, result) != 0) | ||
2033 | - { | ||
2034 | -#if defined _LIBC || defined HAVE_STRDUP | ||
2035 | - result = strdup (codeset); | ||
2036 | -#else | ||
2037 | - size_t len = strlen (codeset) + 1; | ||
2038 | - result = (char *) malloc (len); | ||
2039 | - if (__builtin_expect (result != NULL, 1)) | ||
2040 | - memcpy (result, codeset, len); | ||
2041 | -#endif | ||
2042 | - | ||
2043 | - if (__builtin_expect (result != NULL, 1)) | ||
2044 | - { | ||
2045 | - if (binding->codeset != NULL) | ||
2046 | - free (binding->codeset); | ||
2047 | - | ||
2048 | - binding->codeset = result; | ||
2049 | - modified = 1; | ||
2050 | - } | ||
2051 | - } | ||
2052 | - *codesetp = result; | ||
2053 | - } | ||
2054 | - } | ||
2055 | - } | ||
2056 | - else if ((dirnamep == NULL || *dirnamep == NULL) | ||
2057 | - && (codesetp == NULL || *codesetp == NULL)) | ||
2058 | - { | ||
2059 | - /* Simply return the default values. */ | ||
2060 | - if (dirnamep) | ||
2061 | - *dirnamep = _nl_default_dirname; | ||
2062 | - if (codesetp) | ||
2063 | - *codesetp = NULL; | ||
2064 | - } | ||
2065 | - else | ||
2066 | - { | ||
2067 | - /* We have to create a new binding. */ | ||
2068 | - size_t len = strlen (domainname) + 1; | ||
2069 | - struct binding *new_binding = | ||
2070 | - (struct binding *) malloc (offsetof (struct binding, domainname) + len); | ||
2071 | - | ||
2072 | - if (__builtin_expect (new_binding == NULL, 0)) | ||
2073 | - goto failed; | ||
2074 | - | ||
2075 | - memcpy (new_binding->domainname, domainname, len); | ||
2076 | - | ||
2077 | - if (dirnamep) | ||
2078 | - { | ||
2079 | - const char *dirname = *dirnamep; | ||
2080 | - | ||
2081 | - if (dirname == NULL) | ||
2082 | - /* The default value. */ | ||
2083 | - dirname = _nl_default_dirname; | ||
2084 | - else | ||
2085 | - { | ||
2086 | - if (strcmp (dirname, _nl_default_dirname) == 0) | ||
2087 | - dirname = _nl_default_dirname; | ||
2088 | - else | ||
2089 | - { | ||
2090 | - char *result; | ||
2091 | -#if defined _LIBC || defined HAVE_STRDUP | ||
2092 | - result = strdup (dirname); | ||
2093 | - if (__builtin_expect (result == NULL, 0)) | ||
2094 | - goto failed_dirname; | ||
2095 | -#else | ||
2096 | - size_t len = strlen (dirname) + 1; | ||
2097 | - result = (char *) malloc (len); | ||
2098 | - if (__builtin_expect (result == NULL, 0)) | ||
2099 | - goto failed_dirname; | ||
2100 | - memcpy (result, dirname, len); | ||
2101 | -#endif | ||
2102 | - dirname = result; | ||
2103 | - } | ||
2104 | - } | ||
2105 | - *dirnamep = dirname; | ||
2106 | - new_binding->dirname = (char *) dirname; | ||
2107 | - } | ||
2108 | - else | ||
2109 | - /* The default value. */ | ||
2110 | - new_binding->dirname = (char *) _nl_default_dirname; | ||
2111 | - | ||
2112 | - if (codesetp) | ||
2113 | - { | ||
2114 | - const char *codeset = *codesetp; | ||
2115 | - | ||
2116 | - if (codeset != NULL) | ||
2117 | - { | ||
2118 | - char *result; | ||
2119 | - | ||
2120 | -#if defined _LIBC || defined HAVE_STRDUP | ||
2121 | - result = strdup (codeset); | ||
2122 | - if (__builtin_expect (result == NULL, 0)) | ||
2123 | - goto failed_codeset; | ||
2124 | -#else | ||
2125 | - size_t len = strlen (codeset) + 1; | ||
2126 | - result = (char *) malloc (len); | ||
2127 | - if (__builtin_expect (result == NULL, 0)) | ||
2128 | - goto failed_codeset; | ||
2129 | - memcpy (result, codeset, len); | ||
2130 | -#endif | ||
2131 | - codeset = result; | ||
2132 | - } | ||
2133 | - *codesetp = codeset; | ||
2134 | - new_binding->codeset = (char *) codeset; | ||
2135 | - } | ||
2136 | - else | ||
2137 | - new_binding->codeset = NULL; | ||
2138 | - | ||
2139 | - /* Now enqueue it. */ | ||
2140 | - if (_nl_domain_bindings == NULL | ||
2141 | - || strcmp (domainname, _nl_domain_bindings->domainname) < 0) | ||
2142 | - { | ||
2143 | - new_binding->next = _nl_domain_bindings; | ||
2144 | - _nl_domain_bindings = new_binding; | ||
2145 | - } | ||
2146 | - else | ||
2147 | - { | ||
2148 | - binding = _nl_domain_bindings; | ||
2149 | - while (binding->next != NULL | ||
2150 | - && strcmp (domainname, binding->next->domainname) > 0) | ||
2151 | - binding = binding->next; | ||
2152 | - | ||
2153 | - new_binding->next = binding->next; | ||
2154 | - binding->next = new_binding; | ||
2155 | - } | ||
2156 | - | ||
2157 | - modified = 1; | ||
2158 | - | ||
2159 | - /* Here we deal with memory allocation failures. */ | ||
2160 | - if (0) | ||
2161 | - { | ||
2162 | - failed_codeset: | ||
2163 | - if (new_binding->dirname != _nl_default_dirname) | ||
2164 | - free (new_binding->dirname); | ||
2165 | - failed_dirname: | ||
2166 | - free (new_binding); | ||
2167 | - failed: | ||
2168 | - if (dirnamep) | ||
2169 | - *dirnamep = NULL; | ||
2170 | - if (codesetp) | ||
2171 | - *codesetp = NULL; | ||
2172 | - } | ||
2173 | - } | ||
2174 | - | ||
2175 | - /* If we modified any binding, we flush the caches. */ | ||
2176 | - if (modified) | ||
2177 | - ++_nl_msg_cat_cntr; | ||
2178 | - | ||
2179 | - gl_rwlock_unlock (_nl_state_lock); | ||
2180 | -} | ||
2181 | - | ||
2182 | -/* Specify that the DOMAINNAME message catalog will be found | ||
2183 | - in DIRNAME rather than in the system locale data base. */ | ||
2184 | -char * | ||
2185 | -BINDTEXTDOMAIN (const char *domainname, const char *dirname) | ||
2186 | -{ | ||
2187 | - set_binding_values (domainname, &dirname, NULL); | ||
2188 | - return (char *) dirname; | ||
2189 | -} | ||
2190 | - | ||
2191 | -/* Specify the character encoding in which the messages from the | ||
2192 | - DOMAINNAME message catalog will be returned. */ | ||
2193 | -char * | ||
2194 | -BIND_TEXTDOMAIN_CODESET (const char *domainname, const char *codeset) | ||
2195 | -{ | ||
2196 | - set_binding_values (domainname, NULL, &codeset); | ||
2197 | - return (char *) codeset; | ||
2198 | -} | ||
2199 | - | ||
2200 | -#ifdef _LIBC | ||
2201 | -/* Aliases for function names in GNU C Library. */ | ||
2202 | -weak_alias (__bindtextdomain, bindtextdomain); | ||
2203 | -weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset); | ||
2204 | -#endif | ||
2205 | --- a/intl/config.charset | ||
2206 | +++ /dev/null | ||
2207 | @@ -1,640 +0,0 @@ | ||
2208 | -#! /bin/sh | ||
2209 | -# Output a system dependent table of character encoding aliases. | ||
2210 | -# | ||
2211 | -# Copyright (C) 2000-2004, 2006 Free Software Foundation, Inc. | ||
2212 | -# | ||
2213 | -# This program is free software; you can redistribute it and/or modify it | ||
2214 | -# under the terms of the GNU Library General Public License as published | ||
2215 | -# by the Free Software Foundation; either version 2, or (at your option) | ||
2216 | -# any later version. | ||
2217 | -# | ||
2218 | -# This program is distributed in the hope that it will be useful, | ||
2219 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2220 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2221 | -# Library General Public License for more details. | ||
2222 | -# | ||
2223 | -# You should have received a copy of the GNU Library General Public | ||
2224 | -# License along with this program; if not, write to the Free Software | ||
2225 | -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
2226 | -# USA. | ||
2227 | -# | ||
2228 | -# The table consists of lines of the form | ||
2229 | -# ALIAS CANONICAL | ||
2230 | -# | ||
2231 | -# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)". | ||
2232 | -# ALIAS is compared in a case sensitive way. | ||
2233 | -# | ||
2234 | -# CANONICAL is the GNU canonical name for this character encoding. | ||
2235 | -# It must be an encoding supported by libiconv. Support by GNU libc is | ||
2236 | -# also desirable. CANONICAL is case insensitive. Usually an upper case | ||
2237 | -# MIME charset name is preferred. | ||
2238 | -# The current list of GNU canonical charset names is as follows. | ||
2239 | -# | ||
2240 | -# name MIME? used by which systems | ||
2241 | -# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin | ||
2242 | -# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd darwin | ||
2243 | -# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd darwin | ||
2244 | -# ISO-8859-3 Y glibc solaris | ||
2245 | -# ISO-8859-4 Y osf solaris freebsd netbsd darwin | ||
2246 | -# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd darwin | ||
2247 | -# ISO-8859-6 Y glibc aix hpux solaris | ||
2248 | -# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd darwin | ||
2249 | -# ISO-8859-8 Y glibc aix hpux osf solaris | ||
2250 | -# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin | ||
2251 | -# ISO-8859-13 glibc netbsd darwin | ||
2252 | -# ISO-8859-14 glibc | ||
2253 | -# ISO-8859-15 glibc aix osf solaris freebsd darwin | ||
2254 | -# KOI8-R Y glibc solaris freebsd netbsd darwin | ||
2255 | -# KOI8-U Y glibc freebsd netbsd darwin | ||
2256 | -# KOI8-T glibc | ||
2257 | -# CP437 dos | ||
2258 | -# CP775 dos | ||
2259 | -# CP850 aix osf dos | ||
2260 | -# CP852 dos | ||
2261 | -# CP855 dos | ||
2262 | -# CP856 aix | ||
2263 | -# CP857 dos | ||
2264 | -# CP861 dos | ||
2265 | -# CP862 dos | ||
2266 | -# CP864 dos | ||
2267 | -# CP865 dos | ||
2268 | -# CP866 freebsd netbsd darwin dos | ||
2269 | -# CP869 dos | ||
2270 | -# CP874 woe32 dos | ||
2271 | -# CP922 aix | ||
2272 | -# CP932 aix woe32 dos | ||
2273 | -# CP943 aix | ||
2274 | -# CP949 osf woe32 dos | ||
2275 | -# CP950 woe32 dos | ||
2276 | -# CP1046 aix | ||
2277 | -# CP1124 aix | ||
2278 | -# CP1125 dos | ||
2279 | -# CP1129 aix | ||
2280 | -# CP1250 woe32 | ||
2281 | -# CP1251 glibc solaris netbsd darwin woe32 | ||
2282 | -# CP1252 aix woe32 | ||
2283 | -# CP1253 woe32 | ||
2284 | -# CP1254 woe32 | ||
2285 | -# CP1255 glibc woe32 | ||
2286 | -# CP1256 woe32 | ||
2287 | -# CP1257 woe32 | ||
2288 | -# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin | ||
2289 | -# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin | ||
2290 | -# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin | ||
2291 | -# EUC-TW glibc aix hpux irix osf solaris netbsd | ||
2292 | -# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin | ||
2293 | -# BIG5-HKSCS glibc solaris | ||
2294 | -# GBK glibc aix osf solaris woe32 dos | ||
2295 | -# GB18030 glibc solaris netbsd | ||
2296 | -# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin | ||
2297 | -# JOHAB glibc solaris woe32 | ||
2298 | -# TIS-620 glibc aix hpux osf solaris | ||
2299 | -# VISCII Y glibc | ||
2300 | -# TCVN5712-1 glibc | ||
2301 | -# GEORGIAN-PS glibc | ||
2302 | -# HP-ROMAN8 hpux | ||
2303 | -# HP-ARABIC8 hpux | ||
2304 | -# HP-GREEK8 hpux | ||
2305 | -# HP-HEBREW8 hpux | ||
2306 | -# HP-TURKISH8 hpux | ||
2307 | -# HP-KANA8 hpux | ||
2308 | -# DEC-KANJI osf | ||
2309 | -# DEC-HANYU osf | ||
2310 | -# UTF-8 Y glibc aix hpux osf solaris netbsd darwin | ||
2311 | -# | ||
2312 | -# Note: Names which are not marked as being a MIME name should not be used in | ||
2313 | -# Internet protocols for information interchange (mail, news, etc.). | ||
2314 | -# | ||
2315 | -# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications | ||
2316 | -# must understand both names and treat them as equivalent. | ||
2317 | -# | ||
2318 | -# The first argument passed to this file is the canonical host specification, | ||
2319 | -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM | ||
2320 | -# or | ||
2321 | -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM | ||
2322 | - | ||
2323 | -host="$1" | ||
2324 | -os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'` | ||
2325 | -echo "# This file contains a table of character encoding aliases," | ||
2326 | -echo "# suitable for operating system '${os}'." | ||
2327 | -echo "# It was automatically generated from config.charset." | ||
2328 | -# List of references, updated during installation: | ||
2329 | -echo "# Packages using this file: " | ||
2330 | -case "$os" in | ||
2331 | - linux-gnulibc1*) | ||
2332 | - # Linux libc5 doesn't have nl_langinfo(CODESET); therefore | ||
2333 | - # localcharset.c falls back to using the full locale name | ||
2334 | - # from the environment variables. | ||
2335 | - echo "C ASCII" | ||
2336 | - echo "POSIX ASCII" | ||
2337 | - for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \ | ||
2338 | - en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \ | ||
2339 | - en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \ | ||
2340 | - es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \ | ||
2341 | - et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \ | ||
2342 | - fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \ | ||
2343 | - it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \ | ||
2344 | - sv_FI sv_SE; do | ||
2345 | - echo "$l ISO-8859-1" | ||
2346 | - echo "$l.iso-8859-1 ISO-8859-1" | ||
2347 | - echo "$l.iso-8859-15 ISO-8859-15" | ||
2348 | - echo "$l.iso-8859-15@euro ISO-8859-15" | ||
2349 | - echo "$l@euro ISO-8859-15" | ||
2350 | - echo "$l.cp-437 CP437" | ||
2351 | - echo "$l.cp-850 CP850" | ||
2352 | - echo "$l.cp-1252 CP1252" | ||
2353 | - echo "$l.cp-1252@euro CP1252" | ||
2354 | - #echo "$l.atari-st ATARI-ST" # not a commonly used encoding | ||
2355 | - echo "$l.utf-8 UTF-8" | ||
2356 | - echo "$l.utf-8@euro UTF-8" | ||
2357 | - done | ||
2358 | - for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \ | ||
2359 | - sl_SI sr sr_CS sr_YU; do | ||
2360 | - echo "$l ISO-8859-2" | ||
2361 | - echo "$l.iso-8859-2 ISO-8859-2" | ||
2362 | - echo "$l.cp-852 CP852" | ||
2363 | - echo "$l.cp-1250 CP1250" | ||
2364 | - echo "$l.utf-8 UTF-8" | ||
2365 | - done | ||
2366 | - for l in mk mk_MK ru ru_RU; do | ||
2367 | - echo "$l ISO-8859-5" | ||
2368 | - echo "$l.iso-8859-5 ISO-8859-5" | ||
2369 | - echo "$l.koi8-r KOI8-R" | ||
2370 | - echo "$l.cp-866 CP866" | ||
2371 | - echo "$l.cp-1251 CP1251" | ||
2372 | - echo "$l.utf-8 UTF-8" | ||
2373 | - done | ||
2374 | - for l in ar ar_SA; do | ||
2375 | - echo "$l ISO-8859-6" | ||
2376 | - echo "$l.iso-8859-6 ISO-8859-6" | ||
2377 | - echo "$l.cp-864 CP864" | ||
2378 | - #echo "$l.cp-868 CP868" # not a commonly used encoding | ||
2379 | - echo "$l.cp-1256 CP1256" | ||
2380 | - echo "$l.utf-8 UTF-8" | ||
2381 | - done | ||
2382 | - for l in el el_GR gr gr_GR; do | ||
2383 | - echo "$l ISO-8859-7" | ||
2384 | - echo "$l.iso-8859-7 ISO-8859-7" | ||
2385 | - echo "$l.cp-869 CP869" | ||
2386 | - echo "$l.cp-1253 CP1253" | ||
2387 | - echo "$l.cp-1253@euro CP1253" | ||
2388 | - echo "$l.utf-8 UTF-8" | ||
2389 | - echo "$l.utf-8@euro UTF-8" | ||
2390 | - done | ||
2391 | - for l in he he_IL iw iw_IL; do | ||
2392 | - echo "$l ISO-8859-8" | ||
2393 | - echo "$l.iso-8859-8 ISO-8859-8" | ||
2394 | - echo "$l.cp-862 CP862" | ||
2395 | - echo "$l.cp-1255 CP1255" | ||
2396 | - echo "$l.utf-8 UTF-8" | ||
2397 | - done | ||
2398 | - for l in tr tr_TR; do | ||
2399 | - echo "$l ISO-8859-9" | ||
2400 | - echo "$l.iso-8859-9 ISO-8859-9" | ||
2401 | - echo "$l.cp-857 CP857" | ||
2402 | - echo "$l.cp-1254 CP1254" | ||
2403 | - echo "$l.utf-8 UTF-8" | ||
2404 | - done | ||
2405 | - for l in lt lt_LT lv lv_LV; do | ||
2406 | - #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name | ||
2407 | - echo "$l ISO-8859-13" | ||
2408 | - done | ||
2409 | - for l in ru_UA uk uk_UA; do | ||
2410 | - echo "$l KOI8-U" | ||
2411 | - done | ||
2412 | - for l in zh zh_CN; do | ||
2413 | - #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name | ||
2414 | - echo "$l GB2312" | ||
2415 | - done | ||
2416 | - for l in ja ja_JP ja_JP.EUC; do | ||
2417 | - echo "$l EUC-JP" | ||
2418 | - done | ||
2419 | - for l in ko ko_KR; do | ||
2420 | - echo "$l EUC-KR" | ||
2421 | - done | ||
2422 | - for l in th th_TH; do | ||
2423 | - echo "$l TIS-620" | ||
2424 | - done | ||
2425 | - for l in fa fa_IR; do | ||
2426 | - #echo "$l ISIRI-3342" # a broken encoding | ||
2427 | - echo "$l.utf-8 UTF-8" | ||
2428 | - done | ||
2429 | - ;; | ||
2430 | - linux* | *-gnu*) | ||
2431 | - # With glibc-2.1 or newer, we don't need any canonicalization, | ||
2432 | - # because glibc has iconv and both glibc and libiconv support all | ||
2433 | - # GNU canonical names directly. Therefore, the Makefile does not | ||
2434 | - # need to install the alias file at all. | ||
2435 | - # The following applies only to glibc-2.0.x and older libcs. | ||
2436 | - echo "ISO_646.IRV:1983 ASCII" | ||
2437 | - ;; | ||
2438 | - aix*) | ||
2439 | - echo "ISO8859-1 ISO-8859-1" | ||
2440 | - echo "ISO8859-2 ISO-8859-2" | ||
2441 | - echo "ISO8859-5 ISO-8859-5" | ||
2442 | - echo "ISO8859-6 ISO-8859-6" | ||
2443 | - echo "ISO8859-7 ISO-8859-7" | ||
2444 | - echo "ISO8859-8 ISO-8859-8" | ||
2445 | - echo "ISO8859-9 ISO-8859-9" | ||
2446 | - echo "ISO8859-15 ISO-8859-15" | ||
2447 | - echo "IBM-850 CP850" | ||
2448 | - echo "IBM-856 CP856" | ||
2449 | - echo "IBM-921 ISO-8859-13" | ||
2450 | - echo "IBM-922 CP922" | ||
2451 | - echo "IBM-932 CP932" | ||
2452 | - echo "IBM-943 CP943" | ||
2453 | - echo "IBM-1046 CP1046" | ||
2454 | - echo "IBM-1124 CP1124" | ||
2455 | - echo "IBM-1129 CP1129" | ||
2456 | - echo "IBM-1252 CP1252" | ||
2457 | - echo "IBM-eucCN GB2312" | ||
2458 | - echo "IBM-eucJP EUC-JP" | ||
2459 | - echo "IBM-eucKR EUC-KR" | ||
2460 | - echo "IBM-eucTW EUC-TW" | ||
2461 | - echo "big5 BIG5" | ||
2462 | - echo "GBK GBK" | ||
2463 | - echo "TIS-620 TIS-620" | ||
2464 | - echo "UTF-8 UTF-8" | ||
2465 | - ;; | ||
2466 | - hpux*) | ||
2467 | - echo "iso88591 ISO-8859-1" | ||
2468 | - echo "iso88592 ISO-8859-2" | ||
2469 | - echo "iso88595 ISO-8859-5" | ||
2470 | - echo "iso88596 ISO-8859-6" | ||
2471 | - echo "iso88597 ISO-8859-7" | ||
2472 | - echo "iso88598 ISO-8859-8" | ||
2473 | - echo "iso88599 ISO-8859-9" | ||
2474 | - echo "iso885915 ISO-8859-15" | ||
2475 | - echo "roman8 HP-ROMAN8" | ||
2476 | - echo "arabic8 HP-ARABIC8" | ||
2477 | - echo "greek8 HP-GREEK8" | ||
2478 | - echo "hebrew8 HP-HEBREW8" | ||
2479 | - echo "turkish8 HP-TURKISH8" | ||
2480 | - echo "kana8 HP-KANA8" | ||
2481 | - echo "tis620 TIS-620" | ||
2482 | - echo "big5 BIG5" | ||
2483 | - echo "eucJP EUC-JP" | ||
2484 | - echo "eucKR EUC-KR" | ||
2485 | - echo "eucTW EUC-TW" | ||
2486 | - echo "hp15CN GB2312" | ||
2487 | - #echo "ccdc ?" # what is this? | ||
2488 | - echo "SJIS SHIFT_JIS" | ||
2489 | - echo "utf8 UTF-8" | ||
2490 | - ;; | ||
2491 | - irix*) | ||
2492 | - echo "ISO8859-1 ISO-8859-1" | ||
2493 | - echo "ISO8859-2 ISO-8859-2" | ||
2494 | - echo "ISO8859-5 ISO-8859-5" | ||
2495 | - echo "ISO8859-7 ISO-8859-7" | ||
2496 | - echo "ISO8859-9 ISO-8859-9" | ||
2497 | - echo "eucCN GB2312" | ||
2498 | - echo "eucJP EUC-JP" | ||
2499 | - echo "eucKR EUC-KR" | ||
2500 | - echo "eucTW EUC-TW" | ||
2501 | - ;; | ||
2502 | - osf*) | ||
2503 | - echo "ISO8859-1 ISO-8859-1" | ||
2504 | - echo "ISO8859-2 ISO-8859-2" | ||
2505 | - echo "ISO8859-4 ISO-8859-4" | ||
2506 | - echo "ISO8859-5 ISO-8859-5" | ||
2507 | - echo "ISO8859-7 ISO-8859-7" | ||
2508 | - echo "ISO8859-8 ISO-8859-8" | ||
2509 | - echo "ISO8859-9 ISO-8859-9" | ||
2510 | - echo "ISO8859-15 ISO-8859-15" | ||
2511 | - echo "cp850 CP850" | ||
2512 | - echo "big5 BIG5" | ||
2513 | - echo "dechanyu DEC-HANYU" | ||
2514 | - echo "dechanzi GB2312" | ||
2515 | - echo "deckanji DEC-KANJI" | ||
2516 | - echo "deckorean EUC-KR" | ||
2517 | - echo "eucJP EUC-JP" | ||
2518 | - echo "eucKR EUC-KR" | ||
2519 | - echo "eucTW EUC-TW" | ||
2520 | - echo "GBK GBK" | ||
2521 | - echo "KSC5601 CP949" | ||
2522 | - echo "sdeckanji EUC-JP" | ||
2523 | - echo "SJIS SHIFT_JIS" | ||
2524 | - echo "TACTIS TIS-620" | ||
2525 | - echo "UTF-8 UTF-8" | ||
2526 | - ;; | ||
2527 | - solaris*) | ||
2528 | - echo "646 ASCII" | ||
2529 | - echo "ISO8859-1 ISO-8859-1" | ||
2530 | - echo "ISO8859-2 ISO-8859-2" | ||
2531 | - echo "ISO8859-3 ISO-8859-3" | ||
2532 | - echo "ISO8859-4 ISO-8859-4" | ||
2533 | - echo "ISO8859-5 ISO-8859-5" | ||
2534 | - echo "ISO8859-6 ISO-8859-6" | ||
2535 | - echo "ISO8859-7 ISO-8859-7" | ||
2536 | - echo "ISO8859-8 ISO-8859-8" | ||
2537 | - echo "ISO8859-9 ISO-8859-9" | ||
2538 | - echo "ISO8859-15 ISO-8859-15" | ||
2539 | - echo "koi8-r KOI8-R" | ||
2540 | - echo "ansi-1251 CP1251" | ||
2541 | - echo "BIG5 BIG5" | ||
2542 | - echo "Big5-HKSCS BIG5-HKSCS" | ||
2543 | - echo "gb2312 GB2312" | ||
2544 | - echo "GBK GBK" | ||
2545 | - echo "GB18030 GB18030" | ||
2546 | - echo "cns11643 EUC-TW" | ||
2547 | - echo "5601 EUC-KR" | ||
2548 | - echo "ko_KR.johap92 JOHAB" | ||
2549 | - echo "eucJP EUC-JP" | ||
2550 | - echo "PCK SHIFT_JIS" | ||
2551 | - echo "TIS620.2533 TIS-620" | ||
2552 | - #echo "sun_eu_greek ?" # what is this? | ||
2553 | - echo "UTF-8 UTF-8" | ||
2554 | - ;; | ||
2555 | - freebsd* | os2*) | ||
2556 | - # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore | ||
2557 | - # localcharset.c falls back to using the full locale name | ||
2558 | - # from the environment variables. | ||
2559 | - # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just | ||
2560 | - # reuse FreeBSD's locale data for OS/2. | ||
2561 | - echo "C ASCII" | ||
2562 | - echo "US-ASCII ASCII" | ||
2563 | - for l in la_LN lt_LN; do | ||
2564 | - echo "$l.ASCII ASCII" | ||
2565 | - done | ||
2566 | - for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ | ||
2567 | - fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \ | ||
2568 | - lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do | ||
2569 | - echo "$l.ISO_8859-1 ISO-8859-1" | ||
2570 | - echo "$l.DIS_8859-15 ISO-8859-15" | ||
2571 | - done | ||
2572 | - for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do | ||
2573 | - echo "$l.ISO_8859-2 ISO-8859-2" | ||
2574 | - done | ||
2575 | - for l in la_LN lt_LT; do | ||
2576 | - echo "$l.ISO_8859-4 ISO-8859-4" | ||
2577 | - done | ||
2578 | - for l in ru_RU ru_SU; do | ||
2579 | - echo "$l.KOI8-R KOI8-R" | ||
2580 | - echo "$l.ISO_8859-5 ISO-8859-5" | ||
2581 | - echo "$l.CP866 CP866" | ||
2582 | - done | ||
2583 | - echo "uk_UA.KOI8-U KOI8-U" | ||
2584 | - echo "zh_TW.BIG5 BIG5" | ||
2585 | - echo "zh_TW.Big5 BIG5" | ||
2586 | - echo "zh_CN.EUC GB2312" | ||
2587 | - echo "ja_JP.EUC EUC-JP" | ||
2588 | - echo "ja_JP.SJIS SHIFT_JIS" | ||
2589 | - echo "ja_JP.Shift_JIS SHIFT_JIS" | ||
2590 | - echo "ko_KR.EUC EUC-KR" | ||
2591 | - ;; | ||
2592 | - netbsd*) | ||
2593 | - echo "646 ASCII" | ||
2594 | - echo "ISO8859-1 ISO-8859-1" | ||
2595 | - echo "ISO8859-2 ISO-8859-2" | ||
2596 | - echo "ISO8859-4 ISO-8859-4" | ||
2597 | - echo "ISO8859-5 ISO-8859-5" | ||
2598 | - echo "ISO8859-7 ISO-8859-7" | ||
2599 | - echo "ISO8859-13 ISO-8859-13" | ||
2600 | - echo "ISO8859-15 ISO-8859-15" | ||
2601 | - echo "eucCN GB2312" | ||
2602 | - echo "eucJP EUC-JP" | ||
2603 | - echo "eucKR EUC-KR" | ||
2604 | - echo "eucTW EUC-TW" | ||
2605 | - echo "BIG5 BIG5" | ||
2606 | - echo "SJIS SHIFT_JIS" | ||
2607 | - ;; | ||
2608 | - darwin[56]*) | ||
2609 | - # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore | ||
2610 | - # localcharset.c falls back to using the full locale name | ||
2611 | - # from the environment variables. | ||
2612 | - echo "C ASCII" | ||
2613 | - for l in en_AU en_CA en_GB en_US la_LN; do | ||
2614 | - echo "$l.US-ASCII ASCII" | ||
2615 | - done | ||
2616 | - for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ | ||
2617 | - fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \ | ||
2618 | - nl_NL no_NO pt_PT sv_SE; do | ||
2619 | - echo "$l ISO-8859-1" | ||
2620 | - echo "$l.ISO8859-1 ISO-8859-1" | ||
2621 | - echo "$l.ISO8859-15 ISO-8859-15" | ||
2622 | - done | ||
2623 | - for l in la_LN; do | ||
2624 | - echo "$l.ISO8859-1 ISO-8859-1" | ||
2625 | - echo "$l.ISO8859-15 ISO-8859-15" | ||
2626 | - done | ||
2627 | - for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do | ||
2628 | - echo "$l.ISO8859-2 ISO-8859-2" | ||
2629 | - done | ||
2630 | - for l in la_LN lt_LT; do | ||
2631 | - echo "$l.ISO8859-4 ISO-8859-4" | ||
2632 | - done | ||
2633 | - for l in ru_RU; do | ||
2634 | - echo "$l.KOI8-R KOI8-R" | ||
2635 | - echo "$l.ISO8859-5 ISO-8859-5" | ||
2636 | - echo "$l.CP866 CP866" | ||
2637 | - done | ||
2638 | - for l in bg_BG; do | ||
2639 | - echo "$l.CP1251 CP1251" | ||
2640 | - done | ||
2641 | - echo "uk_UA.KOI8-U KOI8-U" | ||
2642 | - echo "zh_TW.BIG5 BIG5" | ||
2643 | - echo "zh_TW.Big5 BIG5" | ||
2644 | - echo "zh_CN.EUC GB2312" | ||
2645 | - echo "ja_JP.EUC EUC-JP" | ||
2646 | - echo "ja_JP.SJIS SHIFT_JIS" | ||
2647 | - echo "ko_KR.EUC EUC-KR" | ||
2648 | - ;; | ||
2649 | - darwin*) | ||
2650 | - # Darwin 7.5 has nl_langinfo(CODESET), but it is useless: | ||
2651 | - # - It returns the empty string when LANG is set to a locale of the | ||
2652 | - # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 | ||
2653 | - # LC_CTYPE file. | ||
2654 | - # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by | ||
2655 | - # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. | ||
2656 | - # - The documentation says: | ||
2657 | - # "... all code that calls BSD system routines should ensure | ||
2658 | - # that the const *char parameters of these routines are in UTF-8 | ||
2659 | - # encoding. All BSD system functions expect their string | ||
2660 | - # parameters to be in UTF-8 encoding and nothing else." | ||
2661 | - # It also says | ||
2662 | - # "An additional caveat is that string parameters for files, | ||
2663 | - # paths, and other file-system entities must be in canonical | ||
2664 | - # UTF-8. In a canonical UTF-8 Unicode string, all decomposable | ||
2665 | - # characters are decomposed ..." | ||
2666 | - # but this is not true: You can pass non-decomposed UTF-8 strings | ||
2667 | - # to file system functions, and it is the OS which will convert | ||
2668 | - # them to decomposed UTF-8 before accessing the file system. | ||
2669 | - # - The Apple Terminal application displays UTF-8 by default. | ||
2670 | - # - However, other applications are free to use different encodings: | ||
2671 | - # - xterm uses ISO-8859-1 by default. | ||
2672 | - # - TextEdit uses MacRoman by default. | ||
2673 | - # We prefer UTF-8 over decomposed UTF-8-MAC because one should | ||
2674 | - # minimize the use of decomposed Unicode. Unfortunately, through the | ||
2675 | - # Darwin file system, decomposed UTF-8 strings are leaked into user | ||
2676 | - # space nevertheless. | ||
2677 | - echo "* UTF-8" | ||
2678 | - ;; | ||
2679 | - beos*) | ||
2680 | - # BeOS has a single locale, and it has UTF-8 encoding. | ||
2681 | - echo "* UTF-8" | ||
2682 | - ;; | ||
2683 | - msdosdjgpp*) | ||
2684 | - # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore | ||
2685 | - # localcharset.c falls back to using the full locale name | ||
2686 | - # from the environment variables. | ||
2687 | - echo "#" | ||
2688 | - echo "# The encodings given here may not all be correct." | ||
2689 | - echo "# If you find that the encoding given for your language and" | ||
2690 | - echo "# country is not the one your DOS machine actually uses, just" | ||
2691 | - echo "# correct it in this file, and send a mail to" | ||
2692 | - echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>" | ||
2693 | - echo "# and Bruno Haible <bruno@clisp.org>." | ||
2694 | - echo "#" | ||
2695 | - echo "C ASCII" | ||
2696 | - # ISO-8859-1 languages | ||
2697 | - echo "ca CP850" | ||
2698 | - echo "ca_ES CP850" | ||
2699 | - echo "da CP865" # not CP850 ?? | ||
2700 | - echo "da_DK CP865" # not CP850 ?? | ||
2701 | - echo "de CP850" | ||
2702 | - echo "de_AT CP850" | ||
2703 | - echo "de_CH CP850" | ||
2704 | - echo "de_DE CP850" | ||
2705 | - echo "en CP850" | ||
2706 | - echo "en_AU CP850" # not CP437 ?? | ||
2707 | - echo "en_CA CP850" | ||
2708 | - echo "en_GB CP850" | ||
2709 | - echo "en_NZ CP437" | ||
2710 | - echo "en_US CP437" | ||
2711 | - echo "en_ZA CP850" # not CP437 ?? | ||
2712 | - echo "es CP850" | ||
2713 | - echo "es_AR CP850" | ||
2714 | - echo "es_BO CP850" | ||
2715 | - echo "es_CL CP850" | ||
2716 | - echo "es_CO CP850" | ||
2717 | - echo "es_CR CP850" | ||
2718 | - echo "es_CU CP850" | ||
2719 | - echo "es_DO CP850" | ||
2720 | - echo "es_EC CP850" | ||
2721 | - echo "es_ES CP850" | ||
2722 | - echo "es_GT CP850" | ||
2723 | - echo "es_HN CP850" | ||
2724 | - echo "es_MX CP850" | ||
2725 | - echo "es_NI CP850" | ||
2726 | - echo "es_PA CP850" | ||
2727 | - echo "es_PY CP850" | ||
2728 | - echo "es_PE CP850" | ||
2729 | - echo "es_SV CP850" | ||
2730 | - echo "es_UY CP850" | ||
2731 | - echo "es_VE CP850" | ||
2732 | - echo "et CP850" | ||
2733 | - echo "et_EE CP850" | ||
2734 | - echo "eu CP850" | ||
2735 | - echo "eu_ES CP850" | ||
2736 | - echo "fi CP850" | ||
2737 | - echo "fi_FI CP850" | ||
2738 | - echo "fr CP850" | ||
2739 | - echo "fr_BE CP850" | ||
2740 | - echo "fr_CA CP850" | ||
2741 | - echo "fr_CH CP850" | ||
2742 | - echo "fr_FR CP850" | ||
2743 | - echo "ga CP850" | ||
2744 | - echo "ga_IE CP850" | ||
2745 | - echo "gd CP850" | ||
2746 | - echo "gd_GB CP850" | ||
2747 | - echo "gl CP850" | ||
2748 | - echo "gl_ES CP850" | ||
2749 | - echo "id CP850" # not CP437 ?? | ||
2750 | - echo "id_ID CP850" # not CP437 ?? | ||
2751 | - echo "is CP861" # not CP850 ?? | ||
2752 | - echo "is_IS CP861" # not CP850 ?? | ||
2753 | - echo "it CP850" | ||
2754 | - echo "it_CH CP850" | ||
2755 | - echo "it_IT CP850" | ||
2756 | - echo "lt CP775" | ||
2757 | - echo "lt_LT CP775" | ||
2758 | - echo "lv CP775" | ||
2759 | - echo "lv_LV CP775" | ||
2760 | - echo "nb CP865" # not CP850 ?? | ||
2761 | - echo "nb_NO CP865" # not CP850 ?? | ||
2762 | - echo "nl CP850" | ||
2763 | - echo "nl_BE CP850" | ||
2764 | - echo "nl_NL CP850" | ||
2765 | - echo "nn CP865" # not CP850 ?? | ||
2766 | - echo "nn_NO CP865" # not CP850 ?? | ||
2767 | - echo "no CP865" # not CP850 ?? | ||
2768 | - echo "no_NO CP865" # not CP850 ?? | ||
2769 | - echo "pt CP850" | ||
2770 | - echo "pt_BR CP850" | ||
2771 | - echo "pt_PT CP850" | ||
2772 | - echo "sv CP850" | ||
2773 | - echo "sv_SE CP850" | ||
2774 | - # ISO-8859-2 languages | ||
2775 | - echo "cs CP852" | ||
2776 | - echo "cs_CZ CP852" | ||
2777 | - echo "hr CP852" | ||
2778 | - echo "hr_HR CP852" | ||
2779 | - echo "hu CP852" | ||
2780 | - echo "hu_HU CP852" | ||
2781 | - echo "pl CP852" | ||
2782 | - echo "pl_PL CP852" | ||
2783 | - echo "ro CP852" | ||
2784 | - echo "ro_RO CP852" | ||
2785 | - echo "sk CP852" | ||
2786 | - echo "sk_SK CP852" | ||
2787 | - echo "sl CP852" | ||
2788 | - echo "sl_SI CP852" | ||
2789 | - echo "sq CP852" | ||
2790 | - echo "sq_AL CP852" | ||
2791 | - echo "sr CP852" # CP852 or CP866 or CP855 ?? | ||
2792 | - echo "sr_CS CP852" # CP852 or CP866 or CP855 ?? | ||
2793 | - echo "sr_YU CP852" # CP852 or CP866 or CP855 ?? | ||
2794 | - # ISO-8859-3 languages | ||
2795 | - echo "mt CP850" | ||
2796 | - echo "mt_MT CP850" | ||
2797 | - # ISO-8859-5 languages | ||
2798 | - echo "be CP866" | ||
2799 | - echo "be_BE CP866" | ||
2800 | - echo "bg CP866" # not CP855 ?? | ||
2801 | - echo "bg_BG CP866" # not CP855 ?? | ||
2802 | - echo "mk CP866" # not CP855 ?? | ||
2803 | - echo "mk_MK CP866" # not CP855 ?? | ||
2804 | - echo "ru CP866" | ||
2805 | - echo "ru_RU CP866" | ||
2806 | - echo "uk CP1125" | ||
2807 | - echo "uk_UA CP1125" | ||
2808 | - # ISO-8859-6 languages | ||
2809 | - echo "ar CP864" | ||
2810 | - echo "ar_AE CP864" | ||
2811 | - echo "ar_DZ CP864" | ||
2812 | - echo "ar_EG CP864" | ||
2813 | - echo "ar_IQ CP864" | ||
2814 | - echo "ar_IR CP864" | ||
2815 | - echo "ar_JO CP864" | ||
2816 | - echo "ar_KW CP864" | ||
2817 | - echo "ar_MA CP864" | ||
2818 | - echo "ar_OM CP864" | ||
2819 | - echo "ar_QA CP864" | ||
2820 | - echo "ar_SA CP864" | ||
2821 | - echo "ar_SY CP864" | ||
2822 | - # ISO-8859-7 languages | ||
2823 | - echo "el CP869" | ||
2824 | - echo "el_GR CP869" | ||
2825 | - # ISO-8859-8 languages | ||
2826 | - echo "he CP862" | ||
2827 | - echo "he_IL CP862" | ||
2828 | - # ISO-8859-9 languages | ||
2829 | - echo "tr CP857" | ||
2830 | - echo "tr_TR CP857" | ||
2831 | - # Japanese | ||
2832 | - echo "ja CP932" | ||
2833 | - echo "ja_JP CP932" | ||
2834 | - # Chinese | ||
2835 | - echo "zh_CN GBK" | ||
2836 | - echo "zh_TW CP950" # not CP938 ?? | ||
2837 | - # Korean | ||
2838 | - echo "kr CP949" # not CP934 ?? | ||
2839 | - echo "kr_KR CP949" # not CP934 ?? | ||
2840 | - # Thai | ||
2841 | - echo "th CP874" | ||
2842 | - echo "th_TH CP874" | ||
2843 | - # Other | ||
2844 | - echo "eo CP850" | ||
2845 | - echo "eo_EO CP850" | ||
2846 | - ;; | ||
2847 | -esac | ||
2848 | --- a/intl/dcgettext.c | ||
2849 | +++ /dev/null | ||
2850 | @@ -1,56 +0,0 @@ | ||
2851 | -/* Implementation of the dcgettext(3) function. | ||
2852 | - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. | ||
2853 | - | ||
2854 | - This program is free software; you can redistribute it and/or modify it | ||
2855 | - under the terms of the GNU Library General Public License as published | ||
2856 | - by the Free Software Foundation; either version 2, or (at your option) | ||
2857 | - any later version. | ||
2858 | - | ||
2859 | - This program is distributed in the hope that it will be useful, | ||
2860 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2861 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2862 | - Library General Public License for more details. | ||
2863 | - | ||
2864 | - You should have received a copy of the GNU Library General Public | ||
2865 | - License along with this program; if not, write to the Free Software | ||
2866 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
2867 | - USA. */ | ||
2868 | - | ||
2869 | -#ifdef HAVE_CONFIG_H | ||
2870 | -# include <config.h> | ||
2871 | -#endif | ||
2872 | - | ||
2873 | -#include "gettextP.h" | ||
2874 | -#ifdef _LIBC | ||
2875 | -# include <libintl.h> | ||
2876 | -#else | ||
2877 | -# include "libgnuintl.h" | ||
2878 | -#endif | ||
2879 | - | ||
2880 | -/* @@ end of prolog @@ */ | ||
2881 | - | ||
2882 | -/* Names for the libintl functions are a problem. They must not clash | ||
2883 | - with existing names and they should follow ANSI C. But this source | ||
2884 | - code is also used in GNU C Library where the names have a __ | ||
2885 | - prefix. So we have to make a difference here. */ | ||
2886 | -#ifdef _LIBC | ||
2887 | -# define DCGETTEXT __dcgettext | ||
2888 | -# define DCIGETTEXT __dcigettext | ||
2889 | -#else | ||
2890 | -# define DCGETTEXT libintl_dcgettext | ||
2891 | -# define DCIGETTEXT libintl_dcigettext | ||
2892 | -#endif | ||
2893 | - | ||
2894 | -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY | ||
2895 | - locale. */ | ||
2896 | -char * | ||
2897 | -DCGETTEXT (const char *domainname, const char *msgid, int category) | ||
2898 | -{ | ||
2899 | - return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category); | ||
2900 | -} | ||
2901 | - | ||
2902 | -#ifdef _LIBC | ||
2903 | -/* Alias for function name in GNU C Library. */ | ||
2904 | -INTDEF(__dcgettext) | ||
2905 | -weak_alias (__dcgettext, dcgettext); | ||
2906 | -#endif | ||
2907 | --- a/intl/dcigettext.c | ||
2908 | +++ /dev/null | ||
2909 | @@ -1,1689 +0,0 @@ | ||
2910 | -/* Implementation of the internal dcigettext function. | ||
2911 | - Copyright (C) 1995-1999, 2000-2007 Free Software Foundation, Inc. | ||
2912 | - | ||
2913 | - This program is free software; you can redistribute it and/or modify it | ||
2914 | - under the terms of the GNU Library General Public License as published | ||
2915 | - by the Free Software Foundation; either version 2, or (at your option) | ||
2916 | - any later version. | ||
2917 | - | ||
2918 | - This program is distributed in the hope that it will be useful, | ||
2919 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2920 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2921 | - Library General Public License for more details. | ||
2922 | - | ||
2923 | - You should have received a copy of the GNU Library General Public | ||
2924 | - License along with this program; if not, write to the Free Software | ||
2925 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
2926 | - USA. */ | ||
2927 | - | ||
2928 | -/* Tell glibc's <string.h> to provide a prototype for mempcpy(). | ||
2929 | - This must come before <config.h> because <config.h> may include | ||
2930 | - <features.h>, and once <features.h> has been included, it's too late. */ | ||
2931 | -#ifndef _GNU_SOURCE | ||
2932 | -# define _GNU_SOURCE 1 | ||
2933 | -#endif | ||
2934 | - | ||
2935 | -#ifdef HAVE_CONFIG_H | ||
2936 | -# include <config.h> | ||
2937 | -#endif | ||
2938 | - | ||
2939 | -/* NL_LOCALE_NAME does not work in glibc-2.4. Ignore it. */ | ||
2940 | -#undef HAVE_NL_LOCALE_NAME | ||
2941 | - | ||
2942 | -#include <sys/types.h> | ||
2943 | - | ||
2944 | -#ifdef __GNUC__ | ||
2945 | -# define alloca __builtin_alloca | ||
2946 | -# define HAVE_ALLOCA 1 | ||
2947 | -#else | ||
2948 | -# ifdef _MSC_VER | ||
2949 | -# include <malloc.h> | ||
2950 | -# define alloca _alloca | ||
2951 | -# else | ||
2952 | -# if defined HAVE_ALLOCA_H || defined _LIBC | ||
2953 | -# include <alloca.h> | ||
2954 | -# else | ||
2955 | -# ifdef _AIX | ||
2956 | - #pragma alloca | ||
2957 | -# else | ||
2958 | -# ifndef alloca | ||
2959 | -char *alloca (); | ||
2960 | -# endif | ||
2961 | -# endif | ||
2962 | -# endif | ||
2963 | -# endif | ||
2964 | -#endif | ||
2965 | - | ||
2966 | -#include <errno.h> | ||
2967 | -#ifndef errno | ||
2968 | -extern int errno; | ||
2969 | -#endif | ||
2970 | -#ifndef __set_errno | ||
2971 | -# define __set_errno(val) errno = (val) | ||
2972 | -#endif | ||
2973 | - | ||
2974 | -#include <stddef.h> | ||
2975 | -#include <stdlib.h> | ||
2976 | -#include <string.h> | ||
2977 | - | ||
2978 | -#if defined HAVE_UNISTD_H || defined _LIBC | ||
2979 | -# include <unistd.h> | ||
2980 | -#endif | ||
2981 | - | ||
2982 | -#include <locale.h> | ||
2983 | - | ||
2984 | -#ifdef _LIBC | ||
2985 | - /* Guess whether integer division by zero raises signal SIGFPE. | ||
2986 | - Set to 1 only if you know for sure. In case of doubt, set to 0. */ | ||
2987 | -# if defined __alpha__ || defined __arm__ || defined __i386__ \ | ||
2988 | - || defined __m68k__ || defined __s390__ | ||
2989 | -# define INTDIV0_RAISES_SIGFPE 1 | ||
2990 | -# else | ||
2991 | -# define INTDIV0_RAISES_SIGFPE 0 | ||
2992 | -# endif | ||
2993 | -#endif | ||
2994 | -#if !INTDIV0_RAISES_SIGFPE | ||
2995 | -# include <signal.h> | ||
2996 | -#endif | ||
2997 | - | ||
2998 | -#if defined HAVE_SYS_PARAM_H || defined _LIBC | ||
2999 | -# include <sys/param.h> | ||
3000 | -#endif | ||
3001 | - | ||
3002 | -#if !defined _LIBC | ||
3003 | -# if HAVE_NL_LOCALE_NAME | ||
3004 | -# include <langinfo.h> | ||
3005 | -# endif | ||
3006 | -# include "localcharset.h" | ||
3007 | -#endif | ||
3008 | - | ||
3009 | -#include "gettextP.h" | ||
3010 | -#include "plural-exp.h" | ||
3011 | -#ifdef _LIBC | ||
3012 | -# include <libintl.h> | ||
3013 | -#else | ||
3014 | -# ifdef IN_LIBGLOCALE | ||
3015 | -# include <libintl.h> | ||
3016 | -# endif | ||
3017 | -# include "libgnuintl.h" | ||
3018 | -#endif | ||
3019 | -#include "hash-string.h" | ||
3020 | - | ||
3021 | -/* Handle multi-threaded applications. */ | ||
3022 | -#ifdef _LIBC | ||
3023 | -# include <bits/libc-lock.h> | ||
3024 | -# define gl_rwlock_define_initialized __libc_rwlock_define_initialized | ||
3025 | -# define gl_rwlock_rdlock __libc_rwlock_rdlock | ||
3026 | -# define gl_rwlock_wrlock __libc_rwlock_wrlock | ||
3027 | -# define gl_rwlock_unlock __libc_rwlock_unlock | ||
3028 | -#else | ||
3029 | -# include "lock.h" | ||
3030 | -#endif | ||
3031 | - | ||
3032 | -/* Alignment of types. */ | ||
3033 | -#if defined __GNUC__ && __GNUC__ >= 2 | ||
3034 | -# define alignof(TYPE) __alignof__ (TYPE) | ||
3035 | -#else | ||
3036 | -# define alignof(TYPE) \ | ||
3037 | - ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2) | ||
3038 | -#endif | ||
3039 | - | ||
3040 | -/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */ | ||
3041 | -#ifndef offsetof | ||
3042 | -# define offsetof(type,ident) ((size_t)&(((type*)0)->ident)) | ||
3043 | -#endif | ||
3044 | - | ||
3045 | -/* @@ end of prolog @@ */ | ||
3046 | - | ||
3047 | -#ifdef _LIBC | ||
3048 | -/* Rename the non ANSI C functions. This is required by the standard | ||
3049 | - because some ANSI C functions will require linking with this object | ||
3050 | - file and the name space must not be polluted. */ | ||
3051 | -# define getcwd __getcwd | ||
3052 | -# ifndef stpcpy | ||
3053 | -# define stpcpy __stpcpy | ||
3054 | -# endif | ||
3055 | -# define tfind __tfind | ||
3056 | -#else | ||
3057 | -# if !defined HAVE_GETCWD | ||
3058 | -char *getwd (); | ||
3059 | -# define getcwd(buf, max) getwd (buf) | ||
3060 | -# else | ||
3061 | -# if VMS | ||
3062 | -# define getcwd(buf, max) (getcwd) (buf, max, 0) | ||
3063 | -# else | ||
3064 | -char *getcwd (); | ||
3065 | -# endif | ||
3066 | -# endif | ||
3067 | -# ifndef HAVE_STPCPY | ||
3068 | -static char *stpcpy (char *dest, const char *src); | ||
3069 | -# endif | ||
3070 | -# ifndef HAVE_MEMPCPY | ||
3071 | -static void *mempcpy (void *dest, const void *src, size_t n); | ||
3072 | -# endif | ||
3073 | -#endif | ||
3074 | - | ||
3075 | -/* Use a replacement if the system does not provide the `tsearch' function | ||
3076 | - family. */ | ||
3077 | -#if HAVE_TSEARCH || defined _LIBC | ||
3078 | -# include <search.h> | ||
3079 | -#else | ||
3080 | -# define tsearch libintl_tsearch | ||
3081 | -# define tfind libintl_tfind | ||
3082 | -# define tdelete libintl_tdelete | ||
3083 | -# define twalk libintl_twalk | ||
3084 | -# include "tsearch.h" | ||
3085 | -#endif | ||
3086 | - | ||
3087 | -#ifdef _LIBC | ||
3088 | -# define tsearch __tsearch | ||
3089 | -#endif | ||
3090 | - | ||
3091 | -/* Amount to increase buffer size by in each try. */ | ||
3092 | -#define PATH_INCR 32 | ||
3093 | - | ||
3094 | -/* The following is from pathmax.h. */ | ||
3095 | -/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define | ||
3096 | - PATH_MAX but might cause redefinition warnings when sys/param.h is | ||
3097 | - later included (as on MORE/BSD 4.3). */ | ||
3098 | -#if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__) | ||
3099 | -# include <limits.h> | ||
3100 | -#endif | ||
3101 | - | ||
3102 | -#ifndef _POSIX_PATH_MAX | ||
3103 | -# define _POSIX_PATH_MAX 255 | ||
3104 | -#endif | ||
3105 | - | ||
3106 | -#if !defined PATH_MAX && defined _PC_PATH_MAX | ||
3107 | -# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX)) | ||
3108 | -#endif | ||
3109 | - | ||
3110 | -/* Don't include sys/param.h if it already has been. */ | ||
3111 | -#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN | ||
3112 | -# include <sys/param.h> | ||
3113 | -#endif | ||
3114 | - | ||
3115 | -#if !defined PATH_MAX && defined MAXPATHLEN | ||
3116 | -# define PATH_MAX MAXPATHLEN | ||
3117 | -#endif | ||
3118 | - | ||
3119 | -#ifndef PATH_MAX | ||
3120 | -# define PATH_MAX _POSIX_PATH_MAX | ||
3121 | -#endif | ||
3122 | - | ||
3123 | -/* Pathname support. | ||
3124 | - ISSLASH(C) tests whether C is a directory separator character. | ||
3125 | - IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not, | ||
3126 | - it may be concatenated to a directory pathname. | ||
3127 | - IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. | ||
3128 | - */ | ||
3129 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | ||
3130 | - /* Win32, Cygwin, OS/2, DOS */ | ||
3131 | -# define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||
3132 | -# define HAS_DEVICE(P) \ | ||
3133 | - ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ | ||
3134 | - && (P)[1] == ':') | ||
3135 | -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) | ||
3136 | -# define IS_PATH_WITH_DIR(P) \ | ||
3137 | - (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P)) | ||
3138 | -#else | ||
3139 | - /* Unix */ | ||
3140 | -# define ISSLASH(C) ((C) == '/') | ||
3141 | -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) | ||
3142 | -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) | ||
3143 | -#endif | ||
3144 | - | ||
3145 | -/* Whether to support different locales in different threads. */ | ||
3146 | -#if defined _LIBC || HAVE_NL_LOCALE_NAME || (HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS) || defined IN_LIBGLOCALE | ||
3147 | -# define HAVE_PER_THREAD_LOCALE | ||
3148 | -#endif | ||
3149 | - | ||
3150 | -/* This is the type used for the search tree where known translations | ||
3151 | - are stored. */ | ||
3152 | -struct known_translation_t | ||
3153 | -{ | ||
3154 | - /* Domain in which to search. */ | ||
3155 | - const char *domainname; | ||
3156 | - | ||
3157 | - /* The category. */ | ||
3158 | - int category; | ||
3159 | - | ||
3160 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3161 | - /* Name of the relevant locale category, or "" for the global locale. */ | ||
3162 | - const char *localename; | ||
3163 | -#endif | ||
3164 | - | ||
3165 | -#ifdef IN_LIBGLOCALE | ||
3166 | - /* The character encoding. */ | ||
3167 | - const char *encoding; | ||
3168 | -#endif | ||
3169 | - | ||
3170 | - /* State of the catalog counter at the point the string was found. */ | ||
3171 | - int counter; | ||
3172 | - | ||
3173 | - /* Catalog where the string was found. */ | ||
3174 | - struct loaded_l10nfile *domain; | ||
3175 | - | ||
3176 | - /* And finally the translation. */ | ||
3177 | - const char *translation; | ||
3178 | - size_t translation_length; | ||
3179 | - | ||
3180 | - /* Pointer to the string in question. */ | ||
3181 | - char msgid[ZERO]; | ||
3182 | -}; | ||
3183 | - | ||
3184 | -gl_rwlock_define_initialized (static, tree_lock) | ||
3185 | - | ||
3186 | -/* Root of the search tree with known translations. */ | ||
3187 | -static void *root; | ||
3188 | - | ||
3189 | -/* Function to compare two entries in the table of known translations. */ | ||
3190 | -static int | ||
3191 | -transcmp (const void *p1, const void *p2) | ||
3192 | -{ | ||
3193 | - const struct known_translation_t *s1; | ||
3194 | - const struct known_translation_t *s2; | ||
3195 | - int result; | ||
3196 | - | ||
3197 | - s1 = (const struct known_translation_t *) p1; | ||
3198 | - s2 = (const struct known_translation_t *) p2; | ||
3199 | - | ||
3200 | - result = strcmp (s1->msgid, s2->msgid); | ||
3201 | - if (result == 0) | ||
3202 | - { | ||
3203 | - result = strcmp (s1->domainname, s2->domainname); | ||
3204 | - if (result == 0) | ||
3205 | - { | ||
3206 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3207 | - result = strcmp (s1->localename, s2->localename); | ||
3208 | - if (result == 0) | ||
3209 | -#endif | ||
3210 | - { | ||
3211 | -#ifdef IN_LIBGLOCALE | ||
3212 | - result = strcmp (s1->encoding, s2->encoding); | ||
3213 | - if (result == 0) | ||
3214 | -#endif | ||
3215 | - /* We compare the category last (though this is the cheapest | ||
3216 | - operation) since it is hopefully always the same (namely | ||
3217 | - LC_MESSAGES). */ | ||
3218 | - result = s1->category - s2->category; | ||
3219 | - } | ||
3220 | - } | ||
3221 | - } | ||
3222 | - | ||
3223 | - return result; | ||
3224 | -} | ||
3225 | - | ||
3226 | -/* Name of the default domain used for gettext(3) prior any call to | ||
3227 | - textdomain(3). The default value for this is "messages". */ | ||
3228 | -const char _nl_default_default_domain[] attribute_hidden = "messages"; | ||
3229 | - | ||
3230 | -#ifndef IN_LIBGLOCALE | ||
3231 | -/* Value used as the default domain for gettext(3). */ | ||
3232 | -const char *_nl_current_default_domain attribute_hidden | ||
3233 | - = _nl_default_default_domain; | ||
3234 | -#endif | ||
3235 | - | ||
3236 | -/* Contains the default location of the message catalogs. */ | ||
3237 | -#if defined __EMX__ | ||
3238 | -extern const char _nl_default_dirname[]; | ||
3239 | -#else | ||
3240 | -# ifdef _LIBC | ||
3241 | -extern const char _nl_default_dirname[]; | ||
3242 | -libc_hidden_proto (_nl_default_dirname) | ||
3243 | -# endif | ||
3244 | -const char _nl_default_dirname[] = LOCALEDIR; | ||
3245 | -# ifdef _LIBC | ||
3246 | -libc_hidden_data_def (_nl_default_dirname) | ||
3247 | -# endif | ||
3248 | -#endif | ||
3249 | - | ||
3250 | -#ifndef IN_LIBGLOCALE | ||
3251 | -/* List with bindings of specific domains created by bindtextdomain() | ||
3252 | - calls. */ | ||
3253 | -struct binding *_nl_domain_bindings; | ||
3254 | -#endif | ||
3255 | - | ||
3256 | -/* Prototypes for local functions. */ | ||
3257 | -static char *plural_lookup (struct loaded_l10nfile *domain, | ||
3258 | - unsigned long int n, | ||
3259 | - const char *translation, size_t translation_len) | ||
3260 | - internal_function; | ||
3261 | - | ||
3262 | -#ifdef IN_LIBGLOCALE | ||
3263 | -static const char *guess_category_value (int category, | ||
3264 | - const char *categoryname, | ||
3265 | - const char *localename) | ||
3266 | - internal_function; | ||
3267 | -#else | ||
3268 | -static const char *guess_category_value (int category, | ||
3269 | - const char *categoryname) | ||
3270 | - internal_function; | ||
3271 | -#endif | ||
3272 | - | ||
3273 | -#ifdef _LIBC | ||
3274 | -# include "../locale/localeinfo.h" | ||
3275 | -# define category_to_name(category) \ | ||
3276 | - _nl_category_names.str + _nl_category_name_idxs[category] | ||
3277 | -#else | ||
3278 | -static const char *category_to_name (int category) internal_function; | ||
3279 | -#endif | ||
3280 | -#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE | ||
3281 | -static const char *get_output_charset (struct binding *domainbinding) | ||
3282 | - internal_function; | ||
3283 | -#endif | ||
3284 | - | ||
3285 | - | ||
3286 | -/* For those loosing systems which don't have `alloca' we have to add | ||
3287 | - some additional code emulating it. */ | ||
3288 | -#ifdef HAVE_ALLOCA | ||
3289 | -/* Nothing has to be done. */ | ||
3290 | -# define freea(p) /* nothing */ | ||
3291 | -# define ADD_BLOCK(list, address) /* nothing */ | ||
3292 | -# define FREE_BLOCKS(list) /* nothing */ | ||
3293 | -#else | ||
3294 | -struct block_list | ||
3295 | -{ | ||
3296 | - void *address; | ||
3297 | - struct block_list *next; | ||
3298 | -}; | ||
3299 | -# define ADD_BLOCK(list, addr) \ | ||
3300 | - do { \ | ||
3301 | - struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \ | ||
3302 | - /* If we cannot get a free block we cannot add the new element to \ | ||
3303 | - the list. */ \ | ||
3304 | - if (newp != NULL) { \ | ||
3305 | - newp->address = (addr); \ | ||
3306 | - newp->next = (list); \ | ||
3307 | - (list) = newp; \ | ||
3308 | - } \ | ||
3309 | - } while (0) | ||
3310 | -# define FREE_BLOCKS(list) \ | ||
3311 | - do { \ | ||
3312 | - while (list != NULL) { \ | ||
3313 | - struct block_list *old = list; \ | ||
3314 | - list = list->next; \ | ||
3315 | - free (old->address); \ | ||
3316 | - free (old); \ | ||
3317 | - } \ | ||
3318 | - } while (0) | ||
3319 | -# undef alloca | ||
3320 | -# define alloca(size) (malloc (size)) | ||
3321 | -# define freea(p) free (p) | ||
3322 | -#endif /* have alloca */ | ||
3323 | - | ||
3324 | - | ||
3325 | -#ifdef _LIBC | ||
3326 | -/* List of blocks allocated for translations. */ | ||
3327 | -typedef struct transmem_list | ||
3328 | -{ | ||
3329 | - struct transmem_list *next; | ||
3330 | - char data[ZERO]; | ||
3331 | -} transmem_block_t; | ||
3332 | -static struct transmem_list *transmem_list; | ||
3333 | -#else | ||
3334 | -typedef unsigned char transmem_block_t; | ||
3335 | -#endif | ||
3336 | - | ||
3337 | - | ||
3338 | -/* Names for the libintl functions are a problem. They must not clash | ||
3339 | - with existing names and they should follow ANSI C. But this source | ||
3340 | - code is also used in GNU C Library where the names have a __ | ||
3341 | - prefix. So we have to make a difference here. */ | ||
3342 | -#ifdef _LIBC | ||
3343 | -# define DCIGETTEXT __dcigettext | ||
3344 | -#else | ||
3345 | -# define DCIGETTEXT libintl_dcigettext | ||
3346 | -#endif | ||
3347 | - | ||
3348 | -/* Lock variable to protect the global data in the gettext implementation. */ | ||
3349 | -gl_rwlock_define_initialized (, _nl_state_lock attribute_hidden) | ||
3350 | - | ||
3351 | -/* Checking whether the binaries runs SUID must be done and glibc provides | ||
3352 | - easier methods therefore we make a difference here. */ | ||
3353 | -#ifdef _LIBC | ||
3354 | -# define ENABLE_SECURE __libc_enable_secure | ||
3355 | -# define DETERMINE_SECURE | ||
3356 | -#else | ||
3357 | -# ifndef HAVE_GETUID | ||
3358 | -# define getuid() 0 | ||
3359 | -# endif | ||
3360 | -# ifndef HAVE_GETGID | ||
3361 | -# define getgid() 0 | ||
3362 | -# endif | ||
3363 | -# ifndef HAVE_GETEUID | ||
3364 | -# define geteuid() getuid() | ||
3365 | -# endif | ||
3366 | -# ifndef HAVE_GETEGID | ||
3367 | -# define getegid() getgid() | ||
3368 | -# endif | ||
3369 | -static int enable_secure; | ||
3370 | -# define ENABLE_SECURE (enable_secure == 1) | ||
3371 | -# define DETERMINE_SECURE \ | ||
3372 | - if (enable_secure == 0) \ | ||
3373 | - { \ | ||
3374 | - if (getuid () != geteuid () || getgid () != getegid ()) \ | ||
3375 | - enable_secure = 1; \ | ||
3376 | - else \ | ||
3377 | - enable_secure = -1; \ | ||
3378 | - } | ||
3379 | -#endif | ||
3380 | - | ||
3381 | -/* Get the function to evaluate the plural expression. */ | ||
3382 | -#include "eval-plural.h" | ||
3383 | - | ||
3384 | -/* Look up MSGID in the DOMAINNAME message catalog for the current | ||
3385 | - CATEGORY locale and, if PLURAL is nonzero, search over string | ||
3386 | - depending on the plural form determined by N. */ | ||
3387 | -#ifdef IN_LIBGLOCALE | ||
3388 | -char * | ||
3389 | -gl_dcigettext (const char *domainname, | ||
3390 | - const char *msgid1, const char *msgid2, | ||
3391 | - int plural, unsigned long int n, | ||
3392 | - int category, | ||
3393 | - const char *localename, const char *encoding) | ||
3394 | -#else | ||
3395 | -char * | ||
3396 | -DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, | ||
3397 | - int plural, unsigned long int n, int category) | ||
3398 | -#endif | ||
3399 | -{ | ||
3400 | -#ifndef HAVE_ALLOCA | ||
3401 | - struct block_list *block_list = NULL; | ||
3402 | -#endif | ||
3403 | - struct loaded_l10nfile *domain; | ||
3404 | - struct binding *binding; | ||
3405 | - const char *categoryname; | ||
3406 | - const char *categoryvalue; | ||
3407 | - const char *dirname; | ||
3408 | - char *xdomainname; | ||
3409 | - char *single_locale; | ||
3410 | - char *retval; | ||
3411 | - size_t retlen; | ||
3412 | - int saved_errno; | ||
3413 | - struct known_translation_t *search; | ||
3414 | - struct known_translation_t **foundp = NULL; | ||
3415 | - size_t msgid_len; | ||
3416 | -#if defined HAVE_PER_THREAD_LOCALE && !defined IN_LIBGLOCALE | ||
3417 | - const char *localename; | ||
3418 | -#endif | ||
3419 | - size_t domainname_len; | ||
3420 | - | ||
3421 | - /* If no real MSGID is given return NULL. */ | ||
3422 | - if (msgid1 == NULL) | ||
3423 | - return NULL; | ||
3424 | - | ||
3425 | -#ifdef _LIBC | ||
3426 | - if (category < 0 || category >= __LC_LAST || category == LC_ALL) | ||
3427 | - /* Bogus. */ | ||
3428 | - return (plural == 0 | ||
3429 | - ? (char *) msgid1 | ||
3430 | - /* Use the Germanic plural rule. */ | ||
3431 | - : n == 1 ? (char *) msgid1 : (char *) msgid2); | ||
3432 | -#endif | ||
3433 | - | ||
3434 | - /* Preserve the `errno' value. */ | ||
3435 | - saved_errno = errno; | ||
3436 | - | ||
3437 | - gl_rwlock_rdlock (_nl_state_lock); | ||
3438 | - | ||
3439 | - /* If DOMAINNAME is NULL, we are interested in the default domain. If | ||
3440 | - CATEGORY is not LC_MESSAGES this might not make much sense but the | ||
3441 | - definition left this undefined. */ | ||
3442 | - if (domainname == NULL) | ||
3443 | - domainname = _nl_current_default_domain; | ||
3444 | - | ||
3445 | - /* OS/2 specific: backward compatibility with older libintl versions */ | ||
3446 | -#ifdef LC_MESSAGES_COMPAT | ||
3447 | - if (category == LC_MESSAGES_COMPAT) | ||
3448 | - category = LC_MESSAGES; | ||
3449 | -#endif | ||
3450 | - | ||
3451 | - msgid_len = strlen (msgid1) + 1; | ||
3452 | - | ||
3453 | - /* Try to find the translation among those which we found at | ||
3454 | - some time. */ | ||
3455 | - search = (struct known_translation_t *) | ||
3456 | - alloca (offsetof (struct known_translation_t, msgid) + msgid_len); | ||
3457 | - memcpy (search->msgid, msgid1, msgid_len); | ||
3458 | - search->domainname = domainname; | ||
3459 | - search->category = category; | ||
3460 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3461 | -# ifndef IN_LIBGLOCALE | ||
3462 | -# ifdef _LIBC | ||
3463 | - localename = __current_locale_name (category); | ||
3464 | -# else | ||
3465 | -# if HAVE_NL_LOCALE_NAME | ||
3466 | - /* NL_LOCALE_NAME is public glibc API introduced in glibc-2.4. */ | ||
3467 | - localename = nl_langinfo (NL_LOCALE_NAME (category)); | ||
3468 | -# else | ||
3469 | -# if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS | ||
3470 | - /* The __names field is not public glibc API and must therefore not be used | ||
3471 | - in code that is installed in public locations. */ | ||
3472 | - { | ||
3473 | - locale_t thread_locale = uselocale (NULL); | ||
3474 | - if (thread_locale != LC_GLOBAL_LOCALE) | ||
3475 | - localename = thread_locale->__names[category]; | ||
3476 | - else | ||
3477 | - localename = ""; | ||
3478 | - } | ||
3479 | -# endif | ||
3480 | -# endif | ||
3481 | -# endif | ||
3482 | -# endif | ||
3483 | - search->localename = localename; | ||
3484 | -# ifdef IN_LIBGLOCALE | ||
3485 | - search->encoding = encoding; | ||
3486 | -# endif | ||
3487 | - | ||
3488 | - /* Since tfind/tsearch manage a balanced tree, concurrent tfind and | ||
3489 | - tsearch calls can be fatal. */ | ||
3490 | - gl_rwlock_rdlock (tree_lock); | ||
3491 | - | ||
3492 | - foundp = (struct known_translation_t **) tfind (search, &root, transcmp); | ||
3493 | - | ||
3494 | - gl_rwlock_unlock (tree_lock); | ||
3495 | - | ||
3496 | - freea (search); | ||
3497 | - if (foundp != NULL && (*foundp)->counter == _nl_msg_cat_cntr) | ||
3498 | - { | ||
3499 | - /* Now deal with plural. */ | ||
3500 | - if (plural) | ||
3501 | - retval = plural_lookup ((*foundp)->domain, n, (*foundp)->translation, | ||
3502 | - (*foundp)->translation_length); | ||
3503 | - else | ||
3504 | - retval = (char *) (*foundp)->translation; | ||
3505 | - | ||
3506 | - gl_rwlock_unlock (_nl_state_lock); | ||
3507 | - __set_errno (saved_errno); | ||
3508 | - return retval; | ||
3509 | - } | ||
3510 | -#endif | ||
3511 | - | ||
3512 | - /* See whether this is a SUID binary or not. */ | ||
3513 | - DETERMINE_SECURE; | ||
3514 | - | ||
3515 | - /* First find matching binding. */ | ||
3516 | -#ifdef IN_LIBGLOCALE | ||
3517 | - /* We can use a trivial binding, since _nl_find_msg will ignore it anyway, | ||
3518 | - and _nl_load_domain and _nl_find_domain just pass it through. */ | ||
3519 | - binding = NULL; | ||
3520 | - dirname = bindtextdomain (domainname, NULL); | ||
3521 | -#else | ||
3522 | - for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) | ||
3523 | - { | ||
3524 | - int compare = strcmp (domainname, binding->domainname); | ||
3525 | - if (compare == 0) | ||
3526 | - /* We found it! */ | ||
3527 | - break; | ||
3528 | - if (compare < 0) | ||
3529 | - { | ||
3530 | - /* It is not in the list. */ | ||
3531 | - binding = NULL; | ||
3532 | - break; | ||
3533 | - } | ||
3534 | - } | ||
3535 | - | ||
3536 | - if (binding == NULL) | ||
3537 | - dirname = _nl_default_dirname; | ||
3538 | - else | ||
3539 | - { | ||
3540 | - dirname = binding->dirname; | ||
3541 | -#endif | ||
3542 | - if (!IS_ABSOLUTE_PATH (dirname)) | ||
3543 | - { | ||
3544 | - /* We have a relative path. Make it absolute now. */ | ||
3545 | - size_t dirname_len = strlen (dirname) + 1; | ||
3546 | - size_t path_max; | ||
3547 | - char *resolved_dirname; | ||
3548 | - char *ret; | ||
3549 | - | ||
3550 | - path_max = (unsigned int) PATH_MAX; | ||
3551 | - path_max += 2; /* The getcwd docs say to do this. */ | ||
3552 | - | ||
3553 | - for (;;) | ||
3554 | - { | ||
3555 | - resolved_dirname = (char *) alloca (path_max + dirname_len); | ||
3556 | - ADD_BLOCK (block_list, tmp_dirname); | ||
3557 | - | ||
3558 | - __set_errno (0); | ||
3559 | - ret = getcwd (resolved_dirname, path_max); | ||
3560 | - if (ret != NULL || errno != ERANGE) | ||
3561 | - break; | ||
3562 | - | ||
3563 | - path_max += path_max / 2; | ||
3564 | - path_max += PATH_INCR; | ||
3565 | - } | ||
3566 | - | ||
3567 | - if (ret == NULL) | ||
3568 | - /* We cannot get the current working directory. Don't signal an | ||
3569 | - error but simply return the default string. */ | ||
3570 | - goto return_untranslated; | ||
3571 | - | ||
3572 | - stpcpy (stpcpy (strchr (resolved_dirname, '\0'), "/"), dirname); | ||
3573 | - dirname = resolved_dirname; | ||
3574 | - } | ||
3575 | -#ifndef IN_LIBGLOCALE | ||
3576 | - } | ||
3577 | -#endif | ||
3578 | - | ||
3579 | - /* Now determine the symbolic name of CATEGORY and its value. */ | ||
3580 | - categoryname = category_to_name (category); | ||
3581 | -#ifdef IN_LIBGLOCALE | ||
3582 | - categoryvalue = guess_category_value (category, categoryname, localename); | ||
3583 | -#else | ||
3584 | - categoryvalue = guess_category_value (category, categoryname); | ||
3585 | -#endif | ||
3586 | - | ||
3587 | - domainname_len = strlen (domainname); | ||
3588 | - xdomainname = (char *) alloca (strlen (categoryname) | ||
3589 | - + domainname_len + 5); | ||
3590 | - ADD_BLOCK (block_list, xdomainname); | ||
3591 | - | ||
3592 | - stpcpy ((char *) mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"), | ||
3593 | - domainname, domainname_len), | ||
3594 | - ".mo"); | ||
3595 | - | ||
3596 | - /* Creating working area. */ | ||
3597 | - single_locale = (char *) alloca (strlen (categoryvalue) + 1); | ||
3598 | - ADD_BLOCK (block_list, single_locale); | ||
3599 | - | ||
3600 | - | ||
3601 | - /* Search for the given string. This is a loop because we perhaps | ||
3602 | - got an ordered list of languages to consider for the translation. */ | ||
3603 | - while (1) | ||
3604 | - { | ||
3605 | - /* Make CATEGORYVALUE point to the next element of the list. */ | ||
3606 | - while (categoryvalue[0] != '\0' && categoryvalue[0] == ':') | ||
3607 | - ++categoryvalue; | ||
3608 | - if (categoryvalue[0] == '\0') | ||
3609 | - { | ||
3610 | - /* The whole contents of CATEGORYVALUE has been searched but | ||
3611 | - no valid entry has been found. We solve this situation | ||
3612 | - by implicitly appending a "C" entry, i.e. no translation | ||
3613 | - will take place. */ | ||
3614 | - single_locale[0] = 'C'; | ||
3615 | - single_locale[1] = '\0'; | ||
3616 | - } | ||
3617 | - else | ||
3618 | - { | ||
3619 | - char *cp = single_locale; | ||
3620 | - while (categoryvalue[0] != '\0' && categoryvalue[0] != ':') | ||
3621 | - *cp++ = *categoryvalue++; | ||
3622 | - *cp = '\0'; | ||
3623 | - | ||
3624 | - /* When this is a SUID binary we must not allow accessing files | ||
3625 | - outside the dedicated directories. */ | ||
3626 | - if (ENABLE_SECURE && IS_PATH_WITH_DIR (single_locale)) | ||
3627 | - /* Ingore this entry. */ | ||
3628 | - continue; | ||
3629 | - } | ||
3630 | - | ||
3631 | - /* If the current locale value is C (or POSIX) we don't load a | ||
3632 | - domain. Return the MSGID. */ | ||
3633 | - if (strcmp (single_locale, "C") == 0 | ||
3634 | - || strcmp (single_locale, "POSIX") == 0) | ||
3635 | - break; | ||
3636 | - | ||
3637 | - /* Find structure describing the message catalog matching the | ||
3638 | - DOMAINNAME and CATEGORY. */ | ||
3639 | - domain = _nl_find_domain (dirname, single_locale, xdomainname, binding); | ||
3640 | - | ||
3641 | - if (domain != NULL) | ||
3642 | - { | ||
3643 | -#if defined IN_LIBGLOCALE | ||
3644 | - retval = _nl_find_msg (domain, binding, encoding, msgid1, &retlen); | ||
3645 | -#else | ||
3646 | - retval = _nl_find_msg (domain, binding, msgid1, 1, &retlen); | ||
3647 | -#endif | ||
3648 | - | ||
3649 | - if (retval == NULL) | ||
3650 | - { | ||
3651 | - int cnt; | ||
3652 | - | ||
3653 | - for (cnt = 0; domain->successor[cnt] != NULL; ++cnt) | ||
3654 | - { | ||
3655 | -#if defined IN_LIBGLOCALE | ||
3656 | - retval = _nl_find_msg (domain->successor[cnt], binding, | ||
3657 | - encoding, msgid1, &retlen); | ||
3658 | -#else | ||
3659 | - retval = _nl_find_msg (domain->successor[cnt], binding, | ||
3660 | - msgid1, 1, &retlen); | ||
3661 | -#endif | ||
3662 | - | ||
3663 | - if (retval != NULL) | ||
3664 | - { | ||
3665 | - domain = domain->successor[cnt]; | ||
3666 | - break; | ||
3667 | - } | ||
3668 | - } | ||
3669 | - } | ||
3670 | - | ||
3671 | - /* Returning -1 means that some resource problem exists | ||
3672 | - (likely memory) and that the strings could not be | ||
3673 | - converted. Return the original strings. */ | ||
3674 | - if (__builtin_expect (retval == (char *) -1, 0)) | ||
3675 | - break; | ||
3676 | - | ||
3677 | - if (retval != NULL) | ||
3678 | - { | ||
3679 | - /* Found the translation of MSGID1 in domain DOMAIN: | ||
3680 | - starting at RETVAL, RETLEN bytes. */ | ||
3681 | - FREE_BLOCKS (block_list); | ||
3682 | - if (foundp == NULL) | ||
3683 | - { | ||
3684 | - /* Create a new entry and add it to the search tree. */ | ||
3685 | - size_t size; | ||
3686 | - struct known_translation_t *newp; | ||
3687 | - | ||
3688 | - size = offsetof (struct known_translation_t, msgid) | ||
3689 | - + msgid_len + domainname_len + 1; | ||
3690 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3691 | - size += strlen (localename) + 1; | ||
3692 | -#endif | ||
3693 | - newp = (struct known_translation_t *) malloc (size); | ||
3694 | - if (newp != NULL) | ||
3695 | - { | ||
3696 | - char *new_domainname; | ||
3697 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3698 | - char *new_localename; | ||
3699 | -#endif | ||
3700 | - | ||
3701 | - new_domainname = | ||
3702 | - (char *) mempcpy (newp->msgid, msgid1, msgid_len); | ||
3703 | - memcpy (new_domainname, domainname, domainname_len + 1); | ||
3704 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3705 | - new_localename = new_domainname + domainname_len + 1; | ||
3706 | - strcpy (new_localename, localename); | ||
3707 | -#endif | ||
3708 | - newp->domainname = new_domainname; | ||
3709 | - newp->category = category; | ||
3710 | -#ifdef HAVE_PER_THREAD_LOCALE | ||
3711 | - newp->localename = new_localename; | ||
3712 | -#endif | ||
3713 | -#ifdef IN_LIBGLOCALE | ||
3714 | - newp->encoding = encoding; | ||
3715 | -#endif | ||
3716 | - newp->counter = _nl_msg_cat_cntr; | ||
3717 | - newp->domain = domain; | ||
3718 | - newp->translation = retval; | ||
3719 | - newp->translation_length = retlen; | ||
3720 | - | ||
3721 | - gl_rwlock_wrlock (tree_lock); | ||
3722 | - | ||
3723 | - /* Insert the entry in the search tree. */ | ||
3724 | - foundp = (struct known_translation_t **) | ||
3725 | - tsearch (newp, &root, transcmp); | ||
3726 | - | ||
3727 | - gl_rwlock_unlock (tree_lock); | ||
3728 | - | ||
3729 | - if (foundp == NULL | ||
3730 | - || __builtin_expect (*foundp != newp, 0)) | ||
3731 | - /* The insert failed. */ | ||
3732 | - free (newp); | ||
3733 | - } | ||
3734 | - } | ||
3735 | - else | ||
3736 | - { | ||
3737 | - /* We can update the existing entry. */ | ||
3738 | - (*foundp)->counter = _nl_msg_cat_cntr; | ||
3739 | - (*foundp)->domain = domain; | ||
3740 | - (*foundp)->translation = retval; | ||
3741 | - (*foundp)->translation_length = retlen; | ||
3742 | - } | ||
3743 | - | ||
3744 | - __set_errno (saved_errno); | ||
3745 | - | ||
3746 | - /* Now deal with plural. */ | ||
3747 | - if (plural) | ||
3748 | - retval = plural_lookup (domain, n, retval, retlen); | ||
3749 | - | ||
3750 | - gl_rwlock_unlock (_nl_state_lock); | ||
3751 | - return retval; | ||
3752 | - } | ||
3753 | - } | ||
3754 | - } | ||
3755 | - | ||
3756 | - return_untranslated: | ||
3757 | - /* Return the untranslated MSGID. */ | ||
3758 | - FREE_BLOCKS (block_list); | ||
3759 | - gl_rwlock_unlock (_nl_state_lock); | ||
3760 | -#ifndef _LIBC | ||
3761 | - if (!ENABLE_SECURE) | ||
3762 | - { | ||
3763 | - extern void _nl_log_untranslated (const char *logfilename, | ||
3764 | - const char *domainname, | ||
3765 | - const char *msgid1, const char *msgid2, | ||
3766 | - int plural); | ||
3767 | - const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED"); | ||
3768 | - | ||
3769 | - if (logfilename != NULL && logfilename[0] != '\0') | ||
3770 | - _nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural); | ||
3771 | - } | ||
3772 | -#endif | ||
3773 | - __set_errno (saved_errno); | ||
3774 | - return (plural == 0 | ||
3775 | - ? (char *) msgid1 | ||
3776 | - /* Use the Germanic plural rule. */ | ||
3777 | - : n == 1 ? (char *) msgid1 : (char *) msgid2); | ||
3778 | -} | ||
3779 | - | ||
3780 | - | ||
3781 | -/* Look up the translation of msgid within DOMAIN_FILE and DOMAINBINDING. | ||
3782 | - Return it if found. Return NULL if not found or in case of a conversion | ||
3783 | - failure (problem in the particular message catalog). Return (char *) -1 | ||
3784 | - in case of a memory allocation failure during conversion (only if | ||
3785 | - ENCODING != NULL resp. CONVERT == true). */ | ||
3786 | -char * | ||
3787 | -internal_function | ||
3788 | -#ifdef IN_LIBGLOCALE | ||
3789 | -_nl_find_msg (struct loaded_l10nfile *domain_file, | ||
3790 | - struct binding *domainbinding, const char *encoding, | ||
3791 | - const char *msgid, | ||
3792 | - size_t *lengthp) | ||
3793 | -#else | ||
3794 | -_nl_find_msg (struct loaded_l10nfile *domain_file, | ||
3795 | - struct binding *domainbinding, | ||
3796 | - const char *msgid, int convert, | ||
3797 | - size_t *lengthp) | ||
3798 | -#endif | ||
3799 | -{ | ||
3800 | - struct loaded_domain *domain; | ||
3801 | - nls_uint32 nstrings; | ||
3802 | - size_t act; | ||
3803 | - char *result; | ||
3804 | - size_t resultlen; | ||
3805 | - | ||
3806 | - if (domain_file->decided <= 0) | ||
3807 | - _nl_load_domain (domain_file, domainbinding); | ||
3808 | - | ||
3809 | - if (domain_file->data == NULL) | ||
3810 | - return NULL; | ||
3811 | - | ||
3812 | - domain = (struct loaded_domain *) domain_file->data; | ||
3813 | - | ||
3814 | - nstrings = domain->nstrings; | ||
3815 | - | ||
3816 | - /* Locate the MSGID and its translation. */ | ||
3817 | - if (domain->hash_tab != NULL) | ||
3818 | - { | ||
3819 | - /* Use the hashing table. */ | ||
3820 | - nls_uint32 len = strlen (msgid); | ||
3821 | - nls_uint32 hash_val = __hash_string (msgid); | ||
3822 | - nls_uint32 idx = hash_val % domain->hash_size; | ||
3823 | - nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); | ||
3824 | - | ||
3825 | - while (1) | ||
3826 | - { | ||
3827 | - nls_uint32 nstr = | ||
3828 | - W (domain->must_swap_hash_tab, domain->hash_tab[idx]); | ||
3829 | - | ||
3830 | - if (nstr == 0) | ||
3831 | - /* Hash table entry is empty. */ | ||
3832 | - return NULL; | ||
3833 | - | ||
3834 | - nstr--; | ||
3835 | - | ||
3836 | - /* Compare msgid with the original string at index nstr. | ||
3837 | - We compare the lengths with >=, not ==, because plural entries | ||
3838 | - are represented by strings with an embedded NUL. */ | ||
3839 | - if (nstr < nstrings | ||
3840 | - ? W (domain->must_swap, domain->orig_tab[nstr].length) >= len | ||
3841 | - && (strcmp (msgid, | ||
3842 | - domain->data + W (domain->must_swap, | ||
3843 | - domain->orig_tab[nstr].offset)) | ||
3844 | - == 0) | ||
3845 | - : domain->orig_sysdep_tab[nstr - nstrings].length > len | ||
3846 | - && (strcmp (msgid, | ||
3847 | - domain->orig_sysdep_tab[nstr - nstrings].pointer) | ||
3848 | - == 0)) | ||
3849 | - { | ||
3850 | - act = nstr; | ||
3851 | - goto found; | ||
3852 | - } | ||
3853 | - | ||
3854 | - if (idx >= domain->hash_size - incr) | ||
3855 | - idx -= domain->hash_size - incr; | ||
3856 | - else | ||
3857 | - idx += incr; | ||
3858 | - } | ||
3859 | - /* NOTREACHED */ | ||
3860 | - } | ||
3861 | - else | ||
3862 | - { | ||
3863 | - /* Try the default method: binary search in the sorted array of | ||
3864 | - messages. */ | ||
3865 | - size_t top, bottom; | ||
3866 | - | ||
3867 | - bottom = 0; | ||
3868 | - top = nstrings; | ||
3869 | - while (bottom < top) | ||
3870 | - { | ||
3871 | - int cmp_val; | ||
3872 | - | ||
3873 | - act = (bottom + top) / 2; | ||
3874 | - cmp_val = strcmp (msgid, (domain->data | ||
3875 | - + W (domain->must_swap, | ||
3876 | - domain->orig_tab[act].offset))); | ||
3877 | - if (cmp_val < 0) | ||
3878 | - top = act; | ||
3879 | - else if (cmp_val > 0) | ||
3880 | - bottom = act + 1; | ||
3881 | - else | ||
3882 | - goto found; | ||
3883 | - } | ||
3884 | - /* No translation was found. */ | ||
3885 | - return NULL; | ||
3886 | - } | ||
3887 | - | ||
3888 | - found: | ||
3889 | - /* The translation was found at index ACT. If we have to convert the | ||
3890 | - string to use a different character set, this is the time. */ | ||
3891 | - if (act < nstrings) | ||
3892 | - { | ||
3893 | - result = (char *) | ||
3894 | - (domain->data + W (domain->must_swap, domain->trans_tab[act].offset)); | ||
3895 | - resultlen = W (domain->must_swap, domain->trans_tab[act].length) + 1; | ||
3896 | - } | ||
3897 | - else | ||
3898 | - { | ||
3899 | - result = (char *) domain->trans_sysdep_tab[act - nstrings].pointer; | ||
3900 | - resultlen = domain->trans_sysdep_tab[act - nstrings].length; | ||
3901 | - } | ||
3902 | - | ||
3903 | -#if defined _LIBC || HAVE_ICONV | ||
3904 | -# ifdef IN_LIBGLOCALE | ||
3905 | - if (encoding != NULL) | ||
3906 | -# else | ||
3907 | - if (convert) | ||
3908 | -# endif | ||
3909 | - { | ||
3910 | - /* We are supposed to do a conversion. */ | ||
3911 | -# ifndef IN_LIBGLOCALE | ||
3912 | - const char *encoding = get_output_charset (domainbinding); | ||
3913 | -# endif | ||
3914 | - size_t nconversions; | ||
3915 | - struct converted_domain *convd; | ||
3916 | - size_t i; | ||
3917 | - | ||
3918 | - /* Protect against reallocation of the table. */ | ||
3919 | - gl_rwlock_rdlock (domain->conversions_lock); | ||
3920 | - | ||
3921 | - /* Search whether a table with converted translations for this | ||
3922 | - encoding has already been allocated. */ | ||
3923 | - nconversions = domain->nconversions; | ||
3924 | - convd = NULL; | ||
3925 | - | ||
3926 | - for (i = nconversions; i > 0; ) | ||
3927 | - { | ||
3928 | - i--; | ||
3929 | - if (strcmp (domain->conversions[i].encoding, encoding) == 0) | ||
3930 | - { | ||
3931 | - convd = &domain->conversions[i]; | ||
3932 | - break; | ||
3933 | - } | ||
3934 | - } | ||
3935 | - | ||
3936 | - gl_rwlock_unlock (domain->conversions_lock); | ||
3937 | - | ||
3938 | - if (convd == NULL) | ||
3939 | - { | ||
3940 | - /* We have to allocate a new conversions table. */ | ||
3941 | - gl_rwlock_wrlock (domain->conversions_lock); | ||
3942 | - | ||
3943 | - /* Maybe in the meantime somebody added the translation. | ||
3944 | - Recheck. */ | ||
3945 | - for (i = nconversions; i > 0; ) | ||
3946 | - { | ||
3947 | - i--; | ||
3948 | - if (strcmp (domain->conversions[i].encoding, encoding) == 0) | ||
3949 | - { | ||
3950 | - convd = &domain->conversions[i]; | ||
3951 | - goto found_convd; | ||
3952 | - } | ||
3953 | - } | ||
3954 | - | ||
3955 | - { | ||
3956 | - /* Allocate a table for the converted translations for this | ||
3957 | - encoding. */ | ||
3958 | - struct converted_domain *new_conversions = | ||
3959 | - (struct converted_domain *) | ||
3960 | - (domain->conversions != NULL | ||
3961 | - ? realloc (domain->conversions, | ||
3962 | - (nconversions + 1) * sizeof (struct converted_domain)) | ||
3963 | - : malloc ((nconversions + 1) * sizeof (struct converted_domain))); | ||
3964 | - | ||
3965 | - if (__builtin_expect (new_conversions == NULL, 0)) | ||
3966 | - { | ||
3967 | - /* Nothing we can do, no more memory. We cannot use the | ||
3968 | - translation because it might be encoded incorrectly. */ | ||
3969 | - unlock_fail: | ||
3970 | - gl_rwlock_unlock (domain->conversions_lock); | ||
3971 | - return (char *) -1; | ||
3972 | - } | ||
3973 | - | ||
3974 | - domain->conversions = new_conversions; | ||
3975 | - | ||
3976 | - /* Copy the 'encoding' string to permanent storage. */ | ||
3977 | - encoding = strdup (encoding); | ||
3978 | - if (__builtin_expect (encoding == NULL, 0)) | ||
3979 | - /* Nothing we can do, no more memory. We cannot use the | ||
3980 | - translation because it might be encoded incorrectly. */ | ||
3981 | - goto unlock_fail; | ||
3982 | - | ||
3983 | - convd = &new_conversions[nconversions]; | ||
3984 | - convd->encoding = encoding; | ||
3985 | - | ||
3986 | - /* Find out about the character set the file is encoded with. | ||
3987 | - This can be found (in textual form) in the entry "". If this | ||
3988 | - entry does not exist or if this does not contain the 'charset=' | ||
3989 | - information, we will assume the charset matches the one the | ||
3990 | - current locale and we don't have to perform any conversion. */ | ||
3991 | -# ifdef _LIBC | ||
3992 | - convd->conv = (__gconv_t) -1; | ||
3993 | -# else | ||
3994 | -# if HAVE_ICONV | ||
3995 | - convd->conv = (iconv_t) -1; | ||
3996 | -# endif | ||
3997 | -# endif | ||
3998 | - { | ||
3999 | - char *nullentry; | ||
4000 | - size_t nullentrylen; | ||
4001 | - | ||
4002 | - /* Get the header entry. This is a recursion, but it doesn't | ||
4003 | - reallocate domain->conversions because we pass | ||
4004 | - encoding = NULL or convert = 0, respectively. */ | ||
4005 | - nullentry = | ||
4006 | -# ifdef IN_LIBGLOCALE | ||
4007 | - _nl_find_msg (domain_file, domainbinding, NULL, "", | ||
4008 | - &nullentrylen); | ||
4009 | -# else | ||
4010 | - _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); | ||
4011 | -# endif | ||
4012 | - | ||
4013 | - if (nullentry != NULL) | ||
4014 | - { | ||
4015 | - const char *charsetstr; | ||
4016 | - | ||
4017 | - charsetstr = strstr (nullentry, "charset="); | ||
4018 | - if (charsetstr != NULL) | ||
4019 | - { | ||
4020 | - size_t len; | ||
4021 | - char *charset; | ||
4022 | - const char *outcharset; | ||
4023 | - | ||
4024 | - charsetstr += strlen ("charset="); | ||
4025 | - len = strcspn (charsetstr, " \t\n"); | ||
4026 | - | ||
4027 | - charset = (char *) alloca (len + 1); | ||
4028 | -# if defined _LIBC || HAVE_MEMPCPY | ||
4029 | - *((char *) mempcpy (charset, charsetstr, len)) = '\0'; | ||
4030 | -# else | ||
4031 | - memcpy (charset, charsetstr, len); | ||
4032 | - charset[len] = '\0'; | ||
4033 | -# endif | ||
4034 | - | ||
4035 | - outcharset = encoding; | ||
4036 | - | ||
4037 | -# ifdef _LIBC | ||
4038 | - /* We always want to use transliteration. */ | ||
4039 | - outcharset = norm_add_slashes (outcharset, "TRANSLIT"); | ||
4040 | - charset = norm_add_slashes (charset, ""); | ||
4041 | - int r = __gconv_open (outcharset, charset, &convd->conv, | ||
4042 | - GCONV_AVOID_NOCONV); | ||
4043 | - if (__builtin_expect (r != __GCONV_OK, 0)) | ||
4044 | - { | ||
4045 | - /* If the output encoding is the same there is | ||
4046 | - nothing to do. Otherwise do not use the | ||
4047 | - translation at all. */ | ||
4048 | - if (__builtin_expect (r != __GCONV_NULCONV, 1)) | ||
4049 | - { | ||
4050 | - gl_rwlock_unlock (domain->conversions_lock); | ||
4051 | - free ((char *) encoding); | ||
4052 | - return NULL; | ||
4053 | - } | ||
4054 | - | ||
4055 | - convd->conv = (__gconv_t) -1; | ||
4056 | - } | ||
4057 | -# else | ||
4058 | -# if HAVE_ICONV | ||
4059 | - /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5, | ||
4060 | - we want to use transliteration. */ | ||
4061 | -# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ | ||
4062 | - || _LIBICONV_VERSION >= 0x0105 | ||
4063 | - if (strchr (outcharset, '/') == NULL) | ||
4064 | - { | ||
4065 | - char *tmp; | ||
4066 | - | ||
4067 | - len = strlen (outcharset); | ||
4068 | - tmp = (char *) alloca (len + 10 + 1); | ||
4069 | - memcpy (tmp, outcharset, len); | ||
4070 | - memcpy (tmp + len, "//TRANSLIT", 10 + 1); | ||
4071 | - outcharset = tmp; | ||
4072 | - | ||
4073 | - convd->conv = iconv_open (outcharset, charset); | ||
4074 | - | ||
4075 | - freea (outcharset); | ||
4076 | - } | ||
4077 | - else | ||
4078 | -# endif | ||
4079 | - convd->conv = iconv_open (outcharset, charset); | ||
4080 | -# endif | ||
4081 | -# endif | ||
4082 | - | ||
4083 | - freea (charset); | ||
4084 | - } | ||
4085 | - } | ||
4086 | - } | ||
4087 | - convd->conv_tab = NULL; | ||
4088 | - /* Here domain->conversions is still == new_conversions. */ | ||
4089 | - domain->nconversions++; | ||
4090 | - } | ||
4091 | - | ||
4092 | - found_convd: | ||
4093 | - gl_rwlock_unlock (domain->conversions_lock); | ||
4094 | - } | ||
4095 | - | ||
4096 | - if ( | ||
4097 | -# ifdef _LIBC | ||
4098 | - convd->conv != (__gconv_t) -1 | ||
4099 | -# else | ||
4100 | -# if HAVE_ICONV | ||
4101 | - convd->conv != (iconv_t) -1 | ||
4102 | -# endif | ||
4103 | -# endif | ||
4104 | - ) | ||
4105 | - { | ||
4106 | - /* We are supposed to do a conversion. First allocate an | ||
4107 | - appropriate table with the same structure as the table | ||
4108 | - of translations in the file, where we can put the pointers | ||
4109 | - to the converted strings in. | ||
4110 | - There is a slight complication with plural entries. They | ||
4111 | - are represented by consecutive NUL terminated strings. We | ||
4112 | - handle this case by converting RESULTLEN bytes, including | ||
4113 | - NULs. */ | ||
4114 | - | ||
4115 | - if (convd->conv_tab == NULL | ||
4116 | - && ((convd->conv_tab = | ||
4117 | - (char **) calloc (nstrings + domain->n_sysdep_strings, | ||
4118 | - sizeof (char *))) | ||
4119 | - == NULL)) | ||
4120 | - /* Mark that we didn't succeed allocating a table. */ | ||
4121 | - convd->conv_tab = (char **) -1; | ||
4122 | - | ||
4123 | - if (__builtin_expect (convd->conv_tab == (char **) -1, 0)) | ||
4124 | - /* Nothing we can do, no more memory. We cannot use the | ||
4125 | - translation because it might be encoded incorrectly. */ | ||
4126 | - return (char *) -1; | ||
4127 | - | ||
4128 | - if (convd->conv_tab[act] == NULL) | ||
4129 | - { | ||
4130 | - /* We haven't used this string so far, so it is not | ||
4131 | - translated yet. Do this now. */ | ||
4132 | - /* We use a bit more efficient memory handling. | ||
4133 | - We allocate always larger blocks which get used over | ||
4134 | - time. This is faster than many small allocations. */ | ||
4135 | - __libc_lock_define_initialized (static, lock) | ||
4136 | -# define INITIAL_BLOCK_SIZE 4080 | ||
4137 | - static unsigned char *freemem; | ||
4138 | - static size_t freemem_size; | ||
4139 | - | ||
4140 | - const unsigned char *inbuf; | ||
4141 | - unsigned char *outbuf; | ||
4142 | - int malloc_count; | ||
4143 | -# ifndef _LIBC | ||
4144 | - transmem_block_t *transmem_list = NULL; | ||
4145 | -# endif | ||
4146 | - | ||
4147 | - __libc_lock_lock (lock); | ||
4148 | - | ||
4149 | - inbuf = (const unsigned char *) result; | ||
4150 | - outbuf = freemem + sizeof (size_t); | ||
4151 | - | ||
4152 | - malloc_count = 0; | ||
4153 | - while (1) | ||
4154 | - { | ||
4155 | - transmem_block_t *newmem; | ||
4156 | -# ifdef _LIBC | ||
4157 | - size_t non_reversible; | ||
4158 | - int res; | ||
4159 | - | ||
4160 | - if (freemem_size < sizeof (size_t)) | ||
4161 | - goto resize_freemem; | ||
4162 | - | ||
4163 | - res = __gconv (convd->conv, | ||
4164 | - &inbuf, inbuf + resultlen, | ||
4165 | - &outbuf, | ||
4166 | - outbuf + freemem_size - sizeof (size_t), | ||
4167 | - &non_reversible); | ||
4168 | - | ||
4169 | - if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT) | ||
4170 | - break; | ||
4171 | - | ||
4172 | - if (res != __GCONV_FULL_OUTPUT) | ||
4173 | - { | ||
4174 | - /* We should not use the translation at all, it | ||
4175 | - is incorrectly encoded. */ | ||
4176 | - __libc_lock_unlock (lock); | ||
4177 | - return NULL; | ||
4178 | - } | ||
4179 | - | ||
4180 | - inbuf = (const unsigned char *) result; | ||
4181 | -# else | ||
4182 | -# if HAVE_ICONV | ||
4183 | - const char *inptr = (const char *) inbuf; | ||
4184 | - size_t inleft = resultlen; | ||
4185 | - char *outptr = (char *) outbuf; | ||
4186 | - size_t outleft; | ||
4187 | - | ||
4188 | - if (freemem_size < sizeof (size_t)) | ||
4189 | - goto resize_freemem; | ||
4190 | - | ||
4191 | - outleft = freemem_size - sizeof (size_t); | ||
4192 | - if (iconv (convd->conv, | ||
4193 | - (ICONV_CONST char **) &inptr, &inleft, | ||
4194 | - &outptr, &outleft) | ||
4195 | - != (size_t) (-1)) | ||
4196 | - { | ||
4197 | - outbuf = (unsigned char *) outptr; | ||
4198 | - break; | ||
4199 | - } | ||
4200 | - if (errno != E2BIG) | ||
4201 | - { | ||
4202 | - __libc_lock_unlock (lock); | ||
4203 | - return NULL; | ||
4204 | - } | ||
4205 | -# endif | ||
4206 | -# endif | ||
4207 | - | ||
4208 | - resize_freemem: | ||
4209 | - /* We must allocate a new buffer or resize the old one. */ | ||
4210 | - if (malloc_count > 0) | ||
4211 | - { | ||
4212 | - ++malloc_count; | ||
4213 | - freemem_size = malloc_count * INITIAL_BLOCK_SIZE; | ||
4214 | - newmem = (transmem_block_t *) realloc (transmem_list, | ||
4215 | - freemem_size); | ||
4216 | -# ifdef _LIBC | ||
4217 | - if (newmem != NULL) | ||
4218 | - transmem_list = transmem_list->next; | ||
4219 | - else | ||
4220 | - { | ||
4221 | - struct transmem_list *old = transmem_list; | ||
4222 | - | ||
4223 | - transmem_list = transmem_list->next; | ||
4224 | - free (old); | ||
4225 | - } | ||
4226 | -# endif | ||
4227 | - } | ||
4228 | - else | ||
4229 | - { | ||
4230 | - malloc_count = 1; | ||
4231 | - freemem_size = INITIAL_BLOCK_SIZE; | ||
4232 | - newmem = (transmem_block_t *) malloc (freemem_size); | ||
4233 | - } | ||
4234 | - if (__builtin_expect (newmem == NULL, 0)) | ||
4235 | - { | ||
4236 | - freemem = NULL; | ||
4237 | - freemem_size = 0; | ||
4238 | - __libc_lock_unlock (lock); | ||
4239 | - return (char *) -1; | ||
4240 | - } | ||
4241 | - | ||
4242 | -# ifdef _LIBC | ||
4243 | - /* Add the block to the list of blocks we have to free | ||
4244 | - at some point. */ | ||
4245 | - newmem->next = transmem_list; | ||
4246 | - transmem_list = newmem; | ||
4247 | - | ||
4248 | - freemem = (unsigned char *) newmem->data; | ||
4249 | - freemem_size -= offsetof (struct transmem_list, data); | ||
4250 | -# else | ||
4251 | - transmem_list = newmem; | ||
4252 | - freemem = newmem; | ||
4253 | -# endif | ||
4254 | - | ||
4255 | - outbuf = freemem + sizeof (size_t); | ||
4256 | - } | ||
4257 | - | ||
4258 | - /* We have now in our buffer a converted string. Put this | ||
4259 | - into the table of conversions. */ | ||
4260 | - *(size_t *) freemem = outbuf - freemem - sizeof (size_t); | ||
4261 | - convd->conv_tab[act] = (char *) freemem; | ||
4262 | - /* Shrink freemem, but keep it aligned. */ | ||
4263 | - freemem_size -= outbuf - freemem; | ||
4264 | - freemem = outbuf; | ||
4265 | - freemem += freemem_size & (alignof (size_t) - 1); | ||
4266 | - freemem_size = freemem_size & ~ (alignof (size_t) - 1); | ||
4267 | - | ||
4268 | - __libc_lock_unlock (lock); | ||
4269 | - } | ||
4270 | - | ||
4271 | - /* Now convd->conv_tab[act] contains the translation of all | ||
4272 | - the plural variants. */ | ||
4273 | - result = convd->conv_tab[act] + sizeof (size_t); | ||
4274 | - resultlen = *(size_t *) convd->conv_tab[act]; | ||
4275 | - } | ||
4276 | - } | ||
4277 | - | ||
4278 | - /* The result string is converted. */ | ||
4279 | - | ||
4280 | -#endif /* _LIBC || HAVE_ICONV */ | ||
4281 | - | ||
4282 | - *lengthp = resultlen; | ||
4283 | - return result; | ||
4284 | -} | ||
4285 | - | ||
4286 | - | ||
4287 | -/* Look up a plural variant. */ | ||
4288 | -static char * | ||
4289 | -internal_function | ||
4290 | -plural_lookup (struct loaded_l10nfile *domain, unsigned long int n, | ||
4291 | - const char *translation, size_t translation_len) | ||
4292 | -{ | ||
4293 | - struct loaded_domain *domaindata = (struct loaded_domain *) domain->data; | ||
4294 | - unsigned long int index; | ||
4295 | - const char *p; | ||
4296 | - | ||
4297 | - index = plural_eval (domaindata->plural, n); | ||
4298 | - if (index >= domaindata->nplurals) | ||
4299 | - /* This should never happen. It means the plural expression and the | ||
4300 | - given maximum value do not match. */ | ||
4301 | - index = 0; | ||
4302 | - | ||
4303 | - /* Skip INDEX strings at TRANSLATION. */ | ||
4304 | - p = translation; | ||
4305 | - while (index-- > 0) | ||
4306 | - { | ||
4307 | -#ifdef _LIBC | ||
4308 | - p = __rawmemchr (p, '\0'); | ||
4309 | -#else | ||
4310 | - p = strchr (p, '\0'); | ||
4311 | -#endif | ||
4312 | - /* And skip over the NUL byte. */ | ||
4313 | - p++; | ||
4314 | - | ||
4315 | - if (p >= translation + translation_len) | ||
4316 | - /* This should never happen. It means the plural expression | ||
4317 | - evaluated to a value larger than the number of variants | ||
4318 | - available for MSGID1. */ | ||
4319 | - return (char *) translation; | ||
4320 | - } | ||
4321 | - return (char *) p; | ||
4322 | -} | ||
4323 | - | ||
4324 | -#ifndef _LIBC | ||
4325 | -/* Return string representation of locale CATEGORY. */ | ||
4326 | -static const char * | ||
4327 | -internal_function | ||
4328 | -category_to_name (int category) | ||
4329 | -{ | ||
4330 | - const char *retval; | ||
4331 | - | ||
4332 | - switch (category) | ||
4333 | - { | ||
4334 | -#ifdef LC_COLLATE | ||
4335 | - case LC_COLLATE: | ||
4336 | - retval = "LC_COLLATE"; | ||
4337 | - break; | ||
4338 | -#endif | ||
4339 | -#ifdef LC_CTYPE | ||
4340 | - case LC_CTYPE: | ||
4341 | - retval = "LC_CTYPE"; | ||
4342 | - break; | ||
4343 | -#endif | ||
4344 | -#ifdef LC_MONETARY | ||
4345 | - case LC_MONETARY: | ||
4346 | - retval = "LC_MONETARY"; | ||
4347 | - break; | ||
4348 | -#endif | ||
4349 | -#ifdef LC_NUMERIC | ||
4350 | - case LC_NUMERIC: | ||
4351 | - retval = "LC_NUMERIC"; | ||
4352 | - break; | ||
4353 | -#endif | ||
4354 | -#ifdef LC_TIME | ||
4355 | - case LC_TIME: | ||
4356 | - retval = "LC_TIME"; | ||
4357 | - break; | ||
4358 | -#endif | ||
4359 | -#ifdef LC_MESSAGES | ||
4360 | - case LC_MESSAGES: | ||
4361 | - retval = "LC_MESSAGES"; | ||
4362 | - break; | ||
4363 | -#endif | ||
4364 | -#ifdef LC_RESPONSE | ||
4365 | - case LC_RESPONSE: | ||
4366 | - retval = "LC_RESPONSE"; | ||
4367 | - break; | ||
4368 | -#endif | ||
4369 | -#ifdef LC_ALL | ||
4370 | - case LC_ALL: | ||
4371 | - /* This might not make sense but is perhaps better than any other | ||
4372 | - value. */ | ||
4373 | - retval = "LC_ALL"; | ||
4374 | - break; | ||
4375 | -#endif | ||
4376 | - default: | ||
4377 | - /* If you have a better idea for a default value let me know. */ | ||
4378 | - retval = "LC_XXX"; | ||
4379 | - } | ||
4380 | - | ||
4381 | - return retval; | ||
4382 | -} | ||
4383 | -#endif | ||
4384 | - | ||
4385 | -/* Guess value of current locale from value of the environment variables | ||
4386 | - or system-dependent defaults. */ | ||
4387 | -static const char * | ||
4388 | -internal_function | ||
4389 | -#ifdef IN_LIBGLOCALE | ||
4390 | -guess_category_value (int category, const char *categoryname, | ||
4391 | - const char *locale) | ||
4392 | - | ||
4393 | -#else | ||
4394 | -guess_category_value (int category, const char *categoryname) | ||
4395 | -#endif | ||
4396 | -{ | ||
4397 | - const char *language; | ||
4398 | -#ifndef IN_LIBGLOCALE | ||
4399 | - const char *locale; | ||
4400 | -# ifndef _LIBC | ||
4401 | - const char *language_default; | ||
4402 | - int locale_defaulted; | ||
4403 | -# endif | ||
4404 | -#endif | ||
4405 | - | ||
4406 | - /* We use the settings in the following order: | ||
4407 | - 1. The value of the environment variable 'LANGUAGE'. This is a GNU | ||
4408 | - extension. Its value can be a colon-separated list of locale names. | ||
4409 | - 2. The value of the environment variable 'LC_ALL', 'LC_xxx', or 'LANG'. | ||
4410 | - More precisely, the first among these that is set to a non-empty value. | ||
4411 | - This is how POSIX specifies it. The value is a single locale name. | ||
4412 | - 3. A system-dependent preference list of languages. Its value can be a | ||
4413 | - colon-separated list of locale names. | ||
4414 | - 4. A system-dependent default locale name. | ||
4415 | - This way: | ||
4416 | - - System-dependent settings can be overridden by environment variables. | ||
4417 | - - If the system provides both a list of languages and a default locale, | ||
4418 | - the former is used. */ | ||
4419 | - | ||
4420 | -#ifndef IN_LIBGLOCALE | ||
4421 | - /* Fetch the locale name, through the POSIX method of looking to `LC_ALL', | ||
4422 | - `LC_xxx', and `LANG'. On some systems this can be done by the | ||
4423 | - `setlocale' function itself. */ | ||
4424 | -# ifdef _LIBC | ||
4425 | - locale = __current_locale_name (category); | ||
4426 | -# else | ||
4427 | -# if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS | ||
4428 | - /* The __names field is not public glibc API and must therefore not be used | ||
4429 | - in code that is installed in public locations. */ | ||
4430 | - locale_t thread_locale = uselocale (NULL); | ||
4431 | - if (thread_locale != LC_GLOBAL_LOCALE) | ||
4432 | - { | ||
4433 | - locale = thread_locale->__names[category]; | ||
4434 | - locale_defaulted = 0; | ||
4435 | - } | ||
4436 | - else | ||
4437 | -# endif | ||
4438 | - { | ||
4439 | - locale = _nl_locale_name_posix (category, categoryname); | ||
4440 | - locale_defaulted = 0; | ||
4441 | - if (locale == NULL) | ||
4442 | - { | ||
4443 | - locale = _nl_locale_name_default (); | ||
4444 | - locale_defaulted = 1; | ||
4445 | - } | ||
4446 | - } | ||
4447 | -# endif | ||
4448 | -#endif | ||
4449 | - | ||
4450 | - /* Ignore LANGUAGE and its system-dependent analogon if the locale is set | ||
4451 | - to "C" because | ||
4452 | - 1. "C" locale usually uses the ASCII encoding, and most international | ||
4453 | - messages use non-ASCII characters. These characters get displayed | ||
4454 | - as question marks (if using glibc's iconv()) or as invalid 8-bit | ||
4455 | - characters (because other iconv()s refuse to convert most non-ASCII | ||
4456 | - characters to ASCII). In any case, the output is ugly. | ||
4457 | - 2. The precise output of some programs in the "C" locale is specified | ||
4458 | - by POSIX and should not depend on environment variables like | ||
4459 | - "LANGUAGE" or system-dependent information. We allow such programs | ||
4460 | - to use gettext(). */ | ||
4461 | - if (strcmp (locale, "C") == 0) | ||
4462 | - return locale; | ||
4463 | - | ||
4464 | - /* The highest priority value is the value of the 'LANGUAGE' environment | ||
4465 | - variable. */ | ||
4466 | - language = getenv ("LANGUAGE"); | ||
4467 | - if (language != NULL && language[0] != '\0') | ||
4468 | - return language; | ||
4469 | -#if !defined IN_LIBGLOCALE && !defined _LIBC | ||
4470 | - /* The next priority value is the locale name, if not defaulted. */ | ||
4471 | - if (locale_defaulted) | ||
4472 | - { | ||
4473 | - /* The next priority value is the default language preferences list. */ | ||
4474 | - language_default = _nl_language_preferences_default (); | ||
4475 | - if (language_default != NULL) | ||
4476 | - return language_default; | ||
4477 | - } | ||
4478 | - /* The least priority value is the locale name, if defaulted. */ | ||
4479 | -#endif | ||
4480 | - return locale; | ||
4481 | -} | ||
4482 | - | ||
4483 | -#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE | ||
4484 | -/* Returns the output charset. */ | ||
4485 | -static const char * | ||
4486 | -internal_function | ||
4487 | -get_output_charset (struct binding *domainbinding) | ||
4488 | -{ | ||
4489 | - /* The output charset should normally be determined by the locale. But | ||
4490 | - sometimes the locale is not used or not correctly set up, so we provide | ||
4491 | - a possibility for the user to override this: the OUTPUT_CHARSET | ||
4492 | - environment variable. Moreover, the value specified through | ||
4493 | - bind_textdomain_codeset overrides both. */ | ||
4494 | - if (domainbinding != NULL && domainbinding->codeset != NULL) | ||
4495 | - return domainbinding->codeset; | ||
4496 | - else | ||
4497 | - { | ||
4498 | - /* For speed reasons, we look at the value of OUTPUT_CHARSET only | ||
4499 | - once. This is a user variable that is not supposed to change | ||
4500 | - during a program run. */ | ||
4501 | - static char *output_charset_cache; | ||
4502 | - static int output_charset_cached; | ||
4503 | - | ||
4504 | - if (!output_charset_cached) | ||
4505 | - { | ||
4506 | - const char *value = getenv ("OUTPUT_CHARSET"); | ||
4507 | - | ||
4508 | - if (value != NULL && value[0] != '\0') | ||
4509 | - { | ||
4510 | - size_t len = strlen (value) + 1; | ||
4511 | - char *value_copy = (char *) malloc (len); | ||
4512 | - | ||
4513 | - if (value_copy != NULL) | ||
4514 | - memcpy (value_copy, value, len); | ||
4515 | - output_charset_cache = value_copy; | ||
4516 | - } | ||
4517 | - output_charset_cached = 1; | ||
4518 | - } | ||
4519 | - | ||
4520 | - if (output_charset_cache != NULL) | ||
4521 | - return output_charset_cache; | ||
4522 | - else | ||
4523 | - { | ||
4524 | -# ifdef _LIBC | ||
4525 | - return _NL_CURRENT (LC_CTYPE, CODESET); | ||
4526 | -# else | ||
4527 | -# if HAVE_ICONV | ||
4528 | - return locale_charset (); | ||
4529 | -# endif | ||
4530 | -# endif | ||
4531 | - } | ||
4532 | - } | ||
4533 | -} | ||
4534 | -#endif | ||
4535 | - | ||
4536 | -/* @@ begin of epilog @@ */ | ||
4537 | - | ||
4538 | -/* We don't want libintl.a to depend on any other library. So we | ||
4539 | - avoid the non-standard function stpcpy. In GNU C Library this | ||
4540 | - function is available, though. Also allow the symbol HAVE_STPCPY | ||
4541 | - to be defined. */ | ||
4542 | -#if !_LIBC && !HAVE_STPCPY | ||
4543 | -static char * | ||
4544 | -stpcpy (char *dest, const char *src) | ||
4545 | -{ | ||
4546 | - while ((*dest++ = *src++) != '\0') | ||
4547 | - /* Do nothing. */ ; | ||
4548 | - return dest - 1; | ||
4549 | -} | ||
4550 | -#endif | ||
4551 | - | ||
4552 | -#if !_LIBC && !HAVE_MEMPCPY | ||
4553 | -static void * | ||
4554 | -mempcpy (void *dest, const void *src, size_t n) | ||
4555 | -{ | ||
4556 | - return (void *) ((char *) memcpy (dest, src, n) + n); | ||
4557 | -} | ||
4558 | -#endif | ||
4559 | - | ||
4560 | -#if !_LIBC && !HAVE_TSEARCH | ||
4561 | -# include "tsearch.c" | ||
4562 | -#endif | ||
4563 | - | ||
4564 | - | ||
4565 | -#ifdef _LIBC | ||
4566 | -/* If we want to free all resources we have to do some work at | ||
4567 | - program's end. */ | ||
4568 | -libc_freeres_fn (free_mem) | ||
4569 | -{ | ||
4570 | - void *old; | ||
4571 | - | ||
4572 | - while (_nl_domain_bindings != NULL) | ||
4573 | - { | ||
4574 | - struct binding *oldp = _nl_domain_bindings; | ||
4575 | - _nl_domain_bindings = _nl_domain_bindings->next; | ||
4576 | - if (oldp->dirname != _nl_default_dirname) | ||
4577 | - /* Yes, this is a pointer comparison. */ | ||
4578 | - free (oldp->dirname); | ||
4579 | - free (oldp->codeset); | ||
4580 | - free (oldp); | ||
4581 | - } | ||
4582 | - | ||
4583 | - if (_nl_current_default_domain != _nl_default_default_domain) | ||
4584 | - /* Yes, again a pointer comparison. */ | ||
4585 | - free ((char *) _nl_current_default_domain); | ||
4586 | - | ||
4587 | - /* Remove the search tree with the known translations. */ | ||
4588 | - __tdestroy (root, free); | ||
4589 | - root = NULL; | ||
4590 | - | ||
4591 | - while (transmem_list != NULL) | ||
4592 | - { | ||
4593 | - old = transmem_list; | ||
4594 | - transmem_list = transmem_list->next; | ||
4595 | - free (old); | ||
4596 | - } | ||
4597 | -} | ||
4598 | -#endif | ||
4599 | --- a/intl/dcngettext.c | ||
4600 | +++ /dev/null | ||
4601 | @@ -1,57 +0,0 @@ | ||
4602 | -/* Implementation of the dcngettext(3) function. | ||
4603 | - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. | ||
4604 | - | ||
4605 | - This program is free software; you can redistribute it and/or modify it | ||
4606 | - under the terms of the GNU Library General Public License as published | ||
4607 | - by the Free Software Foundation; either version 2, or (at your option) | ||
4608 | - any later version. | ||
4609 | - | ||
4610 | - This program is distributed in the hope that it will be useful, | ||
4611 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4612 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4613 | - Library General Public License for more details. | ||
4614 | - | ||
4615 | - You should have received a copy of the GNU Library General Public | ||
4616 | - License along with this program; if not, write to the Free Software | ||
4617 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
4618 | - USA. */ | ||
4619 | - | ||
4620 | -#ifdef HAVE_CONFIG_H | ||
4621 | -# include <config.h> | ||
4622 | -#endif | ||
4623 | - | ||
4624 | -#include "gettextP.h" | ||
4625 | -#ifdef _LIBC | ||
4626 | -# include <libintl.h> | ||
4627 | -#else | ||
4628 | -# include "libgnuintl.h" | ||
4629 | -#endif | ||
4630 | - | ||
4631 | -/* @@ end of prolog @@ */ | ||
4632 | - | ||
4633 | -/* Names for the libintl functions are a problem. They must not clash | ||
4634 | - with existing names and they should follow ANSI C. But this source | ||
4635 | - code is also used in GNU C Library where the names have a __ | ||
4636 | - prefix. So we have to make a difference here. */ | ||
4637 | -#ifdef _LIBC | ||
4638 | -# define DCNGETTEXT __dcngettext | ||
4639 | -# define DCIGETTEXT __dcigettext | ||
4640 | -#else | ||
4641 | -# define DCNGETTEXT libintl_dcngettext | ||
4642 | -# define DCIGETTEXT libintl_dcigettext | ||
4643 | -#endif | ||
4644 | - | ||
4645 | -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY | ||
4646 | - locale. */ | ||
4647 | -char * | ||
4648 | -DCNGETTEXT (const char *domainname, | ||
4649 | - const char *msgid1, const char *msgid2, unsigned long int n, | ||
4650 | - int category) | ||
4651 | -{ | ||
4652 | - return DCIGETTEXT (domainname, msgid1, msgid2, 1, n, category); | ||
4653 | -} | ||
4654 | - | ||
4655 | -#ifdef _LIBC | ||
4656 | -/* Alias for function name in GNU C Library. */ | ||
4657 | -weak_alias (__dcngettext, dcngettext); | ||
4658 | -#endif | ||
4659 | --- a/intl/dgettext.c | ||
4660 | +++ /dev/null | ||
4661 | @@ -1,58 +0,0 @@ | ||
4662 | -/* Implementation of the dgettext(3) function. | ||
4663 | - Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. | ||
4664 | - | ||
4665 | - This program is free software; you can redistribute it and/or modify it | ||
4666 | - under the terms of the GNU Library General Public License as published | ||
4667 | - by the Free Software Foundation; either version 2, or (at your option) | ||
4668 | - any later version. | ||
4669 | - | ||
4670 | - This program is distributed in the hope that it will be useful, | ||
4671 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4672 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4673 | - Library General Public License for more details. | ||
4674 | - | ||
4675 | - You should have received a copy of the GNU Library General Public | ||
4676 | - License along with this program; if not, write to the Free Software | ||
4677 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
4678 | - USA. */ | ||
4679 | - | ||
4680 | -#ifdef HAVE_CONFIG_H | ||
4681 | -# include <config.h> | ||
4682 | -#endif | ||
4683 | - | ||
4684 | -#include "gettextP.h" | ||
4685 | - | ||
4686 | -#include <locale.h> | ||
4687 | - | ||
4688 | -#ifdef _LIBC | ||
4689 | -# include <libintl.h> | ||
4690 | -#else | ||
4691 | -# include "libgnuintl.h" | ||
4692 | -#endif | ||
4693 | - | ||
4694 | -/* @@ end of prolog @@ */ | ||
4695 | - | ||
4696 | -/* Names for the libintl functions are a problem. They must not clash | ||
4697 | - with existing names and they should follow ANSI C. But this source | ||
4698 | - code is also used in GNU C Library where the names have a __ | ||
4699 | - prefix. So we have to make a difference here. */ | ||
4700 | -#ifdef _LIBC | ||
4701 | -# define DGETTEXT __dgettext | ||
4702 | -# define DCGETTEXT INTUSE(__dcgettext) | ||
4703 | -#else | ||
4704 | -# define DGETTEXT libintl_dgettext | ||
4705 | -# define DCGETTEXT libintl_dcgettext | ||
4706 | -#endif | ||
4707 | - | ||
4708 | -/* Look up MSGID in the DOMAINNAME message catalog of the current | ||
4709 | - LC_MESSAGES locale. */ | ||
4710 | -char * | ||
4711 | -DGETTEXT (const char *domainname, const char *msgid) | ||
4712 | -{ | ||
4713 | - return DCGETTEXT (domainname, msgid, LC_MESSAGES); | ||
4714 | -} | ||
4715 | - | ||
4716 | -#ifdef _LIBC | ||
4717 | -/* Alias for function name in GNU C Library. */ | ||
4718 | -weak_alias (__dgettext, dgettext); | ||
4719 | -#endif | ||
4720 | --- a/intl/dngettext.c | ||
4721 | +++ /dev/null | ||
4722 | @@ -1,59 +0,0 @@ | ||
4723 | -/* Implementation of the dngettext(3) function. | ||
4724 | - Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. | ||
4725 | - | ||
4726 | - This program is free software; you can redistribute it and/or modify it | ||
4727 | - under the terms of the GNU Library General Public License as published | ||
4728 | - by the Free Software Foundation; either version 2, or (at your option) | ||
4729 | - any later version. | ||
4730 | - | ||
4731 | - This program is distributed in the hope that it will be useful, | ||
4732 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4733 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4734 | - Library General Public License for more details. | ||
4735 | - | ||
4736 | - You should have received a copy of the GNU Library General Public | ||
4737 | - License along with this program; if not, write to the Free Software | ||
4738 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
4739 | - USA. */ | ||
4740 | - | ||
4741 | -#ifdef HAVE_CONFIG_H | ||
4742 | -# include <config.h> | ||
4743 | -#endif | ||
4744 | - | ||
4745 | -#include "gettextP.h" | ||
4746 | - | ||
4747 | -#include <locale.h> | ||
4748 | - | ||
4749 | -#ifdef _LIBC | ||
4750 | -# include <libintl.h> | ||
4751 | -#else | ||
4752 | -# include "libgnuintl.h" | ||
4753 | -#endif | ||
4754 | - | ||
4755 | -/* @@ end of prolog @@ */ | ||
4756 | - | ||
4757 | -/* Names for the libintl functions are a problem. They must not clash | ||
4758 | - with existing names and they should follow ANSI C. But this source | ||
4759 | - code is also used in GNU C Library where the names have a __ | ||
4760 | - prefix. So we have to make a difference here. */ | ||
4761 | -#ifdef _LIBC | ||
4762 | -# define DNGETTEXT __dngettext | ||
4763 | -# define DCNGETTEXT __dcngettext | ||
4764 | -#else | ||
4765 | -# define DNGETTEXT libintl_dngettext | ||
4766 | -# define DCNGETTEXT libintl_dcngettext | ||
4767 | -#endif | ||
4768 | - | ||
4769 | -/* Look up MSGID in the DOMAINNAME message catalog of the current | ||
4770 | - LC_MESSAGES locale and skip message according to the plural form. */ | ||
4771 | -char * | ||
4772 | -DNGETTEXT (const char *domainname, | ||
4773 | - const char *msgid1, const char *msgid2, unsigned long int n) | ||
4774 | -{ | ||
4775 | - return DCNGETTEXT (domainname, msgid1, msgid2, n, LC_MESSAGES); | ||
4776 | -} | ||
4777 | - | ||
4778 | -#ifdef _LIBC | ||
4779 | -/* Alias for function name in GNU C Library. */ | ||
4780 | -weak_alias (__dngettext, dngettext); | ||
4781 | -#endif | ||
4782 | --- a/intl/eval-plural.h | ||
4783 | +++ /dev/null | ||
4784 | @@ -1,108 +0,0 @@ | ||
4785 | -/* Plural expression evaluation. | ||
4786 | - Copyright (C) 2000-2003, 2007 Free Software Foundation, Inc. | ||
4787 | - | ||
4788 | - This program is free software; you can redistribute it and/or modify it | ||
4789 | - under the terms of the GNU Library General Public License as published | ||
4790 | - by the Free Software Foundation; either version 2, or (at your option) | ||
4791 | - any later version. | ||
4792 | - | ||
4793 | - This program is distributed in the hope that it will be useful, | ||
4794 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4795 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4796 | - Library General Public License for more details. | ||
4797 | - | ||
4798 | - You should have received a copy of the GNU Library General Public | ||
4799 | - License along with this program; if not, write to the Free Software | ||
4800 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
4801 | - USA. */ | ||
4802 | - | ||
4803 | -#ifndef STATIC | ||
4804 | -#define STATIC static | ||
4805 | -#endif | ||
4806 | - | ||
4807 | -/* Evaluate the plural expression and return an index value. */ | ||
4808 | -STATIC | ||
4809 | -unsigned long int | ||
4810 | -internal_function | ||
4811 | -plural_eval (const struct expression *pexp, unsigned long int n) | ||
4812 | -{ | ||
4813 | - switch (pexp->nargs) | ||
4814 | - { | ||
4815 | - case 0: | ||
4816 | - switch (pexp->operation) | ||
4817 | - { | ||
4818 | - case var: | ||
4819 | - return n; | ||
4820 | - case num: | ||
4821 | - return pexp->val.num; | ||
4822 | - default: | ||
4823 | - break; | ||
4824 | - } | ||
4825 | - /* NOTREACHED */ | ||
4826 | - break; | ||
4827 | - case 1: | ||
4828 | - { | ||
4829 | - /* pexp->operation must be lnot. */ | ||
4830 | - unsigned long int arg = plural_eval (pexp->val.args[0], n); | ||
4831 | - return ! arg; | ||
4832 | - } | ||
4833 | - case 2: | ||
4834 | - { | ||
4835 | - unsigned long int leftarg = plural_eval (pexp->val.args[0], n); | ||
4836 | - if (pexp->operation == lor) | ||
4837 | - return leftarg || plural_eval (pexp->val.args[1], n); | ||
4838 | - else if (pexp->operation == land) | ||
4839 | - return leftarg && plural_eval (pexp->val.args[1], n); | ||
4840 | - else | ||
4841 | - { | ||
4842 | - unsigned long int rightarg = plural_eval (pexp->val.args[1], n); | ||
4843 | - | ||
4844 | - switch (pexp->operation) | ||
4845 | - { | ||
4846 | - case mult: | ||
4847 | - return leftarg * rightarg; | ||
4848 | - case divide: | ||
4849 | -#if !INTDIV0_RAISES_SIGFPE | ||
4850 | - if (rightarg == 0) | ||
4851 | - raise (SIGFPE); | ||
4852 | -#endif | ||
4853 | - return leftarg / rightarg; | ||
4854 | - case module: | ||
4855 | -#if !INTDIV0_RAISES_SIGFPE | ||
4856 | - if (rightarg == 0) | ||
4857 | - raise (SIGFPE); | ||
4858 | -#endif | ||
4859 | - return leftarg % rightarg; | ||
4860 | - case plus: | ||
4861 | - return leftarg + rightarg; | ||
4862 | - case minus: | ||
4863 | - return leftarg - rightarg; | ||
4864 | - case less_than: | ||
4865 | - return leftarg < rightarg; | ||
4866 | - case greater_than: | ||
4867 | - return leftarg > rightarg; | ||
4868 | - case less_or_equal: | ||
4869 | - return leftarg <= rightarg; | ||
4870 | - case greater_or_equal: | ||
4871 | - return leftarg >= rightarg; | ||
4872 | - case equal: | ||
4873 | - return leftarg == rightarg; | ||
4874 | - case not_equal: | ||
4875 | - return leftarg != rightarg; | ||
4876 | - default: | ||
4877 | - break; | ||
4878 | - } | ||
4879 | - } | ||
4880 | - /* NOTREACHED */ | ||
4881 | - break; | ||
4882 | - } | ||
4883 | - case 3: | ||
4884 | - { | ||
4885 | - /* pexp->operation must be qmop. */ | ||
4886 | - unsigned long int boolarg = plural_eval (pexp->val.args[0], n); | ||
4887 | - return plural_eval (pexp->val.args[boolarg ? 1 : 2], n); | ||
4888 | - } | ||
4889 | - } | ||
4890 | - /* NOTREACHED */ | ||
4891 | - return 0; | ||
4892 | -} | ||
4893 | --- a/intl/explodename.c | ||
4894 | +++ /dev/null | ||
4895 | @@ -1,135 +0,0 @@ | ||
4896 | -/* Copyright (C) 1995-1998, 2000-2001, 2003, 2005, 2007 Free Software Foundation, Inc. | ||
4897 | - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. | ||
4898 | - | ||
4899 | - This program is free software; you can redistribute it and/or modify it | ||
4900 | - under the terms of the GNU Library General Public License as published | ||
4901 | - by the Free Software Foundation; either version 2, or (at your option) | ||
4902 | - any later version. | ||
4903 | - | ||
4904 | - This program is distributed in the hope that it will be useful, | ||
4905 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4906 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
4907 | - Library General Public License for more details. | ||
4908 | - | ||
4909 | - You should have received a copy of the GNU Library General Public | ||
4910 | - License along with this program; if not, write to the Free Software | ||
4911 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
4912 | - USA. */ | ||
4913 | - | ||
4914 | -#ifdef HAVE_CONFIG_H | ||
4915 | -# include <config.h> | ||
4916 | -#endif | ||
4917 | - | ||
4918 | -#include <stdlib.h> | ||
4919 | -#include <string.h> | ||
4920 | -#include <sys/types.h> | ||
4921 | - | ||
4922 | -#include "loadinfo.h" | ||
4923 | - | ||
4924 | -/* On some strange systems still no definition of NULL is found. Sigh! */ | ||
4925 | -#ifndef NULL | ||
4926 | -# if defined __STDC__ && __STDC__ | ||
4927 | -# define NULL ((void *) 0) | ||
4928 | -# else | ||
4929 | -# define NULL 0 | ||
4930 | -# endif | ||
4931 | -#endif | ||
4932 | - | ||
4933 | -/* @@ end of prolog @@ */ | ||
4934 | - | ||
4935 | -/* Split a locale name NAME into a leading language part and all the | ||
4936 | - rest. Return a pointer to the first character after the language, | ||
4937 | - i.e. to the first byte of the rest. */ | ||
4938 | -static char *_nl_find_language (const char *name); | ||
4939 | - | ||
4940 | -static char * | ||
4941 | -_nl_find_language (const char *name) | ||
4942 | -{ | ||
4943 | - while (name[0] != '\0' && name[0] != '_' && name[0] != '@' && name[0] != '.') | ||
4944 | - ++name; | ||
4945 | - | ||
4946 | - return (char *) name; | ||
4947 | -} | ||
4948 | - | ||
4949 | - | ||
4950 | -int | ||
4951 | -_nl_explode_name (char *name, | ||
4952 | - const char **language, const char **modifier, | ||
4953 | - const char **territory, const char **codeset, | ||
4954 | - const char **normalized_codeset) | ||
4955 | -{ | ||
4956 | - char *cp; | ||
4957 | - int mask; | ||
4958 | - | ||
4959 | - *modifier = NULL; | ||
4960 | - *territory = NULL; | ||
4961 | - *codeset = NULL; | ||
4962 | - *normalized_codeset = NULL; | ||
4963 | - | ||
4964 | - /* Now we determine the single parts of the locale name. First | ||
4965 | - look for the language. Termination symbols are `_', '.', and `@'. */ | ||
4966 | - mask = 0; | ||
4967 | - *language = cp = name; | ||
4968 | - cp = _nl_find_language (*language); | ||
4969 | - | ||
4970 | - if (*language == cp) | ||
4971 | - /* This does not make sense: language has to be specified. Use | ||
4972 | - this entry as it is without exploding. Perhaps it is an alias. */ | ||
4973 | - cp = strchr (*language, '\0'); | ||
4974 | - else | ||
4975 | - { | ||
4976 | - if (cp[0] == '_') | ||
4977 | - { | ||
4978 | - /* Next is the territory. */ | ||
4979 | - cp[0] = '\0'; | ||
4980 | - *territory = ++cp; | ||
4981 | - | ||
4982 | - while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@') | ||
4983 | - ++cp; | ||
4984 | - | ||
4985 | - mask |= XPG_TERRITORY; | ||
4986 | - } | ||
4987 | - | ||
4988 | - if (cp[0] == '.') | ||
4989 | - { | ||
4990 | - /* Next is the codeset. */ | ||
4991 | - cp[0] = '\0'; | ||
4992 | - *codeset = ++cp; | ||
4993 | - | ||
4994 | - while (cp[0] != '\0' && cp[0] != '@') | ||
4995 | - ++cp; | ||
4996 | - | ||
4997 | - mask |= XPG_CODESET; | ||
4998 | - | ||
4999 | - if (*codeset != cp && (*codeset)[0] != '\0') | ||
5000 | - { | ||
5001 | - *normalized_codeset = _nl_normalize_codeset (*codeset, | ||
5002 | - cp - *codeset); | ||
5003 | - if (*normalized_codeset == NULL) | ||
5004 | - return -1; | ||
5005 | - else if (strcmp (*codeset, *normalized_codeset) == 0) | ||
5006 | - free ((char *) *normalized_codeset); | ||
5007 | - else | ||
5008 | - mask |= XPG_NORM_CODESET; | ||
5009 | - } | ||
5010 | - } | ||
5011 | - } | ||
5012 | - | ||
5013 | - if (cp[0] == '@') | ||
5014 | - { | ||
5015 | - /* Next is the modifier. */ | ||
5016 | - cp[0] = '\0'; | ||
5017 | - *modifier = ++cp; | ||
5018 | - | ||
5019 | - if (cp[0] != '\0') | ||
5020 | - mask |= XPG_MODIFIER; | ||
5021 | - } | ||
5022 | - | ||
5023 | - if (*territory != NULL && (*territory)[0] == '\0') | ||
5024 | - mask &= ~XPG_TERRITORY; | ||
5025 | - | ||
5026 | - if (*codeset != NULL && (*codeset)[0] == '\0') | ||
5027 | - mask &= ~XPG_CODESET; | ||
5028 | - | ||
5029 | - return mask; | ||
5030 | -} | ||
5031 | --- a/intl/export.h | ||
5032 | +++ /dev/null | ||
5033 | @@ -1,6 +0,0 @@ | ||
5034 | - | ||
5035 | -#if @HAVE_VISIBILITY@ && BUILDING_LIBINTL | ||
5036 | -#define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default"))) | ||
5037 | -#else | ||
5038 | -#define LIBINTL_DLL_EXPORTED | ||
5039 | -#endif | ||
5040 | --- a/intl/finddomain.c | ||
5041 | +++ /dev/null | ||
5042 | @@ -1,212 +0,0 @@ | ||
5043 | -/* Handle list of needed message catalogs | ||
5044 | - Copyright (C) 1995-1999, 2000-2001, 2003-2007 Free Software Foundation, Inc. | ||
5045 | - Written by Ulrich Drepper <drepper@gnu.org>, 1995. | ||
5046 | - | ||
5047 | - This program is free software; you can redistribute it and/or modify it | ||
5048 | - under the terms of the GNU Library General Public License as published | ||
5049 | - by the Free Software Foundation; either version 2, or (at your option) | ||
5050 | - any later version. | ||
5051 | - | ||
5052 | - This program is distributed in the hope that it will be useful, | ||
5053 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5054 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5055 | - Library General Public License for more details. | ||
5056 | - | ||
5057 | - You should have received a copy of the GNU Library General Public | ||
5058 | - License along with this program; if not, write to the Free Software | ||
5059 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
5060 | - USA. */ | ||
5061 | - | ||
5062 | -#ifdef HAVE_CONFIG_H | ||
5063 | -# include <config.h> | ||
5064 | -#endif | ||
5065 | - | ||
5066 | -#include <stdio.h> | ||
5067 | -#include <sys/types.h> | ||
5068 | -#include <stdlib.h> | ||
5069 | -#include <string.h> | ||
5070 | - | ||
5071 | -#if defined HAVE_UNISTD_H || defined _LIBC | ||
5072 | -# include <unistd.h> | ||
5073 | -#endif | ||
5074 | - | ||
5075 | -#include "gettextP.h" | ||
5076 | -#ifdef _LIBC | ||
5077 | -# include <libintl.h> | ||
5078 | -#else | ||
5079 | -# include "libgnuintl.h" | ||
5080 | -#endif | ||
5081 | - | ||
5082 | -/* Handle multi-threaded applications. */ | ||
5083 | -#ifdef _LIBC | ||
5084 | -# include <bits/libc-lock.h> | ||
5085 | -# define gl_rwlock_define_initialized __libc_rwlock_define_initialized | ||
5086 | -# define gl_rwlock_rdlock __libc_rwlock_rdlock | ||
5087 | -# define gl_rwlock_wrlock __libc_rwlock_wrlock | ||
5088 | -# define gl_rwlock_unlock __libc_rwlock_unlock | ||
5089 | -#else | ||
5090 | -# include "lock.h" | ||
5091 | -#endif | ||
5092 | - | ||
5093 | -/* @@ end of prolog @@ */ | ||
5094 | -/* List of already loaded domains. */ | ||
5095 | -static struct loaded_l10nfile *_nl_loaded_domains; | ||
5096 | - | ||
5097 | - | ||
5098 | -/* Return a data structure describing the message catalog described by | ||
5099 | - the DOMAINNAME and CATEGORY parameters with respect to the currently | ||
5100 | - established bindings. */ | ||
5101 | -struct loaded_l10nfile * | ||
5102 | -internal_function | ||
5103 | -_nl_find_domain (const char *dirname, char *locale, | ||
5104 | - const char *domainname, struct binding *domainbinding) | ||
5105 | -{ | ||
5106 | - struct loaded_l10nfile *retval; | ||
5107 | - const char *language; | ||
5108 | - const char *modifier; | ||
5109 | - const char *territory; | ||
5110 | - const char *codeset; | ||
5111 | - const char *normalized_codeset; | ||
5112 | - const char *alias_value; | ||
5113 | - int mask; | ||
5114 | - | ||
5115 | - /* LOCALE can consist of up to four recognized parts for the XPG syntax: | ||
5116 | - | ||
5117 | - language[_territory][.codeset][@modifier] | ||
5118 | - | ||
5119 | - Beside the first part all of them are allowed to be missing. If | ||
5120 | - the full specified locale is not found, the less specific one are | ||
5121 | - looked for. The various parts will be stripped off according to | ||
5122 | - the following order: | ||
5123 | - (1) codeset | ||
5124 | - (2) normalized codeset | ||
5125 | - (3) territory | ||
5126 | - (4) modifier | ||
5127 | - */ | ||
5128 | - | ||
5129 | - /* We need to protect modifying the _NL_LOADED_DOMAINS data. */ | ||
5130 | - gl_rwlock_define_initialized (static, lock); | ||
5131 | - gl_rwlock_rdlock (lock); | ||
5132 | - | ||
5133 | - /* If we have already tested for this locale entry there has to | ||
5134 | - be one data set in the list of loaded domains. */ | ||
5135 | - retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, | ||
5136 | - strlen (dirname) + 1, 0, locale, NULL, NULL, | ||
5137 | - NULL, NULL, domainname, 0); | ||
5138 | - | ||
5139 | - gl_rwlock_unlock (lock); | ||
5140 | - | ||
5141 | - if (retval != NULL) | ||
5142 | - { | ||
5143 | - /* We know something about this locale. */ | ||
5144 | - int cnt; | ||
5145 | - | ||
5146 | - if (retval->decided <= 0) | ||
5147 | - _nl_load_domain (retval, domainbinding); | ||
5148 | - | ||
5149 | - if (retval->data != NULL) | ||
5150 | - return retval; | ||
5151 | - | ||
5152 | - for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) | ||
5153 | - { | ||
5154 | - if (retval->successor[cnt]->decided <= 0) | ||
5155 | - _nl_load_domain (retval->successor[cnt], domainbinding); | ||
5156 | - | ||
5157 | - if (retval->successor[cnt]->data != NULL) | ||
5158 | - break; | ||
5159 | - } | ||
5160 | - | ||
5161 | - return retval; | ||
5162 | - /* NOTREACHED */ | ||
5163 | - } | ||
5164 | - | ||
5165 | - /* See whether the locale value is an alias. If yes its value | ||
5166 | - *overwrites* the alias name. No test for the original value is | ||
5167 | - done. */ | ||
5168 | - alias_value = _nl_expand_alias (locale); | ||
5169 | - if (alias_value != NULL) | ||
5170 | - { | ||
5171 | -#if defined _LIBC || defined HAVE_STRDUP | ||
5172 | - locale = strdup (alias_value); | ||
5173 | - if (locale == NULL) | ||
5174 | - return NULL; | ||
5175 | -#else | ||
5176 | - size_t len = strlen (alias_value) + 1; | ||
5177 | - locale = (char *) malloc (len); | ||
5178 | - if (locale == NULL) | ||
5179 | - return NULL; | ||
5180 | - | ||
5181 | - memcpy (locale, alias_value, len); | ||
5182 | -#endif | ||
5183 | - } | ||
5184 | - | ||
5185 | - /* Now we determine the single parts of the locale name. First | ||
5186 | - look for the language. Termination symbols are `_', '.', and `@'. */ | ||
5187 | - mask = _nl_explode_name (locale, &language, &modifier, &territory, | ||
5188 | - &codeset, &normalized_codeset); | ||
5189 | - if (mask == -1) | ||
5190 | - /* This means we are out of core. */ | ||
5191 | - return NULL; | ||
5192 | - | ||
5193 | - /* We need to protect modifying the _NL_LOADED_DOMAINS data. */ | ||
5194 | - gl_rwlock_wrlock (lock); | ||
5195 | - | ||
5196 | - /* Create all possible locale entries which might be interested in | ||
5197 | - generalization. */ | ||
5198 | - retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, | ||
5199 | - strlen (dirname) + 1, mask, language, territory, | ||
5200 | - codeset, normalized_codeset, modifier, | ||
5201 | - domainname, 1); | ||
5202 | - | ||
5203 | - gl_rwlock_unlock (lock); | ||
5204 | - | ||
5205 | - if (retval == NULL) | ||
5206 | - /* This means we are out of core. */ | ||
5207 | - goto out; | ||
5208 | - | ||
5209 | - if (retval->decided <= 0) | ||
5210 | - _nl_load_domain (retval, domainbinding); | ||
5211 | - if (retval->data == NULL) | ||
5212 | - { | ||
5213 | - int cnt; | ||
5214 | - for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) | ||
5215 | - { | ||
5216 | - if (retval->successor[cnt]->decided <= 0) | ||
5217 | - _nl_load_domain (retval->successor[cnt], domainbinding); | ||
5218 | - if (retval->successor[cnt]->data != NULL) | ||
5219 | - break; | ||
5220 | - } | ||
5221 | - } | ||
5222 | - | ||
5223 | - /* The room for an alias was dynamically allocated. Free it now. */ | ||
5224 | - if (alias_value != NULL) | ||
5225 | - free (locale); | ||
5226 | - | ||
5227 | -out: | ||
5228 | - /* The space for normalized_codeset is dynamically allocated. Free it. */ | ||
5229 | - if (mask & XPG_NORM_CODESET) | ||
5230 | - free ((void *) normalized_codeset); | ||
5231 | - | ||
5232 | - return retval; | ||
5233 | -} | ||
5234 | - | ||
5235 | - | ||
5236 | -#ifdef _LIBC | ||
5237 | -/* This is called from iconv/gconv_db.c's free_mem, as locales must | ||
5238 | - be freed before freeing gconv steps arrays. */ | ||
5239 | -void __libc_freeres_fn_section | ||
5240 | -_nl_finddomain_subfreeres () | ||
5241 | -{ | ||
5242 | - struct loaded_l10nfile *runp = _nl_loaded_domains; | ||
5243 | - | ||
5244 | - while (runp != NULL) | ||
5245 | - { | ||
5246 | - struct loaded_l10nfile *here = runp; | ||
5247 | - if (runp->data != NULL) | ||
5248 | - _nl_unload_domain ((struct loaded_domain *) runp->data); | ||
5249 | - runp = runp->next; | ||
5250 | - free ((char *) here->filename); | ||
5251 | - free (here); | ||
5252 | - } | ||
5253 | -} | ||
5254 | -#endif | ||
5255 | --- a/intl/gettext.c | ||
5256 | +++ /dev/null | ||
5257 | @@ -1,63 +0,0 @@ | ||
5258 | -/* Implementation of gettext(3) function. | ||
5259 | - Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc. | ||
5260 | - | ||
5261 | - This program is free software; you can redistribute it and/or modify it | ||
5262 | - under the terms of the GNU Library General Public License as published | ||
5263 | - by the Free Software Foundation; either version 2, or (at your option) | ||
5264 | - any later version. | ||
5265 | - | ||
5266 | - This program is distributed in the hope that it will be useful, | ||
5267 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5268 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5269 | - Library General Public License for more details. | ||
5270 | - | ||
5271 | - You should have received a copy of the GNU Library General Public | ||
5272 | - License along with this program; if not, write to the Free Software | ||
5273 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
5274 | - USA. */ | ||
5275 | - | ||
5276 | -#ifdef HAVE_CONFIG_H | ||
5277 | -# include <config.h> | ||
5278 | -#endif | ||
5279 | - | ||
5280 | -#ifdef _LIBC | ||
5281 | -# define __need_NULL | ||
5282 | -# include <stddef.h> | ||
5283 | -#else | ||
5284 | -# include <stdlib.h> /* Just for NULL. */ | ||
5285 | -#endif | ||
5286 | - | ||
5287 | -#include "gettextP.h" | ||
5288 | -#ifdef _LIBC | ||
5289 | -# include <libintl.h> | ||
5290 | -#else | ||
5291 | -# include "libgnuintl.h" | ||
5292 | -#endif | ||
5293 | - | ||
5294 | -/* @@ end of prolog @@ */ | ||
5295 | - | ||
5296 | -/* Names for the libintl functions are a problem. They must not clash | ||
5297 | - with existing names and they should follow ANSI C. But this source | ||
5298 | - code is also used in GNU C Library where the names have a __ | ||
5299 | - prefix. So we have to make a difference here. */ | ||
5300 | -#ifdef _LIBC | ||
5301 | -# define GETTEXT __gettext | ||
5302 | -# define DCGETTEXT INTUSE(__dcgettext) | ||
5303 | -#else | ||
5304 | -# define GETTEXT libintl_gettext | ||
5305 | -# define DCGETTEXT libintl_dcgettext | ||
5306 | -#endif | ||
5307 | - | ||
5308 | -/* Look up MSGID in the current default message catalog for the current | ||
5309 | - LC_MESSAGES locale. If not found, returns MSGID itself (the default | ||
5310 | - text). */ | ||
5311 | -char * | ||
5312 | -GETTEXT (const char *msgid) | ||
5313 | -{ | ||
5314 | - return DCGETTEXT (NULL, msgid, LC_MESSAGES); | ||
5315 | -} | ||
5316 | - | ||
5317 | -#ifdef _LIBC | ||
5318 | -/* Alias for function name in GNU C Library. */ | ||
5319 | -weak_alias (__gettext, gettext); | ||
5320 | -#endif | ||
5321 | --- a/intl/gettextP.h | ||
5322 | +++ /dev/null | ||
5323 | @@ -1,297 +0,0 @@ | ||
5324 | -/* Header describing internals of libintl library. | ||
5325 | - Copyright (C) 1995-1999, 2000-2007 Free Software Foundation, Inc. | ||
5326 | - Written by Ulrich Drepper <drepper@cygnus.com>, 1995. | ||
5327 | - | ||
5328 | - This program is free software; you can redistribute it and/or modify it | ||
5329 | - under the terms of the GNU Library General Public License as published | ||
5330 | - by the Free Software Foundation; either version 2, or (at your option) | ||
5331 | - any later version. | ||
5332 | - | ||
5333 | - This program is distributed in the hope that it will be useful, | ||
5334 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5335 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5336 | - Library General Public License for more details. | ||
5337 | - | ||
5338 | - You should have received a copy of the GNU Library General Public | ||
5339 | - License along with this program; if not, write to the Free Software | ||
5340 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
5341 | - USA. */ | ||
5342 | - | ||
5343 | -#ifndef _GETTEXTP_H | ||
5344 | -#define _GETTEXTP_H | ||
5345 | - | ||
5346 | -#include <stddef.h> /* Get size_t. */ | ||
5347 | - | ||
5348 | -#ifdef _LIBC | ||
5349 | -# include "../iconv/gconv_int.h" | ||
5350 | -#else | ||
5351 | -# if HAVE_ICONV | ||
5352 | -# include <iconv.h> | ||
5353 | -# endif | ||
5354 | -#endif | ||
5355 | - | ||
5356 | -/* Handle multi-threaded applications. */ | ||
5357 | -#ifdef _LIBC | ||
5358 | -# include <bits/libc-lock.h> | ||
5359 | -# define gl_rwlock_define __libc_rwlock_define | ||
5360 | -#else | ||
5361 | -# include "lock.h" | ||
5362 | -#endif | ||
5363 | - | ||
5364 | -#ifdef _LIBC | ||
5365 | -extern char *__gettext (const char *__msgid); | ||
5366 | -extern char *__dgettext (const char *__domainname, const char *__msgid); | ||
5367 | -extern char *__dcgettext (const char *__domainname, const char *__msgid, | ||
5368 | - int __category); | ||
5369 | -extern char *__ngettext (const char *__msgid1, const char *__msgid2, | ||
5370 | - unsigned long int __n); | ||
5371 | -extern char *__dngettext (const char *__domainname, | ||
5372 | - const char *__msgid1, const char *__msgid2, | ||
5373 | - unsigned long int n); | ||
5374 | -extern char *__dcngettext (const char *__domainname, | ||
5375 | - const char *__msgid1, const char *__msgid2, | ||
5376 | - unsigned long int __n, int __category); | ||
5377 | -extern char *__dcigettext (const char *__domainname, | ||
5378 | - const char *__msgid1, const char *__msgid2, | ||
5379 | - int __plural, unsigned long int __n, | ||
5380 | - int __category); | ||
5381 | -extern char *__textdomain (const char *__domainname); | ||
5382 | -extern char *__bindtextdomain (const char *__domainname, | ||
5383 | - const char *__dirname); | ||
5384 | -extern char *__bind_textdomain_codeset (const char *__domainname, | ||
5385 | - const char *__codeset); | ||
5386 | -extern void _nl_finddomain_subfreeres (void) attribute_hidden; | ||
5387 | -extern void _nl_unload_domain (struct loaded_domain *__domain) | ||
5388 | - internal_function attribute_hidden; | ||
5389 | -#else | ||
5390 | -/* Declare the exported libintl_* functions, in a way that allows us to | ||
5391 | - call them under their real name. */ | ||
5392 | -# undef _INTL_REDIRECT_INLINE | ||
5393 | -# undef _INTL_REDIRECT_MACROS | ||
5394 | -# define _INTL_REDIRECT_MACROS | ||
5395 | -# include "libgnuintl.h" | ||
5396 | -# ifdef IN_LIBGLOCALE | ||
5397 | -extern char *gl_dcigettext (const char *__domainname, | ||
5398 | - const char *__msgid1, const char *__msgid2, | ||
5399 | - int __plural, unsigned long int __n, | ||
5400 | - int __category, | ||
5401 | - const char *__localename, const char *__encoding); | ||
5402 | -# else | ||
5403 | -extern char *libintl_dcigettext (const char *__domainname, | ||
5404 | - const char *__msgid1, const char *__msgid2, | ||
5405 | - int __plural, unsigned long int __n, | ||
5406 | - int __category); | ||
5407 | -# endif | ||
5408 | -#endif | ||
5409 | - | ||
5410 | -#include "loadinfo.h" | ||
5411 | - | ||
5412 | -#include "gmo.h" /* Get nls_uint32. */ | ||
5413 | - | ||
5414 | -/* @@ end of prolog @@ */ | ||
5415 | - | ||
5416 | -#ifndef internal_function | ||
5417 | -# define internal_function | ||
5418 | -#endif | ||
5419 | - | ||
5420 | -#ifndef attribute_hidden | ||
5421 | -# define attribute_hidden | ||
5422 | -#endif | ||
5423 | - | ||
5424 | -/* Tell the compiler when a conditional or integer expression is | ||
5425 | - almost always true or almost always false. */ | ||
5426 | -#ifndef HAVE_BUILTIN_EXPECT | ||
5427 | -# define __builtin_expect(expr, val) (expr) | ||
5428 | -#endif | ||
5429 | - | ||
5430 | -#ifndef W | ||
5431 | -# define W(flag, data) ((flag) ? SWAP (data) : (data)) | ||
5432 | -#endif | ||
5433 | - | ||
5434 | - | ||
5435 | -#ifdef _LIBC | ||
5436 | -# include <byteswap.h> | ||
5437 | -# define SWAP(i) bswap_32 (i) | ||
5438 | -#else | ||
5439 | -static inline nls_uint32 | ||
5440 | -# ifdef __cplusplus | ||
5441 | -SWAP (nls_uint32 i) | ||
5442 | -# else | ||
5443 | -SWAP (i) | ||
5444 | - nls_uint32 i; | ||
5445 | -# endif | ||
5446 | -{ | ||
5447 | - return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); | ||
5448 | -} | ||
5449 | -#endif | ||
5450 | - | ||
5451 | - | ||
5452 | -/* In-memory representation of system dependent string. */ | ||
5453 | -struct sysdep_string_desc | ||
5454 | -{ | ||
5455 | - /* Length of addressed string, including the trailing NUL. */ | ||
5456 | - size_t length; | ||
5457 | - /* Pointer to addressed string. */ | ||
5458 | - const char *pointer; | ||
5459 | -}; | ||
5460 | - | ||
5461 | -/* Cache of translated strings after charset conversion. | ||
5462 | - Note: The strings are converted to the target encoding only on an as-needed | ||
5463 | - basis. */ | ||
5464 | -struct converted_domain | ||
5465 | -{ | ||
5466 | - /* The target encoding name. */ | ||
5467 | - const char *encoding; | ||
5468 | - /* The descriptor for conversion from the message catalog's encoding to | ||
5469 | - this target encoding. */ | ||
5470 | -#ifdef _LIBC | ||
5471 | - __gconv_t conv; | ||
5472 | -#else | ||
5473 | -# if HAVE_ICONV | ||
5474 | - iconv_t conv; | ||
5475 | -# endif | ||
5476 | -#endif | ||
5477 | - /* The table of translated strings after charset conversion. */ | ||
5478 | - char **conv_tab; | ||
5479 | -}; | ||
5480 | - | ||
5481 | -/* The representation of an opened message catalog. */ | ||
5482 | -struct loaded_domain | ||
5483 | -{ | ||
5484 | - /* Pointer to memory containing the .mo file. */ | ||
5485 | - const char *data; | ||
5486 | - /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */ | ||
5487 | - int use_mmap; | ||
5488 | - /* Size of mmap()ed memory. */ | ||
5489 | - size_t mmap_size; | ||
5490 | - /* 1 if the .mo file uses a different endianness than this machine. */ | ||
5491 | - int must_swap; | ||
5492 | - /* Pointer to additional malloc()ed memory. */ | ||
5493 | - void *malloced; | ||
5494 | - | ||
5495 | - /* Number of static strings pairs. */ | ||
5496 | - nls_uint32 nstrings; | ||
5497 | - /* Pointer to descriptors of original strings in the file. */ | ||
5498 | - const struct string_desc *orig_tab; | ||
5499 | - /* Pointer to descriptors of translated strings in the file. */ | ||
5500 | - const struct string_desc *trans_tab; | ||
5501 | - | ||
5502 | - /* Number of system dependent strings pairs. */ | ||
5503 | - nls_uint32 n_sysdep_strings; | ||
5504 | - /* Pointer to descriptors of original sysdep strings. */ | ||
5505 | - const struct sysdep_string_desc *orig_sysdep_tab; | ||
5506 | - /* Pointer to descriptors of translated sysdep strings. */ | ||
5507 | - const struct sysdep_string_desc *trans_sysdep_tab; | ||
5508 | - | ||
5509 | - /* Size of hash table. */ | ||
5510 | - nls_uint32 hash_size; | ||
5511 | - /* Pointer to hash table. */ | ||
5512 | - const nls_uint32 *hash_tab; | ||
5513 | - /* 1 if the hash table uses a different endianness than this machine. */ | ||
5514 | - int must_swap_hash_tab; | ||
5515 | - | ||
5516 | - /* Cache of charset conversions of the translated strings. */ | ||
5517 | - struct converted_domain *conversions; | ||
5518 | - size_t nconversions; | ||
5519 | - gl_rwlock_define (, conversions_lock) | ||
5520 | - | ||
5521 | - const struct expression *plural; | ||
5522 | - unsigned long int nplurals; | ||
5523 | -}; | ||
5524 | - | ||
5525 | -/* We want to allocate a string at the end of the struct. But ISO C | ||
5526 | - doesn't allow zero sized arrays. */ | ||
5527 | -#ifdef __GNUC__ | ||
5528 | -# define ZERO 0 | ||
5529 | -#else | ||
5530 | -# define ZERO 1 | ||
5531 | -#endif | ||
5532 | - | ||
5533 | -/* A set of settings bound to a message domain. Used to store settings | ||
5534 | - from bindtextdomain() and bind_textdomain_codeset(). */ | ||
5535 | -struct binding | ||
5536 | -{ | ||
5537 | - struct binding *next; | ||
5538 | - char *dirname; | ||
5539 | - char *codeset; | ||
5540 | - char domainname[ZERO]; | ||
5541 | -}; | ||
5542 | - | ||
5543 | -/* A counter which is incremented each time some previous translations | ||
5544 | - become invalid. | ||
5545 | - This variable is part of the external ABI of the GNU libintl. */ | ||
5546 | -#ifdef IN_LIBGLOCALE | ||
5547 | -# include <glocale/config.h> | ||
5548 | -extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr; | ||
5549 | -#else | ||
5550 | -extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr; | ||
5551 | -#endif | ||
5552 | - | ||
5553 | -#ifndef _LIBC | ||
5554 | -extern const char *_nl_language_preferences_default (void); | ||
5555 | -# define gl_locale_name_canonicalize _nl_locale_name_canonicalize | ||
5556 | -extern void _nl_locale_name_canonicalize (char *name); | ||
5557 | -# define gl_locale_name_posix _nl_locale_name_posix | ||
5558 | -extern const char *_nl_locale_name_posix (int category, | ||
5559 | - const char *categoryname); | ||
5560 | -# define gl_locale_name_default _nl_locale_name_default | ||
5561 | -extern const char *_nl_locale_name_default (void); | ||
5562 | -# define gl_locale_name _nl_locale_name | ||
5563 | -extern const char *_nl_locale_name (int category, const char *categoryname); | ||
5564 | -#endif | ||
5565 | - | ||
5566 | -struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale, | ||
5567 | - const char *__domainname, | ||
5568 | - struct binding *__domainbinding) | ||
5569 | - internal_function; | ||
5570 | -void _nl_load_domain (struct loaded_l10nfile *__domain, | ||
5571 | - struct binding *__domainbinding) | ||
5572 | - internal_function; | ||
5573 | - | ||
5574 | -#ifdef IN_LIBGLOCALE | ||
5575 | -char *_nl_find_msg (struct loaded_l10nfile *domain_file, | ||
5576 | - struct binding *domainbinding, const char *encoding, | ||
5577 | - const char *msgid, | ||
5578 | - size_t *lengthp) | ||
5579 | - internal_function; | ||
5580 | -#else | ||
5581 | -char *_nl_find_msg (struct loaded_l10nfile *domain_file, | ||
5582 | - struct binding *domainbinding, const char *msgid, | ||
5583 | - int convert, size_t *lengthp) | ||
5584 | - internal_function; | ||
5585 | -#endif | ||
5586 | - | ||
5587 | -/* The internal variables in the standalone libintl.a must have different | ||
5588 | - names than the internal variables in GNU libc, otherwise programs | ||
5589 | - using libintl.a cannot be linked statically. */ | ||
5590 | -#if !defined _LIBC | ||
5591 | -# define _nl_default_dirname libintl_nl_default_dirname | ||
5592 | -# define _nl_domain_bindings libintl_nl_domain_bindings | ||
5593 | -#endif | ||
5594 | - | ||
5595 | -/* Contains the default location of the message catalogs. */ | ||
5596 | -extern const char _nl_default_dirname[]; | ||
5597 | -#ifdef _LIBC | ||
5598 | -libc_hidden_proto (_nl_default_dirname) | ||
5599 | -#endif | ||
5600 | - | ||
5601 | -/* List with bindings of specific domains. */ | ||
5602 | -extern struct binding *_nl_domain_bindings; | ||
5603 | - | ||
5604 | -/* The internal variables in the standalone libintl.a must have different | ||
5605 | - names than the internal variables in GNU libc, otherwise programs | ||
5606 | - using libintl.a cannot be linked statically. */ | ||
5607 | -#if !defined _LIBC | ||
5608 | -# define _nl_default_default_domain libintl_nl_default_default_domain | ||
5609 | -# define _nl_current_default_domain libintl_nl_current_default_domain | ||
5610 | -#endif | ||
5611 | - | ||
5612 | -/* Name of the default text domain. */ | ||
5613 | -extern const char _nl_default_default_domain[] attribute_hidden; | ||
5614 | - | ||
5615 | -/* Default text domain in which entries for gettext(3) are to be found. */ | ||
5616 | -extern const char *_nl_current_default_domain attribute_hidden; | ||
5617 | - | ||
5618 | -/* @@ begin of epilog @@ */ | ||
5619 | - | ||
5620 | -#endif /* gettextP.h */ | ||
5621 | --- a/intl/gmo.h | ||
5622 | +++ /dev/null | ||
5623 | @@ -1,152 +0,0 @@ | ||
5624 | -/* Description of GNU message catalog format: general file layout. | ||
5625 | - Copyright (C) 1995, 1997, 2000-2002, 2004, 2006 Free Software Foundation, Inc. | ||
5626 | - | ||
5627 | - This program is free software; you can redistribute it and/or modify it | ||
5628 | - under the terms of the GNU Library General Public License as published | ||
5629 | - by the Free Software Foundation; either version 2, or (at your option) | ||
5630 | - any later version. | ||
5631 | - | ||
5632 | - This program is distributed in the hope that it will be useful, | ||
5633 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5634 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5635 | - Library General Public License for more details. | ||
5636 | - | ||
5637 | - You should have received a copy of the GNU Library General Public | ||
5638 | - License along with this program; if not, write to the Free Software | ||
5639 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
5640 | - USA. */ | ||
5641 | - | ||
5642 | -#ifndef _GETTEXT_H | ||
5643 | -#define _GETTEXT_H 1 | ||
5644 | - | ||
5645 | -#include <limits.h> | ||
5646 | - | ||
5647 | -/* @@ end of prolog @@ */ | ||
5648 | - | ||
5649 | -/* The magic number of the GNU message catalog format. */ | ||
5650 | -#define _MAGIC 0x950412de | ||
5651 | -#define _MAGIC_SWAPPED 0xde120495 | ||
5652 | - | ||
5653 | -/* Revision number of the currently used .mo (binary) file format. */ | ||
5654 | -#define MO_REVISION_NUMBER 0 | ||
5655 | -#define MO_REVISION_NUMBER_WITH_SYSDEP_I 1 | ||
5656 | - | ||
5657 | -/* The following contortions are an attempt to use the C preprocessor | ||
5658 | - to determine an unsigned integral type that is 32 bits wide. An | ||
5659 | - alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but | ||
5660 | - as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work | ||
5661 | - when cross-compiling. */ | ||
5662 | - | ||
5663 | -#if __STDC__ | ||
5664 | -# define UINT_MAX_32_BITS 4294967295U | ||
5665 | -#else | ||
5666 | -# define UINT_MAX_32_BITS 0xFFFFFFFF | ||
5667 | -#endif | ||
5668 | - | ||
5669 | -/* If UINT_MAX isn't defined, assume it's a 32-bit type. | ||
5670 | - This should be valid for all systems GNU cares about because | ||
5671 | - that doesn't include 16-bit systems, and only modern systems | ||
5672 | - (that certainly have <limits.h>) have 64+-bit integral types. */ | ||
5673 | - | ||
5674 | -#ifndef UINT_MAX | ||
5675 | -# define UINT_MAX UINT_MAX_32_BITS | ||
5676 | -#endif | ||
5677 | - | ||
5678 | -#if UINT_MAX == UINT_MAX_32_BITS | ||
5679 | -typedef unsigned nls_uint32; | ||
5680 | -#else | ||
5681 | -# if USHRT_MAX == UINT_MAX_32_BITS | ||
5682 | -typedef unsigned short nls_uint32; | ||
5683 | -# else | ||
5684 | -# if ULONG_MAX == UINT_MAX_32_BITS | ||
5685 | -typedef unsigned long nls_uint32; | ||
5686 | -# else | ||
5687 | - /* The following line is intended to throw an error. Using #error is | ||
5688 | - not portable enough. */ | ||
5689 | - "Cannot determine unsigned 32-bit data type." | ||
5690 | -# endif | ||
5691 | -# endif | ||
5692 | -#endif | ||
5693 | - | ||
5694 | - | ||
5695 | -/* Header for binary .mo file format. */ | ||
5696 | -struct mo_file_header | ||
5697 | -{ | ||
5698 | - /* The magic number. */ | ||
5699 | - nls_uint32 magic; | ||
5700 | - /* The revision number of the file format. */ | ||
5701 | - nls_uint32 revision; | ||
5702 | - | ||
5703 | - /* The following are only used in .mo files with major revision 0 or 1. */ | ||
5704 | - | ||
5705 | - /* The number of strings pairs. */ | ||
5706 | - nls_uint32 nstrings; | ||
5707 | - /* Offset of table with start offsets of original strings. */ | ||
5708 | - nls_uint32 orig_tab_offset; | ||
5709 | - /* Offset of table with start offsets of translated strings. */ | ||
5710 | - nls_uint32 trans_tab_offset; | ||
5711 | - /* Size of hash table. */ | ||
5712 | - nls_uint32 hash_tab_size; | ||
5713 | - /* Offset of first hash table entry. */ | ||
5714 | - nls_uint32 hash_tab_offset; | ||
5715 | - | ||
5716 | - /* The following are only used in .mo files with minor revision >= 1. */ | ||
5717 | - | ||
5718 | - /* The number of system dependent segments. */ | ||
5719 | - nls_uint32 n_sysdep_segments; | ||
5720 | - /* Offset of table describing system dependent segments. */ | ||
5721 | - nls_uint32 sysdep_segments_offset; | ||
5722 | - /* The number of system dependent strings pairs. */ | ||
5723 | - nls_uint32 n_sysdep_strings; | ||
5724 | - /* Offset of table with start offsets of original sysdep strings. */ | ||
5725 | - nls_uint32 orig_sysdep_tab_offset; | ||
5726 | - /* Offset of table with start offsets of translated sysdep strings. */ | ||
5727 | - nls_uint32 trans_sysdep_tab_offset; | ||
5728 | -}; | ||
5729 | - | ||
5730 | -/* Descriptor for static string contained in the binary .mo file. */ | ||
5731 | -struct string_desc | ||
5732 | -{ | ||
5733 | - /* Length of addressed string, not including the trailing NUL. */ | ||
5734 | - nls_uint32 length; | ||
5735 | - /* Offset of string in file. */ | ||
5736 | - nls_uint32 offset; | ||
5737 | -}; | ||
5738 | - | ||
5739 | -/* The following are only used in .mo files with minor revision >= 1. */ | ||
5740 | - | ||
5741 | -/* Descriptor for system dependent string segment. */ | ||
5742 | -struct sysdep_segment | ||
5743 | -{ | ||
5744 | - /* Length of addressed string, including the trailing NUL. */ | ||
5745 | - nls_uint32 length; | ||
5746 | - /* Offset of string in file. */ | ||
5747 | - nls_uint32 offset; | ||
5748 | -}; | ||
5749 | - | ||
5750 | -/* Pair of a static and a system dependent segment, in struct sysdep_string. */ | ||
5751 | -struct segment_pair | ||
5752 | -{ | ||
5753 | - /* Size of static segment. */ | ||
5754 | - nls_uint32 segsize; | ||
5755 | - /* Reference to system dependent string segment, or ~0 at the end. */ | ||
5756 | - nls_uint32 sysdepref; | ||
5757 | -}; | ||
5758 | - | ||
5759 | -/* Descriptor for system dependent string. */ | ||
5760 | -struct sysdep_string | ||
5761 | -{ | ||
5762 | - /* Offset of static string segments in file. */ | ||
5763 | - nls_uint32 offset; | ||
5764 | - /* Alternating sequence of static and system dependent segments. | ||
5765 | - The last segment is a static segment, including the trailing NUL. */ | ||
5766 | - struct segment_pair segments[1]; | ||
5767 | -}; | ||
5768 | - | ||
5769 | -/* Marker for the end of the segments[] array. This has the value 0xFFFFFFFF, | ||
5770 | - regardless whether 'int' is 16 bit, 32 bit, or 64 bit. */ | ||
5771 | -#define SEGMENTS_END ((nls_uint32) ~0) | ||
5772 | - | ||
5773 | -/* @@ begin of epilog @@ */ | ||
5774 | - | ||
5775 | -#endif /* gettext.h */ | ||
5776 | --- a/intl/hash-string.c | ||
5777 | +++ /dev/null | ||
5778 | @@ -1,51 +0,0 @@ | ||
5779 | -/* Implements a string hashing function. | ||
5780 | - Copyright (C) 1995, 1997, 1998, 2000, 2003 Free Software Foundation, Inc. | ||
5781 | - This file is part of the GNU C Library. | ||
5782 | - | ||
5783 | - The GNU C Library is free software; you can redistribute it and/or | ||
5784 | - modify it under the terms of the GNU Lesser General Public | ||
5785 | - License as published by the Free Software Foundation; either | ||
5786 | - version 2.1 of the License, or (at your option) any later version. | ||
5787 | - | ||
5788 | - The GNU C Library is distributed in the hope that it will be useful, | ||
5789 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5790 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5791 | - Lesser General Public License for more details. | ||
5792 | - | ||
5793 | - You should have received a copy of the GNU Lesser General Public | ||
5794 | - License along with the GNU C Library; if not, write to the Free | ||
5795 | - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
5796 | - Boston, MA 02110-1301, USA. */ | ||
5797 | - | ||
5798 | -#ifdef HAVE_CONFIG_H | ||
5799 | -# include <config.h> | ||
5800 | -#endif | ||
5801 | - | ||
5802 | -/* Specification. */ | ||
5803 | -#include "hash-string.h" | ||
5804 | - | ||
5805 | - | ||
5806 | -/* Defines the so called `hashpjw' function by P.J. Weinberger | ||
5807 | - [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, | ||
5808 | - 1986, 1987 Bell Telephone Laboratories, Inc.] */ | ||
5809 | -unsigned long int | ||
5810 | -__hash_string (const char *str_param) | ||
5811 | -{ | ||
5812 | - unsigned long int hval, g; | ||
5813 | - const char *str = str_param; | ||
5814 | - | ||
5815 | - /* Compute the hash value for the given string. */ | ||
5816 | - hval = 0; | ||
5817 | - while (*str != '\0') | ||
5818 | - { | ||
5819 | - hval <<= 4; | ||
5820 | - hval += (unsigned char) *str++; | ||
5821 | - g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4)); | ||
5822 | - if (g != 0) | ||
5823 | - { | ||
5824 | - hval ^= g >> (HASHWORDBITS - 8); | ||
5825 | - hval ^= g; | ||
5826 | - } | ||
5827 | - } | ||
5828 | - return hval; | ||
5829 | -} | ||
5830 | --- a/intl/hash-string.h | ||
5831 | +++ /dev/null | ||
5832 | @@ -1,36 +0,0 @@ | ||
5833 | -/* Description of GNU message catalog format: string hashing function. | ||
5834 | - Copyright (C) 1995, 1997-1998, 2000-2003, 2005 Free Software Foundation, Inc. | ||
5835 | - | ||
5836 | - This program is free software; you can redistribute it and/or modify it | ||
5837 | - under the terms of the GNU Library General Public License as published | ||
5838 | - by the Free Software Foundation; either version 2, or (at your option) | ||
5839 | - any later version. | ||
5840 | - | ||
5841 | - This program is distributed in the hope that it will be useful, | ||
5842 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5843 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5844 | - Library General Public License for more details. | ||
5845 | - | ||
5846 | - You should have received a copy of the GNU Library General Public | ||
5847 | - License along with this program; if not, write to the Free Software | ||
5848 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
5849 | - USA. */ | ||
5850 | - | ||
5851 | -/* @@ end of prolog @@ */ | ||
5852 | - | ||
5853 | -/* We assume to have `unsigned long int' value with at least 32 bits. */ | ||
5854 | -#define HASHWORDBITS 32 | ||
5855 | - | ||
5856 | - | ||
5857 | -#ifndef _LIBC | ||
5858 | -# ifdef IN_LIBINTL | ||
5859 | -# define __hash_string libintl_hash_string | ||
5860 | -# else | ||
5861 | -# define __hash_string hash_string | ||
5862 | -# endif | ||
5863 | -#endif | ||
5864 | - | ||
5865 | -/* Defines the so called `hashpjw' function by P.J. Weinberger | ||
5866 | - [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, | ||
5867 | - 1986, 1987 Bell Telephone Laboratories, Inc.] */ | ||
5868 | -extern unsigned long int __hash_string (const char *str_param); | ||
5869 | --- a/intl/intl-compat.c | ||
5870 | +++ /dev/null | ||
5871 | @@ -1,133 +0,0 @@ | ||
5872 | -/* intl-compat.c - Stub functions to call gettext functions from GNU gettext | ||
5873 | - Library. | ||
5874 | - Copyright (C) 1995, 2000-2003, 2005 Software Foundation, Inc. | ||
5875 | - | ||
5876 | - This program is free software; you can redistribute it and/or modify it | ||
5877 | - under the terms of the GNU Library General Public License as published | ||
5878 | - by the Free Software Foundation; either version 2, or (at your option) | ||
5879 | - any later version. | ||
5880 | - | ||
5881 | - This program is distributed in the hope that it will be useful, | ||
5882 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5883 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
5884 | - Library General Public License for more details. | ||
5885 | - | ||
5886 | - You should have received a copy of the GNU Library General Public | ||
5887 | - License along with this program; if not, write to the Free Software | ||
5888 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
5889 | - USA. */ | ||
5890 | - | ||
5891 | -#ifdef HAVE_CONFIG_H | ||
5892 | -# include <config.h> | ||
5893 | -#endif | ||
5894 | - | ||
5895 | -#include "gettextP.h" | ||
5896 | - | ||
5897 | -/* @@ end of prolog @@ */ | ||
5898 | - | ||
5899 | -/* This file redirects the gettext functions (without prefix) to those | ||
5900 | - defined in the included GNU libintl library (with "libintl_" prefix). | ||
5901 | - It is compiled into libintl in order to make the AM_GNU_GETTEXT test | ||
5902 | - of gettext <= 0.11.2 work with the libintl library >= 0.11.3 which | ||
5903 | - has the redirections primarily in the <libintl.h> include file. | ||
5904 | - It is also compiled into libgnuintl so that libgnuintl.so can be used | ||
5905 | - as LD_PRELOADable library on glibc systems, to provide the extra | ||
5906 | - features that the functions in the libc don't have (namely, logging). */ | ||
5907 | - | ||
5908 | - | ||
5909 | -#undef gettext | ||
5910 | -#undef dgettext | ||
5911 | -#undef dcgettext | ||
5912 | -#undef ngettext | ||
5913 | -#undef dngettext | ||
5914 | -#undef dcngettext | ||
5915 | -#undef textdomain | ||
5916 | -#undef bindtextdomain | ||
5917 | -#undef bind_textdomain_codeset | ||
5918 | - | ||
5919 | - | ||
5920 | -/* When building a DLL, we must export some functions. Note that because | ||
5921 | - the functions are only defined for binary backward compatibility, we | ||
5922 | - don't need to use __declspec(dllimport) in any case. */ | ||
5923 | -#if HAVE_VISIBILITY && BUILDING_DLL | ||
5924 | -# define DLL_EXPORTED __attribute__((__visibility__("default"))) | ||
5925 | -#elif defined _MSC_VER && BUILDING_DLL | ||
5926 | -# define DLL_EXPORTED __declspec(dllexport) | ||
5927 | -#else | ||
5928 | -# define DLL_EXPORTED | ||
5929 | -#endif | ||
5930 | - | ||
5931 | - | ||
5932 | -DLL_EXPORTED | ||
5933 | -char * | ||
5934 | -gettext (const char *msgid) | ||
5935 | -{ | ||
5936 | - return libintl_gettext (msgid); | ||
5937 | -} | ||
5938 | - | ||
5939 | - | ||
5940 | -DLL_EXPORTED | ||
5941 | -char * | ||
5942 | -dgettext (const char *domainname, const char *msgid) | ||
5943 | -{ | ||
5944 | - return libintl_dgettext (domainname, msgid); | ||
5945 | -} | ||
5946 | - | ||
5947 | - | ||
5948 | -DLL_EXPORTED | ||
5949 | -char * | ||
5950 | -dcgettext (const char *domainname, const char *msgid, int category) | ||
5951 | -{ | ||
5952 | - return libintl_dcgettext (domainname, msgid, category); | ||
5953 | -} | ||
5954 | - | ||
5955 | - | ||
5956 | -DLL_EXPORTED | ||
5957 | -char * | ||
5958 | -ngettext (const char *msgid1, const char *msgid2, unsigned long int n) | ||
5959 | -{ | ||
5960 | - return libintl_ngettext (msgid1, msgid2, n); | ||
5961 | -} | ||
5962 | - | ||
5963 | - | ||
5964 | -DLL_EXPORTED | ||
5965 | -char * | ||
5966 | -dngettext (const char *domainname, | ||
5967 | - const char *msgid1, const char *msgid2, unsigned long int n) | ||
5968 | -{ | ||
5969 | - return libintl_dngettext (domainname, msgid1, msgid2, n); | ||
5970 | -} | ||
5971 | - | ||
5972 | - | ||
5973 | -DLL_EXPORTED | ||
5974 | -char * | ||
5975 | -dcngettext (const char *domainname, | ||
5976 | - const char *msgid1, const char *msgid2, unsigned long int n, | ||
5977 | - int category) | ||
5978 | -{ | ||
5979 | - return libintl_dcngettext (domainname, msgid1, msgid2, n, category); | ||
5980 | -} | ||
5981 | - | ||
5982 | - | ||
5983 | -DLL_EXPORTED | ||
5984 | -char * | ||
5985 | -textdomain (const char *domainname) | ||
5986 | -{ | ||
5987 | - return libintl_textdomain (domainname); | ||
5988 | -} | ||
5989 | - | ||
5990 | - | ||
5991 | -DLL_EXPORTED | ||
5992 | -char * | ||
5993 | -bindtextdomain (const char *domainname, const char *dirname) | ||
5994 | -{ | ||
5995 | - return libintl_bindtextdomain (domainname, dirname); | ||
5996 | -} | ||
5997 | - | ||
5998 | - | ||
5999 | -DLL_EXPORTED | ||
6000 | -char * | ||
6001 | -bind_textdomain_codeset (const char *domainname, const char *codeset) | ||
6002 | -{ | ||
6003 | - return libintl_bind_textdomain_codeset (domainname, codeset); | ||
6004 | -} | ||
6005 | --- a/intl/intl-exports.c | ||
6006 | +++ /dev/null | ||
6007 | @@ -1,36 +0,0 @@ | ||
6008 | -/* List of exported symbols of libintl on Cygwin. | ||
6009 | - Copyright (C) 2006 Free Software Foundation, Inc. | ||
6010 | - Written by Bruno Haible <bruno@clisp.org>, 2006. | ||
6011 | - | ||
6012 | - This program is free software; you can redistribute it and/or modify it | ||
6013 | - under the terms of the GNU Library General Public License as published | ||
6014 | - by the Free Software Foundation; either version 2, or (at your option) | ||
6015 | - any later version. | ||
6016 | - | ||
6017 | - This program is distributed in the hope that it will be useful, | ||
6018 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
6019 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
6020 | - Library General Public License for more details. | ||
6021 | - | ||
6022 | - You should have received a copy of the GNU Library General Public | ||
6023 | - License along with this program; if not, write to the Free Software | ||
6024 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
6025 | - USA. */ | ||
6026 | - | ||
6027 | - /* IMP(x) is a symbol that contains the address of x. */ | ||
6028 | -#define IMP(x) _imp__##x | ||
6029 | - | ||
6030 | - /* Ensure that the variable x is exported from the library, and that a | ||
6031 | - pseudo-variable IMP(x) is available. */ | ||
6032 | -#define VARIABLE(x) \ | ||
6033 | - /* Export x without redefining x. This code was found by compiling a \ | ||
6034 | - snippet: \ | ||
6035 | - extern __declspec(dllexport) int x; int x = 42; */ \ | ||
6036 | - asm (".section .drectve\n"); \ | ||
6037 | - asm (".ascii \" -export:" #x ",data\"\n"); \ | ||
6038 | - asm (".data\n"); \ | ||
6039 | - /* Allocate a pseudo-variable IMP(x). */ \ | ||
6040 | - extern int x; \ | ||
6041 | - void * IMP(x) = &x; | ||
6042 | - | ||
6043 | -VARIABLE(libintl_version) | ||
6044 | --- a/intl/l10nflist.c | ||
6045 | +++ /dev/null | ||
6046 | @@ -1,400 +0,0 @@ | ||
6047 | -/* Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc. | ||
6048 | - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. | ||
6049 | - | ||
6050 | - This program is free software; you can redistribute it and/or modify it | ||
6051 | - under the terms of the GNU Library General Public License as published | ||
6052 | - by the Free Software Foundation; either version 2, or (at your option) | ||
6053 | - any later version. | ||
6054 | - | ||
6055 | - This program is distributed in the hope that it will be useful, | ||
6056 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
6057 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
6058 | - Library General Public License for more details. | ||
6059 | - | ||
6060 | - You should have received a copy of the GNU Library General Public | ||
6061 | - License along with this program; if not, write to the Free Software | ||
6062 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
6063 | - USA. */ | ||
6064 | - | ||
6065 | -/* Tell glibc's <string.h> to provide a prototype for stpcpy(). | ||
6066 | - This must come before <config.h> because <config.h> may include | ||
6067 | - <features.h>, and once <features.h> has been included, it's too late. */ | ||
6068 | -#ifndef _GNU_SOURCE | ||
6069 | -# define _GNU_SOURCE 1 | ||
6070 | -#endif | ||
6071 | - | ||
6072 | -#ifdef HAVE_CONFIG_H | ||
6073 | -# include <config.h> | ||
6074 | -#endif | ||
6075 | - | ||
6076 | -#include <string.h> | ||
6077 | - | ||
6078 | -#if defined _LIBC || defined HAVE_ARGZ_H | ||
6079 | -# include <argz.h> | ||
6080 | -#endif | ||
6081 | -#include <ctype.h> | ||
6082 | -#include <sys/types.h> | ||
6083 | -#include <stdlib.h> | ||
6084 | - | ||
6085 | -#include "loadinfo.h" | ||
6086 | - | ||
6087 | -/* On some strange systems still no definition of NULL is found. Sigh! */ | ||
6088 | -#ifndef NULL | ||
6089 | -# if defined __STDC__ && __STDC__ | ||
6090 | -# define NULL ((void *) 0) | ||
6091 | -# else | ||
6092 | -# define NULL 0 | ||
6093 | -# endif | ||
6094 | -#endif | ||
6095 | - | ||
6096 | -/* @@ end of prolog @@ */ | ||
6097 | - | ||
6098 | -#ifdef _LIBC | ||
6099 | -/* Rename the non ANSI C functions. This is required by the standard | ||
6100 | - because some ANSI C functions will require linking with this object | ||
6101 | - file and the name space must not be polluted. */ | ||
6102 | -# ifndef stpcpy | ||
6103 | -# define stpcpy(dest, src) __stpcpy(dest, src) | ||
6104 | -# endif | ||
6105 | -#else | ||
6106 | -# ifndef HAVE_STPCPY | ||
6107 | -static char *stpcpy (char *dest, const char *src); | ||
6108 | -# endif | ||
6109 | -#endif | ||
6110 | - | ||
6111 | -/* Pathname support. | ||
6112 | - ISSLASH(C) tests whether C is a directory separator character. | ||
6113 | - IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not, | ||
6114 | - it may be concatenated to a directory pathname. | ||
6115 | - */ | ||
6116 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | ||
6117 | - /* Win32, Cygwin, OS/2, DOS */ | ||
6118 | -# define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||
6119 | -# define HAS_DEVICE(P) \ | ||
6120 | - ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ | ||
6121 | - && (P)[1] == ':') | ||
6122 | -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) | ||
6123 | -#else | ||
6124 | - /* Unix */ | ||
6125 | -# define ISSLASH(C) ((C) == '/') | ||
6126 | -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) | ||
6127 | -#endif | ||
6128 | - | ||
6129 | -/* Define function which are usually not available. */ | ||
6130 | - | ||
6131 | -#ifdef _LIBC | ||
6132 | -# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) | ||
6133 | -#elif defined HAVE_ARGZ_COUNT | ||
6134 | -# undef __argz_count | ||
6135 | -# define __argz_count argz_count | ||
6136 | -#else | ||
6137 | -/* Returns the number of strings in ARGZ. */ | ||
6138 | -static size_t | ||
6139 | -argz_count__ (const char *argz, size_t len) | ||
6140 | -{ | ||
6141 | - size_t count = 0; | ||
6142 | - while (len > 0) | ||
6143 | - { | ||
6144 | - size_t part_len = strlen (argz); | ||
6145 | - argz += part_len + 1; | ||
6146 | - len -= part_len + 1; | ||
6147 | - count++; | ||
6148 | - } | ||
6149 | - return count; | ||
6150 | -} | ||
6151 | -# undef __argz_count | ||
6152 | -# define __argz_count(argz, len) argz_count__ (argz, len) | ||
6153 | -#endif /* !_LIBC && !HAVE_ARGZ_COUNT */ | ||
6154 | - | ||
6155 | -#ifdef _LIBC | ||
6156 | -# define __argz_stringify(argz, len, sep) \ | ||
6157 | - INTUSE(__argz_stringify) (argz, len, sep) | ||
6158 | -#elif defined HAVE_ARGZ_STRINGIFY | ||
6159 | -# undef __argz_stringify | ||
6160 | -# define __argz_stringify argz_stringify | ||
6161 | -#else | ||
6162 | -/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's | ||
6163 | - except the last into the character SEP. */ | ||
6164 | -static void | ||
6165 | -argz_stringify__ (char *argz, size_t len, int sep) | ||
6166 | -{ | ||
6167 | - while (len > 0) | ||
6168 | - { | ||
6169 | - size_t part_len = strlen (argz); | ||
6170 | - argz += part_len; | ||
6171 | - len -= part_len + 1; | ||
6172 | - if (len > 0) | ||
6173 | - *argz++ = sep; | ||
6174 | - } | ||
6175 | -} | ||
6176 | -# undef __argz_stringify | ||
6177 | -# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep) | ||
6178 | -#endif /* !_LIBC && !HAVE_ARGZ_STRINGIFY */ | ||
6179 | - | ||
6180 | -#ifdef _LIBC | ||
6181 | -#elif defined HAVE_ARGZ_NEXT | ||
6182 | -# undef __argz_next | ||
6183 | -# define __argz_next argz_next | ||
6184 | -#else | ||
6185 | -static char * | ||
6186 | -argz_next__ (char *argz, size_t argz_len, const char *entry) | ||
6187 | -{ | ||
6188 | - if (entry) | ||
6189 | - { | ||
6190 | - if (entry < argz + argz_len) | ||
6191 | - entry = strchr (entry, '\0') + 1; | ||
6192 | - | ||
6193 | - return entry >= argz + argz_len ? NULL : (char *) entry; | ||
6194 | - } | ||
6195 | - else | ||
6196 | - if (argz_len > 0) | ||
6197 | - return argz; | ||
6198 | - else | ||
6199 | - return 0; | ||
6200 | -} | ||
6201 | -# undef __argz_next | ||
6202 | -# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry) | ||
6203 | -#endif /* !_LIBC && !HAVE_ARGZ_NEXT */ | ||
6204 | - | ||
6205 | - | ||
6206 | -/* Return number of bits set in X. */ | ||
6207 | -static inline int | ||
6208 | -pop (int x) | ||
6209 | -{ | ||
6210 | - /* We assume that no more than 16 bits are used. */ | ||
6211 | - x = ((x & ~0x5555) >> 1) + (x & 0x5555); | ||
6212 | - x = ((x & ~0x3333) >> 2) + (x & 0x3333); | ||
6213 | - x = ((x >> 4) + x) & 0x0f0f; | ||
6214 | - x = ((x >> 8) + x) & 0xff; | ||
6215 | - | ||
6216 | - return x; | ||
6217 | -} | ||
6218 | - | ||
6219 | - | ||
6220 | -struct loaded_l10nfile * | ||
6221 | -_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, | ||
6222 | - const char *dirlist, size_t dirlist_len, | ||
6223 | - int mask, const char *language, const char *territory, | ||
6224 | - const char *codeset, const char *normalized_codeset, | ||
6225 | - const char *modifier, | ||
6226 | - const char *filename, int do_allocate) | ||
6227 | -{ | ||
6228 | - char *abs_filename; | ||
6229 | - struct loaded_l10nfile **lastp; | ||
6230 | - struct loaded_l10nfile *retval; | ||
6231 | - char *cp; | ||
6232 | - size_t dirlist_count; | ||
6233 | - size_t entries; | ||
6234 | - int cnt; | ||
6235 | - | ||
6236 | - /* If LANGUAGE contains an absolute directory specification, we ignore | ||
6237 | - DIRLIST. */ | ||
6238 | - if (IS_ABSOLUTE_PATH (language)) | ||
6239 | - dirlist_len = 0; | ||
6240 | - | ||
6241 | - /* Allocate room for the full file name. */ | ||
6242 | - abs_filename = (char *) malloc (dirlist_len | ||
6243 | - + strlen (language) | ||
6244 | - + ((mask & XPG_TERRITORY) != 0 | ||
6245 | - ? strlen (territory) + 1 : 0) | ||
6246 | - + ((mask & XPG_CODESET) != 0 | ||
6247 | - ? strlen (codeset) + 1 : 0) | ||
6248 | - + ((mask & XPG_NORM_CODESET) != 0 | ||
6249 | - ? strlen (normalized_codeset) + 1 : 0) | ||
6250 | - + ((mask & XPG_MODIFIER) != 0 | ||
6251 | - ? strlen (modifier) + 1 : 0) | ||
6252 | - + 1 + strlen (filename) + 1); | ||
6253 | - | ||
6254 | - if (abs_filename == NULL) | ||
6255 | - return NULL; | ||
6256 | - | ||
6257 | - /* Construct file name. */ | ||
6258 | - cp = abs_filename; | ||
6259 | - if (dirlist_len > 0) | ||
6260 | - { | ||
6261 | - memcpy (cp, dirlist, dirlist_len); | ||
6262 | - __argz_stringify (cp, dirlist_len, PATH_SEPARATOR); | ||
6263 | - cp += dirlist_len; | ||
6264 | - cp[-1] = '/'; | ||
6265 | - } | ||
6266 | - | ||
6267 | - cp = stpcpy (cp, language); | ||
6268 | - | ||
6269 | - if ((mask & XPG_TERRITORY) != 0) | ||
6270 | - { | ||
6271 | - *cp++ = '_'; | ||
6272 | - cp = stpcpy (cp, territory); | ||
6273 | - } | ||
6274 | - if ((mask & XPG_CODESET) != 0) | ||
6275 | - { | ||
6276 | - *cp++ = '.'; | ||
6277 | - cp = stpcpy (cp, codeset); | ||
6278 | - } | ||
6279 | - if ((mask & XPG_NORM_CODESET) != 0) | ||
6280 | - { | ||
6281 | - *cp++ = '.'; | ||
6282 | - cp = stpcpy (cp, normalized_codeset); | ||
6283 | - } | ||
6284 | - if ((mask & XPG_MODIFIER) != 0) | ||
6285 | - { | ||
6286 | - *cp++ = '@'; | ||
6287 | - cp = stpcpy (cp, modifier); | ||
6288 | - } | ||
6289 | - | ||
6290 | - *cp++ = '/'; | ||
6291 | - stpcpy (cp, filename); | ||
6292 | - | ||
6293 | - /* Look in list of already loaded domains whether it is already | ||
6294 | - available. */ | ||
6295 | - lastp = l10nfile_list; | ||
6296 | - for (retval = *l10nfile_list; retval != NULL; retval = retval->next) | ||
6297 | - if (retval->filename != NULL) | ||
6298 | - { | ||
6299 | - int compare = strcmp (retval->filename, abs_filename); | ||
6300 | - if (compare == 0) | ||
6301 | - /* We found it! */ | ||
6302 | - break; | ||
6303 | - if (compare < 0) | ||
6304 | - { | ||
6305 | - /* It's not in the list. */ | ||
6306 | - retval = NULL; | ||
6307 | - break; | ||
6308 | - } | ||
6309 | - | ||
6310 | - lastp = &retval->next; | ||
6311 | - } | ||
6312 | - | ||
6313 | - if (retval != NULL || do_allocate == 0) | ||
6314 | - { | ||
6315 | - free (abs_filename); | ||
6316 | - return retval; | ||
6317 | - } | ||
6318 | - | ||
6319 | - dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1); | ||
6320 | - | ||
6321 | - /* Allocate a new loaded_l10nfile. */ | ||
6322 | - retval = | ||
6323 | - (struct loaded_l10nfile *) | ||
6324 | - malloc (sizeof (*retval) | ||
6325 | - + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0)) | ||
6326 | - * sizeof (struct loaded_l10nfile *))); | ||
6327 | - if (retval == NULL) | ||
6328 | - { | ||
6329 | - free (abs_filename); | ||
6330 | - return NULL; | ||
6331 | - } | ||
6332 | - | ||
6333 | - retval->filename = abs_filename; | ||
6334 | - | ||
6335 | - /* We set retval->data to NULL here; it is filled in later. | ||
6336 | - Setting retval->decided to 1 here means that retval does not | ||
6337 | - correspond to a real file (dirlist_count > 1) or is not worth | ||
6338 | - looking up (if an unnormalized codeset was specified). */ | ||
6339 | - retval->decided = (dirlist_count > 1 | ||
6340 | - || ((mask & XPG_CODESET) != 0 | ||
6341 | - && (mask & XPG_NORM_CODESET) != 0)); | ||
6342 | - retval->data = NULL; | ||
6343 | - | ||
6344 | - retval->next = *lastp; | ||
6345 | - *lastp = retval; | ||
6346 | - | ||
6347 | - entries = 0; | ||
6348 | - /* Recurse to fill the inheritance list of RETVAL. | ||
6349 | - If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL | ||
6350 | - entry does not correspond to a real file; retval->filename contains | ||
6351 | - colons. In this case we loop across all elements of DIRLIST and | ||
6352 | - across all bit patterns dominated by MASK. | ||
6353 | - If the DIRLIST is a single directory or entirely redundant (i.e. | ||
6354 | - DIRLIST_COUNT == 1), we loop across all bit patterns dominated by | ||
6355 | - MASK, excluding MASK itself. | ||
6356 | - In either case, we loop down from MASK to 0. This has the effect | ||
6357 | - that the extra bits in the locale name are dropped in this order: | ||
6358 | - first the modifier, then the territory, then the codeset, then the | ||
6359 | - normalized_codeset. */ | ||
6360 | - for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt) | ||
6361 | - if ((cnt & ~mask) == 0 | ||
6362 | - && !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0)) | ||
6363 | - { | ||
6364 | - if (dirlist_count > 1) | ||
6365 | - { | ||
6366 | - /* Iterate over all elements of the DIRLIST. */ | ||
6367 | - char *dir = NULL; | ||
6368 | - | ||
6369 | - while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir)) | ||
6370 | - != NULL) | ||
6371 | - retval->successor[entries++] | ||
6372 | - = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, | ||
6373 | - cnt, language, territory, codeset, | ||
6374 | - normalized_codeset, modifier, filename, | ||
6375 | - 1); | ||
6376 | - } | ||
6377 | - else | ||
6378 | - retval->successor[entries++] | ||
6379 | - = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, | ||
6380 | - cnt, language, territory, codeset, | ||
6381 | - normalized_codeset, modifier, filename, 1); | ||
6382 | - } | ||
6383 | - retval->successor[entries] = NULL; | ||
6384 | - | ||
6385 | - return retval; | ||
6386 | -} | ||
6387 | - | ||
6388 | -/* Normalize codeset name. There is no standard for the codeset | ||
6389 | - names. Normalization allows the user to use any of the common | ||
6390 | - names. The return value is dynamically allocated and has to be | ||
6391 | - freed by the caller. */ | ||
6392 | -const char * | ||
6393 | -_nl_normalize_codeset (const char *codeset, size_t name_len) | ||
6394 | -{ | ||
6395 | - int len = 0; | ||
6396 | - int only_digit = 1; | ||
6397 | - char *retval; | ||
6398 | - char *wp; | ||
6399 | - size_t cnt; | ||
6400 | - | ||
6401 | - for (cnt = 0; cnt < name_len; ++cnt) | ||
6402 | - if (isalnum ((unsigned char) codeset[cnt])) | ||
6403 | - { | ||
6404 | - ++len; | ||
6405 | - | ||
6406 | - if (isalpha ((unsigned char) codeset[cnt])) | ||
6407 | - only_digit = 0; | ||
6408 | - } | ||
6409 | - | ||
6410 | - retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1); | ||
6411 | - | ||
6412 | - if (retval != NULL) | ||
6413 | - { | ||
6414 | - if (only_digit) | ||
6415 | - wp = stpcpy (retval, "iso"); | ||
6416 | - else | ||
6417 | - wp = retval; | ||
6418 | - | ||
6419 | - for (cnt = 0; cnt < name_len; ++cnt) | ||
6420 | - if (isalpha ((unsigned char) codeset[cnt])) | ||
6421 | - *wp++ = tolower ((unsigned char) codeset[cnt]); | ||
6422 | - else if (isdigit ((unsigned char) codeset[cnt])) | ||
6423 | - *wp++ = codeset[cnt]; | ||
6424 | - | ||
6425 | - *wp = '\0'; | ||
6426 | - } | ||
6427 | - | ||
6428 | - return (const char *) retval; | ||
6429 | -} | ||
6430 | - | ||
6431 | - | ||
6432 | -/* @@ begin of epilog @@ */ | ||
6433 | - | ||
6434 | -/* We don't want libintl.a to depend on any other library. So we | ||
6435 | - avoid the non-standard function stpcpy. In GNU C Library this | ||
6436 | - function is available, though. Also allow the symbol HAVE_STPCPY | ||
6437 | - to be defined. */ | ||
6438 | -#if !_LIBC && !HAVE_STPCPY | ||
6439 | -static char * | ||
6440 | -stpcpy (char *dest, const char *src) | ||
6441 | -{ | ||
6442 | - while ((*dest++ = *src++) != '\0') | ||
6443 | - /* Do nothing. */ ; | ||
6444 | - return dest - 1; | ||
6445 | -} | ||
6446 | -#endif | ||
6447 | --- a/intl/langprefs.c | ||
6448 | +++ /dev/null | ||
6449 | @@ -1,130 +0,0 @@ | ||
6450 | -/* Determine the user's language preferences. | ||
6451 | - Copyright (C) 2004-2006 Free Software Foundation, Inc. | ||
6452 | - | ||
6453 | - This program is free software; you can redistribute it and/or modify it | ||
6454 | - under the terms of the GNU Library General Public License as published | ||
6455 | - by the Free Software Foundation; either version 2, or (at your option) | ||
6456 | - any later version. | ||
6457 | - | ||
6458 | - This program is distributed in the hope that it will be useful, | ||
6459 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
6460 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
6461 | - Library General Public License for more details. | ||
6462 | - | ||
6463 | - You should have received a copy of the GNU Library General Public | ||
6464 | - License along with this program; if not, write to the Free Software | ||
6465 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
6466 | - USA. */ | ||
6467 | - | ||
6468 | -/* Written by Bruno Haible <bruno@clisp.org>. */ | ||
6469 | - | ||
6470 | -#ifdef HAVE_CONFIG_H | ||
6471 | -# include <config.h> | ||
6472 | -#endif | ||
6473 | - | ||
6474 | -#include <stdlib.h> | ||
6475 | - | ||
6476 | -#if HAVE_CFPREFERENCESCOPYAPPVALUE | ||
6477 | -# include <string.h> | ||
6478 | -# include <CoreFoundation/CFPreferences.h> | ||
6479 | -# include <CoreFoundation/CFPropertyList.h> | ||
6480 | -# include <CoreFoundation/CFArray.h> | ||
6481 | -# include <CoreFoundation/CFString.h> | ||
6482 | -extern void _nl_locale_name_canonicalize (char *name); | ||
6483 | -#endif | ||
6484 | - | ||
6485 | -/* Determine the user's language preferences, as a colon separated list of | ||
6486 | - locale names in XPG syntax | ||
6487 | - language[_territory][.codeset][@modifier] | ||
6488 | - The result must not be freed; it is statically allocated. | ||
6489 | - The LANGUAGE environment variable does not need to be considered; it is | ||
6490 | - already taken into account by the caller. */ | ||
6491 | - | ||
6492 | -const char * | ||
6493 | -_nl_language_preferences_default (void) | ||
6494 | -{ | ||
6495 | -#if HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */ | ||
6496 | - { | ||
6497 | - /* Cache the preferences list, since CoreFoundation calls are expensive. */ | ||
6498 | - static const char *cached_languages; | ||
6499 | - static int cache_initialized; | ||
6500 | - | ||
6501 | - if (!cache_initialized) | ||
6502 | - { | ||
6503 | - CFTypeRef preferences = | ||
6504 | - CFPreferencesCopyAppValue (CFSTR ("AppleLanguages"), | ||
6505 | - kCFPreferencesCurrentApplication); | ||
6506 | - if (preferences != NULL | ||
6507 | - && CFGetTypeID (preferences) == CFArrayGetTypeID ()) | ||
6508 | - { | ||
6509 | - CFArrayRef prefArray = (CFArrayRef)preferences; | ||
6510 | - int n = CFArrayGetCount (prefArray); | ||
6511 | - char buf[256]; | ||
6512 | - size_t size = 0; | ||
6513 | - int i; | ||
6514 | - | ||
6515 | - for (i = 0; i < n; i++) | ||
6516 | - { | ||
6517 | - CFTypeRef element = CFArrayGetValueAtIndex (prefArray, i); | ||
6518 | - if (element != NULL | ||
6519 | - && CFGetTypeID (element) == CFStringGetTypeID () | ||
6520 | - && CFStringGetCString ((CFStringRef)element, | ||
6521 | - buf, sizeof (buf), | ||
6522 | - kCFStringEncodingASCII)) | ||
6523 | - { | ||
6524 | - _nl_locale_name_canonicalize (buf); | ||
6525 | - size += strlen (buf) + 1; | ||
6526 | - /* Most GNU programs use msgids in English and don't ship | ||
6527 | - an en.mo message catalog. Therefore when we see "en" | ||
6528 | - in the preferences list, arrange for gettext() to | ||
6529 | - return the msgid, and ignore all further elements of | ||
6530 | - the preferences list. */ | ||
6531 | - if (strcmp (buf, "en") == 0) | ||
6532 | - break; | ||
6533 | - } | ||
6534 | - else | ||
6535 | - break; | ||
6536 | - } | ||
6537 | - if (size > 0) | ||
6538 | - { | ||
6539 | - char *languages = (char *) malloc (size); | ||
6540 | - | ||
6541 | - if (languages != NULL) | ||
6542 | - { | ||
6543 | - char *p = languages; | ||
6544 | - | ||
6545 | - for (i = 0; i < n; i++) | ||
6546 | - { | ||
6547 | - CFTypeRef element = | ||
6548 | - CFArrayGetValueAtIndex (prefArray, i); | ||
6549 | - if (element != NULL | ||
6550 | - && CFGetTypeID (element) == CFStringGetTypeID () | ||
6551 | - && CFStringGetCString ((CFStringRef)element, | ||
6552 | - buf, sizeof (buf), | ||
6553 | - kCFStringEncodingASCII)) | ||
6554 | - { | ||
6555 | - _nl_locale_name_canonicalize (buf); | ||
6556 | - strcpy (p, buf); | ||
6557 | - p += strlen (buf); | ||
6558 | - *p++ = ':'; | ||
6559 | - if (strcmp (buf, "en") == 0) | ||
6560 | - break; | ||
6561 | - } | ||
6562 | - else | ||
6563 | - break; | ||
6564 | - } | ||
6565 | - *--p = '\0'; | ||
6566 | - | ||
6567 | - cached_languages = languages; | ||
6568 | - } | ||
6569 | - } | ||
6570 | - } | ||
6571 | - cache_initialized = 1; | ||
6572 | - } | ||
6573 | - if (cached_languages != NULL) | ||
6574 | - return cached_languages; | ||
6575 | - } | ||
6576 | -#endif | ||
6577 | - | ||
6578 | - return NULL; | ||
6579 | -} | ||
6580 | --- a/intl/libgnuintl.h.in | ||
6581 | +++ /dev/null | ||
6582 | @@ -1,419 +0,0 @@ | ||
6583 | -/* Message catalogs for internationalization. | ||
6584 | - Copyright (C) 1995-1997, 2000-2007 Free Software Foundation, Inc. | ||
6585 | - | ||
6586 | - This program is free software; you can redistribute it and/or modify it | ||
6587 | - under the terms of the GNU Library General Public License as published | ||
6588 | - by the Free Software Foundation; either version 2, or (at your option) | ||
6589 | - any later version. | ||
6590 | - | ||
6591 | - This program is distributed in the hope that it will be useful, | ||
6592 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
6593 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
6594 | - Library General Public License for more details. | ||
6595 | - | ||
6596 | - You should have received a copy of the GNU Library General Public | ||
6597 | - License along with this program; if not, write to the Free Software | ||
6598 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
6599 | - USA. */ | ||
6600 | - | ||
6601 | -#ifndef _LIBINTL_H | ||
6602 | -#define _LIBINTL_H 1 | ||
6603 | - | ||
6604 | -#include <locale.h> | ||
6605 | - | ||
6606 | -/* The LC_MESSAGES locale category is the category used by the functions | ||
6607 | - gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. | ||
6608 | - On systems that don't define it, use an arbitrary value instead. | ||
6609 | - On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) | ||
6610 | - then includes <libintl.h> (i.e. this file!) and then only defines | ||
6611 | - LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES | ||
6612 | - in this case. */ | ||
6613 | -#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) | ||
6614 | -# define LC_MESSAGES 1729 | ||
6615 | -#endif | ||
6616 | - | ||
6617 | -/* We define an additional symbol to signal that we use the GNU | ||
6618 | - implementation of gettext. */ | ||
6619 | -#define __USE_GNU_GETTEXT 1 | ||
6620 | - | ||
6621 | -/* Provide information about the supported file formats. Returns the | ||
6622 | - maximum minor revision number supported for a given major revision. */ | ||
6623 | -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ | ||
6624 | - ((major) == 0 || (major) == 1 ? 1 : -1) | ||
6625 | - | ||
6626 | -/* Resolve a platform specific conflict on DJGPP. GNU gettext takes | ||
6627 | - precedence over _conio_gettext. */ | ||
6628 | -#ifdef __DJGPP__ | ||
6629 | -# undef gettext | ||
6630 | -#endif | ||
6631 | - | ||
6632 | -#ifdef __cplusplus | ||
6633 | -extern "C" { | ||
6634 | -#endif | ||
6635 | - | ||
6636 | - | ||
6637 | -/* Version number: (major<<16) + (minor<<8) + subminor */ | ||
6638 | -#define LIBINTL_VERSION 0x001100 | ||
6639 | -extern int libintl_version; | ||
6640 | - | ||
6641 | - | ||
6642 | -/* We redirect the functions to those prefixed with "libintl_". This is | ||
6643 | - necessary, because some systems define gettext/textdomain/... in the C | ||
6644 | - library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). | ||
6645 | - If we used the unprefixed names, there would be cases where the | ||
6646 | - definition in the C library would override the one in the libintl.so | ||
6647 | - shared library. Recall that on ELF systems, the symbols are looked | ||
6648 | - up in the following order: | ||
6649 | - 1. in the executable, | ||
6650 | - 2. in the shared libraries specified on the link command line, in order, | ||
6651 | - 3. in the dependencies of the shared libraries specified on the link | ||
6652 | - command line, | ||
6653 | - 4. in the dlopen()ed shared libraries, in the order in which they were | ||
6654 | - dlopen()ed. | ||
6655 | - The definition in the C library would override the one in libintl.so if | ||
6656 | - either | ||
6657 | - * -lc is given on the link command line and -lintl isn't, or | ||
6658 | - * -lc is given on the link command line before -lintl, or | ||
6659 | - * libintl.so is a dependency of a dlopen()ed shared library but not | ||
6660 | - linked to the executable at link time. | ||
6661 | - Since Solaris gettext() behaves differently than GNU gettext(), this | ||
6662 | - would be unacceptable. | ||
6663 | - | ||
6664 | - The redirection happens by default through macros in C, so that &gettext | ||
6665 | - is independent of the compilation unit, but through inline functions in | ||
6666 | - C++, in order not to interfere with the name mangling of class fields or | ||
6667 | - class methods called 'gettext'. */ | ||
6668 | - | ||
6669 | -/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. | ||
6670 | - If he doesn't, we choose the method. A third possible method is | ||
6671 | - _INTL_REDIRECT_ASM, supported only by GCC. */ | ||
6672 | -#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) | ||
6673 | -# if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) | ||
6674 | -# define _INTL_REDIRECT_ASM | ||
6675 | -# else | ||
6676 | -# ifdef __cplusplus | ||
6677 | -# define _INTL_REDIRECT_INLINE | ||
6678 | -# else | ||
6679 | -# define _INTL_REDIRECT_MACROS | ||
6680 | -# endif | ||
6681 | -# endif | ||
6682 | -#endif | ||
6683 | -/* Auxiliary macros. */ | ||
6684 | -#ifdef _INTL_REDIRECT_ASM | ||
6685 | -# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) | ||
6686 | -# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring | ||
6687 | -# define _INTL_STRINGIFY(prefix) #prefix | ||
6688 | -#else | ||
6689 | -# define _INTL_ASM(cname) | ||
6690 | -#endif | ||
6691 | - | ||
6692 | -/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return | ||
6693 | - its n-th argument literally. This enables GCC to warn for example about | ||
6694 | - printf (gettext ("foo %y")). */ | ||
6695 | -#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus) | ||
6696 | -# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n))) | ||
6697 | -#else | ||
6698 | -# define _INTL_MAY_RETURN_STRING_ARG(n) | ||
6699 | -#endif | ||
6700 | - | ||
6701 | -/* Look up MSGID in the current default message catalog for the current | ||
6702 | - LC_MESSAGES locale. If not found, returns MSGID itself (the default | ||
6703 | - text). */ | ||
6704 | -#ifdef _INTL_REDIRECT_INLINE | ||
6705 | -extern char *libintl_gettext (const char *__msgid) | ||
6706 | - _INTL_MAY_RETURN_STRING_ARG (1); | ||
6707 | -static inline char *gettext (const char *__msgid) | ||
6708 | -{ | ||
6709 | - return libintl_gettext (__msgid); | ||
6710 | -} | ||
6711 | -#else | ||
6712 | -#ifdef _INTL_REDIRECT_MACROS | ||
6713 | -# define gettext libintl_gettext | ||
6714 | -#endif | ||
6715 | -extern char *gettext (const char *__msgid) | ||
6716 | - _INTL_ASM (libintl_gettext) | ||
6717 | - _INTL_MAY_RETURN_STRING_ARG (1); | ||
6718 | -#endif | ||
6719 | - | ||
6720 | -/* Look up MSGID in the DOMAINNAME message catalog for the current | ||
6721 | - LC_MESSAGES locale. */ | ||
6722 | -#ifdef _INTL_REDIRECT_INLINE | ||
6723 | -extern char *libintl_dgettext (const char *__domainname, const char *__msgid) | ||
6724 | - _INTL_MAY_RETURN_STRING_ARG (2); | ||
6725 | -static inline char *dgettext (const char *__domainname, const char *__msgid) | ||
6726 | -{ | ||
6727 | - return libintl_dgettext (__domainname, __msgid); | ||
6728 | -} | ||
6729 | -#else | ||
6730 | -#ifdef _INTL_REDIRECT_MACROS | ||
6731 | -# define dgettext libintl_dgettext | ||
6732 | -#endif | ||
6733 | -extern char *dgettext (const char *__domainname, const char *__msgid) | ||
6734 | - _INTL_ASM (libintl_dgettext) | ||
6735 | - _INTL_MAY_RETURN_STRING_ARG (2); | ||
6736 | -#endif | ||
6737 | - | ||
6738 | -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY | ||
6739 | - locale. */ | ||
6740 | -#ifdef _INTL_REDIRECT_INLINE | ||
6741 | -extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, | ||
6742 | - int __category) | ||
6743 | - _INTL_MAY_RETURN_STRING_ARG (2); | ||
6744 | -static inline char *dcgettext (const char *__domainname, const char *__msgid, | ||
6745 | - int __category) | ||
6746 | -{ | ||
6747 | - return libintl_dcgettext (__domainname, __msgid, __category); | ||
6748 | -} | ||
6749 | -#else | ||
6750 | -#ifdef _INTL_REDIRECT_MACROS | ||
6751 | -# define dcgettext libintl_dcgettext | ||
6752 | -#endif | ||
6753 | -extern char *dcgettext (const char *__domainname, const char *__msgid, | ||
6754 | - int __category) | ||
6755 | - _INTL_ASM (libintl_dcgettext) | ||
6756 | - _INTL_MAY_RETURN_STRING_ARG (2); | ||
6757 | -#endif | ||
6758 | - | ||
6759 | - | ||
6760 | -/* Similar to `gettext' but select the plural form corresponding to the | ||
6761 | - number N. */ | ||
6762 | -#ifdef _INTL_REDIRECT_INLINE | ||
6763 | -extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, | ||
6764 | - unsigned long int __n) | ||
6765 | - _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); | ||
6766 | -static inline char *ngettext (const char *__msgid1, const char *__msgid2, | ||
6767 | - unsigned long int __n) | ||
6768 | -{ | ||
6769 | - return libintl_ngettext (__msgid1, __msgid2, __n); | ||
6770 | -} | ||
6771 | -#else | ||
6772 | -#ifdef _INTL_REDIRECT_MACROS | ||
6773 | -# define ngettext libintl_ngettext | ||
6774 | -#endif | ||
6775 | -extern char *ngettext (const char *__msgid1, const char *__msgid2, | ||
6776 | - unsigned long int __n) | ||
6777 | - _INTL_ASM (libintl_ngettext) | ||
6778 | - _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); | ||
6779 | -#endif | ||
6780 | - | ||
6781 | -/* Similar to `dgettext' but select the plural form corresponding to the | ||
6782 | - number N. */ | ||
6783 | -#ifdef _INTL_REDIRECT_INLINE | ||
6784 | -extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, | ||
6785 | - const char *__msgid2, unsigned long int __n) | ||
6786 | - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); | ||
6787 | -static inline char *dngettext (const char *__domainname, const char *__msgid1, | ||
6788 | - const char *__msgid2, unsigned long int __n) | ||
6789 | -{ | ||
6790 | - return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); | ||
6791 | -} | ||
6792 | -#else | ||
6793 | -#ifdef _INTL_REDIRECT_MACROS | ||
6794 | -# define dngettext libintl_dngettext | ||
6795 | -#endif | ||
6796 | -extern char *dngettext (const char *__domainname, | ||
6797 | - const char *__msgid1, const char *__msgid2, | ||
6798 | - unsigned long int __n) | ||
6799 | - _INTL_ASM (libintl_dngettext) | ||
6800 | - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); | ||
6801 | -#endif | ||
6802 | - | ||
6803 | -/* Similar to `dcgettext' but select the plural form corresponding to the | ||
6804 | - number N. */ | ||
6805 | -#ifdef _INTL_REDIRECT_INLINE | ||
6806 | -extern char *libintl_dcngettext (const char *__domainname, | ||
6807 | - const char *__msgid1, const char *__msgid2, | ||
6808 | - unsigned long int __n, int __category) | ||
6809 | - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); | ||
6810 | -static inline char *dcngettext (const char *__domainname, | ||
6811 | - const char *__msgid1, const char *__msgid2, | ||
6812 | - unsigned long int __n, int __category) | ||
6813 | -{ | ||
6814 | - return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); | ||
6815 | -} | ||
6816 | -#else | ||
6817 | -#ifdef _INTL_REDIRECT_MACROS | ||
6818 | -# define dcngettext libintl_dcngettext | ||
6819 | -#endif | ||
6820 | -extern char *dcngettext (const char *__domainname, | ||
6821 | - const char *__msgid1, const char *__msgid2, | ||
6822 | - unsigned long int __n, int __category) | ||
6823 | - _INTL_ASM (libintl_dcngettext) | ||
6824 | - _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); | ||
6825 | -#endif | ||
6826 | - | ||
6827 | - | ||
6828 | -#ifndef IN_LIBGLOCALE | ||
6829 | - | ||
6830 | -/* Set the current default message catalog to DOMAINNAME. | ||
6831 | - If DOMAINNAME is null, return the current default. | ||
6832 | - If DOMAINNAME is "", reset to the default of "messages". */ | ||
6833 | -#ifdef _INTL_REDIRECT_INLINE | ||
6834 | -extern char *libintl_textdomain (const char *__domainname); | ||
6835 | -static inline char *textdomain (const char *__domainname) | ||
6836 | -{ | ||
6837 | - return libintl_textdomain (__domainname); | ||
6838 | -} | ||
6839 | -#else | ||
6840 | -#ifdef _INTL_REDIRECT_MACROS | ||
6841 | -# define textdomain libintl_textdomain | ||
6842 | -#endif | ||
6843 | -extern char *textdomain (const char *__domainname) | ||
6844 | - _INTL_ASM (libintl_textdomain); | ||
6845 | -#endif | ||
6846 | - | ||
6847 | -/* Specify that the DOMAINNAME message catalog will be found | ||
6848 | - in DIRNAME rather than in the system locale data base. */ | ||
6849 | -#ifdef _INTL_REDIRECT_INLINE | ||
6850 | -extern char *libintl_bindtextdomain (const char *__domainname, | ||
6851 | - const char *__dirname); | ||
6852 | -static inline char *bindtextdomain (const char *__domainname, | ||
6853 | - const char *__dirname) | ||
6854 | -{ | ||
6855 | - return libintl_bindtextdomain (__domainname, __dirname); | ||
6856 | -} | ||
6857 | -#else | ||
6858 | -#ifdef _INTL_REDIRECT_MACROS | ||
6859 | -# define bindtextdomain libintl_bindtextdomain | ||
6860 | -#endif | ||
6861 | -extern char *bindtextdomain (const char *__domainname, const char *__dirname) | ||
6862 | - _INTL_ASM (libintl_bindtextdomain); | ||
6863 | -#endif | ||
6864 | - | ||
6865 | -/* Specify the character encoding in which the messages from the | ||
6866 | - DOMAINNAME message catalog will be returned. */ | ||
6867 | -#ifdef _INTL_REDIRECT_INLINE | ||
6868 | -extern char *libintl_bind_textdomain_codeset (const char *__domainname, | ||
6869 | - const char *__codeset); | ||
6870 | -static inline char *bind_textdomain_codeset (const char *__domainname, | ||
6871 | - const char *__codeset) | ||
6872 | -{ | ||
6873 | - return libintl_bind_textdomain_codeset (__domainname, __codeset); | ||
6874 | -} | ||
6875 | -#else | ||
6876 | -#ifdef _INTL_REDIRECT_MACROS | ||
6877 | -# define bind_textdomain_codeset libintl_bind_textdomain_codeset | ||
6878 | -#endif | ||
6879 | -extern char *bind_textdomain_codeset (const char *__domainname, | ||
6880 | - const char *__codeset) | ||
6881 | - _INTL_ASM (libintl_bind_textdomain_codeset); | ||
6882 | -#endif | ||
6883 | - | ||
6884 | -#endif /* IN_LIBGLOCALE */ | ||
6885 | - | ||
6886 | - | ||
6887 | -/* Support for format strings with positions in *printf(), following the | ||
6888 | - POSIX/XSI specification. | ||
6889 | - Note: These replacements for the *printf() functions are visible only | ||
6890 | - in source files that #include <libintl.h> or #include "gettext.h". | ||
6891 | - Packages that use *printf() in source files that don't refer to _() | ||
6892 | - or gettext() but for which the format string could be the return value | ||
6893 | - of _() or gettext() need to add this #include. Oh well. */ | ||
6894 | - | ||
6895 | -#if !@HAVE_POSIX_PRINTF@ | ||
6896 | - | ||
6897 | -#include <stdio.h> | ||
6898 | -#include <stddef.h> | ||
6899 | - | ||
6900 | -/* Get va_list. */ | ||
6901 | -#if __STDC__ || defined __cplusplus || defined _MSC_VER | ||
6902 | -# include <stdarg.h> | ||
6903 | -#else | ||
6904 | -# include <varargs.h> | ||
6905 | -#endif | ||
6906 | - | ||
6907 | -#undef fprintf | ||
6908 | -#define fprintf libintl_fprintf | ||
6909 | -extern int fprintf (FILE *, const char *, ...); | ||
6910 | -#undef vfprintf | ||
6911 | -#define vfprintf libintl_vfprintf | ||
6912 | -extern int vfprintf (FILE *, const char *, va_list); | ||
6913 | - | ||
6914 | -#undef printf | ||
6915 | -#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ | ||
6916 | -/* Don't break __attribute__((format(printf,M,N))). | ||
6917 | - This redefinition is only possible because the libc in NetBSD, Cygwin, | ||
6918 | - mingw does not have a function __printf__. */ | ||
6919 | -# define libintl_printf __printf__ | ||
6920 | -#endif | ||
6921 | -#define printf libintl_printf | ||
6922 | -extern int printf (const char *, ...); | ||
6923 | -#undef vprintf | ||
6924 | -#define vprintf libintl_vprintf | ||
6925 | -extern int vprintf (const char *, va_list); | ||
6926 | - | ||
6927 | -#undef sprintf | ||
6928 | -#define sprintf libintl_sprintf | ||
6929 | -extern int sprintf (char *, const char *, ...); | ||
6930 | -#undef vsprintf | ||
6931 | -#define vsprintf libintl_vsprintf | ||
6932 | -extern int vsprintf (char *, const char *, va_list); | ||
6933 | - | ||
6934 | -#if @HAVE_SNPRINTF@ | ||
6935 | - | ||
6936 | -#undef snprintf | ||
6937 | -#define snprintf libintl_snprintf | ||
6938 | -extern int snprintf (char *, size_t, const char *, ...); | ||
6939 | -#undef vsnprintf | ||
6940 | -#define vsnprintf libintl_vsnprintf | ||
6941 | -extern int vsnprintf (char *, size_t, const char *, va_list); | ||
6942 | - | ||
6943 | -#endif | ||
6944 | - | ||
6945 | -#if @HAVE_ASPRINTF@ | ||
6946 | - | ||
6947 | -#undef asprintf | ||
6948 | -#define asprintf libintl_asprintf | ||
6949 | -extern int asprintf (char **, const char *, ...); | ||
6950 | -#undef vasprintf | ||
6951 | -#define vasprintf libintl_vasprintf | ||
6952 | -extern int vasprintf (char **, const char *, va_list); | ||
6953 | - | ||
6954 | -#endif | ||
6955 | - | ||
6956 | -#if @HAVE_WPRINTF@ | ||
6957 | - | ||
6958 | -#undef fwprintf | ||
6959 | -#define fwprintf libintl_fwprintf | ||
6960 | -extern int fwprintf (FILE *, const wchar_t *, ...); | ||
6961 | -#undef vfwprintf | ||
6962 | -#define vfwprintf libintl_vfwprintf | ||
6963 | -extern int vfwprintf (FILE *, const wchar_t *, va_list); | ||
6964 | - | ||
6965 | -#undef wprintf | ||
6966 | -#define wprintf libintl_wprintf | ||
6967 | -extern int wprintf (const wchar_t *, ...); | ||
6968 | -#undef vwprintf | ||
6969 | -#define vwprintf libintl_vwprintf | ||
6970 | -extern int vwprintf (const wchar_t *, va_list); | ||
6971 | - | ||
6972 | -#undef swprintf | ||
6973 | -#define swprintf libintl_swprintf | ||
6974 | -extern int swprintf (wchar_t *, size_t, const wchar_t *, ...); | ||
6975 | -#undef vswprintf | ||
6976 | -#define vswprintf libintl_vswprintf | ||
6977 | -extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); | ||
6978 | - | ||
6979 | -#endif | ||
6980 | - | ||
6981 | -#endif | ||
6982 | - | ||
6983 | - | ||
6984 | -/* Support for relocatable packages. */ | ||
6985 | - | ||
6986 | -/* Sets the original and the current installation prefix of the package. | ||
6987 | - Relocation simply replaces a pathname starting with the original prefix | ||
6988 | - by the corresponding pathname with the current prefix instead. Both | ||
6989 | - prefixes should be directory names without trailing slash (i.e. use "" | ||
6990 | - instead of "/"). */ | ||
6991 | -#define libintl_set_relocation_prefix libintl_set_relocation_prefix | ||
6992 | -extern void | ||
6993 | - libintl_set_relocation_prefix (const char *orig_prefix, | ||
6994 | - const char *curr_prefix); | ||
6995 | - | ||
6996 | - | ||
6997 | -#ifdef __cplusplus | ||
6998 | -} | ||
6999 | -#endif | ||
7000 | - | ||
7001 | -#endif /* libintl.h */ | ||
7002 | --- a/intl/libintl.rc | ||
7003 | +++ /dev/null | ||
7004 | @@ -1,38 +0,0 @@ | ||
7005 | -/* Resources for intl.dll */ | ||
7006 | - | ||
7007 | -#include <winver.h> | ||
7008 | - | ||
7009 | -VS_VERSION_INFO VERSIONINFO | ||
7010 | - FILEVERSION PACKAGE_VERSION_MAJOR,PACKAGE_VERSION_MINOR,PACKAGE_VERSION_SUBMINOR,0 | ||
7011 | - PRODUCTVERSION PACKAGE_VERSION_MAJOR,PACKAGE_VERSION_MINOR,PACKAGE_VERSION_SUBMINOR,0 | ||
7012 | - FILEFLAGSMASK 0x3fL /* VS_FFI_FILEFLAGSMASK */ | ||
7013 | -#ifdef _DEBUG | ||
7014 | - FILEFLAGS 0x1L /* VS_FF_DEBUG */ | ||
7015 | -#else | ||
7016 | - FILEFLAGS 0x0L | ||
7017 | -#endif | ||
7018 | - FILEOS 0x10004L /* VOS_DOS_WINDOWS32 */ | ||
7019 | - FILETYPE 0x2L /* VFT_DLL */ | ||
7020 | - FILESUBTYPE 0x0L /* VFT2_UNKNOWN */ | ||
7021 | -BEGIN | ||
7022 | - BLOCK "StringFileInfo" | ||
7023 | - BEGIN | ||
7024 | - BLOCK "04090000" /* Lang = US English, Charset = ASCII */ | ||
7025 | - BEGIN | ||
7026 | - VALUE "Comments", "This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\0" | ||
7027 | - VALUE "CompanyName", "Free Software Foundation\0" | ||
7028 | - VALUE "FileDescription", "LGPLed libintl for Windows NT/2000/XP/Vista and Windows 95/98/ME\0" | ||
7029 | - VALUE "FileVersion", PACKAGE_VERSION_STRING "\0" | ||
7030 | - VALUE "InternalName", "intl.dll\0" | ||
7031 | - VALUE "LegalCopyright", "Copyright (C) 1995-2007\0" | ||
7032 | - VALUE "LegalTrademarks", "\0" | ||
7033 | - VALUE "OriginalFilename", "intl.dll\0" | ||
7034 | - VALUE "ProductName", "libintl: accessing NLS message catalogs\0" | ||
7035 | - VALUE "ProductVersion", PACKAGE_VERSION_STRING "\0" | ||
7036 | - END | ||
7037 | - END | ||
7038 | - BLOCK "VarFileInfo" | ||
7039 | - BEGIN | ||
7040 | - VALUE "Translation", 0x0409, 0 /* US English, ASCII */ | ||
7041 | - END | ||
7042 | -END | ||
7043 | --- a/intl/loadinfo.h | ||
7044 | +++ /dev/null | ||
7045 | @@ -1,132 +0,0 @@ | ||
7046 | -/* Copyright (C) 1996-1999, 2000-2003, 2005-2006 Free Software Foundation, Inc. | ||
7047 | - This file is part of the GNU C Library. | ||
7048 | - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | ||
7049 | - | ||
7050 | - This program is free software; you can redistribute it and/or modify it | ||
7051 | - under the terms of the GNU Library General Public License as published | ||
7052 | - by the Free Software Foundation; either version 2, or (at your option) | ||
7053 | - any later version. | ||
7054 | - | ||
7055 | - This program is distributed in the hope that it will be useful, | ||
7056 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
7057 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
7058 | - Library General Public License for more details. | ||
7059 | - | ||
7060 | - You should have received a copy of the GNU Library General Public | ||
7061 | - License along with this program; if not, write to the Free Software | ||
7062 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
7063 | - USA. */ | ||
7064 | - | ||
7065 | -#ifndef _LOADINFO_H | ||
7066 | -#define _LOADINFO_H 1 | ||
7067 | - | ||
7068 | -/* Declarations of locale dependent catalog lookup functions. | ||
7069 | - Implemented in | ||
7070 | - | ||
7071 | - localealias.c Possibly replace a locale name by another. | ||
7072 | - explodename.c Split a locale name into its various fields. | ||
7073 | - l10nflist.c Generate a list of filenames of possible message catalogs. | ||
7074 | - finddomain.c Find and open the relevant message catalogs. | ||
7075 | - | ||
7076 | - The main function _nl_find_domain() in finddomain.c is declared | ||
7077 | - in gettextP.h. | ||
7078 | - */ | ||
7079 | - | ||
7080 | -#ifndef internal_function | ||
7081 | -# define internal_function | ||
7082 | -#endif | ||
7083 | - | ||
7084 | -#ifndef LIBINTL_DLL_EXPORTED | ||
7085 | -# define LIBINTL_DLL_EXPORTED | ||
7086 | -#endif | ||
7087 | - | ||
7088 | -/* Tell the compiler when a conditional or integer expression is | ||
7089 | - almost always true or almost always false. */ | ||
7090 | -#ifndef HAVE_BUILTIN_EXPECT | ||
7091 | -# define __builtin_expect(expr, val) (expr) | ||
7092 | -#endif | ||
7093 | - | ||
7094 | -/* Separator in PATH like lists of pathnames. */ | ||
7095 | -#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ | ||
7096 | - /* Win32, OS/2, DOS */ | ||
7097 | -# define PATH_SEPARATOR ';' | ||
7098 | -#else | ||
7099 | - /* Unix */ | ||
7100 | -# define PATH_SEPARATOR ':' | ||
7101 | -#endif | ||
7102 | - | ||
7103 | -/* Encoding of locale name parts. */ | ||
7104 | -#define XPG_NORM_CODESET 1 | ||
7105 | -#define XPG_CODESET 2 | ||
7106 | -#define XPG_TERRITORY 4 | ||
7107 | -#define XPG_MODIFIER 8 | ||
7108 | - | ||
7109 | - | ||
7110 | -struct loaded_l10nfile | ||
7111 | -{ | ||
7112 | - const char *filename; | ||
7113 | - int decided; | ||
7114 | - | ||
7115 | - const void *data; | ||
7116 | - | ||
7117 | - struct loaded_l10nfile *next; | ||
7118 | - struct loaded_l10nfile *successor[1]; | ||
7119 | -}; | ||
7120 | - | ||
7121 | - | ||
7122 | -/* Normalize codeset name. There is no standard for the codeset | ||
7123 | - names. Normalization allows the user to use any of the common | ||
7124 | - names. The return value is dynamically allocated and has to be | ||
7125 | - freed by the caller. */ | ||
7126 | -extern const char *_nl_normalize_codeset (const char *codeset, | ||
7127 | - size_t name_len); | ||
7128 | - | ||
7129 | -/* Lookup a locale dependent file. | ||
7130 | - *L10NFILE_LIST denotes a pool of lookup results of locale dependent | ||
7131 | - files of the same kind, sorted in decreasing order of ->filename. | ||
7132 | - DIRLIST and DIRLIST_LEN are an argz list of directories in which to | ||
7133 | - look, containing at least one directory (i.e. DIRLIST_LEN > 0). | ||
7134 | - MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER | ||
7135 | - are the pieces of the locale name, as produced by _nl_explode_name(). | ||
7136 | - FILENAME is the filename suffix. | ||
7137 | - The return value is the lookup result, either found in *L10NFILE_LIST, | ||
7138 | - or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL. | ||
7139 | - If the return value is non-NULL, it is added to *L10NFILE_LIST, and | ||
7140 | - its ->next field denotes the chaining inside *L10NFILE_LIST, and | ||
7141 | - furthermore its ->successor[] field contains a list of other lookup | ||
7142 | - results from which this lookup result inherits. */ | ||
7143 | -extern struct loaded_l10nfile * | ||
7144 | -_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, | ||
7145 | - const char *dirlist, size_t dirlist_len, int mask, | ||
7146 | - const char *language, const char *territory, | ||
7147 | - const char *codeset, const char *normalized_codeset, | ||
7148 | - const char *modifier, | ||
7149 | - const char *filename, int do_allocate); | ||
7150 | - | ||
7151 | -/* Lookup the real locale name for a locale alias NAME, or NULL if | ||
7152 | - NAME is not a locale alias (but possibly a real locale name). | ||
7153 | - The return value is statically allocated and must not be freed. */ | ||
7154 | -/* Part of the libintl ABI only for the sake of the gettext.m4 macro. */ | ||
7155 | -extern LIBINTL_DLL_EXPORTED const char *_nl_expand_alias (const char *name); | ||
7156 | - | ||
7157 | -/* Split a locale name NAME into its pieces: language, modifier, | ||
7158 | - territory, codeset. | ||
7159 | - NAME gets destructively modified: NUL bytes are inserted here and | ||
7160 | - there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY, | ||
7161 | - *CODESET gets assigned either a pointer into the old NAME string, or | ||
7162 | - NULL. *NORMALIZED_CODESET gets assigned the expanded *CODESET, if it | ||
7163 | - is different from *CODESET; this one is dynamically allocated and has | ||
7164 | - to be freed by the caller. | ||
7165 | - The return value is a bitmask, where each bit corresponds to one | ||
7166 | - filled-in value: | ||
7167 | - XPG_MODIFIER for *MODIFIER, | ||
7168 | - XPG_TERRITORY for *TERRITORY, | ||
7169 | - XPG_CODESET for *CODESET, | ||
7170 | - XPG_NORM_CODESET for *NORMALIZED_CODESET. | ||
7171 | - */ | ||
7172 | -extern int _nl_explode_name (char *name, const char **language, | ||
7173 | - const char **modifier, const char **territory, | ||
7174 | - const char **codeset, | ||
7175 | - const char **normalized_codeset); | ||
7176 | - | ||
7177 | -#endif /* loadinfo.h */ | ||
7178 | --- a/intl/loadmsgcat.c | ||
7179 | +++ /dev/null | ||
7180 | @@ -1,1336 +0,0 @@ | ||
7181 | -/* Load needed message catalogs. | ||
7182 | - Copyright (C) 1995-1999, 2000-2007 Free Software Foundation, Inc. | ||
7183 | - | ||
7184 | - This program is free software; you can redistribute it and/or modify it | ||
7185 | - under the terms of the GNU Library General Public License as published | ||
7186 | - by the Free Software Foundation; either version 2, or (at your option) | ||
7187 | - any later version. | ||
7188 | - | ||
7189 | - This program is distributed in the hope that it will be useful, | ||
7190 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
7191 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
7192 | - Library General Public License for more details. | ||
7193 | - | ||
7194 | - You should have received a copy of the GNU Library General Public | ||
7195 | - License along with this program; if not, write to the Free Software | ||
7196 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
7197 | - USA. */ | ||
7198 | - | ||
7199 | -/* Tell glibc's <string.h> to provide a prototype for mempcpy(). | ||
7200 | - This must come before <config.h> because <config.h> may include | ||
7201 | - <features.h>, and once <features.h> has been included, it's too late. */ | ||
7202 | -#ifndef _GNU_SOURCE | ||
7203 | -# define _GNU_SOURCE 1 | ||
7204 | -#endif | ||
7205 | - | ||
7206 | -#ifdef HAVE_CONFIG_H | ||
7207 | -# include <config.h> | ||
7208 | -#endif | ||
7209 | - | ||
7210 | -#include <ctype.h> | ||
7211 | -#include <errno.h> | ||
7212 | -#include <fcntl.h> | ||
7213 | -#include <sys/types.h> | ||
7214 | -#include <sys/stat.h> | ||
7215 | - | ||
7216 | -#ifdef __GNUC__ | ||
7217 | -# undef alloca | ||
7218 | -# define alloca __builtin_alloca | ||
7219 | -# define HAVE_ALLOCA 1 | ||
7220 | -#else | ||
7221 | -# ifdef _MSC_VER | ||
7222 | -# include <malloc.h> | ||
7223 | -# define alloca _alloca | ||
7224 | -# else | ||
7225 | -# if defined HAVE_ALLOCA_H || defined _LIBC | ||
7226 | -# include <alloca.h> | ||
7227 | -# else | ||
7228 | -# ifdef _AIX | ||
7229 | - #pragma alloca | ||
7230 | -# else | ||
7231 | -# ifndef alloca | ||
7232 | -char *alloca (); | ||
7233 | -# endif | ||
7234 | -# endif | ||
7235 | -# endif | ||
7236 | -# endif | ||
7237 | -#endif | ||
7238 | - | ||
7239 | -#include <stdlib.h> | ||
7240 | -#include <string.h> | ||
7241 | - | ||
7242 | -#if defined HAVE_UNISTD_H || defined _LIBC | ||
7243 | -# include <unistd.h> | ||
7244 | -#endif | ||
7245 | - | ||
7246 | -#ifdef _LIBC | ||
7247 | -# include <langinfo.h> | ||
7248 | -# include <locale.h> | ||
7249 | -#endif | ||
7250 | - | ||
7251 | -#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ | ||
7252 | - || (defined _LIBC && defined _POSIX_MAPPED_FILES) | ||
7253 | -# include <sys/mman.h> | ||
7254 | -# undef HAVE_MMAP | ||
7255 | -# define HAVE_MMAP 1 | ||
7256 | -#else | ||
7257 | -# undef HAVE_MMAP | ||
7258 | -#endif | ||
7259 | - | ||
7260 | -#if defined HAVE_STDINT_H_WITH_UINTMAX || defined _LIBC | ||
7261 | -# include <stdint.h> | ||
7262 | -#endif | ||
7263 | -#if defined HAVE_INTTYPES_H || defined _LIBC | ||
7264 | -# include <inttypes.h> | ||
7265 | -#endif | ||
7266 | - | ||
7267 | -#include "gmo.h" | ||
7268 | -#include "gettextP.h" | ||
7269 | -#include "hash-string.h" | ||
7270 | -#include "plural-exp.h" | ||
7271 | - | ||
7272 | -#ifdef _LIBC | ||
7273 | -# include "../locale/localeinfo.h" | ||
7274 | -# include <not-cancel.h> | ||
7275 | -#endif | ||
7276 | - | ||
7277 | -/* Handle multi-threaded applications. */ | ||
7278 | -#ifdef _LIBC | ||
7279 | -# include <bits/libc-lock.h> | ||
7280 | -#else | ||
7281 | -# include "lock.h" | ||
7282 | -#endif | ||
7283 | - | ||
7284 | -/* Provide fallback values for macros that ought to be defined in <inttypes.h>. | ||
7285 | - Note that our fallback values need not be literal strings, because we don't | ||
7286 | - use them with preprocessor string concatenation. */ | ||
7287 | -#if !defined PRId8 || PRI_MACROS_BROKEN | ||
7288 | -# undef PRId8 | ||
7289 | -# define PRId8 "d" | ||
7290 | -#endif | ||
7291 | -#if !defined PRIi8 || PRI_MACROS_BROKEN | ||
7292 | -# undef PRIi8 | ||
7293 | -# define PRIi8 "i" | ||
7294 | -#endif | ||
7295 | -#if !defined PRIo8 || PRI_MACROS_BROKEN | ||
7296 | -# undef PRIo8 | ||
7297 | -# define PRIo8 "o" | ||
7298 | -#endif | ||
7299 | -#if !defined PRIu8 || PRI_MACROS_BROKEN | ||
7300 | -# undef PRIu8 | ||
7301 | -# define PRIu8 "u" | ||
7302 | -#endif | ||
7303 | -#if !defined PRIx8 || PRI_MACROS_BROKEN | ||
7304 | -# undef PRIx8 | ||
7305 | -# define PRIx8 "x" | ||
7306 | -#endif | ||
7307 | -#if !defined PRIX8 || PRI_MACROS_BROKEN | ||
7308 | -# undef PRIX8 | ||
7309 | -# define PRIX8 "X" | ||
7310 | -#endif | ||
7311 | -#if !defined PRId16 || PRI_MACROS_BROKEN | ||
7312 | -# undef PRId16 | ||
7313 | -# define PRId16 "d" | ||
7314 | -#endif | ||
7315 | -#if !defined PRIi16 || PRI_MACROS_BROKEN | ||
7316 | -# undef PRIi16 | ||
7317 | -# define PRIi16 "i" | ||
7318 | -#endif | ||
7319 | -#if !defined PRIo16 || PRI_MACROS_BROKEN | ||
7320 | -# undef PRIo16 | ||
7321 | -# define PRIo16 "o" | ||
7322 | -#endif | ||
7323 | -#if !defined PRIu16 || PRI_MACROS_BROKEN | ||
7324 | -# undef PRIu16 | ||
7325 | -# define PRIu16 "u" | ||
7326 | -#endif | ||
7327 | -#if !defined PRIx16 || PRI_MACROS_BROKEN | ||
7328 | -# undef PRIx16 | ||
7329 | -# define PRIx16 "x" | ||
7330 | -#endif | ||
7331 | -#if !defined PRIX16 || PRI_MACROS_BROKEN | ||
7332 | -# undef PRIX16 | ||
7333 | -# define PRIX16 "X" | ||
7334 | -#endif | ||
7335 | -#if !defined PRId32 || PRI_MACROS_BROKEN | ||
7336 | -# undef PRId32 | ||
7337 | -# define PRId32 "d" | ||
7338 | -#endif | ||
7339 | -#if !defined PRIi32 || PRI_MACROS_BROKEN | ||
7340 | -# undef PRIi32 | ||
7341 | -# define PRIi32 "i" | ||
7342 | -#endif | ||
7343 | -#if !defined PRIo32 || PRI_MACROS_BROKEN | ||
7344 | -# undef PRIo32 | ||
7345 | -# define PRIo32 "o" | ||
7346 | -#endif | ||
7347 | -#if !defined PRIu32 || PRI_MACROS_BROKEN | ||
7348 | -# undef PRIu32 | ||
7349 | -# define PRIu32 "u" | ||
7350 | -#endif | ||
7351 | -#if !defined PRIx32 || PRI_MACROS_BROKEN | ||
7352 | -# undef PRIx32 | ||
7353 | -# define PRIx32 "x" | ||
7354 | -#endif | ||
7355 | -#if !defined PRIX32 || PRI_MACROS_BROKEN | ||
7356 | -# undef PRIX32 | ||
7357 | -# define PRIX32 "X" | ||
7358 | -#endif | ||
7359 | -#if !defined PRId64 || PRI_MACROS_BROKEN | ||
7360 | -# undef PRId64 | ||
7361 | -# define PRId64 (sizeof (long) == 8 ? "ld" : "lld") | ||
7362 | -#endif | ||
7363 | -#if !defined PRIi64 || PRI_MACROS_BROKEN | ||
7364 | -# undef PRIi64 | ||
7365 | -# define PRIi64 (sizeof (long) == 8 ? "li" : "lli") | ||
7366 | -#endif | ||
7367 | -#if !defined PRIo64 || PRI_MACROS_BROKEN | ||
7368 | -# undef PRIo64 | ||
7369 | -# define PRIo64 (sizeof (long) == 8 ? "lo" : "llo") | ||
7370 | -#endif | ||
7371 | -#if !defined PRIu64 || PRI_MACROS_BROKEN | ||
7372 | -# undef PRIu64 | ||
7373 | -# define PRIu64 (sizeof (long) == 8 ? "lu" : "llu") | ||
7374 | -#endif | ||
7375 | -#if !defined PRIx64 || PRI_MACROS_BROKEN | ||
7376 | -# undef PRIx64 | ||
7377 | -# define PRIx64 (sizeof (long) == 8 ? "lx" : "llx") | ||
7378 | -#endif | ||
7379 | -#if !defined PRIX64 || PRI_MACROS_BROKEN | ||
7380 | -# undef PRIX64 | ||
7381 | -# define PRIX64 (sizeof (long) == 8 ? "lX" : "llX") | ||
7382 | -#endif | ||
7383 | -#if !defined PRIdLEAST8 || PRI_MACROS_BROKEN | ||
7384 | -# undef PRIdLEAST8 | ||
7385 | -# define PRIdLEAST8 "d" | ||
7386 | -#endif | ||
7387 | -#if !defined PRIiLEAST8 || PRI_MACROS_BROKEN | ||
7388 | -# undef PRIiLEAST8 | ||
7389 | -# define PRIiLEAST8 "i" | ||
7390 | -#endif | ||
7391 | -#if !defined PRIoLEAST8 || PRI_MACROS_BROKEN | ||
7392 | -# undef PRIoLEAST8 | ||
7393 | -# define PRIoLEAST8 "o" | ||
7394 | -#endif | ||
7395 | -#if !defined PRIuLEAST8 || PRI_MACROS_BROKEN | ||
7396 | -# undef PRIuLEAST8 | ||
7397 | -# define PRIuLEAST8 "u" | ||
7398 | -#endif | ||
7399 | -#if !defined PRIxLEAST8 || PRI_MACROS_BROKEN | ||
7400 | -# undef PRIxLEAST8 | ||
7401 | -# define PRIxLEAST8 "x" | ||
7402 | -#endif | ||
7403 | -#if !defined PRIXLEAST8 || PRI_MACROS_BROKEN | ||
7404 | -# undef PRIXLEAST8 | ||
7405 | -# define PRIXLEAST8 "X" | ||
7406 | -#endif | ||
7407 | -#if !defined PRIdLEAST16 || PRI_MACROS_BROKEN | ||
7408 | -# undef PRIdLEAST16 | ||
7409 | -# define PRIdLEAST16 "d" | ||
7410 | -#endif | ||
7411 | -#if !defined PRIiLEAST16 || PRI_MACROS_BROKEN | ||
7412 | -# undef PRIiLEAST16 | ||
7413 | -# define PRIiLEAST16 "i" | ||
7414 | -#endif | ||
7415 | -#if !defined PRIoLEAST16 || PRI_MACROS_BROKEN | ||
7416 | -# undef PRIoLEAST16 | ||
7417 | -# define PRIoLEAST16 "o" | ||
7418 | -#endif | ||
7419 | -#if !defined PRIuLEAST16 || PRI_MACROS_BROKEN | ||
7420 | -# undef PRIuLEAST16 | ||
7421 | -# define PRIuLEAST16 "u" | ||
7422 | -#endif | ||
7423 | -#if !defined PRIxLEAST16 || PRI_MACROS_BROKEN | ||
7424 | -# undef PRIxLEAST16 | ||
7425 | -# define PRIxLEAST16 "x" | ||
7426 | -#endif | ||
7427 | -#if !defined PRIXLEAST16 || PRI_MACROS_BROKEN | ||
7428 | -# undef PRIXLEAST16 | ||
7429 | -# define PRIXLEAST16 "X" | ||
7430 | -#endif | ||
7431 | -#if !defined PRIdLEAST32 || PRI_MACROS_BROKEN | ||
7432 | -# undef PRIdLEAST32 | ||
7433 | -# define PRIdLEAST32 "d" | ||
7434 | -#endif | ||
7435 | -#if !defined PRIiLEAST32 || PRI_MACROS_BROKEN | ||
7436 | -# undef PRIiLEAST32 | ||
7437 | -# define PRIiLEAST32 "i" | ||
7438 | -#endif | ||
7439 | -#if !defined PRIoLEAST32 || PRI_MACROS_BROKEN | ||
7440 | -# undef PRIoLEAST32 | ||
7441 | -# define PRIoLEAST32 "o" | ||
7442 | -#endif | ||
7443 | -#if !defined PRIuLEAST32 || PRI_MACROS_BROKEN | ||
7444 | -# undef PRIuLEAST32 | ||
7445 | -# define PRIuLEAST32 "u" | ||
7446 | -#endif | ||
7447 | -#if !defined PRIxLEAST32 || PRI_MACROS_BROKEN | ||
7448 | -# undef PRIxLEAST32 | ||
7449 | -# define PRIxLEAST32 "x" | ||
7450 | -#endif | ||
7451 | -#if !defined PRIXLEAST32 || PRI_MACROS_BROKEN | ||
7452 | -# undef PRIXLEAST32 | ||
7453 | -# define PRIXLEAST32 "X" | ||
7454 | -#endif | ||
7455 | -#if !defined PRIdLEAST64 || PRI_MACROS_BROKEN | ||
7456 | -# undef PRIdLEAST64 | ||
7457 | -# define PRIdLEAST64 PRId64 | ||
7458 | -#endif | ||
7459 | -#if !defined PRIiLEAST64 || PRI_MACROS_BROKEN | ||
7460 | -# undef PRIiLEAST64 | ||
7461 | -# define PRIiLEAST64 PRIi64 | ||
7462 | -#endif | ||
7463 | -#if !defined PRIoLEAST64 || PRI_MACROS_BROKEN | ||
7464 | -# undef PRIoLEAST64 | ||
7465 | -# define PRIoLEAST64 PRIo64 | ||
7466 | -#endif | ||
7467 | -#if !defined PRIuLEAST64 || PRI_MACROS_BROKEN | ||
7468 | -# undef PRIuLEAST64 | ||
7469 | -# define PRIuLEAST64 PRIu64 | ||
7470 | -#endif | ||
7471 | -#if !defined PRIxLEAST64 || PRI_MACROS_BROKEN | ||
7472 | -# undef PRIxLEAST64 | ||
7473 | -# define PRIxLEAST64 PRIx64 | ||
7474 | -#endif | ||
7475 | -#if !defined PRIXLEAST64 || PRI_MACROS_BROKEN | ||
7476 | -# undef PRIXLEAST64 | ||
7477 | -# define PRIXLEAST64 PRIX64 | ||
7478 | -#endif | ||
7479 | -#if !defined PRIdFAST8 || PRI_MACROS_BROKEN | ||
7480 | -# undef PRIdFAST8 | ||
7481 | -# define PRIdFAST8 "d" | ||
7482 | -#endif | ||
7483 | -#if !defined PRIiFAST8 || PRI_MACROS_BROKEN | ||
7484 | -# undef PRIiFAST8 | ||
7485 | -# define PRIiFAST8 "i" | ||
7486 | -#endif | ||
7487 | -#if !defined PRIoFAST8 || PRI_MACROS_BROKEN | ||
7488 | -# undef PRIoFAST8 | ||
7489 | -# define PRIoFAST8 "o" | ||
7490 | -#endif | ||
7491 | -#if !defined PRIuFAST8 || PRI_MACROS_BROKEN | ||
7492 | -# undef PRIuFAST8 | ||
7493 | -# define PRIuFAST8 "u" | ||
7494 | -#endif | ||
7495 | -#if !defined PRIxFAST8 || PRI_MACROS_BROKEN | ||
7496 | -# undef PRIxFAST8 | ||
7497 | -# define PRIxFAST8 "x" | ||
7498 | -#endif | ||
7499 | -#if !defined PRIXFAST8 || PRI_MACROS_BROKEN | ||
7500 | -# undef PRIXFAST8 | ||
7501 | -# define PRIXFAST8 "X" | ||
7502 | -#endif | ||
7503 | -#if !defined PRIdFAST16 || PRI_MACROS_BROKEN | ||
7504 | -# undef PRIdFAST16 | ||
7505 | -# define PRIdFAST16 "d" | ||
7506 | -#endif | ||
7507 | -#if !defined PRIiFAST16 || PRI_MACROS_BROKEN | ||
7508 | -# undef PRIiFAST16 | ||
7509 | -# define PRIiFAST16 "i" | ||
7510 | -#endif | ||
7511 | -#if !defined PRIoFAST16 || PRI_MACROS_BROKEN | ||
7512 | -# undef PRIoFAST16 | ||
7513 | -# define PRIoFAST16 "o" | ||
7514 | -#endif | ||
7515 | -#if !defined PRIuFAST16 || PRI_MACROS_BROKEN | ||
7516 | -# undef PRIuFAST16 | ||
7517 | -# define PRIuFAST16 "u" | ||
7518 | -#endif | ||
7519 | -#if !defined PRIxFAST16 || PRI_MACROS_BROKEN | ||
7520 | -# undef PRIxFAST16 | ||
7521 | -# define PRIxFAST16 "x" | ||
7522 | -#endif | ||
7523 | -#if !defined PRIXFAST16 || PRI_MACROS_BROKEN | ||
7524 | -# undef PRIXFAST16 | ||
7525 | -# define PRIXFAST16 "X" | ||
7526 | -#endif | ||
7527 | -#if !defined PRIdFAST32 || PRI_MACROS_BROKEN | ||
7528 | -# undef PRIdFAST32 | ||
7529 | -# define PRIdFAST32 "d" | ||
7530 | -#endif | ||
7531 | -#if !defined PRIiFAST32 || PRI_MACROS_BROKEN | ||
7532 | -# undef PRIiFAST32 | ||
7533 | -# define PRIiFAST32 "i" | ||
7534 | -#endif | ||
7535 | -#if !defined PRIoFAST32 || PRI_MACROS_BROKEN | ||
7536 | -# undef PRIoFAST32 | ||
7537 | -# define PRIoFAST32 "o" | ||
7538 | -#endif | ||
7539 | -#if !defined PRIuFAST32 || PRI_MACROS_BROKEN | ||
7540 | -# undef PRIuFAST32 | ||
7541 | -# define PRIuFAST32 "u" | ||
7542 | -#endif | ||
7543 | -#if !defined PRIxFAST32 || PRI_MACROS_BROKEN | ||
7544 | -# undef PRIxFAST32 | ||
7545 | -# define PRIxFAST32 "x" | ||
7546 | -#endif | ||
7547 | -#if !defined PRIXFAST32 || PRI_MACROS_BROKEN | ||
7548 | -# undef PRIXFAST32 | ||
7549 | -# define PRIXFAST32 "X" | ||
7550 | -#endif | ||
7551 | -#if !defined PRIdFAST64 || PRI_MACROS_BROKEN | ||
7552 | -# undef PRIdFAST64 | ||
7553 | -# define PRIdFAST64 PRId64 | ||
7554 | -#endif | ||
7555 | -#if !defined PRIiFAST64 || PRI_MACROS_BROKEN | ||
7556 | -# undef PRIiFAST64 | ||
7557 | -# define PRIiFAST64 PRIi64 | ||
7558 | -#endif | ||
7559 | -#if !defined PRIoFAST64 || PRI_MACROS_BROKEN | ||
7560 | -# undef PRIoFAST64 | ||
7561 | -# define PRIoFAST64 PRIo64 | ||
7562 | -#endif | ||
7563 | -#if !defined PRIuFAST64 || PRI_MACROS_BROKEN | ||
7564 | -# undef PRIuFAST64 | ||
7565 | -# define PRIuFAST64 PRIu64 | ||
7566 | -#endif | ||
7567 | -#if !defined PRIxFAST64 || PRI_MACROS_BROKEN | ||
7568 | -# undef PRIxFAST64 | ||
7569 | -# define PRIxFAST64 PRIx64 | ||
7570 | -#endif | ||
7571 | -#if !defined PRIXFAST64 || PRI_MACROS_BROKEN | ||
7572 | -# undef PRIXFAST64 | ||
7573 | -# define PRIXFAST64 PRIX64 | ||
7574 | -#endif | ||
7575 | -#if !defined PRIdMAX || PRI_MACROS_BROKEN | ||
7576 | -# undef PRIdMAX | ||
7577 | -# define PRIdMAX (sizeof (uintmax_t) == sizeof (long) ? "ld" : "lld") | ||
7578 | -#endif | ||
7579 | -#if !defined PRIiMAX || PRI_MACROS_BROKEN | ||
7580 | -# undef PRIiMAX | ||
7581 | -# define PRIiMAX (sizeof (uintmax_t) == sizeof (long) ? "li" : "lli") | ||
7582 | -#endif | ||
7583 | -#if !defined PRIoMAX || PRI_MACROS_BROKEN | ||
7584 | -# undef PRIoMAX | ||
7585 | -# define PRIoMAX (sizeof (uintmax_t) == sizeof (long) ? "lo" : "llo") | ||
7586 | -#endif | ||
7587 | -#if !defined PRIuMAX || PRI_MACROS_BROKEN | ||
7588 | -# undef PRIuMAX | ||
7589 | -# define PRIuMAX (sizeof (uintmax_t) == sizeof (long) ? "lu" : "llu") | ||
7590 | -#endif | ||
7591 | -#if !defined PRIxMAX || PRI_MACROS_BROKEN | ||
7592 | -# undef PRIxMAX | ||
7593 | -# define PRIxMAX (sizeof (uintmax_t) == sizeof (long) ? "lx" : "llx") | ||
7594 | -#endif | ||
7595 | -#if !defined PRIXMAX || PRI_MACROS_BROKEN | ||
7596 | -# undef PRIXMAX | ||
7597 | -# define PRIXMAX (sizeof (uintmax_t) == sizeof (long) ? "lX" : "llX") | ||
7598 | -#endif | ||
7599 | -#if !defined PRIdPTR || PRI_MACROS_BROKEN | ||
7600 | -# undef PRIdPTR | ||
7601 | -# define PRIdPTR \ | ||
7602 | - (sizeof (void *) == sizeof (long) ? "ld" : \ | ||
7603 | - sizeof (void *) == sizeof (int) ? "d" : \ | ||
7604 | - "lld") | ||
7605 | -#endif | ||
7606 | -#if !defined PRIiPTR || PRI_MACROS_BROKEN | ||
7607 | -# undef PRIiPTR | ||
7608 | -# define PRIiPTR \ | ||
7609 | - (sizeof (void *) == sizeof (long) ? "li" : \ | ||
7610 | - sizeof (void *) == sizeof (int) ? "i" : \ | ||
7611 | - "lli") | ||
7612 | -#endif | ||
7613 | -#if !defined PRIoPTR || PRI_MACROS_BROKEN | ||
7614 | -# undef PRIoPTR | ||
7615 | -# define PRIoPTR \ | ||
7616 | - (sizeof (void *) == sizeof (long) ? "lo" : \ | ||
7617 | - sizeof (void *) == sizeof (int) ? "o" : \ | ||
7618 | - "llo") | ||
7619 | -#endif | ||
7620 | -#if !defined PRIuPTR || PRI_MACROS_BROKEN | ||
7621 | -# undef PRIuPTR | ||
7622 | -# define PRIuPTR \ | ||
7623 | - (sizeof (void *) == sizeof (long) ? "lu" : \ | ||
7624 | - sizeof (void *) == sizeof (int) ? "u" : \ | ||
7625 | - "llu") | ||
7626 | -#endif | ||
7627 | -#if !defined PRIxPTR || PRI_MACROS_BROKEN | ||
7628 | -# undef PRIxPTR | ||
7629 | -# define PRIxPTR \ | ||
7630 | - (sizeof (void *) == sizeof (long) ? "lx" : \ | ||
7631 | - sizeof (void *) == sizeof (int) ? "x" : \ | ||
7632 | - "llx") | ||
7633 | -#endif | ||
7634 | -#if !defined PRIXPTR || PRI_MACROS_BROKEN | ||
7635 | -# undef PRIXPTR | ||
7636 | -# define PRIXPTR \ | ||
7637 | - (sizeof (void *) == sizeof (long) ? "lX" : \ | ||
7638 | - sizeof (void *) == sizeof (int) ? "X" : \ | ||
7639 | - "llX") | ||
7640 | -#endif | ||
7641 | - | ||
7642 | -/* @@ end of prolog @@ */ | ||
7643 | - | ||
7644 | -#ifdef _LIBC | ||
7645 | -/* Rename the non ISO C functions. This is required by the standard | ||
7646 | - because some ISO C functions will require linking with this object | ||
7647 | - file and the name space must not be polluted. */ | ||
7648 | -# define open(name, flags) open_not_cancel_2 (name, flags) | ||
7649 | -# define close(fd) close_not_cancel_no_status (fd) | ||
7650 | -# define read(fd, buf, n) read_not_cancel (fd, buf, n) | ||
7651 | -# define mmap(addr, len, prot, flags, fd, offset) \ | ||
7652 | - __mmap (addr, len, prot, flags, fd, offset) | ||
7653 | -# define munmap(addr, len) __munmap (addr, len) | ||
7654 | -#endif | ||
7655 | - | ||
7656 | -/* For those losing systems which don't have `alloca' we have to add | ||
7657 | - some additional code emulating it. */ | ||
7658 | -#ifdef HAVE_ALLOCA | ||
7659 | -# define freea(p) /* nothing */ | ||
7660 | -#else | ||
7661 | -# define alloca(n) malloc (n) | ||
7662 | -# define freea(p) free (p) | ||
7663 | -#endif | ||
7664 | - | ||
7665 | -/* For systems that distinguish between text and binary I/O. | ||
7666 | - O_BINARY is usually declared in <fcntl.h>. */ | ||
7667 | -#if !defined O_BINARY && defined _O_BINARY | ||
7668 | - /* For MSC-compatible compilers. */ | ||
7669 | -# define O_BINARY _O_BINARY | ||
7670 | -# define O_TEXT _O_TEXT | ||
7671 | -#endif | ||
7672 | -#ifdef __BEOS__ | ||
7673 | - /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ | ||
7674 | -# undef O_BINARY | ||
7675 | -# undef O_TEXT | ||
7676 | -#endif | ||
7677 | -/* On reasonable systems, binary I/O is the default. */ | ||
7678 | -#ifndef O_BINARY | ||
7679 | -# define O_BINARY 0 | ||
7680 | -#endif | ||
7681 | - | ||
7682 | - | ||
7683 | -/* We need a sign, whether a new catalog was loaded, which can be associated | ||
7684 | - with all translations. This is important if the translations are | ||
7685 | - cached by one of GCC's features. */ | ||
7686 | -int _nl_msg_cat_cntr; | ||
7687 | - | ||
7688 | - | ||
7689 | -/* Expand a system dependent string segment. Return NULL if unsupported. */ | ||
7690 | -static const char * | ||
7691 | -get_sysdep_segment_value (const char *name) | ||
7692 | -{ | ||
7693 | - /* Test for an ISO C 99 section 7.8.1 format string directive. | ||
7694 | - Syntax: | ||
7695 | - P R I { d | i | o | u | x | X } | ||
7696 | - { { | LEAST | FAST } { 8 | 16 | 32 | 64 } | MAX | PTR } */ | ||
7697 | - /* We don't use a table of 14 times 6 'const char *' strings here, because | ||
7698 | - data relocations cost startup time. */ | ||
7699 | - if (name[0] == 'P' && name[1] == 'R' && name[2] == 'I') | ||
7700 | - { | ||
7701 | - if (name[3] == 'd' || name[3] == 'i' || name[3] == 'o' || name[3] == 'u' | ||
7702 | - || name[3] == 'x' || name[3] == 'X') | ||
7703 | - { | ||
7704 | - if (name[4] == '8' && name[5] == '\0') | ||
7705 | - { | ||
7706 | - if (name[3] == 'd') | ||
7707 | - return PRId8; | ||
7708 | - if (name[3] == 'i') | ||
7709 | - return PRIi8; | ||
7710 | - if (name[3] == 'o') | ||
7711 | - return PRIo8; | ||
7712 | - if (name[3] == 'u') | ||
7713 | - return PRIu8; | ||
7714 | - if (name[3] == 'x') | ||
7715 | - return PRIx8; | ||
7716 | - if (name[3] == 'X') | ||
7717 | - return PRIX8; | ||
7718 | - abort (); | ||
7719 | - } | ||
7720 | - if (name[4] == '1' && name[5] == '6' && name[6] == '\0') | ||
7721 | - { | ||
7722 | - if (name[3] == 'd') | ||
7723 | - return PRId16; | ||
7724 | - if (name[3] == 'i') | ||
7725 | - return PRIi16; | ||
7726 | - if (name[3] == 'o') | ||
7727 | - return PRIo16; | ||
7728 | - if (name[3] == 'u') | ||
7729 | - return PRIu16; | ||
7730 | - if (name[3] == 'x') | ||
7731 | - return PRIx16; | ||
7732 | - if (name[3] == 'X') | ||
7733 | - return PRIX16; | ||
7734 | - abort (); | ||
7735 | - } | ||
7736 | - if (name[4] == '3' && name[5] == '2' && name[6] == '\0') | ||
7737 | - { | ||
7738 | - if (name[3] == 'd') | ||
7739 | - return PRId32; | ||
7740 | - if (name[3] == 'i') | ||
7741 | - return PRIi32; | ||
7742 | - if (name[3] == 'o') | ||
7743 | - return PRIo32; | ||
7744 | - if (name[3] == 'u') | ||
7745 | - return PRIu32; | ||
7746 | - if (name[3] == 'x') | ||
7747 | - return PRIx32; | ||
7748 | - if (name[3] == 'X') | ||
7749 | - return PRIX32; | ||
7750 | - abort (); | ||
7751 | - } | ||
7752 | - if (name[4] == '6' && name[5] == '4' && name[6] == '\0') | ||
7753 | - { | ||
7754 | - if (name[3] == 'd') | ||
7755 | - return PRId64; | ||
7756 | - if (name[3] == 'i') | ||
7757 | - return PRIi64; | ||
7758 | - if (name[3] == 'o') | ||
7759 | - return PRIo64; | ||
7760 | - if (name[3] == 'u') | ||
7761 | - return PRIu64; | ||
7762 | - if (name[3] == 'x') | ||
7763 | - return PRIx64; | ||
7764 | - if (name[3] == 'X') | ||
7765 | - return PRIX64; | ||
7766 | - abort (); | ||
7767 | - } | ||
7768 | - if (name[4] == 'L' && name[5] == 'E' && name[6] == 'A' | ||
7769 | - && name[7] == 'S' && name[8] == 'T') | ||
7770 | - { | ||
7771 | - if (name[9] == '8' && name[10] == '\0') | ||
7772 | - { | ||
7773 | - if (name[3] == 'd') | ||
7774 | - return PRIdLEAST8; | ||
7775 | - if (name[3] == 'i') | ||
7776 | - return PRIiLEAST8; | ||
7777 | - if (name[3] == 'o') | ||
7778 | - return PRIoLEAST8; | ||
7779 | - if (name[3] == 'u') | ||
7780 | - return PRIuLEAST8; | ||
7781 | - if (name[3] == 'x') | ||
7782 | - return PRIxLEAST8; | ||
7783 | - if (name[3] == 'X') | ||
7784 | - return PRIXLEAST8; | ||
7785 | - abort (); | ||
7786 | - } | ||
7787 | - if (name[9] == '1' && name[10] == '6' && name[11] == '\0') | ||
7788 | - { | ||
7789 | - if (name[3] == 'd') | ||
7790 | - return PRIdLEAST16; | ||
7791 | - if (name[3] == 'i') | ||
7792 | - return PRIiLEAST16; | ||
7793 | - if (name[3] == 'o') | ||
7794 | - return PRIoLEAST16; | ||
7795 | - if (name[3] == 'u') | ||
7796 | - return PRIuLEAST16; | ||
7797 | - if (name[3] == 'x') | ||
7798 | - return PRIxLEAST16; | ||
7799 | - if (name[3] == 'X') | ||
7800 | - return PRIXLEAST16; | ||
7801 | - abort (); | ||
7802 | - } | ||
7803 | - if (name[9] == '3' && name[10] == '2' && name[11] == '\0') | ||
7804 | - { | ||
7805 | - if (name[3] == 'd') | ||
7806 | - return PRIdLEAST32; | ||
7807 | - if (name[3] == 'i') | ||
7808 | - return PRIiLEAST32; | ||
7809 | - if (name[3] == 'o') | ||
7810 | - return PRIoLEAST32; | ||
7811 | - if (name[3] == 'u') | ||
7812 | - return PRIuLEAST32; | ||
7813 | - if (name[3] == 'x') | ||
7814 | - return PRIxLEAST32; | ||
7815 | - if (name[3] == 'X') | ||
7816 | - return PRIXLEAST32; | ||
7817 | - abort (); | ||
7818 | - } | ||
7819 | - if (name[9] == '6' && name[10] == '4' && name[11] == '\0') | ||
7820 | - { | ||
7821 | - if (name[3] == 'd') | ||
7822 | - return PRIdLEAST64; | ||
7823 | - if (name[3] == 'i') | ||
7824 | - return PRIiLEAST64; | ||
7825 | - if (name[3] == 'o') | ||
7826 | - return PRIoLEAST64; | ||
7827 | - if (name[3] == 'u') | ||
7828 | - return PRIuLEAST64; | ||
7829 | - if (name[3] == 'x') | ||
7830 | - return PRIxLEAST64; | ||
7831 | - if (name[3] == 'X') | ||
7832 | - return PRIXLEAST64; | ||
7833 | - abort (); | ||
7834 | - } | ||
7835 | - } | ||
7836 | - if (name[4] == 'F' && name[5] == 'A' && name[6] == 'S' | ||
7837 | - && name[7] == 'T') | ||
7838 | - { | ||
7839 | - if (name[8] == '8' && name[9] == '\0') | ||
7840 | - { | ||
7841 | - if (name[3] == 'd') | ||
7842 | - return PRIdFAST8; | ||
7843 | - if (name[3] == 'i') | ||
7844 | - return PRIiFAST8; | ||
7845 | - if (name[3] == 'o') | ||
7846 | - return PRIoFAST8; | ||
7847 | - if (name[3] == 'u') | ||
7848 | - return PRIuFAST8; | ||
7849 | - if (name[3] == 'x') | ||
7850 | - return PRIxFAST8; | ||
7851 | - if (name[3] == 'X') | ||
7852 | - return PRIXFAST8; | ||
7853 | - abort (); | ||
7854 | - } | ||
7855 | - if (name[8] == '1' && name[9] == '6' && name[10] == '\0') | ||
7856 | - { | ||
7857 | - if (name[3] == 'd') | ||
7858 | - return PRIdFAST16; | ||
7859 | - if (name[3] == 'i') | ||
7860 | - return PRIiFAST16; | ||
7861 | - if (name[3] == 'o') | ||
7862 | - return PRIoFAST16; | ||
7863 | - if (name[3] == 'u') | ||
7864 | - return PRIuFAST16; | ||
7865 | - if (name[3] == 'x') | ||
7866 | - return PRIxFAST16; | ||
7867 | - if (name[3] == 'X') | ||
7868 | - return PRIXFAST16; | ||
7869 | - abort (); | ||
7870 | - } | ||
7871 | - if (name[8] == '3' && name[9] == '2' && name[10] == '\0') | ||
7872 | - { | ||
7873 | - if (name[3] == 'd') | ||
7874 | - return PRIdFAST32; | ||
7875 | - if (name[3] == 'i') | ||
7876 | - return PRIiFAST32; | ||
7877 | - if (name[3] == 'o') | ||
7878 | - return PRIoFAST32; | ||
7879 | - if (name[3] == 'u') | ||
7880 | - return PRIuFAST32; | ||
7881 | - if (name[3] == 'x') | ||
7882 | - return PRIxFAST32; | ||
7883 | - if (name[3] == 'X') | ||
7884 | - return PRIXFAST32; | ||
7885 | - abort (); | ||
7886 | - } | ||
7887 | - if (name[8] == '6' && name[9] == '4' && name[10] == '\0') | ||
7888 | - { | ||
7889 | - if (name[3] == 'd') | ||
7890 | - return PRIdFAST64; | ||
7891 | - if (name[3] == 'i') | ||
7892 | - return PRIiFAST64; | ||
7893 | - if (name[3] == 'o') | ||
7894 | - return PRIoFAST64; | ||
7895 | - if (name[3] == 'u') | ||
7896 | - return PRIuFAST64; | ||
7897 | - if (name[3] == 'x') | ||
7898 | - return PRIxFAST64; | ||
7899 | - if (name[3] == 'X') | ||
7900 | - return PRIXFAST64; | ||
7901 | - abort (); | ||
7902 | - } | ||
7903 | - } | ||
7904 | - if (name[4] == 'M' && name[5] == 'A' && name[6] == 'X' | ||
7905 | - && name[7] == '\0') | ||
7906 | - { | ||
7907 | - if (name[3] == 'd') | ||
7908 | - return PRIdMAX; | ||
7909 | - if (name[3] == 'i') | ||
7910 | - return PRIiMAX; | ||
7911 | - if (name[3] == 'o') | ||
7912 | - return PRIoMAX; | ||
7913 | - if (name[3] == 'u') | ||
7914 | - return PRIuMAX; | ||
7915 | - if (name[3] == 'x') | ||
7916 | - return PRIxMAX; | ||
7917 | - if (name[3] == 'X') | ||
7918 | - return PRIXMAX; | ||
7919 | - abort (); | ||
7920 | - } | ||
7921 | - if (name[4] == 'P' && name[5] == 'T' && name[6] == 'R' | ||
7922 | - && name[7] == '\0') | ||
7923 | - { | ||
7924 | - if (name[3] == 'd') | ||
7925 | - return PRIdPTR; | ||
7926 | - if (name[3] == 'i') | ||
7927 | - return PRIiPTR; | ||
7928 | - if (name[3] == 'o') | ||
7929 | - return PRIoPTR; | ||
7930 | - if (name[3] == 'u') | ||
7931 | - return PRIuPTR; | ||
7932 | - if (name[3] == 'x') | ||
7933 | - return PRIxPTR; | ||
7934 | - if (name[3] == 'X') | ||
7935 | - return PRIXPTR; | ||
7936 | - abort (); | ||
7937 | - } | ||
7938 | - } | ||
7939 | - } | ||
7940 | - /* Test for a glibc specific printf() format directive flag. */ | ||
7941 | - if (name[0] == 'I' && name[1] == '\0') | ||
7942 | - { | ||
7943 | -#if defined _LIBC || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) | ||
7944 | - /* The 'I' flag, in numeric format directives, replaces ASCII digits | ||
7945 | - with the 'outdigits' defined in the LC_CTYPE locale facet. This is | ||
7946 | - used for Farsi (Persian) and maybe Arabic. */ | ||
7947 | - return "I"; | ||
7948 | -#else | ||
7949 | - return ""; | ||
7950 | -#endif | ||
7951 | - } | ||
7952 | - /* Other system dependent strings are not valid. */ | ||
7953 | - return NULL; | ||
7954 | -} | ||
7955 | - | ||
7956 | -/* Load the message catalogs specified by FILENAME. If it is no valid | ||
7957 | - message catalog do nothing. */ | ||
7958 | -void | ||
7959 | -internal_function | ||
7960 | -_nl_load_domain (struct loaded_l10nfile *domain_file, | ||
7961 | - struct binding *domainbinding) | ||
7962 | -{ | ||
7963 | - __libc_lock_define_initialized_recursive (static, lock) | ||
7964 | - int fd = -1; | ||
7965 | - size_t size; | ||
7966 | -#ifdef _LIBC | ||
7967 | - struct stat64 st; | ||
7968 | -#else | ||
7969 | - struct stat st; | ||
7970 | -#endif | ||
7971 | - struct mo_file_header *data = (struct mo_file_header *) -1; | ||
7972 | - int use_mmap = 0; | ||
7973 | - struct loaded_domain *domain; | ||
7974 | - int revision; | ||
7975 | - const char *nullentry; | ||
7976 | - size_t nullentrylen; | ||
7977 | - | ||
7978 | - __libc_lock_lock_recursive (lock); | ||
7979 | - if (domain_file->decided != 0) | ||
7980 | - { | ||
7981 | - /* There are two possibilities: | ||
7982 | - | ||
7983 | - + this is the same thread calling again during this initialization | ||
7984 | - via _nl_find_msg. We have initialized everything this call needs. | ||
7985 | - | ||
7986 | - + this is another thread which tried to initialize this object. | ||
7987 | - Not necessary anymore since if the lock is available this | ||
7988 | - is finished. | ||
7989 | - */ | ||
7990 | - goto done; | ||
7991 | - } | ||
7992 | - | ||
7993 | - domain_file->decided = -1; | ||
7994 | - domain_file->data = NULL; | ||
7995 | - | ||
7996 | - /* Note that it would be useless to store domainbinding in domain_file | ||
7997 | - because domainbinding might be == NULL now but != NULL later (after | ||
7998 | - a call to bind_textdomain_codeset). */ | ||
7999 | - | ||
8000 | - /* If the record does not represent a valid locale the FILENAME | ||
8001 | - might be NULL. This can happen when according to the given | ||
8002 | - specification the locale file name is different for XPG and CEN | ||
8003 | - syntax. */ | ||
8004 | - if (domain_file->filename == NULL) | ||
8005 | - goto out; | ||
8006 | - | ||
8007 | - /* Try to open the addressed file. */ | ||
8008 | - fd = open (domain_file->filename, O_RDONLY | O_BINARY); | ||
8009 | - if (fd == -1) | ||
8010 | - goto out; | ||
8011 | - | ||
8012 | - /* We must know about the size of the file. */ | ||
8013 | - if ( | ||
8014 | -#ifdef _LIBC | ||
8015 | - __builtin_expect (fstat64 (fd, &st) != 0, 0) | ||
8016 | -#else | ||
8017 | - __builtin_expect (fstat (fd, &st) != 0, 0) | ||
8018 | -#endif | ||
8019 | - || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0) | ||
8020 | - || __builtin_expect (size < sizeof (struct mo_file_header), 0)) | ||
8021 | - /* Something went wrong. */ | ||
8022 | - goto out; | ||
8023 | - | ||
8024 | -#ifdef HAVE_MMAP | ||
8025 | - /* Now we are ready to load the file. If mmap() is available we try | ||
8026 | - this first. If not available or it failed we try to load it. */ | ||
8027 | - data = (struct mo_file_header *) mmap (NULL, size, PROT_READ, | ||
8028 | - MAP_PRIVATE, fd, 0); | ||
8029 | - | ||
8030 | - if (__builtin_expect (data != (struct mo_file_header *) -1, 1)) | ||
8031 | - { | ||
8032 | - /* mmap() call was successful. */ | ||
8033 | - close (fd); | ||
8034 | - fd = -1; | ||
8035 | - use_mmap = 1; | ||
8036 | - } | ||
8037 | -#endif | ||
8038 | - | ||
8039 | - /* If the data is not yet available (i.e. mmap'ed) we try to load | ||
8040 | - it manually. */ | ||
8041 | - if (data == (struct mo_file_header *) -1) | ||
8042 | - { | ||
8043 | - size_t to_read; | ||
8044 | - char *read_ptr; | ||
8045 | - | ||
8046 | - data = (struct mo_file_header *) malloc (size); | ||
8047 | - if (data == NULL) | ||
8048 | - goto out; | ||
8049 | - | ||
8050 | - to_read = size; | ||
8051 | - read_ptr = (char *) data; | ||
8052 | - do | ||
8053 | - { | ||
8054 | - long int nb = (long int) read (fd, read_ptr, to_read); | ||
8055 | - if (nb <= 0) | ||
8056 | - { | ||
8057 | -#ifdef EINTR | ||
8058 | - if (nb == -1 && errno == EINTR) | ||
8059 | - continue; | ||
8060 | -#endif | ||
8061 | - goto out; | ||
8062 | - } | ||
8063 | - read_ptr += nb; | ||
8064 | - to_read -= nb; | ||
8065 | - } | ||
8066 | - while (to_read > 0); | ||
8067 | - | ||
8068 | - close (fd); | ||
8069 | - fd = -1; | ||
8070 | - } | ||
8071 | - | ||
8072 | - /* Using the magic number we can test whether it really is a message | ||
8073 | - catalog file. */ | ||
8074 | - if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED, | ||
8075 | - 0)) | ||
8076 | - { | ||
8077 | - /* The magic number is wrong: not a message catalog file. */ | ||
8078 | -#ifdef HAVE_MMAP | ||
8079 | - if (use_mmap) | ||
8080 | - munmap ((caddr_t) data, size); | ||
8081 | - else | ||
8082 | -#endif | ||
8083 | - free (data); | ||
8084 | - goto out; | ||
8085 | - } | ||
8086 | - | ||
8087 | - domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); | ||
8088 | - if (domain == NULL) | ||
8089 | - goto out; | ||
8090 | - domain_file->data = domain; | ||
8091 | - | ||
8092 | - domain->data = (char *) data; | ||
8093 | - domain->use_mmap = use_mmap; | ||
8094 | - domain->mmap_size = size; | ||
8095 | - domain->must_swap = data->magic != _MAGIC; | ||
8096 | - domain->malloced = NULL; | ||
8097 | - | ||
8098 | - /* Fill in the information about the available tables. */ | ||
8099 | - revision = W (domain->must_swap, data->revision); | ||
8100 | - /* We support only the major revisions 0 and 1. */ | ||
8101 | - switch (revision >> 16) | ||
8102 | - { | ||
8103 | - case 0: | ||
8104 | - case 1: | ||
8105 | - domain->nstrings = W (domain->must_swap, data->nstrings); | ||
8106 | - domain->orig_tab = (const struct string_desc *) | ||
8107 | - ((char *) data + W (domain->must_swap, data->orig_tab_offset)); | ||
8108 | - domain->trans_tab = (const struct string_desc *) | ||
8109 | - ((char *) data + W (domain->must_swap, data->trans_tab_offset)); | ||
8110 | - domain->hash_size = W (domain->must_swap, data->hash_tab_size); | ||
8111 | - domain->hash_tab = | ||
8112 | - (domain->hash_size > 2 | ||
8113 | - ? (const nls_uint32 *) | ||
8114 | - ((char *) data + W (domain->must_swap, data->hash_tab_offset)) | ||
8115 | - : NULL); | ||
8116 | - domain->must_swap_hash_tab = domain->must_swap; | ||
8117 | - | ||
8118 | - /* Now dispatch on the minor revision. */ | ||
8119 | - switch (revision & 0xffff) | ||
8120 | - { | ||
8121 | - case 0: | ||
8122 | - domain->n_sysdep_strings = 0; | ||
8123 | - domain->orig_sysdep_tab = NULL; | ||
8124 | - domain->trans_sysdep_tab = NULL; | ||
8125 | - break; | ||
8126 | - case 1: | ||
8127 | - default: | ||
8128 | - { | ||
8129 | - nls_uint32 n_sysdep_strings; | ||
8130 | - | ||
8131 | - if (domain->hash_tab == NULL) | ||
8132 | - /* This is invalid. These minor revisions need a hash table. */ | ||
8133 | - goto invalid; | ||
8134 | - | ||
8135 | - n_sysdep_strings = | ||
8136 | - W (domain->must_swap, data->n_sysdep_strings); | ||
8137 | - if (n_sysdep_strings > 0) | ||
8138 | - { | ||
8139 | - nls_uint32 n_sysdep_segments; | ||
8140 | - const struct sysdep_segment *sysdep_segments; | ||
8141 | - const char **sysdep_segment_values; | ||
8142 | - const nls_uint32 *orig_sysdep_tab; | ||
8143 | - const nls_uint32 *trans_sysdep_tab; | ||
8144 | - nls_uint32 n_inmem_sysdep_strings; | ||
8145 | - size_t memneed; | ||
8146 | - char *mem; | ||
8147 | - struct sysdep_string_desc *inmem_orig_sysdep_tab; | ||
8148 | - struct sysdep_string_desc *inmem_trans_sysdep_tab; | ||
8149 | - nls_uint32 *inmem_hash_tab; | ||
8150 | - unsigned int i, j; | ||
8151 | - | ||
8152 | - /* Get the values of the system dependent segments. */ | ||
8153 | - n_sysdep_segments = | ||
8154 | - W (domain->must_swap, data->n_sysdep_segments); | ||
8155 | - sysdep_segments = (const struct sysdep_segment *) | ||
8156 | - ((char *) data | ||
8157 | - + W (domain->must_swap, data->sysdep_segments_offset)); | ||
8158 | - sysdep_segment_values = | ||
8159 | - (const char **) | ||
8160 | - alloca (n_sysdep_segments * sizeof (const char *)); | ||
8161 | - for (i = 0; i < n_sysdep_segments; i++) | ||
8162 | - { | ||
8163 | - const char *name = | ||
8164 | - (char *) data | ||
8165 | - + W (domain->must_swap, sysdep_segments[i].offset); | ||
8166 | - nls_uint32 namelen = | ||
8167 | - W (domain->must_swap, sysdep_segments[i].length); | ||
8168 | - | ||
8169 | - if (!(namelen > 0 && name[namelen - 1] == '\0')) | ||
8170 | - { | ||
8171 | - freea (sysdep_segment_values); | ||
8172 | - goto invalid; | ||
8173 | - } | ||
8174 | - | ||
8175 | - sysdep_segment_values[i] = get_sysdep_segment_value (name); | ||
8176 | - } | ||
8177 | - | ||
8178 | - orig_sysdep_tab = (const nls_uint32 *) | ||
8179 | - ((char *) data | ||
8180 | - + W (domain->must_swap, data->orig_sysdep_tab_offset)); | ||
8181 | - trans_sysdep_tab = (const nls_uint32 *) | ||
8182 | - ((char *) data | ||
8183 | - + W (domain->must_swap, data->trans_sysdep_tab_offset)); | ||
8184 | - | ||
8185 | - /* Compute the amount of additional memory needed for the | ||
8186 | - system dependent strings and the augmented hash table. | ||
8187 | - At the same time, also drop string pairs which refer to | ||
8188 | - an undefined system dependent segment. */ | ||
8189 | - n_inmem_sysdep_strings = 0; | ||
8190 | - memneed = domain->hash_size * sizeof (nls_uint32); | ||
8191 | - for (i = 0; i < n_sysdep_strings; i++) | ||
8192 | - { | ||
8193 | - int valid = 1; | ||
8194 | - size_t needs[2]; | ||
8195 | - | ||
8196 | - for (j = 0; j < 2; j++) | ||
8197 | - { | ||
8198 | - const struct sysdep_string *sysdep_string = | ||
8199 | - (const struct sysdep_string *) | ||
8200 | - ((char *) data | ||
8201 | - + W (domain->must_swap, | ||
8202 | - j == 0 | ||
8203 | - ? orig_sysdep_tab[i] | ||
8204 | - : trans_sysdep_tab[i])); | ||
8205 | - size_t need = 0; | ||
8206 | - const struct segment_pair *p = sysdep_string->segments; | ||
8207 | - | ||
8208 | - if (W (domain->must_swap, p->sysdepref) != SEGMENTS_END) | ||
8209 | - for (p = sysdep_string->segments;; p++) | ||
8210 | - { | ||
8211 | - nls_uint32 sysdepref; | ||
8212 | - | ||
8213 | - need += W (domain->must_swap, p->segsize); | ||
8214 | - | ||
8215 | - sysdepref = W (domain->must_swap, p->sysdepref); | ||
8216 | - if (sysdepref == SEGMENTS_END) | ||
8217 | - break; | ||
8218 | - | ||
8219 | - if (sysdepref >= n_sysdep_segments) | ||
8220 | - { | ||
8221 | - /* Invalid. */ | ||
8222 | - freea (sysdep_segment_values); | ||
8223 | - goto invalid; | ||
8224 | - } | ||
8225 | - | ||
8226 | - if (sysdep_segment_values[sysdepref] == NULL) | ||
8227 | - { | ||
8228 | - /* This particular string pair is invalid. */ | ||
8229 | - valid = 0; | ||
8230 | - break; | ||
8231 | - } | ||
8232 | - | ||
8233 | - need += strlen (sysdep_segment_values[sysdepref]); | ||
8234 | - } | ||
8235 | - | ||
8236 | - needs[j] = need; | ||
8237 | - if (!valid) | ||
8238 | - break; | ||
8239 | - } | ||
8240 | - | ||
8241 | - if (valid) | ||
8242 | - { | ||
8243 | - n_inmem_sysdep_strings++; | ||
8244 | - memneed += needs[0] + needs[1]; | ||
8245 | - } | ||
8246 | - } | ||
8247 | - memneed += 2 * n_inmem_sysdep_strings | ||
8248 | - * sizeof (struct sysdep_string_desc); | ||
8249 | - | ||
8250 | - if (n_inmem_sysdep_strings > 0) | ||
8251 | - { | ||
8252 | - unsigned int k; | ||
8253 | - | ||
8254 | - /* Allocate additional memory. */ | ||
8255 | - mem = (char *) malloc (memneed); | ||
8256 | - if (mem == NULL) | ||
8257 | - goto invalid; | ||
8258 | - | ||
8259 | - domain->malloced = mem; | ||
8260 | - inmem_orig_sysdep_tab = (struct sysdep_string_desc *) mem; | ||
8261 | - mem += n_inmem_sysdep_strings | ||
8262 | - * sizeof (struct sysdep_string_desc); | ||
8263 | - inmem_trans_sysdep_tab = (struct sysdep_string_desc *) mem; | ||
8264 | - mem += n_inmem_sysdep_strings | ||
8265 | - * sizeof (struct sysdep_string_desc); | ||
8266 | - inmem_hash_tab = (nls_uint32 *) mem; | ||
8267 | - mem += domain->hash_size * sizeof (nls_uint32); | ||
8268 | - | ||
8269 | - /* Compute the system dependent strings. */ | ||
8270 | - k = 0; | ||
8271 | - for (i = 0; i < n_sysdep_strings; i++) | ||
8272 | - { | ||
8273 | - int valid = 1; | ||
8274 | - | ||
8275 | - for (j = 0; j < 2; j++) | ||
8276 | - { | ||
8277 | - const struct sysdep_string *sysdep_string = | ||
8278 | - (const struct sysdep_string *) | ||
8279 | - ((char *) data | ||
8280 | - + W (domain->must_swap, | ||
8281 | - j == 0 | ||
8282 | - ? orig_sysdep_tab[i] | ||
8283 | - : trans_sysdep_tab[i])); | ||
8284 | - const struct segment_pair *p = | ||
8285 | - sysdep_string->segments; | ||
8286 | - | ||
8287 | - if (W (domain->must_swap, p->sysdepref) | ||
8288 | - != SEGMENTS_END) | ||
8289 | - for (p = sysdep_string->segments;; p++) | ||
8290 | - { | ||
8291 | - nls_uint32 sysdepref; | ||
8292 | - | ||
8293 | - sysdepref = | ||
8294 | - W (domain->must_swap, p->sysdepref); | ||
8295 | - if (sysdepref == SEGMENTS_END) | ||
8296 | - break; | ||
8297 | - | ||
8298 | - if (sysdep_segment_values[sysdepref] == NULL) | ||
8299 | - { | ||
8300 | - /* This particular string pair is | ||
8301 | - invalid. */ | ||
8302 | - valid = 0; | ||
8303 | - break; | ||
8304 | - } | ||
8305 | - } | ||
8306 | - | ||
8307 | - if (!valid) | ||
8308 | - break; | ||
8309 | - } | ||
8310 | - | ||
8311 | - if (valid) | ||
8312 | - { | ||
8313 | - for (j = 0; j < 2; j++) | ||
8314 | - { | ||
8315 | - const struct sysdep_string *sysdep_string = | ||
8316 | - (const struct sysdep_string *) | ||
8317 | - ((char *) data | ||
8318 | - + W (domain->must_swap, | ||
8319 | - j == 0 | ||
8320 | - ? orig_sysdep_tab[i] | ||
8321 | - : trans_sysdep_tab[i])); | ||
8322 | - const char *static_segments = | ||
8323 | - (char *) data | ||
8324 | - + W (domain->must_swap, sysdep_string->offset); | ||
8325 | - const struct segment_pair *p = | ||
8326 | - sysdep_string->segments; | ||
8327 | - | ||
8328 | - /* Concatenate the segments, and fill | ||
8329 | - inmem_orig_sysdep_tab[k] (for j == 0) and | ||
8330 | - inmem_trans_sysdep_tab[k] (for j == 1). */ | ||
8331 | - | ||
8332 | - struct sysdep_string_desc *inmem_tab_entry = | ||
8333 | - (j == 0 | ||
8334 | - ? inmem_orig_sysdep_tab | ||
8335 | - : inmem_trans_sysdep_tab) | ||
8336 | - + k; | ||
8337 | - | ||
8338 | - if (W (domain->must_swap, p->sysdepref) | ||
8339 | - == SEGMENTS_END) | ||
8340 | - { | ||
8341 | - /* Only one static segment. */ | ||
8342 | - inmem_tab_entry->length = | ||
8343 | - W (domain->must_swap, p->segsize); | ||
8344 | - inmem_tab_entry->pointer = static_segments; | ||
8345 | - } | ||
8346 | - else | ||
8347 | - { | ||
8348 | - inmem_tab_entry->pointer = mem; | ||
8349 | - | ||
8350 | - for (p = sysdep_string->segments;; p++) | ||
8351 | - { | ||
8352 | - nls_uint32 segsize = | ||
8353 | - W (domain->must_swap, p->segsize); | ||
8354 | - nls_uint32 sysdepref = | ||
8355 | - W (domain->must_swap, p->sysdepref); | ||
8356 | - size_t n; | ||
8357 | - | ||
8358 | - if (segsize > 0) | ||
8359 | - { | ||
8360 | - memcpy (mem, static_segments, segsize); | ||
8361 | - mem += segsize; | ||
8362 | - static_segments += segsize; | ||
8363 | - } | ||
8364 | - | ||
8365 | - if (sysdepref == SEGMENTS_END) | ||
8366 | - break; | ||
8367 | - | ||
8368 | - n = strlen (sysdep_segment_values[sysdepref]); | ||
8369 | - memcpy (mem, sysdep_segment_values[sysdepref], n); | ||
8370 | - mem += n; | ||
8371 | - } | ||
8372 | - | ||
8373 | - inmem_tab_entry->length = | ||
8374 | - mem - inmem_tab_entry->pointer; | ||
8375 | - } | ||
8376 | - } | ||
8377 | - | ||
8378 | - k++; | ||
8379 | - } | ||
8380 | - } | ||
8381 | - if (k != n_inmem_sysdep_strings) | ||
8382 | - abort (); | ||
8383 | - | ||
8384 | - /* Compute the augmented hash table. */ | ||
8385 | - for (i = 0; i < domain->hash_size; i++) | ||
8386 | - inmem_hash_tab[i] = | ||
8387 | - W (domain->must_swap_hash_tab, domain->hash_tab[i]); | ||
8388 | - for (i = 0; i < n_inmem_sysdep_strings; i++) | ||
8389 | - { | ||
8390 | - const char *msgid = inmem_orig_sysdep_tab[i].pointer; | ||
8391 | - nls_uint32 hash_val = __hash_string (msgid); | ||
8392 | - nls_uint32 idx = hash_val % domain->hash_size; | ||
8393 | - nls_uint32 incr = | ||
8394 | - 1 + (hash_val % (domain->hash_size - 2)); | ||
8395 | - | ||
8396 | - for (;;) | ||
8397 | - { | ||
8398 | - if (inmem_hash_tab[idx] == 0) | ||
8399 | - { | ||
8400 | - /* Hash table entry is empty. Use it. */ | ||
8401 | - inmem_hash_tab[idx] = 1 + domain->nstrings + i; | ||
8402 | - break; | ||
8403 | - } | ||
8404 | - | ||
8405 | - if (idx >= domain->hash_size - incr) | ||
8406 | - idx -= domain->hash_size - incr; | ||
8407 | - else | ||
8408 | - idx += incr; | ||
8409 | - } | ||
8410 | - } | ||
8411 | - | ||
8412 | - domain->n_sysdep_strings = n_inmem_sysdep_strings; | ||
8413 | - domain->orig_sysdep_tab = inmem_orig_sysdep_tab; | ||
8414 | - domain->trans_sysdep_tab = inmem_trans_sysdep_tab; | ||
8415 | - | ||
8416 | - domain->hash_tab = inmem_hash_tab; | ||
8417 | - domain->must_swap_hash_tab = 0; | ||
8418 | - } | ||
8419 | - else | ||
8420 | - { | ||
8421 | - domain->n_sysdep_strings = 0; | ||
8422 | - domain->orig_sysdep_tab = NULL; | ||
8423 | - domain->trans_sysdep_tab = NULL; | ||
8424 | - } | ||
8425 | - | ||
8426 | - freea (sysdep_segment_values); | ||
8427 | - } | ||
8428 | - else | ||
8429 | - { | ||
8430 | - domain->n_sysdep_strings = 0; | ||
8431 | - domain->orig_sysdep_tab = NULL; | ||
8432 | - domain->trans_sysdep_tab = NULL; | ||
8433 | - } | ||
8434 | - } | ||
8435 | - break; | ||
8436 | - } | ||
8437 | - break; | ||
8438 | - default: | ||
8439 | - /* This is an invalid revision. */ | ||
8440 | - invalid: | ||
8441 | - /* This is an invalid .mo file. */ | ||
8442 | - if (domain->malloced) | ||
8443 | - free (domain->malloced); | ||
8444 | -#ifdef HAVE_MMAP | ||
8445 | - if (use_mmap) | ||
8446 | - munmap ((caddr_t) data, size); | ||
8447 | - else | ||
8448 | -#endif | ||
8449 | - free (data); | ||
8450 | - free (domain); | ||
8451 | - domain_file->data = NULL; | ||
8452 | - goto out; | ||
8453 | - } | ||
8454 | - | ||
8455 | - /* No caches of converted translations so far. */ | ||
8456 | - domain->conversions = NULL; | ||
8457 | - domain->nconversions = 0; | ||
8458 | - gl_rwlock_init (domain->conversions_lock); | ||
8459 | - | ||
8460 | - /* Get the header entry and look for a plural specification. */ | ||
8461 | -#ifdef IN_LIBGLOCALE | ||
8462 | - nullentry = | ||
8463 | - _nl_find_msg (domain_file, domainbinding, NULL, "", &nullentrylen); | ||
8464 | -#else | ||
8465 | - nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); | ||
8466 | -#endif | ||
8467 | - EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals); | ||
8468 | - | ||
8469 | - out: | ||
8470 | - if (fd != -1) | ||
8471 | - close (fd); | ||
8472 | - | ||
8473 | - domain_file->decided = 1; | ||
8474 | - | ||
8475 | - done: | ||
8476 | - __libc_lock_unlock_recursive (lock); | ||
8477 | -} | ||
8478 | - | ||
8479 | - | ||
8480 | -#ifdef _LIBC | ||
8481 | -void | ||
8482 | -internal_function __libc_freeres_fn_section | ||
8483 | -_nl_unload_domain (struct loaded_domain *domain) | ||
8484 | -{ | ||
8485 | - size_t i; | ||
8486 | - | ||
8487 | - if (domain->plural != &__gettext_germanic_plural) | ||
8488 | - __gettext_free_exp ((struct expression *) domain->plural); | ||
8489 | - | ||
8490 | - for (i = 0; i < domain->nconversions; i++) | ||
8491 | - { | ||
8492 | - struct converted_domain *convd = &domain->conversions[i]; | ||
8493 | - | ||
8494 | - free (convd->encoding); | ||
8495 | - if (convd->conv_tab != NULL && convd->conv_tab != (char **) -1) | ||
8496 | - free (convd->conv_tab); | ||
8497 | - if (convd->conv != (__gconv_t) -1) | ||
8498 | - __gconv_close (convd->conv); | ||
8499 | - } | ||
8500 | - if (domain->conversions != NULL) | ||
8501 | - free (domain->conversions); | ||
8502 | - __libc_rwlock_fini (domain->conversions_lock); | ||
8503 | - | ||
8504 | - if (domain->malloced) | ||
8505 | - free (domain->malloced); | ||
8506 | - | ||
8507 | -# ifdef _POSIX_MAPPED_FILES | ||
8508 | - if (domain->use_mmap) | ||
8509 | - munmap ((caddr_t) domain->data, domain->mmap_size); | ||
8510 | - else | ||
8511 | -# endif /* _POSIX_MAPPED_FILES */ | ||
8512 | - free ((void *) domain->data); | ||
8513 | - | ||
8514 | - free (domain); | ||
8515 | -} | ||
8516 | -#endif | ||
8517 | --- a/intl/localcharset.c | ||
8518 | +++ /dev/null | ||
8519 | @@ -1,461 +0,0 @@ | ||
8520 | -/* Determine a canonical name for the current locale's character encoding. | ||
8521 | - | ||
8522 | - Copyright (C) 2000-2006 Free Software Foundation, Inc. | ||
8523 | - | ||
8524 | - This program is free software; you can redistribute it and/or modify it | ||
8525 | - under the terms of the GNU Library General Public License as published | ||
8526 | - by the Free Software Foundation; either version 2, or (at your option) | ||
8527 | - any later version. | ||
8528 | - | ||
8529 | - This program is distributed in the hope that it will be useful, | ||
8530 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
8531 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
8532 | - Library General Public License for more details. | ||
8533 | - | ||
8534 | - You should have received a copy of the GNU Library General Public | ||
8535 | - License along with this program; if not, write to the Free Software | ||
8536 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
8537 | - USA. */ | ||
8538 | - | ||
8539 | -/* Written by Bruno Haible <bruno@clisp.org>. */ | ||
8540 | - | ||
8541 | -#include <config.h> | ||
8542 | - | ||
8543 | -/* Specification. */ | ||
8544 | -#include "localcharset.h" | ||
8545 | - | ||
8546 | -#include <stddef.h> | ||
8547 | -#include <stdio.h> | ||
8548 | -#include <string.h> | ||
8549 | -#include <stdlib.h> | ||
8550 | - | ||
8551 | -#if defined _WIN32 || defined __WIN32__ | ||
8552 | -# define WIN32_NATIVE | ||
8553 | -#endif | ||
8554 | - | ||
8555 | -#if defined __EMX__ | ||
8556 | -/* Assume EMX program runs on OS/2, even if compiled under DOS. */ | ||
8557 | -# define OS2 | ||
8558 | -#endif | ||
8559 | - | ||
8560 | -#if !defined WIN32_NATIVE | ||
8561 | -# if HAVE_LANGINFO_CODESET | ||
8562 | -# include <langinfo.h> | ||
8563 | -# else | ||
8564 | -# if 0 /* see comment below */ | ||
8565 | -# include <locale.h> | ||
8566 | -# endif | ||
8567 | -# endif | ||
8568 | -# ifdef __CYGWIN__ | ||
8569 | -# define WIN32_LEAN_AND_MEAN | ||
8570 | -# include <windows.h> | ||
8571 | -# endif | ||
8572 | -#elif defined WIN32_NATIVE | ||
8573 | -# define WIN32_LEAN_AND_MEAN | ||
8574 | -# include <windows.h> | ||
8575 | -#endif | ||
8576 | -#if defined OS2 | ||
8577 | -# define INCL_DOS | ||
8578 | -# include <os2.h> | ||
8579 | -#endif | ||
8580 | - | ||
8581 | -#if ENABLE_RELOCATABLE | ||
8582 | -# include "relocatable.h" | ||
8583 | -#else | ||
8584 | -# define relocate(pathname) (pathname) | ||
8585 | -#endif | ||
8586 | - | ||
8587 | -/* Get LIBDIR. */ | ||
8588 | -#ifndef LIBDIR | ||
8589 | -# include "configmake.h" | ||
8590 | -#endif | ||
8591 | - | ||
8592 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | ||
8593 | - /* Win32, Cygwin, OS/2, DOS */ | ||
8594 | -# define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||
8595 | -#endif | ||
8596 | - | ||
8597 | -#ifndef DIRECTORY_SEPARATOR | ||
8598 | -# define DIRECTORY_SEPARATOR '/' | ||
8599 | -#endif | ||
8600 | - | ||
8601 | -#ifndef ISSLASH | ||
8602 | -# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) | ||
8603 | -#endif | ||
8604 | - | ||
8605 | -#if HAVE_DECL_GETC_UNLOCKED | ||
8606 | -# undef getc | ||
8607 | -# define getc getc_unlocked | ||
8608 | -#endif | ||
8609 | - | ||
8610 | -/* The following static variable is declared 'volatile' to avoid a | ||
8611 | - possible multithread problem in the function get_charset_aliases. If we | ||
8612 | - are running in a threaded environment, and if two threads initialize | ||
8613 | - 'charset_aliases' simultaneously, both will produce the same value, | ||
8614 | - and everything will be ok if the two assignments to 'charset_aliases' | ||
8615 | - are atomic. But I don't know what will happen if the two assignments mix. */ | ||
8616 | -#if __STDC__ != 1 | ||
8617 | -# define volatile /* empty */ | ||
8618 | -#endif | ||
8619 | -/* Pointer to the contents of the charset.alias file, if it has already been | ||
8620 | - read, else NULL. Its format is: | ||
8621 | - ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */ | ||
8622 | -static const char * volatile charset_aliases; | ||
8623 | - | ||
8624 | -/* Return a pointer to the contents of the charset.alias file. */ | ||
8625 | -static const char * | ||
8626 | -get_charset_aliases (void) | ||
8627 | -{ | ||
8628 | - const char *cp; | ||
8629 | - | ||
8630 | - cp = charset_aliases; | ||
8631 | - if (cp == NULL) | ||
8632 | - { | ||
8633 | -#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__) | ||
8634 | - FILE *fp; | ||
8635 | - const char *dir; | ||
8636 | - const char *base = "charset.alias"; | ||
8637 | - char *file_name; | ||
8638 | - | ||
8639 | - /* Make it possible to override the charset.alias location. This is | ||
8640 | - necessary for running the testsuite before "make install". */ | ||
8641 | - dir = getenv ("CHARSETALIASDIR"); | ||
8642 | - if (dir == NULL || dir[0] == '\0') | ||
8643 | - dir = relocate (LIBDIR); | ||
8644 | - | ||
8645 | - /* Concatenate dir and base into freshly allocated file_name. */ | ||
8646 | - { | ||
8647 | - size_t dir_len = strlen (dir); | ||
8648 | - size_t base_len = strlen (base); | ||
8649 | - int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); | ||
8650 | - file_name = (char *) malloc (dir_len + add_slash + base_len + 1); | ||
8651 | - if (file_name != NULL) | ||
8652 | - { | ||
8653 | - memcpy (file_name, dir, dir_len); | ||
8654 | - if (add_slash) | ||
8655 | - file_name[dir_len] = DIRECTORY_SEPARATOR; | ||
8656 | - memcpy (file_name + dir_len + add_slash, base, base_len + 1); | ||
8657 | - } | ||
8658 | - } | ||
8659 | - | ||
8660 | - if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL) | ||
8661 | - /* Out of memory or file not found, treat it as empty. */ | ||
8662 | - cp = ""; | ||
8663 | - else | ||
8664 | - { | ||
8665 | - /* Parse the file's contents. */ | ||
8666 | - char *res_ptr = NULL; | ||
8667 | - size_t res_size = 0; | ||
8668 | - | ||
8669 | - for (;;) | ||
8670 | - { | ||
8671 | - int c; | ||
8672 | - char buf1[50+1]; | ||
8673 | - char buf2[50+1]; | ||
8674 | - size_t l1, l2; | ||
8675 | - char *old_res_ptr; | ||
8676 | - | ||
8677 | - c = getc (fp); | ||
8678 | - if (c == EOF) | ||
8679 | - break; | ||
8680 | - if (c == '\n' || c == ' ' || c == '\t') | ||
8681 | - continue; | ||
8682 | - if (c == '#') | ||
8683 | - { | ||
8684 | - /* Skip comment, to end of line. */ | ||
8685 | - do | ||
8686 | - c = getc (fp); | ||
8687 | - while (!(c == EOF || c == '\n')); | ||
8688 | - if (c == EOF) | ||
8689 | - break; | ||
8690 | - continue; | ||
8691 | - } | ||
8692 | - ungetc (c, fp); | ||
8693 | - if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) | ||
8694 | - break; | ||
8695 | - l1 = strlen (buf1); | ||
8696 | - l2 = strlen (buf2); | ||
8697 | - old_res_ptr = res_ptr; | ||
8698 | - if (res_size == 0) | ||
8699 | - { | ||
8700 | - res_size = l1 + 1 + l2 + 1; | ||
8701 | - res_ptr = (char *) malloc (res_size + 1); | ||
8702 | - } | ||
8703 | - else | ||
8704 | - { | ||
8705 | - res_size += l1 + 1 + l2 + 1; | ||
8706 | - res_ptr = (char *) realloc (res_ptr, res_size + 1); | ||
8707 | - } | ||
8708 | - if (res_ptr == NULL) | ||
8709 | - { | ||
8710 | - /* Out of memory. */ | ||
8711 | - res_size = 0; | ||
8712 | - if (old_res_ptr != NULL) | ||
8713 | - free (old_res_ptr); | ||
8714 | - break; | ||
8715 | - } | ||
8716 | - strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); | ||
8717 | - strcpy (res_ptr + res_size - (l2 + 1), buf2); | ||
8718 | - } | ||
8719 | - fclose (fp); | ||
8720 | - if (res_size == 0) | ||
8721 | - cp = ""; | ||
8722 | - else | ||
8723 | - { | ||
8724 | - *(res_ptr + res_size) = '\0'; | ||
8725 | - cp = res_ptr; | ||
8726 | - } | ||
8727 | - } | ||
8728 | - | ||
8729 | - if (file_name != NULL) | ||
8730 | - free (file_name); | ||
8731 | - | ||
8732 | -#else | ||
8733 | - | ||
8734 | -# if defined VMS | ||
8735 | - /* To avoid the troubles of an extra file charset.alias_vms in the | ||
8736 | - sources of many GNU packages, simply inline the aliases here. */ | ||
8737 | - /* The list of encodings is taken from the OpenVMS 7.3-1 documentation | ||
8738 | - "Compaq C Run-Time Library Reference Manual for OpenVMS systems" | ||
8739 | - section 10.7 "Handling Different Character Sets". */ | ||
8740 | - cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" | ||
8741 | - "ISO8859-2" "\0" "ISO-8859-2" "\0" | ||
8742 | - "ISO8859-5" "\0" "ISO-8859-5" "\0" | ||
8743 | - "ISO8859-7" "\0" "ISO-8859-7" "\0" | ||
8744 | - "ISO8859-8" "\0" "ISO-8859-8" "\0" | ||
8745 | - "ISO8859-9" "\0" "ISO-8859-9" "\0" | ||
8746 | - /* Japanese */ | ||
8747 | - "eucJP" "\0" "EUC-JP" "\0" | ||
8748 | - "SJIS" "\0" "SHIFT_JIS" "\0" | ||
8749 | - "DECKANJI" "\0" "DEC-KANJI" "\0" | ||
8750 | - "SDECKANJI" "\0" "EUC-JP" "\0" | ||
8751 | - /* Chinese */ | ||
8752 | - "eucTW" "\0" "EUC-TW" "\0" | ||
8753 | - "DECHANYU" "\0" "DEC-HANYU" "\0" | ||
8754 | - "DECHANZI" "\0" "GB2312" "\0" | ||
8755 | - /* Korean */ | ||
8756 | - "DECKOREAN" "\0" "EUC-KR" "\0"; | ||
8757 | -# endif | ||
8758 | - | ||
8759 | -# if defined WIN32_NATIVE || defined __CYGWIN__ | ||
8760 | - /* To avoid the troubles of installing a separate file in the same | ||
8761 | - directory as the DLL and of retrieving the DLL's directory at | ||
8762 | - runtime, simply inline the aliases here. */ | ||
8763 | - | ||
8764 | - cp = "CP936" "\0" "GBK" "\0" | ||
8765 | - "CP1361" "\0" "JOHAB" "\0" | ||
8766 | - "CP20127" "\0" "ASCII" "\0" | ||
8767 | - "CP20866" "\0" "KOI8-R" "\0" | ||
8768 | - "CP20936" "\0" "GB2312" "\0" | ||
8769 | - "CP21866" "\0" "KOI8-RU" "\0" | ||
8770 | - "CP28591" "\0" "ISO-8859-1" "\0" | ||
8771 | - "CP28592" "\0" "ISO-8859-2" "\0" | ||
8772 | - "CP28593" "\0" "ISO-8859-3" "\0" | ||
8773 | - "CP28594" "\0" "ISO-8859-4" "\0" | ||
8774 | - "CP28595" "\0" "ISO-8859-5" "\0" | ||
8775 | - "CP28596" "\0" "ISO-8859-6" "\0" | ||
8776 | - "CP28597" "\0" "ISO-8859-7" "\0" | ||
8777 | - "CP28598" "\0" "ISO-8859-8" "\0" | ||
8778 | - "CP28599" "\0" "ISO-8859-9" "\0" | ||
8779 | - "CP28605" "\0" "ISO-8859-15" "\0" | ||
8780 | - "CP38598" "\0" "ISO-8859-8" "\0" | ||
8781 | - "CP51932" "\0" "EUC-JP" "\0" | ||
8782 | - "CP51936" "\0" "GB2312" "\0" | ||
8783 | - "CP51949" "\0" "EUC-KR" "\0" | ||
8784 | - "CP51950" "\0" "EUC-TW" "\0" | ||
8785 | - "CP54936" "\0" "GB18030" "\0" | ||
8786 | - "CP65001" "\0" "UTF-8" "\0"; | ||
8787 | -# endif | ||
8788 | -#endif | ||
8789 | - | ||
8790 | - charset_aliases = cp; | ||
8791 | - } | ||
8792 | - | ||
8793 | - return cp; | ||
8794 | -} | ||
8795 | - | ||
8796 | -/* Determine the current locale's character encoding, and canonicalize it | ||
8797 | - into one of the canonical names listed in config.charset. | ||
8798 | - The result must not be freed; it is statically allocated. | ||
8799 | - If the canonical name cannot be determined, the result is a non-canonical | ||
8800 | - name. */ | ||
8801 | - | ||
8802 | -#ifdef STATIC | ||
8803 | -STATIC | ||
8804 | -#endif | ||
8805 | -const char * | ||
8806 | -locale_charset (void) | ||
8807 | -{ | ||
8808 | - const char *codeset; | ||
8809 | - const char *aliases; | ||
8810 | - | ||
8811 | -#if !(defined WIN32_NATIVE || defined OS2) | ||
8812 | - | ||
8813 | -# if HAVE_LANGINFO_CODESET | ||
8814 | - | ||
8815 | - /* Most systems support nl_langinfo (CODESET) nowadays. */ | ||
8816 | - codeset = nl_langinfo (CODESET); | ||
8817 | - | ||
8818 | -# ifdef __CYGWIN__ | ||
8819 | - /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always | ||
8820 | - returns "US-ASCII". As long as this is not fixed, return the suffix | ||
8821 | - of the locale name from the environment variables (if present) or | ||
8822 | - the codepage as a number. */ | ||
8823 | - if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) | ||
8824 | - { | ||
8825 | - const char *locale; | ||
8826 | - static char buf[2 + 10 + 1]; | ||
8827 | - | ||
8828 | - locale = getenv ("LC_ALL"); | ||
8829 | - if (locale == NULL || locale[0] == '\0') | ||
8830 | - { | ||
8831 | - locale = getenv ("LC_CTYPE"); | ||
8832 | - if (locale == NULL || locale[0] == '\0') | ||
8833 | - locale = getenv ("LANG"); | ||
8834 | - } | ||
8835 | - if (locale != NULL && locale[0] != '\0') | ||
8836 | - { | ||
8837 | - /* If the locale name contains an encoding after the dot, return | ||
8838 | - it. */ | ||
8839 | - const char *dot = strchr (locale, '.'); | ||
8840 | - | ||
8841 | - if (dot != NULL) | ||
8842 | - { | ||
8843 | - const char *modifier; | ||
8844 | - | ||
8845 | - dot++; | ||
8846 | - /* Look for the possible @... trailer and remove it, if any. */ | ||
8847 | - modifier = strchr (dot, '@'); | ||
8848 | - if (modifier == NULL) | ||
8849 | - return dot; | ||
8850 | - if (modifier - dot < sizeof (buf)) | ||
8851 | - { | ||
8852 | - memcpy (buf, dot, modifier - dot); | ||
8853 | - buf [modifier - dot] = '\0'; | ||
8854 | - return buf; | ||
8855 | - } | ||
8856 | - } | ||
8857 | - } | ||
8858 | - | ||
8859 | - /* Woe32 has a function returning the locale's codepage as a number. */ | ||
8860 | - sprintf (buf, "CP%u", GetACP ()); | ||
8861 | - codeset = buf; | ||
8862 | - } | ||
8863 | -# endif | ||
8864 | - | ||
8865 | -# else | ||
8866 | - | ||
8867 | - /* On old systems which lack it, use setlocale or getenv. */ | ||
8868 | - const char *locale = NULL; | ||
8869 | - | ||
8870 | - /* But most old systems don't have a complete set of locales. Some | ||
8871 | - (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't | ||
8872 | - use setlocale here; it would return "C" when it doesn't support the | ||
8873 | - locale name the user has set. */ | ||
8874 | -# if 0 | ||
8875 | - locale = setlocale (LC_CTYPE, NULL); | ||
8876 | -# endif | ||
8877 | - if (locale == NULL || locale[0] == '\0') | ||
8878 | - { | ||
8879 | - locale = getenv ("LC_ALL"); | ||
8880 | - if (locale == NULL || locale[0] == '\0') | ||
8881 | - { | ||
8882 | - locale = getenv ("LC_CTYPE"); | ||
8883 | - if (locale == NULL || locale[0] == '\0') | ||
8884 | - locale = getenv ("LANG"); | ||
8885 | - } | ||
8886 | - } | ||
8887 | - | ||
8888 | - /* On some old systems, one used to set locale = "iso8859_1". On others, | ||
8889 | - you set it to "language_COUNTRY.charset". In any case, we resolve it | ||
8890 | - through the charset.alias file. */ | ||
8891 | - codeset = locale; | ||
8892 | - | ||
8893 | -# endif | ||
8894 | - | ||
8895 | -#elif defined WIN32_NATIVE | ||
8896 | - | ||
8897 | - static char buf[2 + 10 + 1]; | ||
8898 | - | ||
8899 | - /* Woe32 has a function returning the locale's codepage as a number. */ | ||
8900 | - sprintf (buf, "CP%u", GetACP ()); | ||
8901 | - codeset = buf; | ||
8902 | - | ||
8903 | -#elif defined OS2 | ||
8904 | - | ||
8905 | - const char *locale; | ||
8906 | - static char buf[2 + 10 + 1]; | ||
8907 | - ULONG cp[3]; | ||
8908 | - ULONG cplen; | ||
8909 | - | ||
8910 | - /* Allow user to override the codeset, as set in the operating system, | ||
8911 | - with standard language environment variables. */ | ||
8912 | - locale = getenv ("LC_ALL"); | ||
8913 | - if (locale == NULL || locale[0] == '\0') | ||
8914 | - { | ||
8915 | - locale = getenv ("LC_CTYPE"); | ||
8916 | - if (locale == NULL || locale[0] == '\0') | ||
8917 | - locale = getenv ("LANG"); | ||
8918 | - } | ||
8919 | - if (locale != NULL && locale[0] != '\0') | ||
8920 | - { | ||
8921 | - /* If the locale name contains an encoding after the dot, return it. */ | ||
8922 | - const char *dot = strchr (locale, '.'); | ||
8923 | - | ||
8924 | - if (dot != NULL) | ||
8925 | - { | ||
8926 | - const char *modifier; | ||
8927 | - | ||
8928 | - dot++; | ||
8929 | - /* Look for the possible @... trailer and remove it, if any. */ | ||
8930 | - modifier = strchr (dot, '@'); | ||
8931 | - if (modifier == NULL) | ||
8932 | - return dot; | ||
8933 | - if (modifier - dot < sizeof (buf)) | ||
8934 | - { | ||
8935 | - memcpy (buf, dot, modifier - dot); | ||
8936 | - buf [modifier - dot] = '\0'; | ||
8937 | - return buf; | ||
8938 | - } | ||
8939 | - } | ||
8940 | - | ||
8941 | - /* Resolve through the charset.alias file. */ | ||
8942 | - codeset = locale; | ||
8943 | - } | ||
8944 | - else | ||
8945 | - { | ||
8946 | - /* OS/2 has a function returning the locale's codepage as a number. */ | ||
8947 | - if (DosQueryCp (sizeof (cp), cp, &cplen)) | ||
8948 | - codeset = ""; | ||
8949 | - else | ||
8950 | - { | ||
8951 | - sprintf (buf, "CP%u", cp[0]); | ||
8952 | - codeset = buf; | ||
8953 | - } | ||
8954 | - } | ||
8955 | - | ||
8956 | -#endif | ||
8957 | - | ||
8958 | - if (codeset == NULL) | ||
8959 | - /* The canonical name cannot be determined. */ | ||
8960 | - codeset = ""; | ||
8961 | - | ||
8962 | - /* Resolve alias. */ | ||
8963 | - for (aliases = get_charset_aliases (); | ||
8964 | - *aliases != '\0'; | ||
8965 | - aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) | ||
8966 | - if (strcmp (codeset, aliases) == 0 | ||
8967 | - || (aliases[0] == '*' && aliases[1] == '\0')) | ||
8968 | - { | ||
8969 | - codeset = aliases + strlen (aliases) + 1; | ||
8970 | - break; | ||
8971 | - } | ||
8972 | - | ||
8973 | - /* Don't return an empty string. GNU libc and GNU libiconv interpret | ||
8974 | - the empty string as denoting "the locale's character encoding", | ||
8975 | - thus GNU libiconv would call this function a second time. */ | ||
8976 | - if (codeset[0] == '\0') | ||
8977 | - codeset = "ASCII"; | ||
8978 | - | ||
8979 | - return codeset; | ||
8980 | -} | ||
8981 | --- a/intl/localcharset.h | ||
8982 | +++ /dev/null | ||
8983 | @@ -1,42 +0,0 @@ | ||
8984 | -/* Determine a canonical name for the current locale's character encoding. | ||
8985 | - Copyright (C) 2000-2003 Free Software Foundation, Inc. | ||
8986 | - This file is part of the GNU CHARSET Library. | ||
8987 | - | ||
8988 | - This program is free software; you can redistribute it and/or modify it | ||
8989 | - under the terms of the GNU Library General Public License as published | ||
8990 | - by the Free Software Foundation; either version 2, or (at your option) | ||
8991 | - any later version. | ||
8992 | - | ||
8993 | - This program is distributed in the hope that it will be useful, | ||
8994 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
8995 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
8996 | - Library General Public License for more details. | ||
8997 | - | ||
8998 | - You should have received a copy of the GNU Library General Public | ||
8999 | - License along with this program; if not, write to the Free Software | ||
9000 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
9001 | - USA. */ | ||
9002 | - | ||
9003 | -#ifndef _LOCALCHARSET_H | ||
9004 | -#define _LOCALCHARSET_H | ||
9005 | - | ||
9006 | - | ||
9007 | -#ifdef __cplusplus | ||
9008 | -extern "C" { | ||
9009 | -#endif | ||
9010 | - | ||
9011 | - | ||
9012 | -/* Determine the current locale's character encoding, and canonicalize it | ||
9013 | - into one of the canonical names listed in config.charset. | ||
9014 | - The result must not be freed; it is statically allocated. | ||
9015 | - If the canonical name cannot be determined, the result is a non-canonical | ||
9016 | - name. */ | ||
9017 | -extern const char * locale_charset (void); | ||
9018 | - | ||
9019 | - | ||
9020 | -#ifdef __cplusplus | ||
9021 | -} | ||
9022 | -#endif | ||
9023 | - | ||
9024 | - | ||
9025 | -#endif /* _LOCALCHARSET_H */ | ||
9026 | --- a/intl/locale.alias | ||
9027 | +++ /dev/null | ||
9028 | @@ -1,77 +0,0 @@ | ||
9029 | -# Locale name alias data base. | ||
9030 | -# Copyright (C) 1996-2001,2003,2007 Free Software Foundation, Inc. | ||
9031 | -# | ||
9032 | -# This program is free software; you can redistribute it and/or modify it | ||
9033 | -# under the terms of the GNU Library General Public License as published | ||
9034 | -# by the Free Software Foundation; either version 2, or (at your option) | ||
9035 | -# any later version. | ||
9036 | -# | ||
9037 | -# This program is distributed in the hope that it will be useful, | ||
9038 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9039 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
9040 | -# Library General Public License for more details. | ||
9041 | -# | ||
9042 | -# You should have received a copy of the GNU Library General Public | ||
9043 | -# License along with this program; if not, write to the Free Software | ||
9044 | -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
9045 | -# USA. | ||
9046 | - | ||
9047 | -# The format of this file is the same as for the corresponding file of | ||
9048 | -# the X Window System, which normally can be found in | ||
9049 | -# /usr/lib/X11/locale/locale.alias | ||
9050 | -# A single line contains two fields: an alias and a substitution value. | ||
9051 | -# All entries are case independent. | ||
9052 | - | ||
9053 | -# Note: This file is obsolete and is kept around for the time being for | ||
9054 | -# backward compatibility. Nobody should rely on the names defined here. | ||
9055 | -# Locales should always be specified by their full name. | ||
9056 | - | ||
9057 | -# Packages using this file: | ||
9058 | - | ||
9059 | -bokmal nb_NO.ISO-8859-1 | ||
9060 | -bokmål nb_NO.ISO-8859-1 | ||
9061 | -catalan ca_ES.ISO-8859-1 | ||
9062 | -croatian hr_HR.ISO-8859-2 | ||
9063 | -czech cs_CZ.ISO-8859-2 | ||
9064 | -danish da_DK.ISO-8859-1 | ||
9065 | -dansk da_DK.ISO-8859-1 | ||
9066 | -deutsch de_DE.ISO-8859-1 | ||
9067 | -dutch nl_NL.ISO-8859-1 | ||
9068 | -eesti et_EE.ISO-8859-1 | ||
9069 | -estonian et_EE.ISO-8859-1 | ||
9070 | -finnish fi_FI.ISO-8859-1 | ||
9071 | -français fr_FR.ISO-8859-1 | ||
9072 | -french fr_FR.ISO-8859-1 | ||
9073 | -galego gl_ES.ISO-8859-1 | ||
9074 | -galician gl_ES.ISO-8859-1 | ||
9075 | -german de_DE.ISO-8859-1 | ||
9076 | -greek el_GR.ISO-8859-7 | ||
9077 | -hebrew he_IL.ISO-8859-8 | ||
9078 | -hrvatski hr_HR.ISO-8859-2 | ||
9079 | -hungarian hu_HU.ISO-8859-2 | ||
9080 | -icelandic is_IS.ISO-8859-1 | ||
9081 | -italian it_IT.ISO-8859-1 | ||
9082 | -japanese ja_JP.eucJP | ||
9083 | -japanese.euc ja_JP.eucJP | ||
9084 | -ja_JP ja_JP.eucJP | ||
9085 | -ja_JP.ujis ja_JP.eucJP | ||
9086 | -japanese.sjis ja_JP.SJIS | ||
9087 | -korean ko_KR.eucKR | ||
9088 | -korean.euc ko_KR.eucKR | ||
9089 | -ko_KR ko_KR.eucKR | ||
9090 | -lithuanian lt_LT.ISO-8859-13 | ||
9091 | -no_NO nb_NO.ISO-8859-1 | ||
9092 | -no_NO.ISO-8859-1 nb_NO.ISO-8859-1 | ||
9093 | -norwegian nb_NO.ISO-8859-1 | ||
9094 | -nynorsk nn_NO.ISO-8859-1 | ||
9095 | -polish pl_PL.ISO-8859-2 | ||
9096 | -portuguese pt_PT.ISO-8859-1 | ||
9097 | -romanian ro_RO.ISO-8859-2 | ||
9098 | -russian ru_RU.ISO-8859-5 | ||
9099 | -slovak sk_SK.ISO-8859-2 | ||
9100 | -slovene sl_SI.ISO-8859-2 | ||
9101 | -slovenian sl_SI.ISO-8859-2 | ||
9102 | -spanish es_ES.ISO-8859-1 | ||
9103 | -swedish sv_SE.ISO-8859-1 | ||
9104 | -thai th_TH.TIS-620 | ||
9105 | -turkish tr_TR.ISO-8859-9 | ||
9106 | --- a/intl/localealias.c | ||
9107 | +++ /dev/null | ||
9108 | @@ -1,439 +0,0 @@ | ||
9109 | -/* Handle aliases for locale names. | ||
9110 | - Copyright (C) 1995-1999, 2000-2001, 2003, 2005-2006 Free Software Foundation, Inc. | ||
9111 | - | ||
9112 | - This program is free software; you can redistribute it and/or modify it | ||
9113 | - under the terms of the GNU Library General Public License as published | ||
9114 | - by the Free Software Foundation; either version 2, or (at your option) | ||
9115 | - any later version. | ||
9116 | - | ||
9117 | - This program is distributed in the hope that it will be useful, | ||
9118 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9119 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
9120 | - Library General Public License for more details. | ||
9121 | - | ||
9122 | - You should have received a copy of the GNU Library General Public | ||
9123 | - License along with this program; if not, write to the Free Software | ||
9124 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
9125 | - USA. */ | ||
9126 | - | ||
9127 | -/* Tell glibc's <string.h> to provide a prototype for mempcpy(). | ||
9128 | - This must come before <config.h> because <config.h> may include | ||
9129 | - <features.h>, and once <features.h> has been included, it's too late. */ | ||
9130 | -#ifndef _GNU_SOURCE | ||
9131 | -# define _GNU_SOURCE 1 | ||
9132 | -#endif | ||
9133 | - | ||
9134 | -#ifdef HAVE_CONFIG_H | ||
9135 | -# include <config.h> | ||
9136 | -#endif | ||
9137 | - | ||
9138 | -#include <ctype.h> | ||
9139 | -#include <stdio.h> | ||
9140 | -#if defined _LIBC || defined HAVE___FSETLOCKING | ||
9141 | -# include <stdio_ext.h> | ||
9142 | -#endif | ||
9143 | -#include <sys/types.h> | ||
9144 | - | ||
9145 | -#ifdef __GNUC__ | ||
9146 | -# undef alloca | ||
9147 | -# define alloca __builtin_alloca | ||
9148 | -# define HAVE_ALLOCA 1 | ||
9149 | -#else | ||
9150 | -# ifdef _MSC_VER | ||
9151 | -# include <malloc.h> | ||
9152 | -# define alloca _alloca | ||
9153 | -# else | ||
9154 | -# if defined HAVE_ALLOCA_H || defined _LIBC | ||
9155 | -# include <alloca.h> | ||
9156 | -# else | ||
9157 | -# ifdef _AIX | ||
9158 | - #pragma alloca | ||
9159 | -# else | ||
9160 | -# ifndef alloca | ||
9161 | -char *alloca (); | ||
9162 | -# endif | ||
9163 | -# endif | ||
9164 | -# endif | ||
9165 | -# endif | ||
9166 | -#endif | ||
9167 | - | ||
9168 | -#include <stdlib.h> | ||
9169 | -#include <string.h> | ||
9170 | - | ||
9171 | -#include "gettextP.h" | ||
9172 | - | ||
9173 | -#if ENABLE_RELOCATABLE | ||
9174 | -# include "relocatable.h" | ||
9175 | -#else | ||
9176 | -# define relocate(pathname) (pathname) | ||
9177 | -#endif | ||
9178 | - | ||
9179 | -/* @@ end of prolog @@ */ | ||
9180 | - | ||
9181 | -#ifdef _LIBC | ||
9182 | -/* Rename the non ANSI C functions. This is required by the standard | ||
9183 | - because some ANSI C functions will require linking with this object | ||
9184 | - file and the name space must not be polluted. */ | ||
9185 | -# define strcasecmp __strcasecmp | ||
9186 | - | ||
9187 | -# ifndef mempcpy | ||
9188 | -# define mempcpy __mempcpy | ||
9189 | -# endif | ||
9190 | -# define HAVE_MEMPCPY 1 | ||
9191 | -# define HAVE___FSETLOCKING 1 | ||
9192 | -#endif | ||
9193 | - | ||
9194 | -/* Handle multi-threaded applications. */ | ||
9195 | -#ifdef _LIBC | ||
9196 | -# include <bits/libc-lock.h> | ||
9197 | -#else | ||
9198 | -# include "lock.h" | ||
9199 | -#endif | ||
9200 | - | ||
9201 | -#ifndef internal_function | ||
9202 | -# define internal_function | ||
9203 | -#endif | ||
9204 | - | ||
9205 | -/* Some optimizations for glibc. */ | ||
9206 | -#ifdef _LIBC | ||
9207 | -# define FEOF(fp) feof_unlocked (fp) | ||
9208 | -# define FGETS(buf, n, fp) fgets_unlocked (buf, n, fp) | ||
9209 | -#else | ||
9210 | -# define FEOF(fp) feof (fp) | ||
9211 | -# define FGETS(buf, n, fp) fgets (buf, n, fp) | ||
9212 | -#endif | ||
9213 | - | ||
9214 | -/* For those losing systems which don't have `alloca' we have to add | ||
9215 | - some additional code emulating it. */ | ||
9216 | -#ifdef HAVE_ALLOCA | ||
9217 | -# define freea(p) /* nothing */ | ||
9218 | -#else | ||
9219 | -# define alloca(n) malloc (n) | ||
9220 | -# define freea(p) free (p) | ||
9221 | -#endif | ||
9222 | - | ||
9223 | -#if defined _LIBC_REENTRANT || HAVE_DECL_FGETS_UNLOCKED | ||
9224 | -# undef fgets | ||
9225 | -# define fgets(buf, len, s) fgets_unlocked (buf, len, s) | ||
9226 | -#endif | ||
9227 | -#if defined _LIBC_REENTRANT || HAVE_DECL_FEOF_UNLOCKED | ||
9228 | -# undef feof | ||
9229 | -# define feof(s) feof_unlocked (s) | ||
9230 | -#endif | ||
9231 | - | ||
9232 | - | ||
9233 | -__libc_lock_define_initialized (static, lock) | ||
9234 | - | ||
9235 | - | ||
9236 | -struct alias_map | ||
9237 | -{ | ||
9238 | - const char *alias; | ||
9239 | - const char *value; | ||
9240 | -}; | ||
9241 | - | ||
9242 | - | ||
9243 | -#ifndef _LIBC | ||
9244 | -# define libc_freeres_ptr(decl) decl | ||
9245 | -#endif | ||
9246 | - | ||
9247 | -libc_freeres_ptr (static char *string_space); | ||
9248 | -static size_t string_space_act; | ||
9249 | -static size_t string_space_max; | ||
9250 | -libc_freeres_ptr (static struct alias_map *map); | ||
9251 | -static size_t nmap; | ||
9252 | -static size_t maxmap; | ||
9253 | - | ||
9254 | - | ||
9255 | -/* Prototypes for local functions. */ | ||
9256 | -static size_t read_alias_file (const char *fname, int fname_len) | ||
9257 | - internal_function; | ||
9258 | -static int extend_alias_table (void); | ||
9259 | -static int alias_compare (const struct alias_map *map1, | ||
9260 | - const struct alias_map *map2); | ||
9261 | - | ||
9262 | - | ||
9263 | -const char * | ||
9264 | -_nl_expand_alias (const char *name) | ||
9265 | -{ | ||
9266 | - static const char *locale_alias_path; | ||
9267 | - struct alias_map *retval; | ||
9268 | - const char *result = NULL; | ||
9269 | - size_t added; | ||
9270 | - | ||
9271 | - __libc_lock_lock (lock); | ||
9272 | - | ||
9273 | - if (locale_alias_path == NULL) | ||
9274 | - locale_alias_path = LOCALE_ALIAS_PATH; | ||
9275 | - | ||
9276 | - do | ||
9277 | - { | ||
9278 | - struct alias_map item; | ||
9279 | - | ||
9280 | - item.alias = name; | ||
9281 | - | ||
9282 | - if (nmap > 0) | ||
9283 | - retval = (struct alias_map *) bsearch (&item, map, nmap, | ||
9284 | - sizeof (struct alias_map), | ||
9285 | - (int (*) (const void *, | ||
9286 | - const void *) | ||
9287 | - ) alias_compare); | ||
9288 | - else | ||
9289 | - retval = NULL; | ||
9290 | - | ||
9291 | - /* We really found an alias. Return the value. */ | ||
9292 | - if (retval != NULL) | ||
9293 | - { | ||
9294 | - result = retval->value; | ||
9295 | - break; | ||
9296 | - } | ||
9297 | - | ||
9298 | - /* Perhaps we can find another alias file. */ | ||
9299 | - added = 0; | ||
9300 | - while (added == 0 && locale_alias_path[0] != '\0') | ||
9301 | - { | ||
9302 | - const char *start; | ||
9303 | - | ||
9304 | - while (locale_alias_path[0] == PATH_SEPARATOR) | ||
9305 | - ++locale_alias_path; | ||
9306 | - start = locale_alias_path; | ||
9307 | - | ||
9308 | - while (locale_alias_path[0] != '\0' | ||
9309 | - && locale_alias_path[0] != PATH_SEPARATOR) | ||
9310 | - ++locale_alias_path; | ||
9311 | - | ||
9312 | - if (start < locale_alias_path) | ||
9313 | - added = read_alias_file (start, locale_alias_path - start); | ||
9314 | - } | ||
9315 | - } | ||
9316 | - while (added != 0); | ||
9317 | - | ||
9318 | - __libc_lock_unlock (lock); | ||
9319 | - | ||
9320 | - return result; | ||
9321 | -} | ||
9322 | - | ||
9323 | - | ||
9324 | -static size_t | ||
9325 | -internal_function | ||
9326 | -read_alias_file (const char *fname, int fname_len) | ||
9327 | -{ | ||
9328 | - FILE *fp; | ||
9329 | - char *full_fname; | ||
9330 | - size_t added; | ||
9331 | - static const char aliasfile[] = "/locale.alias"; | ||
9332 | - | ||
9333 | - full_fname = (char *) alloca (fname_len + sizeof aliasfile); | ||
9334 | -#ifdef HAVE_MEMPCPY | ||
9335 | - mempcpy (mempcpy (full_fname, fname, fname_len), | ||
9336 | - aliasfile, sizeof aliasfile); | ||
9337 | -#else | ||
9338 | - memcpy (full_fname, fname, fname_len); | ||
9339 | - memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile); | ||
9340 | -#endif | ||
9341 | - | ||
9342 | -#ifdef _LIBC | ||
9343 | - /* Note the file is opened with cancellation in the I/O functions | ||
9344 | - disabled. */ | ||
9345 | - fp = fopen (relocate (full_fname), "rc"); | ||
9346 | -#else | ||
9347 | - fp = fopen (relocate (full_fname), "r"); | ||
9348 | -#endif | ||
9349 | - freea (full_fname); | ||
9350 | - if (fp == NULL) | ||
9351 | - return 0; | ||
9352 | - | ||
9353 | -#ifdef HAVE___FSETLOCKING | ||
9354 | - /* No threads present. */ | ||
9355 | - __fsetlocking (fp, FSETLOCKING_BYCALLER); | ||
9356 | -#endif | ||
9357 | - | ||
9358 | - added = 0; | ||
9359 | - while (!FEOF (fp)) | ||
9360 | - { | ||
9361 | - /* It is a reasonable approach to use a fix buffer here because | ||
9362 | - a) we are only interested in the first two fields | ||
9363 | - b) these fields must be usable as file names and so must not | ||
9364 | - be that long | ||
9365 | - We avoid a multi-kilobyte buffer here since this would use up | ||
9366 | - stack space which we might not have if the program ran out of | ||
9367 | - memory. */ | ||
9368 | - char buf[400]; | ||
9369 | - char *alias; | ||
9370 | - char *value; | ||
9371 | - char *cp; | ||
9372 | - int complete_line; | ||
9373 | - | ||
9374 | - if (FGETS (buf, sizeof buf, fp) == NULL) | ||
9375 | - /* EOF reached. */ | ||
9376 | - break; | ||
9377 | - | ||
9378 | - /* Determine whether the line is complete. */ | ||
9379 | - complete_line = strchr (buf, '\n') != NULL; | ||
9380 | - | ||
9381 | - cp = buf; | ||
9382 | - /* Ignore leading white space. */ | ||
9383 | - while (isspace ((unsigned char) cp[0])) | ||
9384 | - ++cp; | ||
9385 | - | ||
9386 | - /* A leading '#' signals a comment line. */ | ||
9387 | - if (cp[0] != '\0' && cp[0] != '#') | ||
9388 | - { | ||
9389 | - alias = cp++; | ||
9390 | - while (cp[0] != '\0' && !isspace ((unsigned char) cp[0])) | ||
9391 | - ++cp; | ||
9392 | - /* Terminate alias name. */ | ||
9393 | - if (cp[0] != '\0') | ||
9394 | - *cp++ = '\0'; | ||
9395 | - | ||
9396 | - /* Now look for the beginning of the value. */ | ||
9397 | - while (isspace ((unsigned char) cp[0])) | ||
9398 | - ++cp; | ||
9399 | - | ||
9400 | - if (cp[0] != '\0') | ||
9401 | - { | ||
9402 | - value = cp++; | ||
9403 | - while (cp[0] != '\0' && !isspace ((unsigned char) cp[0])) | ||
9404 | - ++cp; | ||
9405 | - /* Terminate value. */ | ||
9406 | - if (cp[0] == '\n') | ||
9407 | - { | ||
9408 | - /* This has to be done to make the following test | ||
9409 | - for the end of line possible. We are looking for | ||
9410 | - the terminating '\n' which do not overwrite here. */ | ||
9411 | - *cp++ = '\0'; | ||
9412 | - *cp = '\n'; | ||
9413 | - } | ||
9414 | - else if (cp[0] != '\0') | ||
9415 | - *cp++ = '\0'; | ||
9416 | - | ||
9417 | -#ifdef IN_LIBGLOCALE | ||
9418 | - /* glibc's locale.alias contains entries for ja_JP and ko_KR | ||
9419 | - that make it impossible to use a Japanese or Korean UTF-8 | ||
9420 | - locale under the name "ja_JP" or "ko_KR". Ignore these | ||
9421 | - entries. */ | ||
9422 | - if (strchr (alias, '_') == NULL) | ||
9423 | -#endif | ||
9424 | - { | ||
9425 | - size_t alias_len; | ||
9426 | - size_t value_len; | ||
9427 | - | ||
9428 | - if (nmap >= maxmap) | ||
9429 | - if (__builtin_expect (extend_alias_table (), 0)) | ||
9430 | - goto out; | ||
9431 | - | ||
9432 | - alias_len = strlen (alias) + 1; | ||
9433 | - value_len = strlen (value) + 1; | ||
9434 | - | ||
9435 | - if (string_space_act + alias_len + value_len > string_space_max) | ||
9436 | - { | ||
9437 | - /* Increase size of memory pool. */ | ||
9438 | - size_t new_size = (string_space_max | ||
9439 | - + (alias_len + value_len > 1024 | ||
9440 | - ? alias_len + value_len : 1024)); | ||
9441 | - char *new_pool = (char *) realloc (string_space, new_size); | ||
9442 | - if (new_pool == NULL) | ||
9443 | - goto out; | ||
9444 | - | ||
9445 | - if (__builtin_expect (string_space != new_pool, 0)) | ||
9446 | - { | ||
9447 | - size_t i; | ||
9448 | - | ||
9449 | - for (i = 0; i < nmap; i++) | ||
9450 | - { | ||
9451 | - map[i].alias += new_pool - string_space; | ||
9452 | - map[i].value += new_pool - string_space; | ||
9453 | - } | ||
9454 | - } | ||
9455 | - | ||
9456 | - string_space = new_pool; | ||
9457 | - string_space_max = new_size; | ||
9458 | - } | ||
9459 | - | ||
9460 | - map[nmap].alias = | ||
9461 | - (const char *) memcpy (&string_space[string_space_act], | ||
9462 | - alias, alias_len); | ||
9463 | - string_space_act += alias_len; | ||
9464 | - | ||
9465 | - map[nmap].value = | ||
9466 | - (const char *) memcpy (&string_space[string_space_act], | ||
9467 | - value, value_len); | ||
9468 | - string_space_act += value_len; | ||
9469 | - | ||
9470 | - ++nmap; | ||
9471 | - ++added; | ||
9472 | - } | ||
9473 | - } | ||
9474 | - } | ||
9475 | - | ||
9476 | - /* Possibly not the whole line fits into the buffer. Ignore | ||
9477 | - the rest of the line. */ | ||
9478 | - if (! complete_line) | ||
9479 | - do | ||
9480 | - if (FGETS (buf, sizeof buf, fp) == NULL) | ||
9481 | - /* Make sure the inner loop will be left. The outer loop | ||
9482 | - will exit at the `feof' test. */ | ||
9483 | - break; | ||
9484 | - while (strchr (buf, '\n') == NULL); | ||
9485 | - } | ||
9486 | - | ||
9487 | - out: | ||
9488 | - /* Should we test for ferror()? I think we have to silently ignore | ||
9489 | - errors. --drepper */ | ||
9490 | - fclose (fp); | ||
9491 | - | ||
9492 | - if (added > 0) | ||
9493 | - qsort (map, nmap, sizeof (struct alias_map), | ||
9494 | - (int (*) (const void *, const void *)) alias_compare); | ||
9495 | - | ||
9496 | - return added; | ||
9497 | -} | ||
9498 | - | ||
9499 | - | ||
9500 | -static int | ||
9501 | -extend_alias_table () | ||
9502 | -{ | ||
9503 | - size_t new_size; | ||
9504 | - struct alias_map *new_map; | ||
9505 | - | ||
9506 | - new_size = maxmap == 0 ? 100 : 2 * maxmap; | ||
9507 | - new_map = (struct alias_map *) realloc (map, (new_size | ||
9508 | - * sizeof (struct alias_map))); | ||
9509 | - if (new_map == NULL) | ||
9510 | - /* Simply don't extend: we don't have any more core. */ | ||
9511 | - return -1; | ||
9512 | - | ||
9513 | - map = new_map; | ||
9514 | - maxmap = new_size; | ||
9515 | - return 0; | ||
9516 | -} | ||
9517 | - | ||
9518 | - | ||
9519 | -static int | ||
9520 | -alias_compare (const struct alias_map *map1, const struct alias_map *map2) | ||
9521 | -{ | ||
9522 | -#if defined _LIBC || defined HAVE_STRCASECMP | ||
9523 | - return strcasecmp (map1->alias, map2->alias); | ||
9524 | -#else | ||
9525 | - const unsigned char *p1 = (const unsigned char *) map1->alias; | ||
9526 | - const unsigned char *p2 = (const unsigned char *) map2->alias; | ||
9527 | - unsigned char c1, c2; | ||
9528 | - | ||
9529 | - if (p1 == p2) | ||
9530 | - return 0; | ||
9531 | - | ||
9532 | - do | ||
9533 | - { | ||
9534 | - /* I know this seems to be odd but the tolower() function in | ||
9535 | - some systems libc cannot handle nonalpha characters. */ | ||
9536 | - c1 = isupper (*p1) ? tolower (*p1) : *p1; | ||
9537 | - c2 = isupper (*p2) ? tolower (*p2) : *p2; | ||
9538 | - if (c1 == '\0') | ||
9539 | - break; | ||
9540 | - ++p1; | ||
9541 | - ++p2; | ||
9542 | - } | ||
9543 | - while (c1 == c2); | ||
9544 | - | ||
9545 | - return c1 - c2; | ||
9546 | -#endif | ||
9547 | -} | ||
9548 | --- a/intl/localename.c | ||
9549 | +++ /dev/null | ||
9550 | @@ -1,1507 +0,0 @@ | ||
9551 | -/* Determine name of the currently selected locale. | ||
9552 | - Copyright (C) 1995-1999, 2000-2007 Free Software Foundation, Inc. | ||
9553 | - | ||
9554 | - This program is free software; you can redistribute it and/or modify it | ||
9555 | - under the terms of the GNU Library General Public License as published | ||
9556 | - by the Free Software Foundation; either version 2, or (at your option) | ||
9557 | - any later version. | ||
9558 | - | ||
9559 | - This program is distributed in the hope that it will be useful, | ||
9560 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9561 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
9562 | - Library General Public License for more details. | ||
9563 | - | ||
9564 | - You should have received a copy of the GNU Library General Public | ||
9565 | - License along with this program; if not, write to the Free Software | ||
9566 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
9567 | - USA. */ | ||
9568 | - | ||
9569 | -/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */ | ||
9570 | -/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */ | ||
9571 | -/* MacOS X code written by Bruno Haible <bruno@clisp.org>. */ | ||
9572 | - | ||
9573 | -#include <config.h> | ||
9574 | - | ||
9575 | -/* Specification. */ | ||
9576 | -#ifdef IN_LIBINTL | ||
9577 | -# include "gettextP.h" | ||
9578 | -#else | ||
9579 | -# include "localename.h" | ||
9580 | -#endif | ||
9581 | - | ||
9582 | -#include <stdlib.h> | ||
9583 | -#include <locale.h> | ||
9584 | - | ||
9585 | -#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE | ||
9586 | -# include <string.h> | ||
9587 | -# include <CoreFoundation/CFString.h> | ||
9588 | -# if HAVE_CFLOCALECOPYCURRENT | ||
9589 | -# include <CoreFoundation/CFLocale.h> | ||
9590 | -# elif HAVE_CFPREFERENCESCOPYAPPVALUE | ||
9591 | -# include <CoreFoundation/CFPreferences.h> | ||
9592 | -# endif | ||
9593 | -#endif | ||
9594 | - | ||
9595 | -#if defined _WIN32 || defined __WIN32__ | ||
9596 | -# define WIN32_NATIVE | ||
9597 | -#endif | ||
9598 | - | ||
9599 | -#ifdef WIN32_NATIVE | ||
9600 | -# define WIN32_LEAN_AND_MEAN | ||
9601 | -# include <windows.h> | ||
9602 | -/* List of language codes, sorted by value: | ||
9603 | - 0x01 LANG_ARABIC | ||
9604 | - 0x02 LANG_BULGARIAN | ||
9605 | - 0x03 LANG_CATALAN | ||
9606 | - 0x04 LANG_CHINESE | ||
9607 | - 0x05 LANG_CZECH | ||
9608 | - 0x06 LANG_DANISH | ||
9609 | - 0x07 LANG_GERMAN | ||
9610 | - 0x08 LANG_GREEK | ||
9611 | - 0x09 LANG_ENGLISH | ||
9612 | - 0x0a LANG_SPANISH | ||
9613 | - 0x0b LANG_FINNISH | ||
9614 | - 0x0c LANG_FRENCH | ||
9615 | - 0x0d LANG_HEBREW | ||
9616 | - 0x0e LANG_HUNGARIAN | ||
9617 | - 0x0f LANG_ICELANDIC | ||
9618 | - 0x10 LANG_ITALIAN | ||
9619 | - 0x11 LANG_JAPANESE | ||
9620 | - 0x12 LANG_KOREAN | ||
9621 | - 0x13 LANG_DUTCH | ||
9622 | - 0x14 LANG_NORWEGIAN | ||
9623 | - 0x15 LANG_POLISH | ||
9624 | - 0x16 LANG_PORTUGUESE | ||
9625 | - 0x17 LANG_RHAETO_ROMANCE | ||
9626 | - 0x18 LANG_ROMANIAN | ||
9627 | - 0x19 LANG_RUSSIAN | ||
9628 | - 0x1a LANG_CROATIAN == LANG_SERBIAN | ||
9629 | - 0x1b LANG_SLOVAK | ||
9630 | - 0x1c LANG_ALBANIAN | ||
9631 | - 0x1d LANG_SWEDISH | ||
9632 | - 0x1e LANG_THAI | ||
9633 | - 0x1f LANG_TURKISH | ||
9634 | - 0x20 LANG_URDU | ||
9635 | - 0x21 LANG_INDONESIAN | ||
9636 | - 0x22 LANG_UKRAINIAN | ||
9637 | - 0x23 LANG_BELARUSIAN | ||
9638 | - 0x24 LANG_SLOVENIAN | ||
9639 | - 0x25 LANG_ESTONIAN | ||
9640 | - 0x26 LANG_LATVIAN | ||
9641 | - 0x27 LANG_LITHUANIAN | ||
9642 | - 0x28 LANG_TAJIK | ||
9643 | - 0x29 LANG_FARSI | ||
9644 | - 0x2a LANG_VIETNAMESE | ||
9645 | - 0x2b LANG_ARMENIAN | ||
9646 | - 0x2c LANG_AZERI | ||
9647 | - 0x2d LANG_BASQUE | ||
9648 | - 0x2e LANG_SORBIAN | ||
9649 | - 0x2f LANG_MACEDONIAN | ||
9650 | - 0x30 LANG_SUTU | ||
9651 | - 0x31 LANG_TSONGA | ||
9652 | - 0x32 LANG_TSWANA | ||
9653 | - 0x33 LANG_VENDA | ||
9654 | - 0x34 LANG_XHOSA | ||
9655 | - 0x35 LANG_ZULU | ||
9656 | - 0x36 LANG_AFRIKAANS | ||
9657 | - 0x37 LANG_GEORGIAN | ||
9658 | - 0x38 LANG_FAEROESE | ||
9659 | - 0x39 LANG_HINDI | ||
9660 | - 0x3a LANG_MALTESE | ||
9661 | - 0x3b LANG_SAAMI | ||
9662 | - 0x3c LANG_GAELIC | ||
9663 | - 0x3d LANG_YIDDISH | ||
9664 | - 0x3e LANG_MALAY | ||
9665 | - 0x3f LANG_KAZAK | ||
9666 | - 0x40 LANG_KYRGYZ | ||
9667 | - 0x41 LANG_SWAHILI | ||
9668 | - 0x42 LANG_TURKMEN | ||
9669 | - 0x43 LANG_UZBEK | ||
9670 | - 0x44 LANG_TATAR | ||
9671 | - 0x45 LANG_BENGALI | ||
9672 | - 0x46 LANG_PUNJABI | ||
9673 | - 0x47 LANG_GUJARATI | ||
9674 | - 0x48 LANG_ORIYA | ||
9675 | - 0x49 LANG_TAMIL | ||
9676 | - 0x4a LANG_TELUGU | ||
9677 | - 0x4b LANG_KANNADA | ||
9678 | - 0x4c LANG_MALAYALAM | ||
9679 | - 0x4d LANG_ASSAMESE | ||
9680 | - 0x4e LANG_MARATHI | ||
9681 | - 0x4f LANG_SANSKRIT | ||
9682 | - 0x50 LANG_MONGOLIAN | ||
9683 | - 0x51 LANG_TIBETAN | ||
9684 | - 0x52 LANG_WELSH | ||
9685 | - 0x53 LANG_CAMBODIAN | ||
9686 | - 0x54 LANG_LAO | ||
9687 | - 0x55 LANG_BURMESE | ||
9688 | - 0x56 LANG_GALICIAN | ||
9689 | - 0x57 LANG_KONKANI | ||
9690 | - 0x58 LANG_MANIPURI | ||
9691 | - 0x59 LANG_SINDHI | ||
9692 | - 0x5a LANG_SYRIAC | ||
9693 | - 0x5b LANG_SINHALESE | ||
9694 | - 0x5c LANG_CHEROKEE | ||
9695 | - 0x5d LANG_INUKTITUT | ||
9696 | - 0x5e LANG_AMHARIC | ||
9697 | - 0x5f LANG_TAMAZIGHT | ||
9698 | - 0x60 LANG_KASHMIRI | ||
9699 | - 0x61 LANG_NEPALI | ||
9700 | - 0x62 LANG_FRISIAN | ||
9701 | - 0x63 LANG_PASHTO | ||
9702 | - 0x64 LANG_TAGALOG | ||
9703 | - 0x65 LANG_DIVEHI | ||
9704 | - 0x66 LANG_EDO | ||
9705 | - 0x67 LANG_FULFULDE | ||
9706 | - 0x68 LANG_HAUSA | ||
9707 | - 0x69 LANG_IBIBIO | ||
9708 | - 0x6a LANG_YORUBA | ||
9709 | - 0x70 LANG_IGBO | ||
9710 | - 0x71 LANG_KANURI | ||
9711 | - 0x72 LANG_OROMO | ||
9712 | - 0x73 LANG_TIGRINYA | ||
9713 | - 0x74 LANG_GUARANI | ||
9714 | - 0x75 LANG_HAWAIIAN | ||
9715 | - 0x76 LANG_LATIN | ||
9716 | - 0x77 LANG_SOMALI | ||
9717 | - 0x78 LANG_YI | ||
9718 | - 0x79 LANG_PAPIAMENTU | ||
9719 | -*/ | ||
9720 | -/* Mingw headers don't have latest language and sublanguage codes. */ | ||
9721 | -# ifndef LANG_AFRIKAANS | ||
9722 | -# define LANG_AFRIKAANS 0x36 | ||
9723 | -# endif | ||
9724 | -# ifndef LANG_ALBANIAN | ||
9725 | -# define LANG_ALBANIAN 0x1c | ||
9726 | -# endif | ||
9727 | -# ifndef LANG_AMHARIC | ||
9728 | -# define LANG_AMHARIC 0x5e | ||
9729 | -# endif | ||
9730 | -# ifndef LANG_ARABIC | ||
9731 | -# define LANG_ARABIC 0x01 | ||
9732 | -# endif | ||
9733 | -# ifndef LANG_ARMENIAN | ||
9734 | -# define LANG_ARMENIAN 0x2b | ||
9735 | -# endif | ||
9736 | -# ifndef LANG_ASSAMESE | ||
9737 | -# define LANG_ASSAMESE 0x4d | ||
9738 | -# endif | ||
9739 | -# ifndef LANG_AZERI | ||
9740 | -# define LANG_AZERI 0x2c | ||
9741 | -# endif | ||
9742 | -# ifndef LANG_BASQUE | ||
9743 | -# define LANG_BASQUE 0x2d | ||
9744 | -# endif | ||
9745 | -# ifndef LANG_BELARUSIAN | ||
9746 | -# define LANG_BELARUSIAN 0x23 | ||
9747 | -# endif | ||
9748 | -# ifndef LANG_BENGALI | ||
9749 | -# define LANG_BENGALI 0x45 | ||
9750 | -# endif | ||
9751 | -# ifndef LANG_BURMESE | ||
9752 | -# define LANG_BURMESE 0x55 | ||
9753 | -# endif | ||
9754 | -# ifndef LANG_CAMBODIAN | ||
9755 | -# define LANG_CAMBODIAN 0x53 | ||
9756 | -# endif | ||
9757 | -# ifndef LANG_CATALAN | ||
9758 | -# define LANG_CATALAN 0x03 | ||
9759 | -# endif | ||
9760 | -# ifndef LANG_CHEROKEE | ||
9761 | -# define LANG_CHEROKEE 0x5c | ||
9762 | -# endif | ||
9763 | -# ifndef LANG_DIVEHI | ||
9764 | -# define LANG_DIVEHI 0x65 | ||
9765 | -# endif | ||
9766 | -# ifndef LANG_EDO | ||
9767 | -# define LANG_EDO 0x66 | ||
9768 | -# endif | ||
9769 | -# ifndef LANG_ESTONIAN | ||
9770 | -# define LANG_ESTONIAN 0x25 | ||
9771 | -# endif | ||
9772 | -# ifndef LANG_FAEROESE | ||
9773 | -# define LANG_FAEROESE 0x38 | ||
9774 | -# endif | ||
9775 | -# ifndef LANG_FARSI | ||
9776 | -# define LANG_FARSI 0x29 | ||
9777 | -# endif | ||
9778 | -# ifndef LANG_FRISIAN | ||
9779 | -# define LANG_FRISIAN 0x62 | ||
9780 | -# endif | ||
9781 | -# ifndef LANG_FULFULDE | ||
9782 | -# define LANG_FULFULDE 0x67 | ||
9783 | -# endif | ||
9784 | -# ifndef LANG_GAELIC | ||
9785 | -# define LANG_GAELIC 0x3c | ||
9786 | -# endif | ||
9787 | -# ifndef LANG_GALICIAN | ||
9788 | -# define LANG_GALICIAN 0x56 | ||
9789 | -# endif | ||
9790 | -# ifndef LANG_GEORGIAN | ||
9791 | -# define LANG_GEORGIAN 0x37 | ||
9792 | -# endif | ||
9793 | -# ifndef LANG_GUARANI | ||
9794 | -# define LANG_GUARANI 0x74 | ||
9795 | -# endif | ||
9796 | -# ifndef LANG_GUJARATI | ||
9797 | -# define LANG_GUJARATI 0x47 | ||
9798 | -# endif | ||
9799 | -# ifndef LANG_HAUSA | ||
9800 | -# define LANG_HAUSA 0x68 | ||
9801 | -# endif | ||
9802 | -# ifndef LANG_HAWAIIAN | ||
9803 | -# define LANG_HAWAIIAN 0x75 | ||
9804 | -# endif | ||
9805 | -# ifndef LANG_HEBREW | ||
9806 | -# define LANG_HEBREW 0x0d | ||
9807 | -# endif | ||
9808 | -# ifndef LANG_HINDI | ||
9809 | -# define LANG_HINDI 0x39 | ||
9810 | -# endif | ||
9811 | -# ifndef LANG_IBIBIO | ||
9812 | -# define LANG_IBIBIO 0x69 | ||
9813 | -# endif | ||
9814 | -# ifndef LANG_IGBO | ||
9815 | -# define LANG_IGBO 0x70 | ||
9816 | -# endif | ||
9817 | -# ifndef LANG_INDONESIAN | ||
9818 | -# define LANG_INDONESIAN 0x21 | ||
9819 | -# endif | ||
9820 | -# ifndef LANG_INUKTITUT | ||
9821 | -# define LANG_INUKTITUT 0x5d | ||
9822 | -# endif | ||
9823 | -# ifndef LANG_KANNADA | ||
9824 | -# define LANG_KANNADA 0x4b | ||
9825 | -# endif | ||
9826 | -# ifndef LANG_KANURI | ||
9827 | -# define LANG_KANURI 0x71 | ||
9828 | -# endif | ||
9829 | -# ifndef LANG_KASHMIRI | ||
9830 | -# define LANG_KASHMIRI 0x60 | ||
9831 | -# endif | ||
9832 | -# ifndef LANG_KAZAK | ||
9833 | -# define LANG_KAZAK 0x3f | ||
9834 | -# endif | ||
9835 | -# ifndef LANG_KONKANI | ||
9836 | -# define LANG_KONKANI 0x57 | ||
9837 | -# endif | ||
9838 | -# ifndef LANG_KYRGYZ | ||
9839 | -# define LANG_KYRGYZ 0x40 | ||
9840 | -# endif | ||
9841 | -# ifndef LANG_LAO | ||
9842 | -# define LANG_LAO 0x54 | ||
9843 | -# endif | ||
9844 | -# ifndef LANG_LATIN | ||
9845 | -# define LANG_LATIN 0x76 | ||
9846 | -# endif | ||
9847 | -# ifndef LANG_LATVIAN | ||
9848 | -# define LANG_LATVIAN 0x26 | ||
9849 | -# endif | ||
9850 | -# ifndef LANG_LITHUANIAN | ||
9851 | -# define LANG_LITHUANIAN 0x27 | ||
9852 | -# endif | ||
9853 | -# ifndef LANG_MACEDONIAN | ||
9854 | -# define LANG_MACEDONIAN 0x2f | ||
9855 | -# endif | ||
9856 | -# ifndef LANG_MALAY | ||
9857 | -# define LANG_MALAY 0x3e | ||
9858 | -# endif | ||
9859 | -# ifndef LANG_MALAYALAM | ||
9860 | -# define LANG_MALAYALAM 0x4c | ||
9861 | -# endif | ||
9862 | -# ifndef LANG_MALTESE | ||
9863 | -# define LANG_MALTESE 0x3a | ||
9864 | -# endif | ||
9865 | -# ifndef LANG_MANIPURI | ||
9866 | -# define LANG_MANIPURI 0x58 | ||
9867 | -# endif | ||
9868 | -# ifndef LANG_MARATHI | ||
9869 | -# define LANG_MARATHI 0x4e | ||
9870 | -# endif | ||
9871 | -# ifndef LANG_MONGOLIAN | ||
9872 | -# define LANG_MONGOLIAN 0x50 | ||
9873 | -# endif | ||
9874 | -# ifndef LANG_NEPALI | ||
9875 | -# define LANG_NEPALI 0x61 | ||
9876 | -# endif | ||
9877 | -# ifndef LANG_ORIYA | ||
9878 | -# define LANG_ORIYA 0x48 | ||
9879 | -# endif | ||
9880 | -# ifndef LANG_OROMO | ||
9881 | -# define LANG_OROMO 0x72 | ||
9882 | -# endif | ||
9883 | -# ifndef LANG_PAPIAMENTU | ||
9884 | -# define LANG_PAPIAMENTU 0x79 | ||
9885 | -# endif | ||
9886 | -# ifndef LANG_PASHTO | ||
9887 | -# define LANG_PASHTO 0x63 | ||
9888 | -# endif | ||
9889 | -# ifndef LANG_PUNJABI | ||
9890 | -# define LANG_PUNJABI 0x46 | ||
9891 | -# endif | ||
9892 | -# ifndef LANG_RHAETO_ROMANCE | ||
9893 | -# define LANG_RHAETO_ROMANCE 0x17 | ||
9894 | -# endif | ||
9895 | -# ifndef LANG_SAAMI | ||
9896 | -# define LANG_SAAMI 0x3b | ||
9897 | -# endif | ||
9898 | -# ifndef LANG_SANSKRIT | ||
9899 | -# define LANG_SANSKRIT 0x4f | ||
9900 | -# endif | ||
9901 | -# ifndef LANG_SERBIAN | ||
9902 | -# define LANG_SERBIAN 0x1a | ||
9903 | -# endif | ||
9904 | -# ifndef LANG_SINDHI | ||
9905 | -# define LANG_SINDHI 0x59 | ||
9906 | -# endif | ||
9907 | -# ifndef LANG_SINHALESE | ||
9908 | -# define LANG_SINHALESE 0x5b | ||
9909 | -# endif | ||
9910 | -# ifndef LANG_SLOVAK | ||
9911 | -# define LANG_SLOVAK 0x1b | ||
9912 | -# endif | ||
9913 | -# ifndef LANG_SOMALI | ||
9914 | -# define LANG_SOMALI 0x77 | ||
9915 | -# endif | ||
9916 | -# ifndef LANG_SORBIAN | ||
9917 | -# define LANG_SORBIAN 0x2e | ||
9918 | -# endif | ||
9919 | -# ifndef LANG_SUTU | ||
9920 | -# define LANG_SUTU 0x30 | ||
9921 | -# endif | ||
9922 | -# ifndef LANG_SWAHILI | ||
9923 | -# define LANG_SWAHILI 0x41 | ||
9924 | -# endif | ||
9925 | -# ifndef LANG_SYRIAC | ||
9926 | -# define LANG_SYRIAC 0x5a | ||
9927 | -# endif | ||
9928 | -# ifndef LANG_TAGALOG | ||
9929 | -# define LANG_TAGALOG 0x64 | ||
9930 | -# endif | ||
9931 | -# ifndef LANG_TAJIK | ||
9932 | -# define LANG_TAJIK 0x28 | ||
9933 | -# endif | ||
9934 | -# ifndef LANG_TAMAZIGHT | ||
9935 | -# define LANG_TAMAZIGHT 0x5f | ||
9936 | -# endif | ||
9937 | -# ifndef LANG_TAMIL | ||
9938 | -# define LANG_TAMIL 0x49 | ||
9939 | -# endif | ||
9940 | -# ifndef LANG_TATAR | ||
9941 | -# define LANG_TATAR 0x44 | ||
9942 | -# endif | ||
9943 | -# ifndef LANG_TELUGU | ||
9944 | -# define LANG_TELUGU 0x4a | ||
9945 | -# endif | ||
9946 | -# ifndef LANG_THAI | ||
9947 | -# define LANG_THAI 0x1e | ||
9948 | -# endif | ||
9949 | -# ifndef LANG_TIBETAN | ||
9950 | -# define LANG_TIBETAN 0x51 | ||
9951 | -# endif | ||
9952 | -# ifndef LANG_TIGRINYA | ||
9953 | -# define LANG_TIGRINYA 0x73 | ||
9954 | -# endif | ||
9955 | -# ifndef LANG_TSONGA | ||
9956 | -# define LANG_TSONGA 0x31 | ||
9957 | -# endif | ||
9958 | -# ifndef LANG_TSWANA | ||
9959 | -# define LANG_TSWANA 0x32 | ||
9960 | -# endif | ||
9961 | -# ifndef LANG_TURKMEN | ||
9962 | -# define LANG_TURKMEN 0x42 | ||
9963 | -# endif | ||
9964 | -# ifndef LANG_UKRAINIAN | ||
9965 | -# define LANG_UKRAINIAN 0x22 | ||
9966 | -# endif | ||
9967 | -# ifndef LANG_URDU | ||
9968 | -# define LANG_URDU 0x20 | ||
9969 | -# endif | ||
9970 | -# ifndef LANG_UZBEK | ||
9971 | -# define LANG_UZBEK 0x43 | ||
9972 | -# endif | ||
9973 | -# ifndef LANG_VENDA | ||
9974 | -# define LANG_VENDA 0x33 | ||
9975 | -# endif | ||
9976 | -# ifndef LANG_VIETNAMESE | ||
9977 | -# define LANG_VIETNAMESE 0x2a | ||
9978 | -# endif | ||
9979 | -# ifndef LANG_WELSH | ||
9980 | -# define LANG_WELSH 0x52 | ||
9981 | -# endif | ||
9982 | -# ifndef LANG_XHOSA | ||
9983 | -# define LANG_XHOSA 0x34 | ||
9984 | -# endif | ||
9985 | -# ifndef LANG_YI | ||
9986 | -# define LANG_YI 0x78 | ||
9987 | -# endif | ||
9988 | -# ifndef LANG_YIDDISH | ||
9989 | -# define LANG_YIDDISH 0x3d | ||
9990 | -# endif | ||
9991 | -# ifndef LANG_YORUBA | ||
9992 | -# define LANG_YORUBA 0x6a | ||
9993 | -# endif | ||
9994 | -# ifndef LANG_ZULU | ||
9995 | -# define LANG_ZULU 0x35 | ||
9996 | -# endif | ||
9997 | -# ifndef SUBLANG_ARABIC_SAUDI_ARABIA | ||
9998 | -# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01 | ||
9999 | -# endif | ||
10000 | -# ifndef SUBLANG_ARABIC_IRAQ | ||
10001 | -# define SUBLANG_ARABIC_IRAQ 0x02 | ||
10002 | -# endif | ||
10003 | -# ifndef SUBLANG_ARABIC_EGYPT | ||
10004 | -# define SUBLANG_ARABIC_EGYPT 0x03 | ||
10005 | -# endif | ||
10006 | -# ifndef SUBLANG_ARABIC_LIBYA | ||
10007 | -# define SUBLANG_ARABIC_LIBYA 0x04 | ||
10008 | -# endif | ||
10009 | -# ifndef SUBLANG_ARABIC_ALGERIA | ||
10010 | -# define SUBLANG_ARABIC_ALGERIA 0x05 | ||
10011 | -# endif | ||
10012 | -# ifndef SUBLANG_ARABIC_MOROCCO | ||
10013 | -# define SUBLANG_ARABIC_MOROCCO 0x06 | ||
10014 | -# endif | ||
10015 | -# ifndef SUBLANG_ARABIC_TUNISIA | ||
10016 | -# define SUBLANG_ARABIC_TUNISIA 0x07 | ||
10017 | -# endif | ||
10018 | -# ifndef SUBLANG_ARABIC_OMAN | ||
10019 | -# define SUBLANG_ARABIC_OMAN 0x08 | ||
10020 | -# endif | ||
10021 | -# ifndef SUBLANG_ARABIC_YEMEN | ||
10022 | -# define SUBLANG_ARABIC_YEMEN 0x09 | ||
10023 | -# endif | ||
10024 | -# ifndef SUBLANG_ARABIC_SYRIA | ||
10025 | -# define SUBLANG_ARABIC_SYRIA 0x0a | ||
10026 | -# endif | ||
10027 | -# ifndef SUBLANG_ARABIC_JORDAN | ||
10028 | -# define SUBLANG_ARABIC_JORDAN 0x0b | ||
10029 | -# endif | ||
10030 | -# ifndef SUBLANG_ARABIC_LEBANON | ||
10031 | -# define SUBLANG_ARABIC_LEBANON 0x0c | ||
10032 | -# endif | ||
10033 | -# ifndef SUBLANG_ARABIC_KUWAIT | ||
10034 | -# define SUBLANG_ARABIC_KUWAIT 0x0d | ||
10035 | -# endif | ||
10036 | -# ifndef SUBLANG_ARABIC_UAE | ||
10037 | -# define SUBLANG_ARABIC_UAE 0x0e | ||
10038 | -# endif | ||
10039 | -# ifndef SUBLANG_ARABIC_BAHRAIN | ||
10040 | -# define SUBLANG_ARABIC_BAHRAIN 0x0f | ||
10041 | -# endif | ||
10042 | -# ifndef SUBLANG_ARABIC_QATAR | ||
10043 | -# define SUBLANG_ARABIC_QATAR 0x10 | ||
10044 | -# endif | ||
10045 | -# ifndef SUBLANG_AZERI_LATIN | ||
10046 | -# define SUBLANG_AZERI_LATIN 0x01 | ||
10047 | -# endif | ||
10048 | -# ifndef SUBLANG_AZERI_CYRILLIC | ||
10049 | -# define SUBLANG_AZERI_CYRILLIC 0x02 | ||
10050 | -# endif | ||
10051 | -# ifndef SUBLANG_BENGALI_INDIA | ||
10052 | -# define SUBLANG_BENGALI_INDIA 0x01 | ||
10053 | -# endif | ||
10054 | -# ifndef SUBLANG_BENGALI_BANGLADESH | ||
10055 | -# define SUBLANG_BENGALI_BANGLADESH 0x02 | ||
10056 | -# endif | ||
10057 | -# ifndef SUBLANG_CHINESE_MACAU | ||
10058 | -# define SUBLANG_CHINESE_MACAU 0x05 | ||
10059 | -# endif | ||
10060 | -# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA | ||
10061 | -# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07 | ||
10062 | -# endif | ||
10063 | -# ifndef SUBLANG_ENGLISH_JAMAICA | ||
10064 | -# define SUBLANG_ENGLISH_JAMAICA 0x08 | ||
10065 | -# endif | ||
10066 | -# ifndef SUBLANG_ENGLISH_CARIBBEAN | ||
10067 | -# define SUBLANG_ENGLISH_CARIBBEAN 0x09 | ||
10068 | -# endif | ||
10069 | -# ifndef SUBLANG_ENGLISH_BELIZE | ||
10070 | -# define SUBLANG_ENGLISH_BELIZE 0x0a | ||
10071 | -# endif | ||
10072 | -# ifndef SUBLANG_ENGLISH_TRINIDAD | ||
10073 | -# define SUBLANG_ENGLISH_TRINIDAD 0x0b | ||
10074 | -# endif | ||
10075 | -# ifndef SUBLANG_ENGLISH_ZIMBABWE | ||
10076 | -# define SUBLANG_ENGLISH_ZIMBABWE 0x0c | ||
10077 | -# endif | ||
10078 | -# ifndef SUBLANG_ENGLISH_PHILIPPINES | ||
10079 | -# define SUBLANG_ENGLISH_PHILIPPINES 0x0d | ||
10080 | -# endif | ||
10081 | -# ifndef SUBLANG_ENGLISH_INDONESIA | ||
10082 | -# define SUBLANG_ENGLISH_INDONESIA 0x0e | ||
10083 | -# endif | ||
10084 | -# ifndef SUBLANG_ENGLISH_HONGKONG | ||
10085 | -# define SUBLANG_ENGLISH_HONGKONG 0x0f | ||
10086 | -# endif | ||
10087 | -# ifndef SUBLANG_ENGLISH_INDIA | ||
10088 | -# define SUBLANG_ENGLISH_INDIA 0x10 | ||
10089 | -# endif | ||
10090 | -# ifndef SUBLANG_ENGLISH_MALAYSIA | ||
10091 | -# define SUBLANG_ENGLISH_MALAYSIA 0x11 | ||
10092 | -# endif | ||
10093 | -# ifndef SUBLANG_ENGLISH_SINGAPORE | ||
10094 | -# define SUBLANG_ENGLISH_SINGAPORE 0x12 | ||
10095 | -# endif | ||
10096 | -# ifndef SUBLANG_FRENCH_LUXEMBOURG | ||
10097 | -# define SUBLANG_FRENCH_LUXEMBOURG 0x05 | ||
10098 | -# endif | ||
10099 | -# ifndef SUBLANG_FRENCH_MONACO | ||
10100 | -# define SUBLANG_FRENCH_MONACO 0x06 | ||
10101 | -# endif | ||
10102 | -# ifndef SUBLANG_FRENCH_WESTINDIES | ||
10103 | -# define SUBLANG_FRENCH_WESTINDIES 0x07 | ||
10104 | -# endif | ||
10105 | -# ifndef SUBLANG_FRENCH_REUNION | ||
10106 | -# define SUBLANG_FRENCH_REUNION 0x08 | ||
10107 | -# endif | ||
10108 | -# ifndef SUBLANG_FRENCH_CONGO | ||
10109 | -# define SUBLANG_FRENCH_CONGO 0x09 | ||
10110 | -# endif | ||
10111 | -# ifndef SUBLANG_FRENCH_SENEGAL | ||
10112 | -# define SUBLANG_FRENCH_SENEGAL 0x0a | ||
10113 | -# endif | ||
10114 | -# ifndef SUBLANG_FRENCH_CAMEROON | ||
10115 | -# define SUBLANG_FRENCH_CAMEROON 0x0b | ||
10116 | -# endif | ||
10117 | -# ifndef SUBLANG_FRENCH_COTEDIVOIRE | ||
10118 | -# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c | ||
10119 | -# endif | ||
10120 | -# ifndef SUBLANG_FRENCH_MALI | ||
10121 | -# define SUBLANG_FRENCH_MALI 0x0d | ||
10122 | -# endif | ||
10123 | -# ifndef SUBLANG_FRENCH_MOROCCO | ||
10124 | -# define SUBLANG_FRENCH_MOROCCO 0x0e | ||
10125 | -# endif | ||
10126 | -# ifndef SUBLANG_FRENCH_HAITI | ||
10127 | -# define SUBLANG_FRENCH_HAITI 0x0f | ||
10128 | -# endif | ||
10129 | -# ifndef SUBLANG_GERMAN_LUXEMBOURG | ||
10130 | -# define SUBLANG_GERMAN_LUXEMBOURG 0x04 | ||
10131 | -# endif | ||
10132 | -# ifndef SUBLANG_GERMAN_LIECHTENSTEIN | ||
10133 | -# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05 | ||
10134 | -# endif | ||
10135 | -# ifndef SUBLANG_KASHMIRI_INDIA | ||
10136 | -# define SUBLANG_KASHMIRI_INDIA 0x02 | ||
10137 | -# endif | ||
10138 | -# ifndef SUBLANG_MALAY_MALAYSIA | ||
10139 | -# define SUBLANG_MALAY_MALAYSIA 0x01 | ||
10140 | -# endif | ||
10141 | -# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM | ||
10142 | -# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02 | ||
10143 | -# endif | ||
10144 | -# ifndef SUBLANG_NEPALI_INDIA | ||
10145 | -# define SUBLANG_NEPALI_INDIA 0x02 | ||
10146 | -# endif | ||
10147 | -# ifndef SUBLANG_PUNJABI_INDIA | ||
10148 | -# define SUBLANG_PUNJABI_INDIA 0x01 | ||
10149 | -# endif | ||
10150 | -# ifndef SUBLANG_PUNJABI_PAKISTAN | ||
10151 | -# define SUBLANG_PUNJABI_PAKISTAN 0x02 | ||
10152 | -# endif | ||
10153 | -# ifndef SUBLANG_ROMANIAN_ROMANIA | ||
10154 | -# define SUBLANG_ROMANIAN_ROMANIA 0x01 | ||
10155 | -# endif | ||
10156 | -# ifndef SUBLANG_ROMANIAN_MOLDOVA | ||
10157 | -# define SUBLANG_ROMANIAN_MOLDOVA 0x02 | ||
10158 | -# endif | ||
10159 | -# ifndef SUBLANG_SERBIAN_LATIN | ||
10160 | -# define SUBLANG_SERBIAN_LATIN 0x02 | ||
10161 | -# endif | ||
10162 | -# ifndef SUBLANG_SERBIAN_CYRILLIC | ||
10163 | -# define SUBLANG_SERBIAN_CYRILLIC 0x03 | ||
10164 | -# endif | ||
10165 | -# ifndef SUBLANG_SINDHI_PAKISTAN | ||
10166 | -# define SUBLANG_SINDHI_PAKISTAN 0x01 | ||
10167 | -# endif | ||
10168 | -# ifndef SUBLANG_SINDHI_AFGHANISTAN | ||
10169 | -# define SUBLANG_SINDHI_AFGHANISTAN 0x02 | ||
10170 | -# endif | ||
10171 | -# ifndef SUBLANG_SPANISH_GUATEMALA | ||
10172 | -# define SUBLANG_SPANISH_GUATEMALA 0x04 | ||
10173 | -# endif | ||
10174 | -# ifndef SUBLANG_SPANISH_COSTA_RICA | ||
10175 | -# define SUBLANG_SPANISH_COSTA_RICA 0x05 | ||
10176 | -# endif | ||
10177 | -# ifndef SUBLANG_SPANISH_PANAMA | ||
10178 | -# define SUBLANG_SPANISH_PANAMA 0x06 | ||
10179 | -# endif | ||
10180 | -# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC | ||
10181 | -# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07 | ||
10182 | -# endif | ||
10183 | -# ifndef SUBLANG_SPANISH_VENEZUELA | ||
10184 | -# define SUBLANG_SPANISH_VENEZUELA 0x08 | ||
10185 | -# endif | ||
10186 | -# ifndef SUBLANG_SPANISH_COLOMBIA | ||
10187 | -# define SUBLANG_SPANISH_COLOMBIA 0x09 | ||
10188 | -# endif | ||
10189 | -# ifndef SUBLANG_SPANISH_PERU | ||
10190 | -# define SUBLANG_SPANISH_PERU 0x0a | ||
10191 | -# endif | ||
10192 | -# ifndef SUBLANG_SPANISH_ARGENTINA | ||
10193 | -# define SUBLANG_SPANISH_ARGENTINA 0x0b | ||
10194 | -# endif | ||
10195 | -# ifndef SUBLANG_SPANISH_ECUADOR | ||
10196 | -# define SUBLANG_SPANISH_ECUADOR 0x0c | ||
10197 | -# endif | ||
10198 | -# ifndef SUBLANG_SPANISH_CHILE | ||
10199 | -# define SUBLANG_SPANISH_CHILE 0x0d | ||
10200 | -# endif | ||
10201 | -# ifndef SUBLANG_SPANISH_URUGUAY | ||
10202 | -# define SUBLANG_SPANISH_URUGUAY 0x0e | ||
10203 | -# endif | ||
10204 | -# ifndef SUBLANG_SPANISH_PARAGUAY | ||
10205 | -# define SUBLANG_SPANISH_PARAGUAY 0x0f | ||
10206 | -# endif | ||
10207 | -# ifndef SUBLANG_SPANISH_BOLIVIA | ||
10208 | -# define SUBLANG_SPANISH_BOLIVIA 0x10 | ||
10209 | -# endif | ||
10210 | -# ifndef SUBLANG_SPANISH_EL_SALVADOR | ||
10211 | -# define SUBLANG_SPANISH_EL_SALVADOR 0x11 | ||
10212 | -# endif | ||
10213 | -# ifndef SUBLANG_SPANISH_HONDURAS | ||
10214 | -# define SUBLANG_SPANISH_HONDURAS 0x12 | ||
10215 | -# endif | ||
10216 | -# ifndef SUBLANG_SPANISH_NICARAGUA | ||
10217 | -# define SUBLANG_SPANISH_NICARAGUA 0x13 | ||
10218 | -# endif | ||
10219 | -# ifndef SUBLANG_SPANISH_PUERTO_RICO | ||
10220 | -# define SUBLANG_SPANISH_PUERTO_RICO 0x14 | ||
10221 | -# endif | ||
10222 | -# ifndef SUBLANG_SWEDISH_FINLAND | ||
10223 | -# define SUBLANG_SWEDISH_FINLAND 0x02 | ||
10224 | -# endif | ||
10225 | -# ifndef SUBLANG_TAMAZIGHT_ARABIC | ||
10226 | -# define SUBLANG_TAMAZIGHT_ARABIC 0x01 | ||
10227 | -# endif | ||
10228 | -# ifndef SUBLANG_TAMAZIGHT_ALGERIA_LATIN | ||
10229 | -# define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02 | ||
10230 | -# endif | ||
10231 | -# ifndef SUBLANG_TIGRINYA_ETHIOPIA | ||
10232 | -# define SUBLANG_TIGRINYA_ETHIOPIA 0x01 | ||
10233 | -# endif | ||
10234 | -# ifndef SUBLANG_TIGRINYA_ERITREA | ||
10235 | -# define SUBLANG_TIGRINYA_ERITREA 0x02 | ||
10236 | -# endif | ||
10237 | -# ifndef SUBLANG_URDU_PAKISTAN | ||
10238 | -# define SUBLANG_URDU_PAKISTAN 0x01 | ||
10239 | -# endif | ||
10240 | -# ifndef SUBLANG_URDU_INDIA | ||
10241 | -# define SUBLANG_URDU_INDIA 0x02 | ||
10242 | -# endif | ||
10243 | -# ifndef SUBLANG_UZBEK_LATIN | ||
10244 | -# define SUBLANG_UZBEK_LATIN 0x01 | ||
10245 | -# endif | ||
10246 | -# ifndef SUBLANG_UZBEK_CYRILLIC | ||
10247 | -# define SUBLANG_UZBEK_CYRILLIC 0x02 | ||
10248 | -# endif | ||
10249 | -#endif | ||
10250 | - | ||
10251 | -# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE | ||
10252 | -/* MacOS X 10.2 or newer */ | ||
10253 | - | ||
10254 | -/* Canonicalize a MacOS X locale name to a Unix locale name. | ||
10255 | - NAME is a sufficiently large buffer. | ||
10256 | - On input, it contains the MacOS X locale name. | ||
10257 | - On output, it contains the Unix locale name. */ | ||
10258 | -# if !defined IN_LIBINTL | ||
10259 | -static | ||
10260 | -# endif | ||
10261 | -void | ||
10262 | -gl_locale_name_canonicalize (char *name) | ||
10263 | -{ | ||
10264 | - /* This conversion is based on a posting by | ||
10265 | - Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08, | ||
10266 | - http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */ | ||
10267 | - | ||
10268 | - /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and | ||
10269 | - ISO 3166) names. Prior to MacOS X 10.3, there is no API for doing this. | ||
10270 | - Therefore we do it ourselves, using a table based on the results of the | ||
10271 | - MacOS X 10.3.8 function | ||
10272 | - CFLocaleCreateCanonicalLocaleIdentifierFromString(). */ | ||
10273 | - typedef struct { const char legacy[21+1]; const char unixy[5+1]; } | ||
10274 | - legacy_entry; | ||
10275 | - static const legacy_entry legacy_table[] = { | ||
10276 | - { "Afrikaans", "af" }, | ||
10277 | - { "Albanian", "sq" }, | ||
10278 | - { "Amharic", "am" }, | ||
10279 | - { "Arabic", "ar" }, | ||
10280 | - { "Armenian", "hy" }, | ||
10281 | - { "Assamese", "as" }, | ||
10282 | - { "Aymara", "ay" }, | ||
10283 | - { "Azerbaijani", "az" }, | ||
10284 | - { "Basque", "eu" }, | ||
10285 | - { "Belarusian", "be" }, | ||
10286 | - { "Belorussian", "be" }, | ||
10287 | - { "Bengali", "bn" }, | ||
10288 | - { "Brazilian Portugese", "pt_BR" }, | ||
10289 | - { "Brazilian Portuguese", "pt_BR" }, | ||
10290 | - { "Breton", "br" }, | ||
10291 | - { "Bulgarian", "bg" }, | ||
10292 | - { "Burmese", "my" }, | ||
10293 | - { "Byelorussian", "be" }, | ||
10294 | - { "Catalan", "ca" }, | ||
10295 | - { "Chewa", "ny" }, | ||
10296 | - { "Chichewa", "ny" }, | ||
10297 | - { "Chinese", "zh" }, | ||
10298 | - { "Chinese, Simplified", "zh_CN" }, | ||
10299 | - { "Chinese, Traditional", "zh_TW" }, | ||
10300 | - { "Chinese, Tradtional", "zh_TW" }, | ||
10301 | - { "Croatian", "hr" }, | ||
10302 | - { "Czech", "cs" }, | ||
10303 | - { "Danish", "da" }, | ||
10304 | - { "Dutch", "nl" }, | ||
10305 | - { "Dzongkha", "dz" }, | ||
10306 | - { "English", "en" }, | ||
10307 | - { "Esperanto", "eo" }, | ||
10308 | - { "Estonian", "et" }, | ||
10309 | - { "Faroese", "fo" }, | ||
10310 | - { "Farsi", "fa" }, | ||
10311 | - { "Finnish", "fi" }, | ||
10312 | - { "Flemish", "nl_BE" }, | ||
10313 | - { "French", "fr" }, | ||
10314 | - { "Galician", "gl" }, | ||
10315 | - { "Gallegan", "gl" }, | ||
10316 | - { "Georgian", "ka" }, | ||
10317 | - { "German", "de" }, | ||
10318 | - { "Greek", "el" }, | ||
10319 | - { "Greenlandic", "kl" }, | ||
10320 | - { "Guarani", "gn" }, | ||
10321 | - { "Gujarati", "gu" }, | ||
10322 | - { "Hawaiian", "haw" }, /* Yes, "haw", not "cpe". */ | ||
10323 | - { "Hebrew", "he" }, | ||
10324 | - { "Hindi", "hi" }, | ||
10325 | - { "Hungarian", "hu" }, | ||
10326 | - { "Icelandic", "is" }, | ||
10327 | - { "Indonesian", "id" }, | ||
10328 | - { "Inuktitut", "iu" }, | ||
10329 | - { "Irish", "ga" }, | ||
10330 | - { "Italian", "it" }, | ||
10331 | - { "Japanese", "ja" }, | ||
10332 | - { "Javanese", "jv" }, | ||
10333 | - { "Kalaallisut", "kl" }, | ||
10334 | - { "Kannada", "kn" }, | ||
10335 | - { "Kashmiri", "ks" }, | ||
10336 | - { "Kazakh", "kk" }, | ||
10337 | - { "Khmer", "km" }, | ||
10338 | - { "Kinyarwanda", "rw" }, | ||
10339 | - { "Kirghiz", "ky" }, | ||
10340 | - { "Korean", "ko" }, | ||
10341 | - { "Kurdish", "ku" }, | ||
10342 | - { "Latin", "la" }, | ||
10343 | - { "Latvian", "lv" }, | ||
10344 | - { "Lithuanian", "lt" }, | ||
10345 | - { "Macedonian", "mk" }, | ||
10346 | - { "Malagasy", "mg" }, | ||
10347 | - { "Malay", "ms" }, | ||
10348 | - { "Malayalam", "ml" }, | ||
10349 | - { "Maltese", "mt" }, | ||
10350 | - { "Manx", "gv" }, | ||
10351 | - { "Marathi", "mr" }, | ||
10352 | - { "Moldavian", "mo" }, | ||
10353 | - { "Mongolian", "mn" }, | ||
10354 | - { "Nepali", "ne" }, | ||
10355 | - { "Norwegian", "nb" }, /* Yes, "nb", not the obsolete "no". */ | ||
10356 | - { "Nyanja", "ny" }, | ||
10357 | - { "Nynorsk", "nn" }, | ||
10358 | - { "Oriya", "or" }, | ||
10359 | - { "Oromo", "om" }, | ||
10360 | - { "Panjabi", "pa" }, | ||
10361 | - { "Pashto", "ps" }, | ||
10362 | - { "Persian", "fa" }, | ||
10363 | - { "Polish", "pl" }, | ||
10364 | - { "Portuguese", "pt" }, | ||
10365 | - { "Portuguese, Brazilian", "pt_BR" }, | ||
10366 | - { "Punjabi", "pa" }, | ||
10367 | - { "Pushto", "ps" }, | ||
10368 | - { "Quechua", "qu" }, | ||
10369 | - { "Romanian", "ro" }, | ||
10370 | - { "Ruanda", "rw" }, | ||
10371 | - { "Rundi", "rn" }, | ||
10372 | - { "Russian", "ru" }, | ||
10373 | - { "Sami", "se_NO" }, /* Not just "se". */ | ||
10374 | - { "Sanskrit", "sa" }, | ||
10375 | - { "Scottish", "gd" }, | ||
10376 | - { "Serbian", "sr" }, | ||
10377 | - { "Simplified Chinese", "zh_CN" }, | ||
10378 | - { "Sindhi", "sd" }, | ||
10379 | - { "Sinhalese", "si" }, | ||
10380 | - { "Slovak", "sk" }, | ||
10381 | - { "Slovenian", "sl" }, | ||
10382 | - { "Somali", "so" }, | ||
10383 | - { "Spanish", "es" }, | ||
10384 | - { "Sundanese", "su" }, | ||
10385 | - { "Swahili", "sw" }, | ||
10386 | - { "Swedish", "sv" }, | ||
10387 | - { "Tagalog", "tl" }, | ||
10388 | - { "Tajik", "tg" }, | ||
10389 | - { "Tajiki", "tg" }, | ||
10390 | - { "Tamil", "ta" }, | ||
10391 | - { "Tatar", "tt" }, | ||
10392 | - { "Telugu", "te" }, | ||
10393 | - { "Thai", "th" }, | ||
10394 | - { "Tibetan", "bo" }, | ||
10395 | - { "Tigrinya", "ti" }, | ||
10396 | - { "Tongan", "to" }, | ||
10397 | - { "Traditional Chinese", "zh_TW" }, | ||
10398 | - { "Turkish", "tr" }, | ||
10399 | - { "Turkmen", "tk" }, | ||
10400 | - { "Uighur", "ug" }, | ||
10401 | - { "Ukrainian", "uk" }, | ||
10402 | - { "Urdu", "ur" }, | ||
10403 | - { "Uzbek", "uz" }, | ||
10404 | - { "Vietnamese", "vi" }, | ||
10405 | - { "Welsh", "cy" }, | ||
10406 | - { "Yiddish", "yi" } | ||
10407 | - }; | ||
10408 | - | ||
10409 | - /* Convert new-style locale names with language tags (ISO 639 and ISO 15924) | ||
10410 | - to Unix (ISO 639 and ISO 3166) names. */ | ||
10411 | - typedef struct { const char langtag[7+1]; const char unixy[12+1]; } | ||
10412 | - langtag_entry; | ||
10413 | - static const langtag_entry langtag_table[] = { | ||
10414 | - /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn". | ||
10415 | - The default script for az on Unix is Latin. */ | ||
10416 | - { "az-Latn", "az" }, | ||
10417 | - /* MacOS X has "ga-dots". Does not yet exist on Unix. */ | ||
10418 | - { "ga-dots", "ga" }, | ||
10419 | - /* MacOS X has "kk-Cyrl". Does not yet exist on Unix. */ | ||
10420 | - /* MacOS X has "mn-Cyrl", "mn-Mong". | ||
10421 | - The default script for mn on Unix is Cyrillic. */ | ||
10422 | - { "mn-Cyrl", "mn" }, | ||
10423 | - /* MacOS X has "ms-Arab", "ms-Latn". | ||
10424 | - The default script for ms on Unix is Latin. */ | ||
10425 | - { "ms-Latn", "ms" }, | ||
10426 | - /* MacOS X has "tg-Cyrl". | ||
10427 | - The default script for tg on Unix is Cyrillic. */ | ||
10428 | - { "tg-Cyrl", "tg" }, | ||
10429 | - /* MacOS X has "tk-Cyrl". Does not yet exist on Unix. */ | ||
10430 | - /* MacOS X has "tt-Cyrl". | ||
10431 | - The default script for tt on Unix is Cyrillic. */ | ||
10432 | - { "tt-Cyrl", "tt" }, | ||
10433 | - /* MacOS X has "zh-Hans", "zh-Hant". | ||
10434 | - Country codes are used to distinguish these on Unix. */ | ||
10435 | - { "zh-Hans", "zh_CN" }, | ||
10436 | - { "zh-Hant", "zh_TW" } | ||
10437 | - }; | ||
10438 | - | ||
10439 | - /* Convert script names (ISO 15924) to Unix conventions. | ||
10440 | - See http://www.unicode.org/iso15924/iso15924-codes.html */ | ||
10441 | - typedef struct { const char script[4+1]; const char unixy[9+1]; } | ||
10442 | - script_entry; | ||
10443 | - static const script_entry script_table[] = { | ||
10444 | - { "Arab", "arabic" }, | ||
10445 | - { "Cyrl", "cyrillic" }, | ||
10446 | - { "Mong", "mongolian" } | ||
10447 | - }; | ||
10448 | - | ||
10449 | - /* Step 1: Convert using legacy_table. */ | ||
10450 | - if (name[0] >= 'A' && name[0] <= 'Z') | ||
10451 | - { | ||
10452 | - unsigned int i1, i2; | ||
10453 | - i1 = 0; | ||
10454 | - i2 = sizeof (legacy_table) / sizeof (legacy_entry); | ||
10455 | - while (i2 - i1 > 1) | ||
10456 | - { | ||
10457 | - /* At this point we know that if name occurs in legacy_table, | ||
10458 | - its index must be >= i1 and < i2. */ | ||
10459 | - unsigned int i = (i1 + i2) >> 1; | ||
10460 | - const legacy_entry *p = &legacy_table[i]; | ||
10461 | - if (strcmp (name, p->legacy) < 0) | ||
10462 | - i2 = i; | ||
10463 | - else | ||
10464 | - i1 = i; | ||
10465 | - } | ||
10466 | - if (strcmp (name, legacy_table[i1].legacy) == 0) | ||
10467 | - { | ||
10468 | - strcpy (name, legacy_table[i1].unixy); | ||
10469 | - return; | ||
10470 | - } | ||
10471 | - } | ||
10472 | - | ||
10473 | - /* Step 2: Convert using langtag_table and script_table. */ | ||
10474 | - if (strlen (name) == 7 && name[2] == '-') | ||
10475 | - { | ||
10476 | - unsigned int i1, i2; | ||
10477 | - i1 = 0; | ||
10478 | - i2 = sizeof (langtag_table) / sizeof (langtag_entry); | ||
10479 | - while (i2 - i1 > 1) | ||
10480 | - { | ||
10481 | - /* At this point we know that if name occurs in langtag_table, | ||
10482 | - its index must be >= i1 and < i2. */ | ||
10483 | - unsigned int i = (i1 + i2) >> 1; | ||
10484 | - const langtag_entry *p = &langtag_table[i]; | ||
10485 | - if (strcmp (name, p->langtag) < 0) | ||
10486 | - i2 = i; | ||
10487 | - else | ||
10488 | - i1 = i; | ||
10489 | - } | ||
10490 | - if (strcmp (name, langtag_table[i1].langtag) == 0) | ||
10491 | - { | ||
10492 | - strcpy (name, langtag_table[i1].unixy); | ||
10493 | - return; | ||
10494 | - } | ||
10495 | - | ||
10496 | - i1 = 0; | ||
10497 | - i2 = sizeof (script_table) / sizeof (script_entry); | ||
10498 | - while (i2 - i1 > 1) | ||
10499 | - { | ||
10500 | - /* At this point we know that if (name + 3) occurs in script_table, | ||
10501 | - its index must be >= i1 and < i2. */ | ||
10502 | - unsigned int i = (i1 + i2) >> 1; | ||
10503 | - const script_entry *p = &script_table[i]; | ||
10504 | - if (strcmp (name + 3, p->script) < 0) | ||
10505 | - i2 = i; | ||
10506 | - else | ||
10507 | - i1 = i; | ||
10508 | - } | ||
10509 | - if (strcmp (name + 3, script_table[i1].script) == 0) | ||
10510 | - { | ||
10511 | - name[2] = '@'; | ||
10512 | - strcpy (name + 3, script_table[i1].unixy); | ||
10513 | - return; | ||
10514 | - } | ||
10515 | - } | ||
10516 | - | ||
10517 | - /* Step 3: Convert new-style dash to Unix underscore. */ | ||
10518 | - { | ||
10519 | - char *p; | ||
10520 | - for (p = name; *p != '\0'; p++) | ||
10521 | - if (*p == '-') | ||
10522 | - *p = '_'; | ||
10523 | - } | ||
10524 | -} | ||
10525 | - | ||
10526 | -#endif | ||
10527 | - | ||
10528 | -/* XPG3 defines the result of 'setlocale (category, NULL)' as: | ||
10529 | - "Directs 'setlocale()' to query 'category' and return the current | ||
10530 | - setting of 'local'." | ||
10531 | - However it does not specify the exact format. Neither do SUSV2 and | ||
10532 | - ISO C 99. So we can use this feature only on selected systems (e.g. | ||
10533 | - those using GNU C Library). */ | ||
10534 | -#if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2) | ||
10535 | -# define HAVE_LOCALE_NULL | ||
10536 | -#endif | ||
10537 | - | ||
10538 | -/* Determine the current locale's name, and canonicalize it into XPG syntax | ||
10539 | - language[_territory][.codeset][@modifier] | ||
10540 | - The codeset part in the result is not reliable; the locale_charset() | ||
10541 | - should be used for codeset information instead. | ||
10542 | - The result must not be freed; it is statically allocated. */ | ||
10543 | - | ||
10544 | -const char * | ||
10545 | -gl_locale_name_posix (int category, const char *categoryname) | ||
10546 | -{ | ||
10547 | - /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'. | ||
10548 | - On some systems this can be done by the 'setlocale' function itself. */ | ||
10549 | -#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL | ||
10550 | - return setlocale (category, NULL); | ||
10551 | -#else | ||
10552 | - const char *retval; | ||
10553 | - | ||
10554 | - /* Setting of LC_ALL overrides all other. */ | ||
10555 | - retval = getenv ("LC_ALL"); | ||
10556 | - if (retval != NULL && retval[0] != '\0') | ||
10557 | - return retval; | ||
10558 | - /* Next comes the name of the desired category. */ | ||
10559 | - retval = getenv (categoryname); | ||
10560 | - if (retval != NULL && retval[0] != '\0') | ||
10561 | - return retval; | ||
10562 | - /* Last possibility is the LANG environment variable. */ | ||
10563 | - retval = getenv ("LANG"); | ||
10564 | - if (retval != NULL && retval[0] != '\0') | ||
10565 | - return retval; | ||
10566 | - | ||
10567 | - return NULL; | ||
10568 | -#endif | ||
10569 | -} | ||
10570 | - | ||
10571 | -const char * | ||
10572 | -gl_locale_name_default (void) | ||
10573 | -{ | ||
10574 | - /* POSIX:2001 says: | ||
10575 | - "All implementations shall define a locale as the default locale, to be | ||
10576 | - invoked when no environment variables are set, or set to the empty | ||
10577 | - string. This default locale can be the POSIX locale or any other | ||
10578 | - implementation-defined locale. Some implementations may provide | ||
10579 | - facilities for local installation administrators to set the default | ||
10580 | - locale, customizing it for each location. POSIX:2001 does not require | ||
10581 | - such a facility. */ | ||
10582 | - | ||
10583 | -#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined(WIN32_NATIVE)) | ||
10584 | - | ||
10585 | - /* The system does not have a way of setting the locale, other than the | ||
10586 | - POSIX specified environment variables. We use C as default locale. */ | ||
10587 | - return "C"; | ||
10588 | - | ||
10589 | -#else | ||
10590 | - | ||
10591 | - /* Return an XPG style locale name language[_territory][@modifier]. | ||
10592 | - Don't even bother determining the codeset; it's not useful in this | ||
10593 | - context, because message catalogs are not specific to a single | ||
10594 | - codeset. */ | ||
10595 | - | ||
10596 | -# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE | ||
10597 | - /* MacOS X 10.2 or newer */ | ||
10598 | - { | ||
10599 | - /* Cache the locale name, since CoreFoundation calls are expensive. */ | ||
10600 | - static const char *cached_localename; | ||
10601 | - | ||
10602 | - if (cached_localename == NULL) | ||
10603 | - { | ||
10604 | - char namebuf[256]; | ||
10605 | -# if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */ | ||
10606 | - CFLocaleRef locale = CFLocaleCopyCurrent (); | ||
10607 | - CFStringRef name = CFLocaleGetIdentifier (locale); | ||
10608 | - | ||
10609 | - if (CFStringGetCString (name, namebuf, sizeof(namebuf), | ||
10610 | - kCFStringEncodingASCII)) | ||
10611 | - { | ||
10612 | - gl_locale_name_canonicalize (namebuf); | ||
10613 | - cached_localename = strdup (namebuf); | ||
10614 | - } | ||
10615 | - CFRelease (locale); | ||
10616 | -# elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */ | ||
10617 | - CFTypeRef value = | ||
10618 | - CFPreferencesCopyAppValue (CFSTR ("AppleLocale"), | ||
10619 | - kCFPreferencesCurrentApplication); | ||
10620 | - if (value != NULL | ||
10621 | - && CFGetTypeID (value) == CFStringGetTypeID () | ||
10622 | - && CFStringGetCString ((CFStringRef)value, namebuf, sizeof(namebuf), | ||
10623 | - kCFStringEncodingASCII)) | ||
10624 | - { | ||
10625 | - gl_locale_name_canonicalize (namebuf); | ||
10626 | - cached_localename = strdup (namebuf); | ||
10627 | - } | ||
10628 | -# endif | ||
10629 | - if (cached_localename == NULL) | ||
10630 | - cached_localename = "C"; | ||
10631 | - } | ||
10632 | - return cached_localename; | ||
10633 | - } | ||
10634 | - | ||
10635 | -# endif | ||
10636 | - | ||
10637 | -# if defined(WIN32_NATIVE) /* WIN32, not Cygwin */ | ||
10638 | - { | ||
10639 | - LCID lcid; | ||
10640 | - LANGID langid; | ||
10641 | - int primary, sub; | ||
10642 | - | ||
10643 | - /* Use native Win32 API locale ID. */ | ||
10644 | - lcid = GetThreadLocale (); | ||
10645 | - | ||
10646 | - /* Strip off the sorting rules, keep only the language part. */ | ||
10647 | - langid = LANGIDFROMLCID (lcid); | ||
10648 | - | ||
10649 | - /* Split into language and territory part. */ | ||
10650 | - primary = PRIMARYLANGID (langid); | ||
10651 | - sub = SUBLANGID (langid); | ||
10652 | - | ||
10653 | - /* Dispatch on language. | ||
10654 | - See also http://www.unicode.org/unicode/onlinedat/languages.html . | ||
10655 | - For details about languages, see http://www.ethnologue.com/ . */ | ||
10656 | - switch (primary) | ||
10657 | - { | ||
10658 | - case LANG_AFRIKAANS: return "af_ZA"; | ||
10659 | - case LANG_ALBANIAN: return "sq_AL"; | ||
10660 | - case LANG_AMHARIC: return "am_ET"; | ||
10661 | - case LANG_ARABIC: | ||
10662 | - switch (sub) | ||
10663 | - { | ||
10664 | - case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA"; | ||
10665 | - case SUBLANG_ARABIC_IRAQ: return "ar_IQ"; | ||
10666 | - case SUBLANG_ARABIC_EGYPT: return "ar_EG"; | ||
10667 | - case SUBLANG_ARABIC_LIBYA: return "ar_LY"; | ||
10668 | - case SUBLANG_ARABIC_ALGERIA: return "ar_DZ"; | ||
10669 | - case SUBLANG_ARABIC_MOROCCO: return "ar_MA"; | ||
10670 | - case SUBLANG_ARABIC_TUNISIA: return "ar_TN"; | ||
10671 | - case SUBLANG_ARABIC_OMAN: return "ar_OM"; | ||
10672 | - case SUBLANG_ARABIC_YEMEN: return "ar_YE"; | ||
10673 | - case SUBLANG_ARABIC_SYRIA: return "ar_SY"; | ||
10674 | - case SUBLANG_ARABIC_JORDAN: return "ar_JO"; | ||
10675 | - case SUBLANG_ARABIC_LEBANON: return "ar_LB"; | ||
10676 | - case SUBLANG_ARABIC_KUWAIT: return "ar_KW"; | ||
10677 | - case SUBLANG_ARABIC_UAE: return "ar_AE"; | ||
10678 | - case SUBLANG_ARABIC_BAHRAIN: return "ar_BH"; | ||
10679 | - case SUBLANG_ARABIC_QATAR: return "ar_QA"; | ||
10680 | - } | ||
10681 | - return "ar"; | ||
10682 | - case LANG_ARMENIAN: return "hy_AM"; | ||
10683 | - case LANG_ASSAMESE: return "as_IN"; | ||
10684 | - case LANG_AZERI: | ||
10685 | - switch (sub) | ||
10686 | - { | ||
10687 | - /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */ | ||
10688 | - case SUBLANG_AZERI_LATIN: return "az_AZ@latin"; | ||
10689 | - case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic"; | ||
10690 | - } | ||
10691 | - return "az"; | ||
10692 | - case LANG_BASQUE: | ||
10693 | - switch (sub) | ||
10694 | - { | ||
10695 | - case SUBLANG_DEFAULT: return "eu_ES"; | ||
10696 | - } | ||
10697 | - return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */ | ||
10698 | - case LANG_BELARUSIAN: return "be_BY"; | ||
10699 | - case LANG_BENGALI: | ||
10700 | - switch (sub) | ||
10701 | - { | ||
10702 | - case SUBLANG_BENGALI_INDIA: return "bn_IN"; | ||
10703 | - case SUBLANG_BENGALI_BANGLADESH: return "bn_BD"; | ||
10704 | - } | ||
10705 | - return "bn"; | ||
10706 | - case LANG_BULGARIAN: return "bg_BG"; | ||
10707 | - case LANG_BURMESE: return "my_MM"; | ||
10708 | - case LANG_CAMBODIAN: return "km_KH"; | ||
10709 | - case LANG_CATALAN: return "ca_ES"; | ||
10710 | - case LANG_CHEROKEE: return "chr_US"; | ||
10711 | - case LANG_CHINESE: | ||
10712 | - switch (sub) | ||
10713 | - { | ||
10714 | - case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW"; | ||
10715 | - case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN"; | ||
10716 | - case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; | ||
10717 | - case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; | ||
10718 | - case SUBLANG_CHINESE_MACAU: return "zh_MO"; | ||
10719 | - } | ||
10720 | - return "zh"; | ||
10721 | - case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN | ||
10722 | - * What used to be called Serbo-Croatian | ||
10723 | - * should really now be two separate | ||
10724 | - * languages because of political reasons. | ||
10725 | - * (Says tml, who knows nothing about Serbian | ||
10726 | - * or Croatian.) | ||
10727 | - * (I can feel those flames coming already.) | ||
10728 | - */ | ||
10729 | - switch (sub) | ||
10730 | - { | ||
10731 | - case SUBLANG_DEFAULT: return "hr_HR"; | ||
10732 | - case SUBLANG_SERBIAN_LATIN: return "sr_CS"; | ||
10733 | - case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic"; | ||
10734 | - } | ||
10735 | - return "hr"; | ||
10736 | - case LANG_CZECH: return "cs_CZ"; | ||
10737 | - case LANG_DANISH: return "da_DK"; | ||
10738 | - case LANG_DIVEHI: return "dv_MV"; | ||
10739 | - case LANG_DUTCH: | ||
10740 | - switch (sub) | ||
10741 | - { | ||
10742 | - case SUBLANG_DUTCH: return "nl_NL"; | ||
10743 | - case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE"; | ||
10744 | - } | ||
10745 | - return "nl"; | ||
10746 | - case LANG_EDO: return "bin_NG"; | ||
10747 | - case LANG_ENGLISH: | ||
10748 | - switch (sub) | ||
10749 | - { | ||
10750 | - /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought | ||
10751 | - * English was the language spoken in England. | ||
10752 | - * Oh well. | ||
10753 | - */ | ||
10754 | - case SUBLANG_ENGLISH_US: return "en_US"; | ||
10755 | - case SUBLANG_ENGLISH_UK: return "en_GB"; | ||
10756 | - case SUBLANG_ENGLISH_AUS: return "en_AU"; | ||
10757 | - case SUBLANG_ENGLISH_CAN: return "en_CA"; | ||
10758 | - case SUBLANG_ENGLISH_NZ: return "en_NZ"; | ||
10759 | - case SUBLANG_ENGLISH_EIRE: return "en_IE"; | ||
10760 | - case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA"; | ||
10761 | - case SUBLANG_ENGLISH_JAMAICA: return "en_JM"; | ||
10762 | - case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */ | ||
10763 | - case SUBLANG_ENGLISH_BELIZE: return "en_BZ"; | ||
10764 | - case SUBLANG_ENGLISH_TRINIDAD: return "en_TT"; | ||
10765 | - case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW"; | ||
10766 | - case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH"; | ||
10767 | - case SUBLANG_ENGLISH_INDONESIA: return "en_ID"; | ||
10768 | - case SUBLANG_ENGLISH_HONGKONG: return "en_HK"; | ||
10769 | - case SUBLANG_ENGLISH_INDIA: return "en_IN"; | ||
10770 | - case SUBLANG_ENGLISH_MALAYSIA: return "en_MY"; | ||
10771 | - case SUBLANG_ENGLISH_SINGAPORE: return "en_SG"; | ||
10772 | - } | ||
10773 | - return "en"; | ||
10774 | - case LANG_ESTONIAN: return "et_EE"; | ||
10775 | - case LANG_FAEROESE: return "fo_FO"; | ||
10776 | - case LANG_FARSI: return "fa_IR"; | ||
10777 | - case LANG_FINNISH: return "fi_FI"; | ||
10778 | - case LANG_FRENCH: | ||
10779 | - switch (sub) | ||
10780 | - { | ||
10781 | - case SUBLANG_FRENCH: return "fr_FR"; | ||
10782 | - case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE"; | ||
10783 | - case SUBLANG_FRENCH_CANADIAN: return "fr_CA"; | ||
10784 | - case SUBLANG_FRENCH_SWISS: return "fr_CH"; | ||
10785 | - case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU"; | ||
10786 | - case SUBLANG_FRENCH_MONACO: return "fr_MC"; | ||
10787 | - case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */ | ||
10788 | - case SUBLANG_FRENCH_REUNION: return "fr_RE"; | ||
10789 | - case SUBLANG_FRENCH_CONGO: return "fr_CG"; | ||
10790 | - case SUBLANG_FRENCH_SENEGAL: return "fr_SN"; | ||
10791 | - case SUBLANG_FRENCH_CAMEROON: return "fr_CM"; | ||
10792 | - case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI"; | ||
10793 | - case SUBLANG_FRENCH_MALI: return "fr_ML"; | ||
10794 | - case SUBLANG_FRENCH_MOROCCO: return "fr_MA"; | ||
10795 | - case SUBLANG_FRENCH_HAITI: return "fr_HT"; | ||
10796 | - } | ||
10797 | - return "fr"; | ||
10798 | - case LANG_FRISIAN: return "fy_NL"; | ||
10799 | - case LANG_FULFULDE: | ||
10800 | - /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */ | ||
10801 | - return "ff_NG"; | ||
10802 | - case LANG_GAELIC: | ||
10803 | - switch (sub) | ||
10804 | - { | ||
10805 | - case 0x01: /* SCOTTISH */ return "gd_GB"; | ||
10806 | - case 0x02: /* IRISH */ return "ga_IE"; | ||
10807 | - } | ||
10808 | - return "C"; | ||
10809 | - case LANG_GALICIAN: return "gl_ES"; | ||
10810 | - case LANG_GEORGIAN: return "ka_GE"; | ||
10811 | - case LANG_GERMAN: | ||
10812 | - switch (sub) | ||
10813 | - { | ||
10814 | - case SUBLANG_GERMAN: return "de_DE"; | ||
10815 | - case SUBLANG_GERMAN_SWISS: return "de_CH"; | ||
10816 | - case SUBLANG_GERMAN_AUSTRIAN: return "de_AT"; | ||
10817 | - case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU"; | ||
10818 | - case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI"; | ||
10819 | - } | ||
10820 | - return "de"; | ||
10821 | - case LANG_GREEK: return "el_GR"; | ||
10822 | - case LANG_GUARANI: return "gn_PY"; | ||
10823 | - case LANG_GUJARATI: return "gu_IN"; | ||
10824 | - case LANG_HAUSA: return "ha_NG"; | ||
10825 | - case LANG_HAWAIIAN: | ||
10826 | - /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers) | ||
10827 | - or Hawaii Creole English ("cpe_US", 600000 speakers)? */ | ||
10828 | - return "cpe_US"; | ||
10829 | - case LANG_HEBREW: return "he_IL"; | ||
10830 | - case LANG_HINDI: return "hi_IN"; | ||
10831 | - case LANG_HUNGARIAN: return "hu_HU"; | ||
10832 | - case LANG_IBIBIO: return "nic_NG"; | ||
10833 | - case LANG_ICELANDIC: return "is_IS"; | ||
10834 | - case LANG_IGBO: return "ig_NG"; | ||
10835 | - case LANG_INDONESIAN: return "id_ID"; | ||
10836 | - case LANG_INUKTITUT: return "iu_CA"; | ||
10837 | - case LANG_ITALIAN: | ||
10838 | - switch (sub) | ||
10839 | - { | ||
10840 | - case SUBLANG_ITALIAN: return "it_IT"; | ||
10841 | - case SUBLANG_ITALIAN_SWISS: return "it_CH"; | ||
10842 | - } | ||
10843 | - return "it"; | ||
10844 | - case LANG_JAPANESE: return "ja_JP"; | ||
10845 | - case LANG_KANNADA: return "kn_IN"; | ||
10846 | - case LANG_KANURI: return "kr_NG"; | ||
10847 | - case LANG_KASHMIRI: | ||
10848 | - switch (sub) | ||
10849 | - { | ||
10850 | - case SUBLANG_DEFAULT: return "ks_PK"; | ||
10851 | - case SUBLANG_KASHMIRI_INDIA: return "ks_IN"; | ||
10852 | - } | ||
10853 | - return "ks"; | ||
10854 | - case LANG_KAZAK: return "kk_KZ"; | ||
10855 | - case LANG_KONKANI: | ||
10856 | - /* FIXME: Adjust this when such locales appear on Unix. */ | ||
10857 | - return "kok_IN"; | ||
10858 | - case LANG_KOREAN: return "ko_KR"; | ||
10859 | - case LANG_KYRGYZ: return "ky_KG"; | ||
10860 | - case LANG_LAO: return "lo_LA"; | ||
10861 | - case LANG_LATIN: return "la_VA"; | ||
10862 | - case LANG_LATVIAN: return "lv_LV"; | ||
10863 | - case LANG_LITHUANIAN: return "lt_LT"; | ||
10864 | - case LANG_MACEDONIAN: return "mk_MK"; | ||
10865 | - case LANG_MALAY: | ||
10866 | - switch (sub) | ||
10867 | - { | ||
10868 | - case SUBLANG_MALAY_MALAYSIA: return "ms_MY"; | ||
10869 | - case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN"; | ||
10870 | - } | ||
10871 | - return "ms"; | ||
10872 | - case LANG_MALAYALAM: return "ml_IN"; | ||
10873 | - case LANG_MALTESE: return "mt_MT"; | ||
10874 | - case LANG_MANIPURI: | ||
10875 | - /* FIXME: Adjust this when such locales appear on Unix. */ | ||
10876 | - return "mni_IN"; | ||
10877 | - case LANG_MARATHI: return "mr_IN"; | ||
10878 | - case LANG_MONGOLIAN: | ||
10879 | - switch (sub) | ||
10880 | - { | ||
10881 | - case SUBLANG_DEFAULT: return "mn_MN"; | ||
10882 | - } | ||
10883 | - return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */ | ||
10884 | - case LANG_NEPALI: | ||
10885 | - switch (sub) | ||
10886 | - { | ||
10887 | - case SUBLANG_DEFAULT: return "ne_NP"; | ||
10888 | - case SUBLANG_NEPALI_INDIA: return "ne_IN"; | ||
10889 | - } | ||
10890 | - return "ne"; | ||
10891 | - case LANG_NORWEGIAN: | ||
10892 | - switch (sub) | ||
10893 | - { | ||
10894 | - case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO"; | ||
10895 | - case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO"; | ||
10896 | - } | ||
10897 | - return "no"; | ||
10898 | - case LANG_ORIYA: return "or_IN"; | ||
10899 | - case LANG_OROMO: return "om_ET"; | ||
10900 | - case LANG_PAPIAMENTU: return "pap_AN"; | ||
10901 | - case LANG_PASHTO: | ||
10902 | - return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */ | ||
10903 | - case LANG_POLISH: return "pl_PL"; | ||
10904 | - case LANG_PORTUGUESE: | ||
10905 | - switch (sub) | ||
10906 | - { | ||
10907 | - case SUBLANG_PORTUGUESE: return "pt_PT"; | ||
10908 | - /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT. | ||
10909 | - Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */ | ||
10910 | - case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR"; | ||
10911 | - } | ||
10912 | - return "pt"; | ||
10913 | - case LANG_PUNJABI: | ||
10914 | - switch (sub) | ||
10915 | - { | ||
10916 | - case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */ | ||
10917 | - case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */ | ||
10918 | - } | ||
10919 | - return "pa"; | ||
10920 | - case LANG_RHAETO_ROMANCE: return "rm_CH"; | ||
10921 | - case LANG_ROMANIAN: | ||
10922 | - switch (sub) | ||
10923 | - { | ||
10924 | - case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO"; | ||
10925 | - case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD"; | ||
10926 | - } | ||
10927 | - return "ro"; | ||
10928 | - case LANG_RUSSIAN: | ||
10929 | - switch (sub) | ||
10930 | - { | ||
10931 | - case SUBLANG_DEFAULT: return "ru_RU"; | ||
10932 | - } | ||
10933 | - return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */ | ||
10934 | - case LANG_SAAMI: /* actually Northern Sami */ return "se_NO"; | ||
10935 | - case LANG_SANSKRIT: return "sa_IN"; | ||
10936 | - case LANG_SINDHI: | ||
10937 | - switch (sub) | ||
10938 | - { | ||
10939 | - case SUBLANG_SINDHI_PAKISTAN: return "sd_PK"; | ||
10940 | - case SUBLANG_SINDHI_AFGHANISTAN: return "sd_AF"; | ||
10941 | - } | ||
10942 | - return "sd"; | ||
10943 | - case LANG_SINHALESE: return "si_LK"; | ||
10944 | - case LANG_SLOVAK: return "sk_SK"; | ||
10945 | - case LANG_SLOVENIAN: return "sl_SI"; | ||
10946 | - case LANG_SOMALI: return "so_SO"; | ||
10947 | - case LANG_SORBIAN: | ||
10948 | - /* FIXME: Adjust this when such locales appear on Unix. */ | ||
10949 | - return "wen_DE"; | ||
10950 | - case LANG_SPANISH: | ||
10951 | - switch (sub) | ||
10952 | - { | ||
10953 | - case SUBLANG_SPANISH: return "es_ES"; | ||
10954 | - case SUBLANG_SPANISH_MEXICAN: return "es_MX"; | ||
10955 | - case SUBLANG_SPANISH_MODERN: | ||
10956 | - return "es_ES@modern"; /* not seen on Unix */ | ||
10957 | - case SUBLANG_SPANISH_GUATEMALA: return "es_GT"; | ||
10958 | - case SUBLANG_SPANISH_COSTA_RICA: return "es_CR"; | ||
10959 | - case SUBLANG_SPANISH_PANAMA: return "es_PA"; | ||
10960 | - case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO"; | ||
10961 | - case SUBLANG_SPANISH_VENEZUELA: return "es_VE"; | ||
10962 | - case SUBLANG_SPANISH_COLOMBIA: return "es_CO"; | ||
10963 | - case SUBLANG_SPANISH_PERU: return "es_PE"; | ||
10964 | - case SUBLANG_SPANISH_ARGENTINA: return "es_AR"; | ||
10965 | - case SUBLANG_SPANISH_ECUADOR: return "es_EC"; | ||
10966 | - case SUBLANG_SPANISH_CHILE: return "es_CL"; | ||
10967 | - case SUBLANG_SPANISH_URUGUAY: return "es_UY"; | ||
10968 | - case SUBLANG_SPANISH_PARAGUAY: return "es_PY"; | ||
10969 | - case SUBLANG_SPANISH_BOLIVIA: return "es_BO"; | ||
10970 | - case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV"; | ||
10971 | - case SUBLANG_SPANISH_HONDURAS: return "es_HN"; | ||
10972 | - case SUBLANG_SPANISH_NICARAGUA: return "es_NI"; | ||
10973 | - case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR"; | ||
10974 | - } | ||
10975 | - return "es"; | ||
10976 | - case LANG_SUTU: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */ | ||
10977 | - case LANG_SWAHILI: return "sw_KE"; | ||
10978 | - case LANG_SWEDISH: | ||
10979 | - switch (sub) | ||
10980 | - { | ||
10981 | - case SUBLANG_DEFAULT: return "sv_SE"; | ||
10982 | - case SUBLANG_SWEDISH_FINLAND: return "sv_FI"; | ||
10983 | - } | ||
10984 | - return "sv"; | ||
10985 | - case LANG_SYRIAC: return "syr_TR"; /* An extinct language. */ | ||
10986 | - case LANG_TAGALOG: return "tl_PH"; | ||
10987 | - case LANG_TAJIK: return "tg_TJ"; | ||
10988 | - case LANG_TAMAZIGHT: | ||
10989 | - switch (sub) | ||
10990 | - { | ||
10991 | - /* FIXME: Adjust this when Tamazight locales appear on Unix. */ | ||
10992 | - case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic"; | ||
10993 | - case SUBLANG_TAMAZIGHT_ALGERIA_LATIN: return "ber_DZ@latin"; | ||
10994 | - } | ||
10995 | - return "ber_MA"; | ||
10996 | - case LANG_TAMIL: | ||
10997 | - switch (sub) | ||
10998 | - { | ||
10999 | - case SUBLANG_DEFAULT: return "ta_IN"; | ||
11000 | - } | ||
11001 | - return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */ | ||
11002 | - case LANG_TATAR: return "tt_RU"; | ||
11003 | - case LANG_TELUGU: return "te_IN"; | ||
11004 | - case LANG_THAI: return "th_TH"; | ||
11005 | - case LANG_TIBETAN: return "bo_CN"; | ||
11006 | - case LANG_TIGRINYA: | ||
11007 | - switch (sub) | ||
11008 | - { | ||
11009 | - case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET"; | ||
11010 | - case SUBLANG_TIGRINYA_ERITREA: return "ti_ER"; | ||
11011 | - } | ||
11012 | - return "ti"; | ||
11013 | - case LANG_TSONGA: return "ts_ZA"; | ||
11014 | - case LANG_TSWANA: return "tn_BW"; | ||
11015 | - case LANG_TURKISH: return "tr_TR"; | ||
11016 | - case LANG_TURKMEN: return "tk_TM"; | ||
11017 | - case LANG_UKRAINIAN: return "uk_UA"; | ||
11018 | - case LANG_URDU: | ||
11019 | - switch (sub) | ||
11020 | - { | ||
11021 | - case SUBLANG_URDU_PAKISTAN: return "ur_PK"; | ||
11022 | - case SUBLANG_URDU_INDIA: return "ur_IN"; | ||
11023 | - } | ||
11024 | - return "ur"; | ||
11025 | - case LANG_UZBEK: | ||
11026 | - switch (sub) | ||
11027 | - { | ||
11028 | - case SUBLANG_UZBEK_LATIN: return "uz_UZ"; | ||
11029 | - case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic"; | ||
11030 | - } | ||
11031 | - return "uz"; | ||
11032 | - case LANG_VENDA: return "ve_ZA"; | ||
11033 | - case LANG_VIETNAMESE: return "vi_VN"; | ||
11034 | - case LANG_WELSH: return "cy_GB"; | ||
11035 | - case LANG_XHOSA: return "xh_ZA"; | ||
11036 | - case LANG_YI: return "sit_CN"; | ||
11037 | - case LANG_YIDDISH: return "yi_IL"; | ||
11038 | - case LANG_YORUBA: return "yo_NG"; | ||
11039 | - case LANG_ZULU: return "zu_ZA"; | ||
11040 | - default: return "C"; | ||
11041 | - } | ||
11042 | - } | ||
11043 | -# endif | ||
11044 | -#endif | ||
11045 | -} | ||
11046 | - | ||
11047 | -const char * | ||
11048 | -gl_locale_name (int category, const char *categoryname) | ||
11049 | -{ | ||
11050 | - const char *retval; | ||
11051 | - | ||
11052 | - retval = gl_locale_name_posix (category, categoryname); | ||
11053 | - if (retval != NULL) | ||
11054 | - return retval; | ||
11055 | - | ||
11056 | - return gl_locale_name_default (); | ||
11057 | -} | ||
11058 | --- a/intl/lock.c | ||
11059 | +++ /dev/null | ||
11060 | @@ -1,922 +0,0 @@ | ||
11061 | -/* Locking in multithreaded situations. | ||
11062 | - Copyright (C) 2005-2006 Free Software Foundation, Inc. | ||
11063 | - | ||
11064 | - This program is free software; you can redistribute it and/or modify it | ||
11065 | - under the terms of the GNU Library General Public License as published | ||
11066 | - by the Free Software Foundation; either version 2, or (at your option) | ||
11067 | - any later version. | ||
11068 | - | ||
11069 | - This program is distributed in the hope that it will be useful, | ||
11070 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11071 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11072 | - Library General Public License for more details. | ||
11073 | - | ||
11074 | - You should have received a copy of the GNU Library General Public | ||
11075 | - License along with this program; if not, write to the Free Software | ||
11076 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
11077 | - USA. */ | ||
11078 | - | ||
11079 | -/* Written by Bruno Haible <bruno@clisp.org>, 2005. | ||
11080 | - Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, | ||
11081 | - gthr-win32.h. */ | ||
11082 | - | ||
11083 | -#include <config.h> | ||
11084 | - | ||
11085 | -#include "lock.h" | ||
11086 | - | ||
11087 | -/* ========================================================================= */ | ||
11088 | - | ||
11089 | -#if USE_POSIX_THREADS | ||
11090 | - | ||
11091 | -/* Use the POSIX threads library. */ | ||
11092 | - | ||
11093 | -# if PTHREAD_IN_USE_DETECTION_HARD | ||
11094 | - | ||
11095 | -/* The function to be executed by a dummy thread. */ | ||
11096 | -static void * | ||
11097 | -dummy_thread_func (void *arg) | ||
11098 | -{ | ||
11099 | - return arg; | ||
11100 | -} | ||
11101 | - | ||
11102 | -int | ||
11103 | -glthread_in_use (void) | ||
11104 | -{ | ||
11105 | - static int tested; | ||
11106 | - static int result; /* 1: linked with -lpthread, 0: only with libc */ | ||
11107 | - | ||
11108 | - if (!tested) | ||
11109 | - { | ||
11110 | - pthread_t thread; | ||
11111 | - | ||
11112 | - if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) | ||
11113 | - /* Thread creation failed. */ | ||
11114 | - result = 0; | ||
11115 | - else | ||
11116 | - { | ||
11117 | - /* Thread creation works. */ | ||
11118 | - void *retval; | ||
11119 | - if (pthread_join (thread, &retval) != 0) | ||
11120 | - abort (); | ||
11121 | - result = 1; | ||
11122 | - } | ||
11123 | - tested = 1; | ||
11124 | - } | ||
11125 | - return result; | ||
11126 | -} | ||
11127 | - | ||
11128 | -# endif | ||
11129 | - | ||
11130 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
11131 | - | ||
11132 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
11133 | - | ||
11134 | -# if HAVE_PTHREAD_RWLOCK | ||
11135 | - | ||
11136 | -# if !defined PTHREAD_RWLOCK_INITIALIZER | ||
11137 | - | ||
11138 | -void | ||
11139 | -glthread_rwlock_init (gl_rwlock_t *lock) | ||
11140 | -{ | ||
11141 | - if (pthread_rwlock_init (&lock->rwlock, NULL) != 0) | ||
11142 | - abort (); | ||
11143 | - lock->initialized = 1; | ||
11144 | -} | ||
11145 | - | ||
11146 | -void | ||
11147 | -glthread_rwlock_rdlock (gl_rwlock_t *lock) | ||
11148 | -{ | ||
11149 | - if (!lock->initialized) | ||
11150 | - { | ||
11151 | - if (pthread_mutex_lock (&lock->guard) != 0) | ||
11152 | - abort (); | ||
11153 | - if (!lock->initialized) | ||
11154 | - glthread_rwlock_init (lock); | ||
11155 | - if (pthread_mutex_unlock (&lock->guard) != 0) | ||
11156 | - abort (); | ||
11157 | - } | ||
11158 | - if (pthread_rwlock_rdlock (&lock->rwlock) != 0) | ||
11159 | - abort (); | ||
11160 | -} | ||
11161 | - | ||
11162 | -void | ||
11163 | -glthread_rwlock_wrlock (gl_rwlock_t *lock) | ||
11164 | -{ | ||
11165 | - if (!lock->initialized) | ||
11166 | - { | ||
11167 | - if (pthread_mutex_lock (&lock->guard) != 0) | ||
11168 | - abort (); | ||
11169 | - if (!lock->initialized) | ||
11170 | - glthread_rwlock_init (lock); | ||
11171 | - if (pthread_mutex_unlock (&lock->guard) != 0) | ||
11172 | - abort (); | ||
11173 | - } | ||
11174 | - if (pthread_rwlock_wrlock (&lock->rwlock) != 0) | ||
11175 | - abort (); | ||
11176 | -} | ||
11177 | - | ||
11178 | -void | ||
11179 | -glthread_rwlock_unlock (gl_rwlock_t *lock) | ||
11180 | -{ | ||
11181 | - if (!lock->initialized) | ||
11182 | - abort (); | ||
11183 | - if (pthread_rwlock_unlock (&lock->rwlock) != 0) | ||
11184 | - abort (); | ||
11185 | -} | ||
11186 | - | ||
11187 | -void | ||
11188 | -glthread_rwlock_destroy (gl_rwlock_t *lock) | ||
11189 | -{ | ||
11190 | - if (!lock->initialized) | ||
11191 | - abort (); | ||
11192 | - if (pthread_rwlock_destroy (&lock->rwlock) != 0) | ||
11193 | - abort (); | ||
11194 | - lock->initialized = 0; | ||
11195 | -} | ||
11196 | - | ||
11197 | -# endif | ||
11198 | - | ||
11199 | -# else | ||
11200 | - | ||
11201 | -void | ||
11202 | -glthread_rwlock_init (gl_rwlock_t *lock) | ||
11203 | -{ | ||
11204 | - if (pthread_mutex_init (&lock->lock, NULL) != 0) | ||
11205 | - abort (); | ||
11206 | - if (pthread_cond_init (&lock->waiting_readers, NULL) != 0) | ||
11207 | - abort (); | ||
11208 | - if (pthread_cond_init (&lock->waiting_writers, NULL) != 0) | ||
11209 | - abort (); | ||
11210 | - lock->waiting_writers_count = 0; | ||
11211 | - lock->runcount = 0; | ||
11212 | -} | ||
11213 | - | ||
11214 | -void | ||
11215 | -glthread_rwlock_rdlock (gl_rwlock_t *lock) | ||
11216 | -{ | ||
11217 | - if (pthread_mutex_lock (&lock->lock) != 0) | ||
11218 | - abort (); | ||
11219 | - /* Test whether only readers are currently running, and whether the runcount | ||
11220 | - field will not overflow. */ | ||
11221 | - /* POSIX says: "It is implementation-defined whether the calling thread | ||
11222 | - acquires the lock when a writer does not hold the lock and there are | ||
11223 | - writers blocked on the lock." Let's say, no: give the writers a higher | ||
11224 | - priority. */ | ||
11225 | - while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) | ||
11226 | - { | ||
11227 | - /* This thread has to wait for a while. Enqueue it among the | ||
11228 | - waiting_readers. */ | ||
11229 | - if (pthread_cond_wait (&lock->waiting_readers, &lock->lock) != 0) | ||
11230 | - abort (); | ||
11231 | - } | ||
11232 | - lock->runcount++; | ||
11233 | - if (pthread_mutex_unlock (&lock->lock) != 0) | ||
11234 | - abort (); | ||
11235 | -} | ||
11236 | - | ||
11237 | -void | ||
11238 | -glthread_rwlock_wrlock (gl_rwlock_t *lock) | ||
11239 | -{ | ||
11240 | - if (pthread_mutex_lock (&lock->lock) != 0) | ||
11241 | - abort (); | ||
11242 | - /* Test whether no readers or writers are currently running. */ | ||
11243 | - while (!(lock->runcount == 0)) | ||
11244 | - { | ||
11245 | - /* This thread has to wait for a while. Enqueue it among the | ||
11246 | - waiting_writers. */ | ||
11247 | - lock->waiting_writers_count++; | ||
11248 | - if (pthread_cond_wait (&lock->waiting_writers, &lock->lock) != 0) | ||
11249 | - abort (); | ||
11250 | - lock->waiting_writers_count--; | ||
11251 | - } | ||
11252 | - lock->runcount--; /* runcount becomes -1 */ | ||
11253 | - if (pthread_mutex_unlock (&lock->lock) != 0) | ||
11254 | - abort (); | ||
11255 | -} | ||
11256 | - | ||
11257 | -void | ||
11258 | -glthread_rwlock_unlock (gl_rwlock_t *lock) | ||
11259 | -{ | ||
11260 | - if (pthread_mutex_lock (&lock->lock) != 0) | ||
11261 | - abort (); | ||
11262 | - if (lock->runcount < 0) | ||
11263 | - { | ||
11264 | - /* Drop a writer lock. */ | ||
11265 | - if (!(lock->runcount == -1)) | ||
11266 | - abort (); | ||
11267 | - lock->runcount = 0; | ||
11268 | - } | ||
11269 | - else | ||
11270 | - { | ||
11271 | - /* Drop a reader lock. */ | ||
11272 | - if (!(lock->runcount > 0)) | ||
11273 | - abort (); | ||
11274 | - lock->runcount--; | ||
11275 | - } | ||
11276 | - if (lock->runcount == 0) | ||
11277 | - { | ||
11278 | - /* POSIX recommends that "write locks shall take precedence over read | ||
11279 | - locks", to avoid "writer starvation". */ | ||
11280 | - if (lock->waiting_writers_count > 0) | ||
11281 | - { | ||
11282 | - /* Wake up one of the waiting writers. */ | ||
11283 | - if (pthread_cond_signal (&lock->waiting_writers) != 0) | ||
11284 | - abort (); | ||
11285 | - } | ||
11286 | - else | ||
11287 | - { | ||
11288 | - /* Wake up all waiting readers. */ | ||
11289 | - if (pthread_cond_broadcast (&lock->waiting_readers) != 0) | ||
11290 | - abort (); | ||
11291 | - } | ||
11292 | - } | ||
11293 | - if (pthread_mutex_unlock (&lock->lock) != 0) | ||
11294 | - abort (); | ||
11295 | -} | ||
11296 | - | ||
11297 | -void | ||
11298 | -glthread_rwlock_destroy (gl_rwlock_t *lock) | ||
11299 | -{ | ||
11300 | - if (pthread_mutex_destroy (&lock->lock) != 0) | ||
11301 | - abort (); | ||
11302 | - if (pthread_cond_destroy (&lock->waiting_readers) != 0) | ||
11303 | - abort (); | ||
11304 | - if (pthread_cond_destroy (&lock->waiting_writers) != 0) | ||
11305 | - abort (); | ||
11306 | -} | ||
11307 | - | ||
11308 | -# endif | ||
11309 | - | ||
11310 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
11311 | - | ||
11312 | -# if HAVE_PTHREAD_MUTEX_RECURSIVE | ||
11313 | - | ||
11314 | -# if !(defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) | ||
11315 | - | ||
11316 | -void | ||
11317 | -glthread_recursive_lock_init (gl_recursive_lock_t *lock) | ||
11318 | -{ | ||
11319 | - pthread_mutexattr_t attributes; | ||
11320 | - | ||
11321 | - if (pthread_mutexattr_init (&attributes) != 0) | ||
11322 | - abort (); | ||
11323 | - if (pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE) != 0) | ||
11324 | - abort (); | ||
11325 | - if (pthread_mutex_init (&lock->recmutex, &attributes) != 0) | ||
11326 | - abort (); | ||
11327 | - if (pthread_mutexattr_destroy (&attributes) != 0) | ||
11328 | - abort (); | ||
11329 | - lock->initialized = 1; | ||
11330 | -} | ||
11331 | - | ||
11332 | -void | ||
11333 | -glthread_recursive_lock_lock (gl_recursive_lock_t *lock) | ||
11334 | -{ | ||
11335 | - if (!lock->initialized) | ||
11336 | - { | ||
11337 | - if (pthread_mutex_lock (&lock->guard) != 0) | ||
11338 | - abort (); | ||
11339 | - if (!lock->initialized) | ||
11340 | - glthread_recursive_lock_init (lock); | ||
11341 | - if (pthread_mutex_unlock (&lock->guard) != 0) | ||
11342 | - abort (); | ||
11343 | - } | ||
11344 | - if (pthread_mutex_lock (&lock->recmutex) != 0) | ||
11345 | - abort (); | ||
11346 | -} | ||
11347 | - | ||
11348 | -void | ||
11349 | -glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) | ||
11350 | -{ | ||
11351 | - if (!lock->initialized) | ||
11352 | - abort (); | ||
11353 | - if (pthread_mutex_unlock (&lock->recmutex) != 0) | ||
11354 | - abort (); | ||
11355 | -} | ||
11356 | - | ||
11357 | -void | ||
11358 | -glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) | ||
11359 | -{ | ||
11360 | - if (!lock->initialized) | ||
11361 | - abort (); | ||
11362 | - if (pthread_mutex_destroy (&lock->recmutex) != 0) | ||
11363 | - abort (); | ||
11364 | - lock->initialized = 0; | ||
11365 | -} | ||
11366 | - | ||
11367 | -# endif | ||
11368 | - | ||
11369 | -# else | ||
11370 | - | ||
11371 | -void | ||
11372 | -glthread_recursive_lock_init (gl_recursive_lock_t *lock) | ||
11373 | -{ | ||
11374 | - if (pthread_mutex_init (&lock->mutex, NULL) != 0) | ||
11375 | - abort (); | ||
11376 | - lock->owner = (pthread_t) 0; | ||
11377 | - lock->depth = 0; | ||
11378 | -} | ||
11379 | - | ||
11380 | -void | ||
11381 | -glthread_recursive_lock_lock (gl_recursive_lock_t *lock) | ||
11382 | -{ | ||
11383 | - pthread_t self = pthread_self (); | ||
11384 | - if (lock->owner != self) | ||
11385 | - { | ||
11386 | - if (pthread_mutex_lock (&lock->mutex) != 0) | ||
11387 | - abort (); | ||
11388 | - lock->owner = self; | ||
11389 | - } | ||
11390 | - if (++(lock->depth) == 0) /* wraparound? */ | ||
11391 | - abort (); | ||
11392 | -} | ||
11393 | - | ||
11394 | -void | ||
11395 | -glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) | ||
11396 | -{ | ||
11397 | - if (lock->owner != pthread_self ()) | ||
11398 | - abort (); | ||
11399 | - if (lock->depth == 0) | ||
11400 | - abort (); | ||
11401 | - if (--(lock->depth) == 0) | ||
11402 | - { | ||
11403 | - lock->owner = (pthread_t) 0; | ||
11404 | - if (pthread_mutex_unlock (&lock->mutex) != 0) | ||
11405 | - abort (); | ||
11406 | - } | ||
11407 | -} | ||
11408 | - | ||
11409 | -void | ||
11410 | -glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) | ||
11411 | -{ | ||
11412 | - if (lock->owner != (pthread_t) 0) | ||
11413 | - abort (); | ||
11414 | - if (pthread_mutex_destroy (&lock->mutex) != 0) | ||
11415 | - abort (); | ||
11416 | -} | ||
11417 | - | ||
11418 | -# endif | ||
11419 | - | ||
11420 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
11421 | - | ||
11422 | -static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; | ||
11423 | - | ||
11424 | -int | ||
11425 | -glthread_once_singlethreaded (pthread_once_t *once_control) | ||
11426 | -{ | ||
11427 | - /* We don't know whether pthread_once_t is an integer type, a floating-point | ||
11428 | - type, a pointer type, or a structure type. */ | ||
11429 | - char *firstbyte = (char *)once_control; | ||
11430 | - if (*firstbyte == *(const char *)&fresh_once) | ||
11431 | - { | ||
11432 | - /* First time use of once_control. Invert the first byte. */ | ||
11433 | - *firstbyte = ~ *(const char *)&fresh_once; | ||
11434 | - return 1; | ||
11435 | - } | ||
11436 | - else | ||
11437 | - return 0; | ||
11438 | -} | ||
11439 | - | ||
11440 | -#endif | ||
11441 | - | ||
11442 | -/* ========================================================================= */ | ||
11443 | - | ||
11444 | -#if USE_PTH_THREADS | ||
11445 | - | ||
11446 | -/* Use the GNU Pth threads library. */ | ||
11447 | - | ||
11448 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
11449 | - | ||
11450 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
11451 | - | ||
11452 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
11453 | - | ||
11454 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
11455 | - | ||
11456 | -void | ||
11457 | -glthread_once_call (void *arg) | ||
11458 | -{ | ||
11459 | - void (**gl_once_temp_addr) (void) = (void (**) (void)) arg; | ||
11460 | - void (*initfunction) (void) = *gl_once_temp_addr; | ||
11461 | - initfunction (); | ||
11462 | -} | ||
11463 | - | ||
11464 | -int | ||
11465 | -glthread_once_singlethreaded (pth_once_t *once_control) | ||
11466 | -{ | ||
11467 | - /* We know that pth_once_t is an integer type. */ | ||
11468 | - if (*once_control == PTH_ONCE_INIT) | ||
11469 | - { | ||
11470 | - /* First time use of once_control. Invert the marker. */ | ||
11471 | - *once_control = ~ PTH_ONCE_INIT; | ||
11472 | - return 1; | ||
11473 | - } | ||
11474 | - else | ||
11475 | - return 0; | ||
11476 | -} | ||
11477 | - | ||
11478 | -#endif | ||
11479 | - | ||
11480 | -/* ========================================================================= */ | ||
11481 | - | ||
11482 | -#if USE_SOLARIS_THREADS | ||
11483 | - | ||
11484 | -/* Use the old Solaris threads library. */ | ||
11485 | - | ||
11486 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
11487 | - | ||
11488 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
11489 | - | ||
11490 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
11491 | - | ||
11492 | -void | ||
11493 | -glthread_recursive_lock_init (gl_recursive_lock_t *lock) | ||
11494 | -{ | ||
11495 | - if (mutex_init (&lock->mutex, USYNC_THREAD, NULL) != 0) | ||
11496 | - abort (); | ||
11497 | - lock->owner = (thread_t) 0; | ||
11498 | - lock->depth = 0; | ||
11499 | -} | ||
11500 | - | ||
11501 | -void | ||
11502 | -glthread_recursive_lock_lock (gl_recursive_lock_t *lock) | ||
11503 | -{ | ||
11504 | - thread_t self = thr_self (); | ||
11505 | - if (lock->owner != self) | ||
11506 | - { | ||
11507 | - if (mutex_lock (&lock->mutex) != 0) | ||
11508 | - abort (); | ||
11509 | - lock->owner = self; | ||
11510 | - } | ||
11511 | - if (++(lock->depth) == 0) /* wraparound? */ | ||
11512 | - abort (); | ||
11513 | -} | ||
11514 | - | ||
11515 | -void | ||
11516 | -glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) | ||
11517 | -{ | ||
11518 | - if (lock->owner != thr_self ()) | ||
11519 | - abort (); | ||
11520 | - if (lock->depth == 0) | ||
11521 | - abort (); | ||
11522 | - if (--(lock->depth) == 0) | ||
11523 | - { | ||
11524 | - lock->owner = (thread_t) 0; | ||
11525 | - if (mutex_unlock (&lock->mutex) != 0) | ||
11526 | - abort (); | ||
11527 | - } | ||
11528 | -} | ||
11529 | - | ||
11530 | -void | ||
11531 | -glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) | ||
11532 | -{ | ||
11533 | - if (lock->owner != (thread_t) 0) | ||
11534 | - abort (); | ||
11535 | - if (mutex_destroy (&lock->mutex) != 0) | ||
11536 | - abort (); | ||
11537 | -} | ||
11538 | - | ||
11539 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
11540 | - | ||
11541 | -void | ||
11542 | -glthread_once (gl_once_t *once_control, void (*initfunction) (void)) | ||
11543 | -{ | ||
11544 | - if (!once_control->inited) | ||
11545 | - { | ||
11546 | - /* Use the mutex to guarantee that if another thread is already calling | ||
11547 | - the initfunction, this thread waits until it's finished. */ | ||
11548 | - if (mutex_lock (&once_control->mutex) != 0) | ||
11549 | - abort (); | ||
11550 | - if (!once_control->inited) | ||
11551 | - { | ||
11552 | - once_control->inited = 1; | ||
11553 | - initfunction (); | ||
11554 | - } | ||
11555 | - if (mutex_unlock (&once_control->mutex) != 0) | ||
11556 | - abort (); | ||
11557 | - } | ||
11558 | -} | ||
11559 | - | ||
11560 | -int | ||
11561 | -glthread_once_singlethreaded (gl_once_t *once_control) | ||
11562 | -{ | ||
11563 | - /* We know that gl_once_t contains an integer type. */ | ||
11564 | - if (!once_control->inited) | ||
11565 | - { | ||
11566 | - /* First time use of once_control. Invert the marker. */ | ||
11567 | - once_control->inited = ~ 0; | ||
11568 | - return 1; | ||
11569 | - } | ||
11570 | - else | ||
11571 | - return 0; | ||
11572 | -} | ||
11573 | - | ||
11574 | -#endif | ||
11575 | - | ||
11576 | -/* ========================================================================= */ | ||
11577 | - | ||
11578 | -#if USE_WIN32_THREADS | ||
11579 | - | ||
11580 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
11581 | - | ||
11582 | -void | ||
11583 | -glthread_lock_init (gl_lock_t *lock) | ||
11584 | -{ | ||
11585 | - InitializeCriticalSection (&lock->lock); | ||
11586 | - lock->guard.done = 1; | ||
11587 | -} | ||
11588 | - | ||
11589 | -void | ||
11590 | -glthread_lock_lock (gl_lock_t *lock) | ||
11591 | -{ | ||
11592 | - if (!lock->guard.done) | ||
11593 | - { | ||
11594 | - if (InterlockedIncrement (&lock->guard.started) == 0) | ||
11595 | - /* This thread is the first one to need this lock. Initialize it. */ | ||
11596 | - glthread_lock_init (lock); | ||
11597 | - else | ||
11598 | - /* Yield the CPU while waiting for another thread to finish | ||
11599 | - initializing this lock. */ | ||
11600 | - while (!lock->guard.done) | ||
11601 | - Sleep (0); | ||
11602 | - } | ||
11603 | - EnterCriticalSection (&lock->lock); | ||
11604 | -} | ||
11605 | - | ||
11606 | -void | ||
11607 | -glthread_lock_unlock (gl_lock_t *lock) | ||
11608 | -{ | ||
11609 | - if (!lock->guard.done) | ||
11610 | - abort (); | ||
11611 | - LeaveCriticalSection (&lock->lock); | ||
11612 | -} | ||
11613 | - | ||
11614 | -void | ||
11615 | -glthread_lock_destroy (gl_lock_t *lock) | ||
11616 | -{ | ||
11617 | - if (!lock->guard.done) | ||
11618 | - abort (); | ||
11619 | - DeleteCriticalSection (&lock->lock); | ||
11620 | - lock->guard.done = 0; | ||
11621 | -} | ||
11622 | - | ||
11623 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
11624 | - | ||
11625 | -static inline void | ||
11626 | -gl_waitqueue_init (gl_waitqueue_t *wq) | ||
11627 | -{ | ||
11628 | - wq->array = NULL; | ||
11629 | - wq->count = 0; | ||
11630 | - wq->alloc = 0; | ||
11631 | - wq->offset = 0; | ||
11632 | -} | ||
11633 | - | ||
11634 | -/* Enqueues the current thread, represented by an event, in a wait queue. | ||
11635 | - Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ | ||
11636 | -static HANDLE | ||
11637 | -gl_waitqueue_add (gl_waitqueue_t *wq) | ||
11638 | -{ | ||
11639 | - HANDLE event; | ||
11640 | - unsigned int index; | ||
11641 | - | ||
11642 | - if (wq->count == wq->alloc) | ||
11643 | - { | ||
11644 | - unsigned int new_alloc = 2 * wq->alloc + 1; | ||
11645 | - HANDLE *new_array = | ||
11646 | - (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); | ||
11647 | - if (new_array == NULL) | ||
11648 | - /* No more memory. */ | ||
11649 | - return INVALID_HANDLE_VALUE; | ||
11650 | - /* Now is a good opportunity to rotate the array so that its contents | ||
11651 | - starts at offset 0. */ | ||
11652 | - if (wq->offset > 0) | ||
11653 | - { | ||
11654 | - unsigned int old_count = wq->count; | ||
11655 | - unsigned int old_alloc = wq->alloc; | ||
11656 | - unsigned int old_offset = wq->offset; | ||
11657 | - unsigned int i; | ||
11658 | - if (old_offset + old_count > old_alloc) | ||
11659 | - { | ||
11660 | - unsigned int limit = old_offset + old_count - old_alloc; | ||
11661 | - for (i = 0; i < limit; i++) | ||
11662 | - new_array[old_alloc + i] = new_array[i]; | ||
11663 | - } | ||
11664 | - for (i = 0; i < old_count; i++) | ||
11665 | - new_array[i] = new_array[old_offset + i]; | ||
11666 | - wq->offset = 0; | ||
11667 | - } | ||
11668 | - wq->array = new_array; | ||
11669 | - wq->alloc = new_alloc; | ||
11670 | - } | ||
11671 | - event = CreateEvent (NULL, TRUE, FALSE, NULL); | ||
11672 | - if (event == INVALID_HANDLE_VALUE) | ||
11673 | - /* No way to allocate an event. */ | ||
11674 | - return INVALID_HANDLE_VALUE; | ||
11675 | - index = wq->offset + wq->count; | ||
11676 | - if (index >= wq->alloc) | ||
11677 | - index -= wq->alloc; | ||
11678 | - wq->array[index] = event; | ||
11679 | - wq->count++; | ||
11680 | - return event; | ||
11681 | -} | ||
11682 | - | ||
11683 | -/* Notifies the first thread from a wait queue and dequeues it. */ | ||
11684 | -static inline void | ||
11685 | -gl_waitqueue_notify_first (gl_waitqueue_t *wq) | ||
11686 | -{ | ||
11687 | - SetEvent (wq->array[wq->offset + 0]); | ||
11688 | - wq->offset++; | ||
11689 | - wq->count--; | ||
11690 | - if (wq->count == 0 || wq->offset == wq->alloc) | ||
11691 | - wq->offset = 0; | ||
11692 | -} | ||
11693 | - | ||
11694 | -/* Notifies all threads from a wait queue and dequeues them all. */ | ||
11695 | -static inline void | ||
11696 | -gl_waitqueue_notify_all (gl_waitqueue_t *wq) | ||
11697 | -{ | ||
11698 | - unsigned int i; | ||
11699 | - | ||
11700 | - for (i = 0; i < wq->count; i++) | ||
11701 | - { | ||
11702 | - unsigned int index = wq->offset + i; | ||
11703 | - if (index >= wq->alloc) | ||
11704 | - index -= wq->alloc; | ||
11705 | - SetEvent (wq->array[index]); | ||
11706 | - } | ||
11707 | - wq->count = 0; | ||
11708 | - wq->offset = 0; | ||
11709 | -} | ||
11710 | - | ||
11711 | -void | ||
11712 | -glthread_rwlock_init (gl_rwlock_t *lock) | ||
11713 | -{ | ||
11714 | - InitializeCriticalSection (&lock->lock); | ||
11715 | - gl_waitqueue_init (&lock->waiting_readers); | ||
11716 | - gl_waitqueue_init (&lock->waiting_writers); | ||
11717 | - lock->runcount = 0; | ||
11718 | - lock->guard.done = 1; | ||
11719 | -} | ||
11720 | - | ||
11721 | -void | ||
11722 | -glthread_rwlock_rdlock (gl_rwlock_t *lock) | ||
11723 | -{ | ||
11724 | - if (!lock->guard.done) | ||
11725 | - { | ||
11726 | - if (InterlockedIncrement (&lock->guard.started) == 0) | ||
11727 | - /* This thread is the first one to need this lock. Initialize it. */ | ||
11728 | - glthread_rwlock_init (lock); | ||
11729 | - else | ||
11730 | - /* Yield the CPU while waiting for another thread to finish | ||
11731 | - initializing this lock. */ | ||
11732 | - while (!lock->guard.done) | ||
11733 | - Sleep (0); | ||
11734 | - } | ||
11735 | - EnterCriticalSection (&lock->lock); | ||
11736 | - /* Test whether only readers are currently running, and whether the runcount | ||
11737 | - field will not overflow. */ | ||
11738 | - if (!(lock->runcount + 1 > 0)) | ||
11739 | - { | ||
11740 | - /* This thread has to wait for a while. Enqueue it among the | ||
11741 | - waiting_readers. */ | ||
11742 | - HANDLE event = gl_waitqueue_add (&lock->waiting_readers); | ||
11743 | - if (event != INVALID_HANDLE_VALUE) | ||
11744 | - { | ||
11745 | - DWORD result; | ||
11746 | - LeaveCriticalSection (&lock->lock); | ||
11747 | - /* Wait until another thread signals this event. */ | ||
11748 | - result = WaitForSingleObject (event, INFINITE); | ||
11749 | - if (result == WAIT_FAILED || result == WAIT_TIMEOUT) | ||
11750 | - abort (); | ||
11751 | - CloseHandle (event); | ||
11752 | - /* The thread which signalled the event already did the bookkeeping: | ||
11753 | - removed us from the waiting_readers, incremented lock->runcount. */ | ||
11754 | - if (!(lock->runcount > 0)) | ||
11755 | - abort (); | ||
11756 | - return; | ||
11757 | - } | ||
11758 | - else | ||
11759 | - { | ||
11760 | - /* Allocation failure. Weird. */ | ||
11761 | - do | ||
11762 | - { | ||
11763 | - LeaveCriticalSection (&lock->lock); | ||
11764 | - Sleep (1); | ||
11765 | - EnterCriticalSection (&lock->lock); | ||
11766 | - } | ||
11767 | - while (!(lock->runcount + 1 > 0)); | ||
11768 | - } | ||
11769 | - } | ||
11770 | - lock->runcount++; | ||
11771 | - LeaveCriticalSection (&lock->lock); | ||
11772 | -} | ||
11773 | - | ||
11774 | -void | ||
11775 | -glthread_rwlock_wrlock (gl_rwlock_t *lock) | ||
11776 | -{ | ||
11777 | - if (!lock->guard.done) | ||
11778 | - { | ||
11779 | - if (InterlockedIncrement (&lock->guard.started) == 0) | ||
11780 | - /* This thread is the first one to need this lock. Initialize it. */ | ||
11781 | - glthread_rwlock_init (lock); | ||
11782 | - else | ||
11783 | - /* Yield the CPU while waiting for another thread to finish | ||
11784 | - initializing this lock. */ | ||
11785 | - while (!lock->guard.done) | ||
11786 | - Sleep (0); | ||
11787 | - } | ||
11788 | - EnterCriticalSection (&lock->lock); | ||
11789 | - /* Test whether no readers or writers are currently running. */ | ||
11790 | - if (!(lock->runcount == 0)) | ||
11791 | - { | ||
11792 | - /* This thread has to wait for a while. Enqueue it among the | ||
11793 | - waiting_writers. */ | ||
11794 | - HANDLE event = gl_waitqueue_add (&lock->waiting_writers); | ||
11795 | - if (event != INVALID_HANDLE_VALUE) | ||
11796 | - { | ||
11797 | - DWORD result; | ||
11798 | - LeaveCriticalSection (&lock->lock); | ||
11799 | - /* Wait until another thread signals this event. */ | ||
11800 | - result = WaitForSingleObject (event, INFINITE); | ||
11801 | - if (result == WAIT_FAILED || result == WAIT_TIMEOUT) | ||
11802 | - abort (); | ||
11803 | - CloseHandle (event); | ||
11804 | - /* The thread which signalled the event already did the bookkeeping: | ||
11805 | - removed us from the waiting_writers, set lock->runcount = -1. */ | ||
11806 | - if (!(lock->runcount == -1)) | ||
11807 | - abort (); | ||
11808 | - return; | ||
11809 | - } | ||
11810 | - else | ||
11811 | - { | ||
11812 | - /* Allocation failure. Weird. */ | ||
11813 | - do | ||
11814 | - { | ||
11815 | - LeaveCriticalSection (&lock->lock); | ||
11816 | - Sleep (1); | ||
11817 | - EnterCriticalSection (&lock->lock); | ||
11818 | - } | ||
11819 | - while (!(lock->runcount == 0)); | ||
11820 | - } | ||
11821 | - } | ||
11822 | - lock->runcount--; /* runcount becomes -1 */ | ||
11823 | - LeaveCriticalSection (&lock->lock); | ||
11824 | -} | ||
11825 | - | ||
11826 | -void | ||
11827 | -glthread_rwlock_unlock (gl_rwlock_t *lock) | ||
11828 | -{ | ||
11829 | - if (!lock->guard.done) | ||
11830 | - abort (); | ||
11831 | - EnterCriticalSection (&lock->lock); | ||
11832 | - if (lock->runcount < 0) | ||
11833 | - { | ||
11834 | - /* Drop a writer lock. */ | ||
11835 | - if (!(lock->runcount == -1)) | ||
11836 | - abort (); | ||
11837 | - lock->runcount = 0; | ||
11838 | - } | ||
11839 | - else | ||
11840 | - { | ||
11841 | - /* Drop a reader lock. */ | ||
11842 | - if (!(lock->runcount > 0)) | ||
11843 | - abort (); | ||
11844 | - lock->runcount--; | ||
11845 | - } | ||
11846 | - if (lock->runcount == 0) | ||
11847 | - { | ||
11848 | - /* POSIX recommends that "write locks shall take precedence over read | ||
11849 | - locks", to avoid "writer starvation". */ | ||
11850 | - if (lock->waiting_writers.count > 0) | ||
11851 | - { | ||
11852 | - /* Wake up one of the waiting writers. */ | ||
11853 | - lock->runcount--; | ||
11854 | - gl_waitqueue_notify_first (&lock->waiting_writers); | ||
11855 | - } | ||
11856 | - else | ||
11857 | - { | ||
11858 | - /* Wake up all waiting readers. */ | ||
11859 | - lock->runcount += lock->waiting_readers.count; | ||
11860 | - gl_waitqueue_notify_all (&lock->waiting_readers); | ||
11861 | - } | ||
11862 | - } | ||
11863 | - LeaveCriticalSection (&lock->lock); | ||
11864 | -} | ||
11865 | - | ||
11866 | -void | ||
11867 | -glthread_rwlock_destroy (gl_rwlock_t *lock) | ||
11868 | -{ | ||
11869 | - if (!lock->guard.done) | ||
11870 | - abort (); | ||
11871 | - if (lock->runcount != 0) | ||
11872 | - abort (); | ||
11873 | - DeleteCriticalSection (&lock->lock); | ||
11874 | - if (lock->waiting_readers.array != NULL) | ||
11875 | - free (lock->waiting_readers.array); | ||
11876 | - if (lock->waiting_writers.array != NULL) | ||
11877 | - free (lock->waiting_writers.array); | ||
11878 | - lock->guard.done = 0; | ||
11879 | -} | ||
11880 | - | ||
11881 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
11882 | - | ||
11883 | -void | ||
11884 | -glthread_recursive_lock_init (gl_recursive_lock_t *lock) | ||
11885 | -{ | ||
11886 | - lock->owner = 0; | ||
11887 | - lock->depth = 0; | ||
11888 | - InitializeCriticalSection (&lock->lock); | ||
11889 | - lock->guard.done = 1; | ||
11890 | -} | ||
11891 | - | ||
11892 | -void | ||
11893 | -glthread_recursive_lock_lock (gl_recursive_lock_t *lock) | ||
11894 | -{ | ||
11895 | - if (!lock->guard.done) | ||
11896 | - { | ||
11897 | - if (InterlockedIncrement (&lock->guard.started) == 0) | ||
11898 | - /* This thread is the first one to need this lock. Initialize it. */ | ||
11899 | - glthread_recursive_lock_init (lock); | ||
11900 | - else | ||
11901 | - /* Yield the CPU while waiting for another thread to finish | ||
11902 | - initializing this lock. */ | ||
11903 | - while (!lock->guard.done) | ||
11904 | - Sleep (0); | ||
11905 | - } | ||
11906 | - { | ||
11907 | - DWORD self = GetCurrentThreadId (); | ||
11908 | - if (lock->owner != self) | ||
11909 | - { | ||
11910 | - EnterCriticalSection (&lock->lock); | ||
11911 | - lock->owner = self; | ||
11912 | - } | ||
11913 | - if (++(lock->depth) == 0) /* wraparound? */ | ||
11914 | - abort (); | ||
11915 | - } | ||
11916 | -} | ||
11917 | - | ||
11918 | -void | ||
11919 | -glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) | ||
11920 | -{ | ||
11921 | - if (lock->owner != GetCurrentThreadId ()) | ||
11922 | - abort (); | ||
11923 | - if (lock->depth == 0) | ||
11924 | - abort (); | ||
11925 | - if (--(lock->depth) == 0) | ||
11926 | - { | ||
11927 | - lock->owner = 0; | ||
11928 | - LeaveCriticalSection (&lock->lock); | ||
11929 | - } | ||
11930 | -} | ||
11931 | - | ||
11932 | -void | ||
11933 | -glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) | ||
11934 | -{ | ||
11935 | - if (lock->owner != 0) | ||
11936 | - abort (); | ||
11937 | - DeleteCriticalSection (&lock->lock); | ||
11938 | - lock->guard.done = 0; | ||
11939 | -} | ||
11940 | - | ||
11941 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
11942 | - | ||
11943 | -void | ||
11944 | -glthread_once (gl_once_t *once_control, void (*initfunction) (void)) | ||
11945 | -{ | ||
11946 | - if (once_control->inited <= 0) | ||
11947 | - { | ||
11948 | - if (InterlockedIncrement (&once_control->started) == 0) | ||
11949 | - { | ||
11950 | - /* This thread is the first one to come to this once_control. */ | ||
11951 | - InitializeCriticalSection (&once_control->lock); | ||
11952 | - EnterCriticalSection (&once_control->lock); | ||
11953 | - once_control->inited = 0; | ||
11954 | - initfunction (); | ||
11955 | - once_control->inited = 1; | ||
11956 | - LeaveCriticalSection (&once_control->lock); | ||
11957 | - } | ||
11958 | - else | ||
11959 | - { | ||
11960 | - /* Undo last operation. */ | ||
11961 | - InterlockedDecrement (&once_control->started); | ||
11962 | - /* Some other thread has already started the initialization. | ||
11963 | - Yield the CPU while waiting for the other thread to finish | ||
11964 | - initializing and taking the lock. */ | ||
11965 | - while (once_control->inited < 0) | ||
11966 | - Sleep (0); | ||
11967 | - if (once_control->inited <= 0) | ||
11968 | - { | ||
11969 | - /* Take the lock. This blocks until the other thread has | ||
11970 | - finished calling the initfunction. */ | ||
11971 | - EnterCriticalSection (&once_control->lock); | ||
11972 | - LeaveCriticalSection (&once_control->lock); | ||
11973 | - if (!(once_control->inited > 0)) | ||
11974 | - abort (); | ||
11975 | - } | ||
11976 | - } | ||
11977 | - } | ||
11978 | -} | ||
11979 | - | ||
11980 | -#endif | ||
11981 | - | ||
11982 | -/* ========================================================================= */ | ||
11983 | --- a/intl/lock.h | ||
11984 | +++ /dev/null | ||
11985 | @@ -1,1105 +0,0 @@ | ||
11986 | -/* Locking in multithreaded situations. | ||
11987 | - Copyright (C) 2005-2007 Free Software Foundation, Inc. | ||
11988 | - | ||
11989 | - This program is free software; you can redistribute it and/or modify it | ||
11990 | - under the terms of the GNU Library General Public License as published | ||
11991 | - by the Free Software Foundation; either version 2, or (at your option) | ||
11992 | - any later version. | ||
11993 | - | ||
11994 | - This program is distributed in the hope that it will be useful, | ||
11995 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11996 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11997 | - Library General Public License for more details. | ||
11998 | - | ||
11999 | - You should have received a copy of the GNU Library General Public | ||
12000 | - License along with this program; if not, write to the Free Software | ||
12001 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
12002 | - USA. */ | ||
12003 | - | ||
12004 | -/* Written by Bruno Haible <bruno@clisp.org>, 2005. | ||
12005 | - Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, | ||
12006 | - gthr-win32.h. */ | ||
12007 | - | ||
12008 | -/* This file contains locking primitives for use with a given thread library. | ||
12009 | - It does not contain primitives for creating threads or for other | ||
12010 | - synchronization primitives. | ||
12011 | - | ||
12012 | - Normal (non-recursive) locks: | ||
12013 | - Type: gl_lock_t | ||
12014 | - Declaration: gl_lock_define(extern, name) | ||
12015 | - Initializer: gl_lock_define_initialized(, name) | ||
12016 | - Initialization: gl_lock_init (name); | ||
12017 | - Taking the lock: gl_lock_lock (name); | ||
12018 | - Releasing the lock: gl_lock_unlock (name); | ||
12019 | - De-initialization: gl_lock_destroy (name); | ||
12020 | - | ||
12021 | - Read-Write (non-recursive) locks: | ||
12022 | - Type: gl_rwlock_t | ||
12023 | - Declaration: gl_rwlock_define(extern, name) | ||
12024 | - Initializer: gl_rwlock_define_initialized(, name) | ||
12025 | - Initialization: gl_rwlock_init (name); | ||
12026 | - Taking the lock: gl_rwlock_rdlock (name); | ||
12027 | - gl_rwlock_wrlock (name); | ||
12028 | - Releasing the lock: gl_rwlock_unlock (name); | ||
12029 | - De-initialization: gl_rwlock_destroy (name); | ||
12030 | - | ||
12031 | - Recursive locks: | ||
12032 | - Type: gl_recursive_lock_t | ||
12033 | - Declaration: gl_recursive_lock_define(extern, name) | ||
12034 | - Initializer: gl_recursive_lock_define_initialized(, name) | ||
12035 | - Initialization: gl_recursive_lock_init (name); | ||
12036 | - Taking the lock: gl_recursive_lock_lock (name); | ||
12037 | - Releasing the lock: gl_recursive_lock_unlock (name); | ||
12038 | - De-initialization: gl_recursive_lock_destroy (name); | ||
12039 | - | ||
12040 | - Once-only execution: | ||
12041 | - Type: gl_once_t | ||
12042 | - Initializer: gl_once_define(extern, name) | ||
12043 | - Execution: gl_once (name, initfunction); | ||
12044 | -*/ | ||
12045 | - | ||
12046 | - | ||
12047 | -#ifndef _LOCK_H | ||
12048 | -#define _LOCK_H | ||
12049 | - | ||
12050 | -/* ========================================================================= */ | ||
12051 | - | ||
12052 | -#if USE_POSIX_THREADS | ||
12053 | - | ||
12054 | -/* Use the POSIX threads library. */ | ||
12055 | - | ||
12056 | -# include <pthread.h> | ||
12057 | -# include <stdlib.h> | ||
12058 | - | ||
12059 | -# ifdef __cplusplus | ||
12060 | -extern "C" { | ||
12061 | -# endif | ||
12062 | - | ||
12063 | -# if PTHREAD_IN_USE_DETECTION_HARD | ||
12064 | - | ||
12065 | -/* The pthread_in_use() detection needs to be done at runtime. */ | ||
12066 | -# define pthread_in_use() \ | ||
12067 | - glthread_in_use () | ||
12068 | -extern int glthread_in_use (void); | ||
12069 | - | ||
12070 | -# endif | ||
12071 | - | ||
12072 | -# if USE_POSIX_THREADS_WEAK | ||
12073 | - | ||
12074 | -/* Use weak references to the POSIX threads library. */ | ||
12075 | - | ||
12076 | -/* Weak references avoid dragging in external libraries if the other parts | ||
12077 | - of the program don't use them. Here we use them, because we don't want | ||
12078 | - every program that uses libintl to depend on libpthread. This assumes | ||
12079 | - that libpthread would not be loaded after libintl; i.e. if libintl is | ||
12080 | - loaded first, by an executable that does not depend on libpthread, and | ||
12081 | - then a module is dynamically loaded that depends on libpthread, libintl | ||
12082 | - will not be multithread-safe. */ | ||
12083 | - | ||
12084 | -/* The way to test at runtime whether libpthread is present is to test | ||
12085 | - whether a function pointer's value, such as &pthread_mutex_init, is | ||
12086 | - non-NULL. However, some versions of GCC have a bug through which, in | ||
12087 | - PIC mode, &foo != NULL always evaluates to true if there is a direct | ||
12088 | - call to foo(...) in the same function. To avoid this, we test the | ||
12089 | - address of a function in libpthread that we don't use. */ | ||
12090 | - | ||
12091 | -# pragma weak pthread_mutex_init | ||
12092 | -# pragma weak pthread_mutex_lock | ||
12093 | -# pragma weak pthread_mutex_unlock | ||
12094 | -# pragma weak pthread_mutex_destroy | ||
12095 | -# pragma weak pthread_rwlock_init | ||
12096 | -# pragma weak pthread_rwlock_rdlock | ||
12097 | -# pragma weak pthread_rwlock_wrlock | ||
12098 | -# pragma weak pthread_rwlock_unlock | ||
12099 | -# pragma weak pthread_rwlock_destroy | ||
12100 | -# pragma weak pthread_once | ||
12101 | -# pragma weak pthread_cond_init | ||
12102 | -# pragma weak pthread_cond_wait | ||
12103 | -# pragma weak pthread_cond_signal | ||
12104 | -# pragma weak pthread_cond_broadcast | ||
12105 | -# pragma weak pthread_cond_destroy | ||
12106 | -# pragma weak pthread_mutexattr_init | ||
12107 | -# pragma weak pthread_mutexattr_settype | ||
12108 | -# pragma weak pthread_mutexattr_destroy | ||
12109 | -# ifndef pthread_self | ||
12110 | -# pragma weak pthread_self | ||
12111 | -# endif | ||
12112 | - | ||
12113 | -# if !PTHREAD_IN_USE_DETECTION_HARD | ||
12114 | -# pragma weak pthread_cancel | ||
12115 | -# define pthread_in_use() (pthread_cancel != NULL) | ||
12116 | -# endif | ||
12117 | - | ||
12118 | -# else | ||
12119 | - | ||
12120 | -# if !PTHREAD_IN_USE_DETECTION_HARD | ||
12121 | -# define pthread_in_use() 1 | ||
12122 | -# endif | ||
12123 | - | ||
12124 | -# endif | ||
12125 | - | ||
12126 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
12127 | - | ||
12128 | -typedef pthread_mutex_t gl_lock_t; | ||
12129 | -# define gl_lock_define(STORAGECLASS, NAME) \ | ||
12130 | - STORAGECLASS pthread_mutex_t NAME; | ||
12131 | -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12132 | - STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; | ||
12133 | -# define gl_lock_initializer \ | ||
12134 | - PTHREAD_MUTEX_INITIALIZER | ||
12135 | -# define gl_lock_init(NAME) \ | ||
12136 | - do \ | ||
12137 | - { \ | ||
12138 | - if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \ | ||
12139 | - abort (); \ | ||
12140 | - } \ | ||
12141 | - while (0) | ||
12142 | -# define gl_lock_lock(NAME) \ | ||
12143 | - do \ | ||
12144 | - { \ | ||
12145 | - if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) \ | ||
12146 | - abort (); \ | ||
12147 | - } \ | ||
12148 | - while (0) | ||
12149 | -# define gl_lock_unlock(NAME) \ | ||
12150 | - do \ | ||
12151 | - { \ | ||
12152 | - if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) \ | ||
12153 | - abort (); \ | ||
12154 | - } \ | ||
12155 | - while (0) | ||
12156 | -# define gl_lock_destroy(NAME) \ | ||
12157 | - do \ | ||
12158 | - { \ | ||
12159 | - if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) \ | ||
12160 | - abort (); \ | ||
12161 | - } \ | ||
12162 | - while (0) | ||
12163 | - | ||
12164 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
12165 | - | ||
12166 | -# if HAVE_PTHREAD_RWLOCK | ||
12167 | - | ||
12168 | -# ifdef PTHREAD_RWLOCK_INITIALIZER | ||
12169 | - | ||
12170 | -typedef pthread_rwlock_t gl_rwlock_t; | ||
12171 | -# define gl_rwlock_define(STORAGECLASS, NAME) \ | ||
12172 | - STORAGECLASS pthread_rwlock_t NAME; | ||
12173 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ | ||
12174 | - STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; | ||
12175 | -# define gl_rwlock_initializer \ | ||
12176 | - PTHREAD_RWLOCK_INITIALIZER | ||
12177 | -# define gl_rwlock_init(NAME) \ | ||
12178 | - do \ | ||
12179 | - { \ | ||
12180 | - if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) \ | ||
12181 | - abort (); \ | ||
12182 | - } \ | ||
12183 | - while (0) | ||
12184 | -# define gl_rwlock_rdlock(NAME) \ | ||
12185 | - do \ | ||
12186 | - { \ | ||
12187 | - if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) \ | ||
12188 | - abort (); \ | ||
12189 | - } \ | ||
12190 | - while (0) | ||
12191 | -# define gl_rwlock_wrlock(NAME) \ | ||
12192 | - do \ | ||
12193 | - { \ | ||
12194 | - if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) \ | ||
12195 | - abort (); \ | ||
12196 | - } \ | ||
12197 | - while (0) | ||
12198 | -# define gl_rwlock_unlock(NAME) \ | ||
12199 | - do \ | ||
12200 | - { \ | ||
12201 | - if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) \ | ||
12202 | - abort (); \ | ||
12203 | - } \ | ||
12204 | - while (0) | ||
12205 | -# define gl_rwlock_destroy(NAME) \ | ||
12206 | - do \ | ||
12207 | - { \ | ||
12208 | - if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) \ | ||
12209 | - abort (); \ | ||
12210 | - } \ | ||
12211 | - while (0) | ||
12212 | - | ||
12213 | -# else | ||
12214 | - | ||
12215 | -typedef struct | ||
12216 | - { | ||
12217 | - int initialized; | ||
12218 | - pthread_mutex_t guard; /* protects the initialization */ | ||
12219 | - pthread_rwlock_t rwlock; /* read-write lock */ | ||
12220 | - } | ||
12221 | - gl_rwlock_t; | ||
12222 | -# define gl_rwlock_define(STORAGECLASS, NAME) \ | ||
12223 | - STORAGECLASS gl_rwlock_t NAME; | ||
12224 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ | ||
12225 | - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; | ||
12226 | -# define gl_rwlock_initializer \ | ||
12227 | - { 0, PTHREAD_MUTEX_INITIALIZER } | ||
12228 | -# define gl_rwlock_init(NAME) \ | ||
12229 | - do \ | ||
12230 | - { \ | ||
12231 | - if (pthread_in_use ()) \ | ||
12232 | - glthread_rwlock_init (&NAME); \ | ||
12233 | - } \ | ||
12234 | - while (0) | ||
12235 | -# define gl_rwlock_rdlock(NAME) \ | ||
12236 | - do \ | ||
12237 | - { \ | ||
12238 | - if (pthread_in_use ()) \ | ||
12239 | - glthread_rwlock_rdlock (&NAME); \ | ||
12240 | - } \ | ||
12241 | - while (0) | ||
12242 | -# define gl_rwlock_wrlock(NAME) \ | ||
12243 | - do \ | ||
12244 | - { \ | ||
12245 | - if (pthread_in_use ()) \ | ||
12246 | - glthread_rwlock_wrlock (&NAME); \ | ||
12247 | - } \ | ||
12248 | - while (0) | ||
12249 | -# define gl_rwlock_unlock(NAME) \ | ||
12250 | - do \ | ||
12251 | - { \ | ||
12252 | - if (pthread_in_use ()) \ | ||
12253 | - glthread_rwlock_unlock (&NAME); \ | ||
12254 | - } \ | ||
12255 | - while (0) | ||
12256 | -# define gl_rwlock_destroy(NAME) \ | ||
12257 | - do \ | ||
12258 | - { \ | ||
12259 | - if (pthread_in_use ()) \ | ||
12260 | - glthread_rwlock_destroy (&NAME); \ | ||
12261 | - } \ | ||
12262 | - while (0) | ||
12263 | -extern void glthread_rwlock_init (gl_rwlock_t *lock); | ||
12264 | -extern void glthread_rwlock_rdlock (gl_rwlock_t *lock); | ||
12265 | -extern void glthread_rwlock_wrlock (gl_rwlock_t *lock); | ||
12266 | -extern void glthread_rwlock_unlock (gl_rwlock_t *lock); | ||
12267 | -extern void glthread_rwlock_destroy (gl_rwlock_t *lock); | ||
12268 | - | ||
12269 | -# endif | ||
12270 | - | ||
12271 | -# else | ||
12272 | - | ||
12273 | -typedef struct | ||
12274 | - { | ||
12275 | - pthread_mutex_t lock; /* protects the remaining fields */ | ||
12276 | - pthread_cond_t waiting_readers; /* waiting readers */ | ||
12277 | - pthread_cond_t waiting_writers; /* waiting writers */ | ||
12278 | - unsigned int waiting_writers_count; /* number of waiting writers */ | ||
12279 | - int runcount; /* number of readers running, or -1 when a writer runs */ | ||
12280 | - } | ||
12281 | - gl_rwlock_t; | ||
12282 | -# define gl_rwlock_define(STORAGECLASS, NAME) \ | ||
12283 | - STORAGECLASS gl_rwlock_t NAME; | ||
12284 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ | ||
12285 | - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; | ||
12286 | -# define gl_rwlock_initializer \ | ||
12287 | - { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } | ||
12288 | -# define gl_rwlock_init(NAME) \ | ||
12289 | - do \ | ||
12290 | - { \ | ||
12291 | - if (pthread_in_use ()) \ | ||
12292 | - glthread_rwlock_init (&NAME); \ | ||
12293 | - } \ | ||
12294 | - while (0) | ||
12295 | -# define gl_rwlock_rdlock(NAME) \ | ||
12296 | - do \ | ||
12297 | - { \ | ||
12298 | - if (pthread_in_use ()) \ | ||
12299 | - glthread_rwlock_rdlock (&NAME); \ | ||
12300 | - } \ | ||
12301 | - while (0) | ||
12302 | -# define gl_rwlock_wrlock(NAME) \ | ||
12303 | - do \ | ||
12304 | - { \ | ||
12305 | - if (pthread_in_use ()) \ | ||
12306 | - glthread_rwlock_wrlock (&NAME); \ | ||
12307 | - } \ | ||
12308 | - while (0) | ||
12309 | -# define gl_rwlock_unlock(NAME) \ | ||
12310 | - do \ | ||
12311 | - { \ | ||
12312 | - if (pthread_in_use ()) \ | ||
12313 | - glthread_rwlock_unlock (&NAME); \ | ||
12314 | - } \ | ||
12315 | - while (0) | ||
12316 | -# define gl_rwlock_destroy(NAME) \ | ||
12317 | - do \ | ||
12318 | - { \ | ||
12319 | - if (pthread_in_use ()) \ | ||
12320 | - glthread_rwlock_destroy (&NAME); \ | ||
12321 | - } \ | ||
12322 | - while (0) | ||
12323 | -extern void glthread_rwlock_init (gl_rwlock_t *lock); | ||
12324 | -extern void glthread_rwlock_rdlock (gl_rwlock_t *lock); | ||
12325 | -extern void glthread_rwlock_wrlock (gl_rwlock_t *lock); | ||
12326 | -extern void glthread_rwlock_unlock (gl_rwlock_t *lock); | ||
12327 | -extern void glthread_rwlock_destroy (gl_rwlock_t *lock); | ||
12328 | - | ||
12329 | -# endif | ||
12330 | - | ||
12331 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
12332 | - | ||
12333 | -# if HAVE_PTHREAD_MUTEX_RECURSIVE | ||
12334 | - | ||
12335 | -# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP | ||
12336 | - | ||
12337 | -typedef pthread_mutex_t gl_recursive_lock_t; | ||
12338 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | ||
12339 | - STORAGECLASS pthread_mutex_t NAME; | ||
12340 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12341 | - STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; | ||
12342 | -# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER | ||
12343 | -# define gl_recursive_lock_initializer \ | ||
12344 | - PTHREAD_RECURSIVE_MUTEX_INITIALIZER | ||
12345 | -# else | ||
12346 | -# define gl_recursive_lock_initializer \ | ||
12347 | - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP | ||
12348 | -# endif | ||
12349 | -# define gl_recursive_lock_init(NAME) \ | ||
12350 | - do \ | ||
12351 | - { \ | ||
12352 | - if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \ | ||
12353 | - abort (); \ | ||
12354 | - } \ | ||
12355 | - while (0) | ||
12356 | -# define gl_recursive_lock_lock(NAME) \ | ||
12357 | - do \ | ||
12358 | - { \ | ||
12359 | - if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) \ | ||
12360 | - abort (); \ | ||
12361 | - } \ | ||
12362 | - while (0) | ||
12363 | -# define gl_recursive_lock_unlock(NAME) \ | ||
12364 | - do \ | ||
12365 | - { \ | ||
12366 | - if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) \ | ||
12367 | - abort (); \ | ||
12368 | - } \ | ||
12369 | - while (0) | ||
12370 | -# define gl_recursive_lock_destroy(NAME) \ | ||
12371 | - do \ | ||
12372 | - { \ | ||
12373 | - if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) \ | ||
12374 | - abort (); \ | ||
12375 | - } \ | ||
12376 | - while (0) | ||
12377 | - | ||
12378 | -# else | ||
12379 | - | ||
12380 | -typedef struct | ||
12381 | - { | ||
12382 | - pthread_mutex_t recmutex; /* recursive mutex */ | ||
12383 | - pthread_mutex_t guard; /* protects the initialization */ | ||
12384 | - int initialized; | ||
12385 | - } | ||
12386 | - gl_recursive_lock_t; | ||
12387 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | ||
12388 | - STORAGECLASS gl_recursive_lock_t NAME; | ||
12389 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12390 | - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; | ||
12391 | -# define gl_recursive_lock_initializer \ | ||
12392 | - { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } | ||
12393 | -# define gl_recursive_lock_init(NAME) \ | ||
12394 | - do \ | ||
12395 | - { \ | ||
12396 | - if (pthread_in_use ()) \ | ||
12397 | - glthread_recursive_lock_init (&NAME); \ | ||
12398 | - } \ | ||
12399 | - while (0) | ||
12400 | -# define gl_recursive_lock_lock(NAME) \ | ||
12401 | - do \ | ||
12402 | - { \ | ||
12403 | - if (pthread_in_use ()) \ | ||
12404 | - glthread_recursive_lock_lock (&NAME); \ | ||
12405 | - } \ | ||
12406 | - while (0) | ||
12407 | -# define gl_recursive_lock_unlock(NAME) \ | ||
12408 | - do \ | ||
12409 | - { \ | ||
12410 | - if (pthread_in_use ()) \ | ||
12411 | - glthread_recursive_lock_unlock (&NAME); \ | ||
12412 | - } \ | ||
12413 | - while (0) | ||
12414 | -# define gl_recursive_lock_destroy(NAME) \ | ||
12415 | - do \ | ||
12416 | - { \ | ||
12417 | - if (pthread_in_use ()) \ | ||
12418 | - glthread_recursive_lock_destroy (&NAME); \ | ||
12419 | - } \ | ||
12420 | - while (0) | ||
12421 | -extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); | ||
12422 | -extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); | ||
12423 | -extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); | ||
12424 | -extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); | ||
12425 | - | ||
12426 | -# endif | ||
12427 | - | ||
12428 | -# else | ||
12429 | - | ||
12430 | -/* Old versions of POSIX threads on Solaris did not have recursive locks. | ||
12431 | - We have to implement them ourselves. */ | ||
12432 | - | ||
12433 | -typedef struct | ||
12434 | - { | ||
12435 | - pthread_mutex_t mutex; | ||
12436 | - pthread_t owner; | ||
12437 | - unsigned long depth; | ||
12438 | - } | ||
12439 | - gl_recursive_lock_t; | ||
12440 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | ||
12441 | - STORAGECLASS gl_recursive_lock_t NAME; | ||
12442 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12443 | - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; | ||
12444 | -# define gl_recursive_lock_initializer \ | ||
12445 | - { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } | ||
12446 | -# define gl_recursive_lock_init(NAME) \ | ||
12447 | - do \ | ||
12448 | - { \ | ||
12449 | - if (pthread_in_use ()) \ | ||
12450 | - glthread_recursive_lock_init (&NAME); \ | ||
12451 | - } \ | ||
12452 | - while (0) | ||
12453 | -# define gl_recursive_lock_lock(NAME) \ | ||
12454 | - do \ | ||
12455 | - { \ | ||
12456 | - if (pthread_in_use ()) \ | ||
12457 | - glthread_recursive_lock_lock (&NAME); \ | ||
12458 | - } \ | ||
12459 | - while (0) | ||
12460 | -# define gl_recursive_lock_unlock(NAME) \ | ||
12461 | - do \ | ||
12462 | - { \ | ||
12463 | - if (pthread_in_use ()) \ | ||
12464 | - glthread_recursive_lock_unlock (&NAME); \ | ||
12465 | - } \ | ||
12466 | - while (0) | ||
12467 | -# define gl_recursive_lock_destroy(NAME) \ | ||
12468 | - do \ | ||
12469 | - { \ | ||
12470 | - if (pthread_in_use ()) \ | ||
12471 | - glthread_recursive_lock_destroy (&NAME); \ | ||
12472 | - } \ | ||
12473 | - while (0) | ||
12474 | -extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); | ||
12475 | -extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); | ||
12476 | -extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); | ||
12477 | -extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); | ||
12478 | - | ||
12479 | -# endif | ||
12480 | - | ||
12481 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
12482 | - | ||
12483 | -typedef pthread_once_t gl_once_t; | ||
12484 | -# define gl_once_define(STORAGECLASS, NAME) \ | ||
12485 | - STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; | ||
12486 | -# define gl_once(NAME, INITFUNCTION) \ | ||
12487 | - do \ | ||
12488 | - { \ | ||
12489 | - if (pthread_in_use ()) \ | ||
12490 | - { \ | ||
12491 | - if (pthread_once (&NAME, INITFUNCTION) != 0) \ | ||
12492 | - abort (); \ | ||
12493 | - } \ | ||
12494 | - else \ | ||
12495 | - { \ | ||
12496 | - if (glthread_once_singlethreaded (&NAME)) \ | ||
12497 | - INITFUNCTION (); \ | ||
12498 | - } \ | ||
12499 | - } \ | ||
12500 | - while (0) | ||
12501 | -extern int glthread_once_singlethreaded (pthread_once_t *once_control); | ||
12502 | - | ||
12503 | -# ifdef __cplusplus | ||
12504 | -} | ||
12505 | -# endif | ||
12506 | - | ||
12507 | -#endif | ||
12508 | - | ||
12509 | -/* ========================================================================= */ | ||
12510 | - | ||
12511 | -#if USE_PTH_THREADS | ||
12512 | - | ||
12513 | -/* Use the GNU Pth threads library. */ | ||
12514 | - | ||
12515 | -# include <pth.h> | ||
12516 | -# include <stdlib.h> | ||
12517 | - | ||
12518 | -# ifdef __cplusplus | ||
12519 | -extern "C" { | ||
12520 | -# endif | ||
12521 | - | ||
12522 | -# if USE_PTH_THREADS_WEAK | ||
12523 | - | ||
12524 | -/* Use weak references to the GNU Pth threads library. */ | ||
12525 | - | ||
12526 | -# pragma weak pth_mutex_init | ||
12527 | -# pragma weak pth_mutex_acquire | ||
12528 | -# pragma weak pth_mutex_release | ||
12529 | -# pragma weak pth_rwlock_init | ||
12530 | -# pragma weak pth_rwlock_acquire | ||
12531 | -# pragma weak pth_rwlock_release | ||
12532 | -# pragma weak pth_once | ||
12533 | - | ||
12534 | -# pragma weak pth_cancel | ||
12535 | -# define pth_in_use() (pth_cancel != NULL) | ||
12536 | - | ||
12537 | -# else | ||
12538 | - | ||
12539 | -# define pth_in_use() 1 | ||
12540 | - | ||
12541 | -# endif | ||
12542 | - | ||
12543 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
12544 | - | ||
12545 | -typedef pth_mutex_t gl_lock_t; | ||
12546 | -# define gl_lock_define(STORAGECLASS, NAME) \ | ||
12547 | - STORAGECLASS pth_mutex_t NAME; | ||
12548 | -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12549 | - STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; | ||
12550 | -# define gl_lock_initializer \ | ||
12551 | - PTH_MUTEX_INIT | ||
12552 | -# define gl_lock_init(NAME) \ | ||
12553 | - do \ | ||
12554 | - { \ | ||
12555 | - if (pth_in_use() && !pth_mutex_init (&NAME)) \ | ||
12556 | - abort (); \ | ||
12557 | - } \ | ||
12558 | - while (0) | ||
12559 | -# define gl_lock_lock(NAME) \ | ||
12560 | - do \ | ||
12561 | - { \ | ||
12562 | - if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) \ | ||
12563 | - abort (); \ | ||
12564 | - } \ | ||
12565 | - while (0) | ||
12566 | -# define gl_lock_unlock(NAME) \ | ||
12567 | - do \ | ||
12568 | - { \ | ||
12569 | - if (pth_in_use() && !pth_mutex_release (&NAME)) \ | ||
12570 | - abort (); \ | ||
12571 | - } \ | ||
12572 | - while (0) | ||
12573 | -# define gl_lock_destroy(NAME) \ | ||
12574 | - (void)(&NAME) | ||
12575 | - | ||
12576 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
12577 | - | ||
12578 | -typedef pth_rwlock_t gl_rwlock_t; | ||
12579 | -# define gl_rwlock_define(STORAGECLASS, NAME) \ | ||
12580 | - STORAGECLASS pth_rwlock_t NAME; | ||
12581 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ | ||
12582 | - STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; | ||
12583 | -# define gl_rwlock_initializer \ | ||
12584 | - PTH_RWLOCK_INIT | ||
12585 | -# define gl_rwlock_init(NAME) \ | ||
12586 | - do \ | ||
12587 | - { \ | ||
12588 | - if (pth_in_use() && !pth_rwlock_init (&NAME)) \ | ||
12589 | - abort (); \ | ||
12590 | - } \ | ||
12591 | - while (0) | ||
12592 | -# define gl_rwlock_rdlock(NAME) \ | ||
12593 | - do \ | ||
12594 | - { \ | ||
12595 | - if (pth_in_use() \ | ||
12596 | - && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) \ | ||
12597 | - abort (); \ | ||
12598 | - } \ | ||
12599 | - while (0) | ||
12600 | -# define gl_rwlock_wrlock(NAME) \ | ||
12601 | - do \ | ||
12602 | - { \ | ||
12603 | - if (pth_in_use() \ | ||
12604 | - && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) \ | ||
12605 | - abort (); \ | ||
12606 | - } \ | ||
12607 | - while (0) | ||
12608 | -# define gl_rwlock_unlock(NAME) \ | ||
12609 | - do \ | ||
12610 | - { \ | ||
12611 | - if (pth_in_use() && !pth_rwlock_release (&NAME)) \ | ||
12612 | - abort (); \ | ||
12613 | - } \ | ||
12614 | - while (0) | ||
12615 | -# define gl_rwlock_destroy(NAME) \ | ||
12616 | - (void)(&NAME) | ||
12617 | - | ||
12618 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
12619 | - | ||
12620 | -/* In Pth, mutexes are recursive by default. */ | ||
12621 | -typedef pth_mutex_t gl_recursive_lock_t; | ||
12622 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | ||
12623 | - STORAGECLASS pth_mutex_t NAME; | ||
12624 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12625 | - STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; | ||
12626 | -# define gl_recursive_lock_initializer \ | ||
12627 | - PTH_MUTEX_INIT | ||
12628 | -# define gl_recursive_lock_init(NAME) \ | ||
12629 | - do \ | ||
12630 | - { \ | ||
12631 | - if (pth_in_use() && !pth_mutex_init (&NAME)) \ | ||
12632 | - abort (); \ | ||
12633 | - } \ | ||
12634 | - while (0) | ||
12635 | -# define gl_recursive_lock_lock(NAME) \ | ||
12636 | - do \ | ||
12637 | - { \ | ||
12638 | - if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) \ | ||
12639 | - abort (); \ | ||
12640 | - } \ | ||
12641 | - while (0) | ||
12642 | -# define gl_recursive_lock_unlock(NAME) \ | ||
12643 | - do \ | ||
12644 | - { \ | ||
12645 | - if (pth_in_use() && !pth_mutex_release (&NAME)) \ | ||
12646 | - abort (); \ | ||
12647 | - } \ | ||
12648 | - while (0) | ||
12649 | -# define gl_recursive_lock_destroy(NAME) \ | ||
12650 | - (void)(&NAME) | ||
12651 | - | ||
12652 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
12653 | - | ||
12654 | -typedef pth_once_t gl_once_t; | ||
12655 | -# define gl_once_define(STORAGECLASS, NAME) \ | ||
12656 | - STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; | ||
12657 | -# define gl_once(NAME, INITFUNCTION) \ | ||
12658 | - do \ | ||
12659 | - { \ | ||
12660 | - if (pth_in_use ()) \ | ||
12661 | - { \ | ||
12662 | - void (*gl_once_temp) (void) = INITFUNCTION; \ | ||
12663 | - if (!pth_once (&NAME, glthread_once_call, &gl_once_temp)) \ | ||
12664 | - abort (); \ | ||
12665 | - } \ | ||
12666 | - else \ | ||
12667 | - { \ | ||
12668 | - if (glthread_once_singlethreaded (&NAME)) \ | ||
12669 | - INITFUNCTION (); \ | ||
12670 | - } \ | ||
12671 | - } \ | ||
12672 | - while (0) | ||
12673 | -extern void glthread_once_call (void *arg); | ||
12674 | -extern int glthread_once_singlethreaded (pth_once_t *once_control); | ||
12675 | - | ||
12676 | -# ifdef __cplusplus | ||
12677 | -} | ||
12678 | -# endif | ||
12679 | - | ||
12680 | -#endif | ||
12681 | - | ||
12682 | -/* ========================================================================= */ | ||
12683 | - | ||
12684 | -#if USE_SOLARIS_THREADS | ||
12685 | - | ||
12686 | -/* Use the old Solaris threads library. */ | ||
12687 | - | ||
12688 | -# include <thread.h> | ||
12689 | -# include <synch.h> | ||
12690 | -# include <stdlib.h> | ||
12691 | - | ||
12692 | -# ifdef __cplusplus | ||
12693 | -extern "C" { | ||
12694 | -# endif | ||
12695 | - | ||
12696 | -# if USE_SOLARIS_THREADS_WEAK | ||
12697 | - | ||
12698 | -/* Use weak references to the old Solaris threads library. */ | ||
12699 | - | ||
12700 | -# pragma weak mutex_init | ||
12701 | -# pragma weak mutex_lock | ||
12702 | -# pragma weak mutex_unlock | ||
12703 | -# pragma weak mutex_destroy | ||
12704 | -# pragma weak rwlock_init | ||
12705 | -# pragma weak rw_rdlock | ||
12706 | -# pragma weak rw_wrlock | ||
12707 | -# pragma weak rw_unlock | ||
12708 | -# pragma weak rwlock_destroy | ||
12709 | -# pragma weak thr_self | ||
12710 | - | ||
12711 | -# pragma weak thr_suspend | ||
12712 | -# define thread_in_use() (thr_suspend != NULL) | ||
12713 | - | ||
12714 | -# else | ||
12715 | - | ||
12716 | -# define thread_in_use() 1 | ||
12717 | - | ||
12718 | -# endif | ||
12719 | - | ||
12720 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
12721 | - | ||
12722 | -typedef mutex_t gl_lock_t; | ||
12723 | -# define gl_lock_define(STORAGECLASS, NAME) \ | ||
12724 | - STORAGECLASS mutex_t NAME; | ||
12725 | -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12726 | - STORAGECLASS mutex_t NAME = gl_lock_initializer; | ||
12727 | -# define gl_lock_initializer \ | ||
12728 | - DEFAULTMUTEX | ||
12729 | -# define gl_lock_init(NAME) \ | ||
12730 | - do \ | ||
12731 | - { \ | ||
12732 | - if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) \ | ||
12733 | - abort (); \ | ||
12734 | - } \ | ||
12735 | - while (0) | ||
12736 | -# define gl_lock_lock(NAME) \ | ||
12737 | - do \ | ||
12738 | - { \ | ||
12739 | - if (thread_in_use () && mutex_lock (&NAME) != 0) \ | ||
12740 | - abort (); \ | ||
12741 | - } \ | ||
12742 | - while (0) | ||
12743 | -# define gl_lock_unlock(NAME) \ | ||
12744 | - do \ | ||
12745 | - { \ | ||
12746 | - if (thread_in_use () && mutex_unlock (&NAME) != 0) \ | ||
12747 | - abort (); \ | ||
12748 | - } \ | ||
12749 | - while (0) | ||
12750 | -# define gl_lock_destroy(NAME) \ | ||
12751 | - do \ | ||
12752 | - { \ | ||
12753 | - if (thread_in_use () && mutex_destroy (&NAME) != 0) \ | ||
12754 | - abort (); \ | ||
12755 | - } \ | ||
12756 | - while (0) | ||
12757 | - | ||
12758 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
12759 | - | ||
12760 | -typedef rwlock_t gl_rwlock_t; | ||
12761 | -# define gl_rwlock_define(STORAGECLASS, NAME) \ | ||
12762 | - STORAGECLASS rwlock_t NAME; | ||
12763 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ | ||
12764 | - STORAGECLASS rwlock_t NAME = gl_rwlock_initializer; | ||
12765 | -# define gl_rwlock_initializer \ | ||
12766 | - DEFAULTRWLOCK | ||
12767 | -# define gl_rwlock_init(NAME) \ | ||
12768 | - do \ | ||
12769 | - { \ | ||
12770 | - if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0) \ | ||
12771 | - abort (); \ | ||
12772 | - } \ | ||
12773 | - while (0) | ||
12774 | -# define gl_rwlock_rdlock(NAME) \ | ||
12775 | - do \ | ||
12776 | - { \ | ||
12777 | - if (thread_in_use () && rw_rdlock (&NAME) != 0) \ | ||
12778 | - abort (); \ | ||
12779 | - } \ | ||
12780 | - while (0) | ||
12781 | -# define gl_rwlock_wrlock(NAME) \ | ||
12782 | - do \ | ||
12783 | - { \ | ||
12784 | - if (thread_in_use () && rw_wrlock (&NAME) != 0) \ | ||
12785 | - abort (); \ | ||
12786 | - } \ | ||
12787 | - while (0) | ||
12788 | -# define gl_rwlock_unlock(NAME) \ | ||
12789 | - do \ | ||
12790 | - { \ | ||
12791 | - if (thread_in_use () && rw_unlock (&NAME) != 0) \ | ||
12792 | - abort (); \ | ||
12793 | - } \ | ||
12794 | - while (0) | ||
12795 | -# define gl_rwlock_destroy(NAME) \ | ||
12796 | - do \ | ||
12797 | - { \ | ||
12798 | - if (thread_in_use () && rwlock_destroy (&NAME) != 0) \ | ||
12799 | - abort (); \ | ||
12800 | - } \ | ||
12801 | - while (0) | ||
12802 | - | ||
12803 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
12804 | - | ||
12805 | -/* Old Solaris threads did not have recursive locks. | ||
12806 | - We have to implement them ourselves. */ | ||
12807 | - | ||
12808 | -typedef struct | ||
12809 | - { | ||
12810 | - mutex_t mutex; | ||
12811 | - thread_t owner; | ||
12812 | - unsigned long depth; | ||
12813 | - } | ||
12814 | - gl_recursive_lock_t; | ||
12815 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | ||
12816 | - STORAGECLASS gl_recursive_lock_t NAME; | ||
12817 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12818 | - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; | ||
12819 | -# define gl_recursive_lock_initializer \ | ||
12820 | - { DEFAULTMUTEX, (thread_t) 0, 0 } | ||
12821 | -# define gl_recursive_lock_init(NAME) \ | ||
12822 | - do \ | ||
12823 | - { \ | ||
12824 | - if (thread_in_use ()) \ | ||
12825 | - glthread_recursive_lock_init (&NAME); \ | ||
12826 | - } \ | ||
12827 | - while (0) | ||
12828 | -# define gl_recursive_lock_lock(NAME) \ | ||
12829 | - do \ | ||
12830 | - { \ | ||
12831 | - if (thread_in_use ()) \ | ||
12832 | - glthread_recursive_lock_lock (&NAME); \ | ||
12833 | - } \ | ||
12834 | - while (0) | ||
12835 | -# define gl_recursive_lock_unlock(NAME) \ | ||
12836 | - do \ | ||
12837 | - { \ | ||
12838 | - if (thread_in_use ()) \ | ||
12839 | - glthread_recursive_lock_unlock (&NAME); \ | ||
12840 | - } \ | ||
12841 | - while (0) | ||
12842 | -# define gl_recursive_lock_destroy(NAME) \ | ||
12843 | - do \ | ||
12844 | - { \ | ||
12845 | - if (thread_in_use ()) \ | ||
12846 | - glthread_recursive_lock_destroy (&NAME); \ | ||
12847 | - } \ | ||
12848 | - while (0) | ||
12849 | -extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); | ||
12850 | -extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); | ||
12851 | -extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); | ||
12852 | -extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); | ||
12853 | - | ||
12854 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
12855 | - | ||
12856 | -typedef struct | ||
12857 | - { | ||
12858 | - volatile int inited; | ||
12859 | - mutex_t mutex; | ||
12860 | - } | ||
12861 | - gl_once_t; | ||
12862 | -# define gl_once_define(STORAGECLASS, NAME) \ | ||
12863 | - STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX }; | ||
12864 | -# define gl_once(NAME, INITFUNCTION) \ | ||
12865 | - do \ | ||
12866 | - { \ | ||
12867 | - if (thread_in_use ()) \ | ||
12868 | - { \ | ||
12869 | - glthread_once (&NAME, INITFUNCTION); \ | ||
12870 | - } \ | ||
12871 | - else \ | ||
12872 | - { \ | ||
12873 | - if (glthread_once_singlethreaded (&NAME)) \ | ||
12874 | - INITFUNCTION (); \ | ||
12875 | - } \ | ||
12876 | - } \ | ||
12877 | - while (0) | ||
12878 | -extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void)); | ||
12879 | -extern int glthread_once_singlethreaded (gl_once_t *once_control); | ||
12880 | - | ||
12881 | -# ifdef __cplusplus | ||
12882 | -} | ||
12883 | -# endif | ||
12884 | - | ||
12885 | -#endif | ||
12886 | - | ||
12887 | -/* ========================================================================= */ | ||
12888 | - | ||
12889 | -#if USE_WIN32_THREADS | ||
12890 | - | ||
12891 | -# include <windows.h> | ||
12892 | - | ||
12893 | -# ifdef __cplusplus | ||
12894 | -extern "C" { | ||
12895 | -# endif | ||
12896 | - | ||
12897 | -/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex, | ||
12898 | - Semaphore types, because | ||
12899 | - - we need only to synchronize inside a single process (address space), | ||
12900 | - not inter-process locking, | ||
12901 | - - we don't need to support trylock operations. (TryEnterCriticalSection | ||
12902 | - does not work on Windows 95/98/ME. Packages that need trylock usually | ||
12903 | - define their own mutex type.) */ | ||
12904 | - | ||
12905 | -/* There is no way to statically initialize a CRITICAL_SECTION. It needs | ||
12906 | - to be done lazily, once only. For this we need spinlocks. */ | ||
12907 | - | ||
12908 | -typedef struct { volatile int done; volatile long started; } gl_spinlock_t; | ||
12909 | - | ||
12910 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
12911 | - | ||
12912 | -typedef struct | ||
12913 | - { | ||
12914 | - gl_spinlock_t guard; /* protects the initialization */ | ||
12915 | - CRITICAL_SECTION lock; | ||
12916 | - } | ||
12917 | - gl_lock_t; | ||
12918 | -# define gl_lock_define(STORAGECLASS, NAME) \ | ||
12919 | - STORAGECLASS gl_lock_t NAME; | ||
12920 | -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12921 | - STORAGECLASS gl_lock_t NAME = gl_lock_initializer; | ||
12922 | -# define gl_lock_initializer \ | ||
12923 | - { { 0, -1 } } | ||
12924 | -# define gl_lock_init(NAME) \ | ||
12925 | - glthread_lock_init (&NAME) | ||
12926 | -# define gl_lock_lock(NAME) \ | ||
12927 | - glthread_lock_lock (&NAME) | ||
12928 | -# define gl_lock_unlock(NAME) \ | ||
12929 | - glthread_lock_unlock (&NAME) | ||
12930 | -# define gl_lock_destroy(NAME) \ | ||
12931 | - glthread_lock_destroy (&NAME) | ||
12932 | -extern void glthread_lock_init (gl_lock_t *lock); | ||
12933 | -extern void glthread_lock_lock (gl_lock_t *lock); | ||
12934 | -extern void glthread_lock_unlock (gl_lock_t *lock); | ||
12935 | -extern void glthread_lock_destroy (gl_lock_t *lock); | ||
12936 | - | ||
12937 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
12938 | - | ||
12939 | -/* It is impossible to implement read-write locks using plain locks, without | ||
12940 | - introducing an extra thread dedicated to managing read-write locks. | ||
12941 | - Therefore here we need to use the low-level Event type. */ | ||
12942 | - | ||
12943 | -typedef struct | ||
12944 | - { | ||
12945 | - HANDLE *array; /* array of waiting threads, each represented by an event */ | ||
12946 | - unsigned int count; /* number of waiting threads */ | ||
12947 | - unsigned int alloc; /* length of allocated array */ | ||
12948 | - unsigned int offset; /* index of first waiting thread in array */ | ||
12949 | - } | ||
12950 | - gl_waitqueue_t; | ||
12951 | -typedef struct | ||
12952 | - { | ||
12953 | - gl_spinlock_t guard; /* protects the initialization */ | ||
12954 | - CRITICAL_SECTION lock; /* protects the remaining fields */ | ||
12955 | - gl_waitqueue_t waiting_readers; /* waiting readers */ | ||
12956 | - gl_waitqueue_t waiting_writers; /* waiting writers */ | ||
12957 | - int runcount; /* number of readers running, or -1 when a writer runs */ | ||
12958 | - } | ||
12959 | - gl_rwlock_t; | ||
12960 | -# define gl_rwlock_define(STORAGECLASS, NAME) \ | ||
12961 | - STORAGECLASS gl_rwlock_t NAME; | ||
12962 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ | ||
12963 | - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; | ||
12964 | -# define gl_rwlock_initializer \ | ||
12965 | - { { 0, -1 } } | ||
12966 | -# define gl_rwlock_init(NAME) \ | ||
12967 | - glthread_rwlock_init (&NAME) | ||
12968 | -# define gl_rwlock_rdlock(NAME) \ | ||
12969 | - glthread_rwlock_rdlock (&NAME) | ||
12970 | -# define gl_rwlock_wrlock(NAME) \ | ||
12971 | - glthread_rwlock_wrlock (&NAME) | ||
12972 | -# define gl_rwlock_unlock(NAME) \ | ||
12973 | - glthread_rwlock_unlock (&NAME) | ||
12974 | -# define gl_rwlock_destroy(NAME) \ | ||
12975 | - glthread_rwlock_destroy (&NAME) | ||
12976 | -extern void glthread_rwlock_init (gl_rwlock_t *lock); | ||
12977 | -extern void glthread_rwlock_rdlock (gl_rwlock_t *lock); | ||
12978 | -extern void glthread_rwlock_wrlock (gl_rwlock_t *lock); | ||
12979 | -extern void glthread_rwlock_unlock (gl_rwlock_t *lock); | ||
12980 | -extern void glthread_rwlock_destroy (gl_rwlock_t *lock); | ||
12981 | - | ||
12982 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
12983 | - | ||
12984 | -/* The Win32 documentation says that CRITICAL_SECTION already implements a | ||
12985 | - recursive lock. But we need not rely on it: It's easy to implement a | ||
12986 | - recursive lock without this assumption. */ | ||
12987 | - | ||
12988 | -typedef struct | ||
12989 | - { | ||
12990 | - gl_spinlock_t guard; /* protects the initialization */ | ||
12991 | - DWORD owner; | ||
12992 | - unsigned long depth; | ||
12993 | - CRITICAL_SECTION lock; | ||
12994 | - } | ||
12995 | - gl_recursive_lock_t; | ||
12996 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | ||
12997 | - STORAGECLASS gl_recursive_lock_t NAME; | ||
12998 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ | ||
12999 | - STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; | ||
13000 | -# define gl_recursive_lock_initializer \ | ||
13001 | - { { 0, -1 }, 0, 0 } | ||
13002 | -# define gl_recursive_lock_init(NAME) \ | ||
13003 | - glthread_recursive_lock_init (&NAME) | ||
13004 | -# define gl_recursive_lock_lock(NAME) \ | ||
13005 | - glthread_recursive_lock_lock (&NAME) | ||
13006 | -# define gl_recursive_lock_unlock(NAME) \ | ||
13007 | - glthread_recursive_lock_unlock (&NAME) | ||
13008 | -# define gl_recursive_lock_destroy(NAME) \ | ||
13009 | - glthread_recursive_lock_destroy (&NAME) | ||
13010 | -extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); | ||
13011 | -extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); | ||
13012 | -extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); | ||
13013 | -extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); | ||
13014 | - | ||
13015 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
13016 | - | ||
13017 | -typedef struct | ||
13018 | - { | ||
13019 | - volatile int inited; | ||
13020 | - volatile long started; | ||
13021 | - CRITICAL_SECTION lock; | ||
13022 | - } | ||
13023 | - gl_once_t; | ||
13024 | -# define gl_once_define(STORAGECLASS, NAME) \ | ||
13025 | - STORAGECLASS gl_once_t NAME = { -1, -1 }; | ||
13026 | -# define gl_once(NAME, INITFUNCTION) \ | ||
13027 | - glthread_once (&NAME, INITFUNCTION) | ||
13028 | -extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void)); | ||
13029 | - | ||
13030 | -# ifdef __cplusplus | ||
13031 | -} | ||
13032 | -# endif | ||
13033 | - | ||
13034 | -#endif | ||
13035 | - | ||
13036 | -/* ========================================================================= */ | ||
13037 | - | ||
13038 | -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS) | ||
13039 | - | ||
13040 | -/* Provide dummy implementation if threads are not supported. */ | ||
13041 | - | ||
13042 | -/* -------------------------- gl_lock_t datatype -------------------------- */ | ||
13043 | - | ||
13044 | -typedef int gl_lock_t; | ||
13045 | -# define gl_lock_define(STORAGECLASS, NAME) | ||
13046 | -# define gl_lock_define_initialized(STORAGECLASS, NAME) | ||
13047 | -# define gl_lock_init(NAME) | ||
13048 | -# define gl_lock_lock(NAME) | ||
13049 | -# define gl_lock_unlock(NAME) | ||
13050 | - | ||
13051 | -/* ------------------------- gl_rwlock_t datatype ------------------------- */ | ||
13052 | - | ||
13053 | -typedef int gl_rwlock_t; | ||
13054 | -# define gl_rwlock_define(STORAGECLASS, NAME) | ||
13055 | -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) | ||
13056 | -# define gl_rwlock_init(NAME) | ||
13057 | -# define gl_rwlock_rdlock(NAME) | ||
13058 | -# define gl_rwlock_wrlock(NAME) | ||
13059 | -# define gl_rwlock_unlock(NAME) | ||
13060 | - | ||
13061 | -/* --------------------- gl_recursive_lock_t datatype --------------------- */ | ||
13062 | - | ||
13063 | -typedef int gl_recursive_lock_t; | ||
13064 | -# define gl_recursive_lock_define(STORAGECLASS, NAME) | ||
13065 | -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) | ||
13066 | -# define gl_recursive_lock_init(NAME) | ||
13067 | -# define gl_recursive_lock_lock(NAME) | ||
13068 | -# define gl_recursive_lock_unlock(NAME) | ||
13069 | - | ||
13070 | -/* -------------------------- gl_once_t datatype -------------------------- */ | ||
13071 | - | ||
13072 | -typedef int gl_once_t; | ||
13073 | -# define gl_once_define(STORAGECLASS, NAME) \ | ||
13074 | - STORAGECLASS gl_once_t NAME = 0; | ||
13075 | -# define gl_once(NAME, INITFUNCTION) \ | ||
13076 | - do \ | ||
13077 | - { \ | ||
13078 | - if (NAME == 0) \ | ||
13079 | - { \ | ||
13080 | - NAME = ~ 0; \ | ||
13081 | - INITFUNCTION (); \ | ||
13082 | - } \ | ||
13083 | - } \ | ||
13084 | - while (0) | ||
13085 | - | ||
13086 | -#endif | ||
13087 | - | ||
13088 | -/* ========================================================================= */ | ||
13089 | - | ||
13090 | -#endif /* _LOCK_H */ | ||
13091 | --- a/intl/log.c | ||
13092 | +++ /dev/null | ||
13093 | @@ -1,116 +0,0 @@ | ||
13094 | -/* Log file output. | ||
13095 | - Copyright (C) 2003, 2005 Free Software Foundation, Inc. | ||
13096 | - | ||
13097 | - This program is free software; you can redistribute it and/or modify it | ||
13098 | - under the terms of the GNU Library General Public License as published | ||
13099 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13100 | - any later version. | ||
13101 | - | ||
13102 | - This program is distributed in the hope that it will be useful, | ||
13103 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13104 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13105 | - Library General Public License for more details. | ||
13106 | - | ||
13107 | - You should have received a copy of the GNU Library General Public | ||
13108 | - License along with this program; if not, write to the Free Software | ||
13109 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13110 | - USA. */ | ||
13111 | - | ||
13112 | -/* Written by Bruno Haible <bruno@clisp.org>. */ | ||
13113 | - | ||
13114 | -#ifdef HAVE_CONFIG_H | ||
13115 | -# include <config.h> | ||
13116 | -#endif | ||
13117 | - | ||
13118 | -#include <stdio.h> | ||
13119 | -#include <stdlib.h> | ||
13120 | -#include <string.h> | ||
13121 | - | ||
13122 | -/* Handle multi-threaded applications. */ | ||
13123 | -#ifdef _LIBC | ||
13124 | -# include <bits/libc-lock.h> | ||
13125 | -#else | ||
13126 | -# include "lock.h" | ||
13127 | -#endif | ||
13128 | - | ||
13129 | -/* Print an ASCII string with quotes and escape sequences where needed. */ | ||
13130 | -static void | ||
13131 | -print_escaped (FILE *stream, const char *str) | ||
13132 | -{ | ||
13133 | - putc ('"', stream); | ||
13134 | - for (; *str != '\0'; str++) | ||
13135 | - if (*str == '\n') | ||
13136 | - { | ||
13137 | - fputs ("\\n\"", stream); | ||
13138 | - if (str[1] == '\0') | ||
13139 | - return; | ||
13140 | - fputs ("\n\"", stream); | ||
13141 | - } | ||
13142 | - else | ||
13143 | - { | ||
13144 | - if (*str == '"' || *str == '\\') | ||
13145 | - putc ('\\', stream); | ||
13146 | - putc (*str, stream); | ||
13147 | - } | ||
13148 | - putc ('"', stream); | ||
13149 | -} | ||
13150 | - | ||
13151 | -static char *last_logfilename = NULL; | ||
13152 | -static FILE *last_logfile = NULL; | ||
13153 | -__libc_lock_define_initialized (static, lock) | ||
13154 | - | ||
13155 | -static inline void | ||
13156 | -_nl_log_untranslated_locked (const char *logfilename, const char *domainname, | ||
13157 | - const char *msgid1, const char *msgid2, int plural) | ||
13158 | -{ | ||
13159 | - FILE *logfile; | ||
13160 | - | ||
13161 | - /* Can we reuse the last opened logfile? */ | ||
13162 | - if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0) | ||
13163 | - { | ||
13164 | - /* Close the last used logfile. */ | ||
13165 | - if (last_logfilename != NULL) | ||
13166 | - { | ||
13167 | - if (last_logfile != NULL) | ||
13168 | - { | ||
13169 | - fclose (last_logfile); | ||
13170 | - last_logfile = NULL; | ||
13171 | - } | ||
13172 | - free (last_logfilename); | ||
13173 | - last_logfilename = NULL; | ||
13174 | - } | ||
13175 | - /* Open the logfile. */ | ||
13176 | - last_logfilename = (char *) malloc (strlen (logfilename) + 1); | ||
13177 | - if (last_logfilename == NULL) | ||
13178 | - return; | ||
13179 | - strcpy (last_logfilename, logfilename); | ||
13180 | - last_logfile = fopen (logfilename, "a"); | ||
13181 | - if (last_logfile == NULL) | ||
13182 | - return; | ||
13183 | - } | ||
13184 | - logfile = last_logfile; | ||
13185 | - | ||
13186 | - fprintf (logfile, "domain "); | ||
13187 | - print_escaped (logfile, domainname); | ||
13188 | - fprintf (logfile, "\nmsgid "); | ||
13189 | - print_escaped (logfile, msgid1); | ||
13190 | - if (plural) | ||
13191 | - { | ||
13192 | - fprintf (logfile, "\nmsgid_plural "); | ||
13193 | - print_escaped (logfile, msgid2); | ||
13194 | - fprintf (logfile, "\nmsgstr[0] \"\"\n"); | ||
13195 | - } | ||
13196 | - else | ||
13197 | - fprintf (logfile, "\nmsgstr \"\"\n"); | ||
13198 | - putc ('\n', logfile); | ||
13199 | -} | ||
13200 | - | ||
13201 | -/* Add to the log file an entry denoting a failed translation. */ | ||
13202 | -void | ||
13203 | -_nl_log_untranslated (const char *logfilename, const char *domainname, | ||
13204 | - const char *msgid1, const char *msgid2, int plural) | ||
13205 | -{ | ||
13206 | - __libc_lock_lock (lock); | ||
13207 | - _nl_log_untranslated_locked (logfilename, domainname, msgid1, msgid2, plural); | ||
13208 | - __libc_lock_unlock (lock); | ||
13209 | -} | ||
13210 | --- a/intl/ngettext.c | ||
13211 | +++ /dev/null | ||
13212 | @@ -1,65 +0,0 @@ | ||
13213 | -/* Implementation of ngettext(3) function. | ||
13214 | - Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc. | ||
13215 | - | ||
13216 | - This program is free software; you can redistribute it and/or modify it | ||
13217 | - under the terms of the GNU Library General Public License as published | ||
13218 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13219 | - any later version. | ||
13220 | - | ||
13221 | - This program is distributed in the hope that it will be useful, | ||
13222 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13223 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13224 | - Library General Public License for more details. | ||
13225 | - | ||
13226 | - You should have received a copy of the GNU Library General Public | ||
13227 | - License along with this program; if not, write to the Free Software | ||
13228 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13229 | - USA. */ | ||
13230 | - | ||
13231 | -#ifdef HAVE_CONFIG_H | ||
13232 | -# include <config.h> | ||
13233 | -#endif | ||
13234 | - | ||
13235 | -#ifdef _LIBC | ||
13236 | -# define __need_NULL | ||
13237 | -# include <stddef.h> | ||
13238 | -#else | ||
13239 | -# include <stdlib.h> /* Just for NULL. */ | ||
13240 | -#endif | ||
13241 | - | ||
13242 | -#include "gettextP.h" | ||
13243 | -#ifdef _LIBC | ||
13244 | -# include <libintl.h> | ||
13245 | -#else | ||
13246 | -# include "libgnuintl.h" | ||
13247 | -#endif | ||
13248 | - | ||
13249 | -#include <locale.h> | ||
13250 | - | ||
13251 | -/* @@ end of prolog @@ */ | ||
13252 | - | ||
13253 | -/* Names for the libintl functions are a problem. They must not clash | ||
13254 | - with existing names and they should follow ANSI C. But this source | ||
13255 | - code is also used in GNU C Library where the names have a __ | ||
13256 | - prefix. So we have to make a difference here. */ | ||
13257 | -#ifdef _LIBC | ||
13258 | -# define NGETTEXT __ngettext | ||
13259 | -# define DCNGETTEXT __dcngettext | ||
13260 | -#else | ||
13261 | -# define NGETTEXT libintl_ngettext | ||
13262 | -# define DCNGETTEXT libintl_dcngettext | ||
13263 | -#endif | ||
13264 | - | ||
13265 | -/* Look up MSGID in the current default message catalog for the current | ||
13266 | - LC_MESSAGES locale. If not found, returns MSGID itself (the default | ||
13267 | - text). */ | ||
13268 | -char * | ||
13269 | -NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n) | ||
13270 | -{ | ||
13271 | - return DCNGETTEXT (NULL, msgid1, msgid2, n, LC_MESSAGES); | ||
13272 | -} | ||
13273 | - | ||
13274 | -#ifdef _LIBC | ||
13275 | -/* Alias for function name in GNU C Library. */ | ||
13276 | -weak_alias (__ngettext, ngettext); | ||
13277 | -#endif | ||
13278 | --- a/intl/os2compat.c | ||
13279 | +++ /dev/null | ||
13280 | @@ -1,98 +0,0 @@ | ||
13281 | -/* OS/2 compatibility functions. | ||
13282 | - Copyright (C) 2001-2002 Free Software Foundation, Inc. | ||
13283 | - | ||
13284 | - This program is free software; you can redistribute it and/or modify it | ||
13285 | - under the terms of the GNU Library General Public License as published | ||
13286 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13287 | - any later version. | ||
13288 | - | ||
13289 | - This program is distributed in the hope that it will be useful, | ||
13290 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13291 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13292 | - Library General Public License for more details. | ||
13293 | - | ||
13294 | - You should have received a copy of the GNU Library General Public | ||
13295 | - License along with this program; if not, write to the Free Software | ||
13296 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13297 | - USA. */ | ||
13298 | - | ||
13299 | -#define OS2_AWARE | ||
13300 | -#ifdef HAVE_CONFIG_H | ||
13301 | -#include <config.h> | ||
13302 | -#endif | ||
13303 | - | ||
13304 | -#include <stdlib.h> | ||
13305 | -#include <string.h> | ||
13306 | -#include <sys/param.h> | ||
13307 | - | ||
13308 | -/* A version of getenv() that works from DLLs */ | ||
13309 | -extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue); | ||
13310 | - | ||
13311 | -char * | ||
13312 | -_nl_getenv (const char *name) | ||
13313 | -{ | ||
13314 | - unsigned char *value; | ||
13315 | - if (DosScanEnv (name, &value)) | ||
13316 | - return NULL; | ||
13317 | - else | ||
13318 | - return value; | ||
13319 | -} | ||
13320 | - | ||
13321 | -/* A fixed size buffer. */ | ||
13322 | -char libintl_nl_default_dirname[MAXPATHLEN+1]; | ||
13323 | - | ||
13324 | -char *_nlos2_libdir = NULL; | ||
13325 | -char *_nlos2_localealiaspath = NULL; | ||
13326 | -char *_nlos2_localedir = NULL; | ||
13327 | - | ||
13328 | -static __attribute__((constructor)) void | ||
13329 | -nlos2_initialize () | ||
13330 | -{ | ||
13331 | - char *root = getenv ("UNIXROOT"); | ||
13332 | - char *gnulocaledir = getenv ("GNULOCALEDIR"); | ||
13333 | - | ||
13334 | - _nlos2_libdir = gnulocaledir; | ||
13335 | - if (!_nlos2_libdir) | ||
13336 | - { | ||
13337 | - if (root) | ||
13338 | - { | ||
13339 | - size_t sl = strlen (root); | ||
13340 | - _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1); | ||
13341 | - memcpy (_nlos2_libdir, root, sl); | ||
13342 | - memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1); | ||
13343 | - } | ||
13344 | - else | ||
13345 | - _nlos2_libdir = LIBDIR; | ||
13346 | - } | ||
13347 | - | ||
13348 | - _nlos2_localealiaspath = gnulocaledir; | ||
13349 | - if (!_nlos2_localealiaspath) | ||
13350 | - { | ||
13351 | - if (root) | ||
13352 | - { | ||
13353 | - size_t sl = strlen (root); | ||
13354 | - _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1); | ||
13355 | - memcpy (_nlos2_localealiaspath, root, sl); | ||
13356 | - memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1); | ||
13357 | - } | ||
13358 | - else | ||
13359 | - _nlos2_localealiaspath = LOCALE_ALIAS_PATH; | ||
13360 | - } | ||
13361 | - | ||
13362 | - _nlos2_localedir = gnulocaledir; | ||
13363 | - if (!_nlos2_localedir) | ||
13364 | - { | ||
13365 | - if (root) | ||
13366 | - { | ||
13367 | - size_t sl = strlen (root); | ||
13368 | - _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1); | ||
13369 | - memcpy (_nlos2_localedir, root, sl); | ||
13370 | - memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1); | ||
13371 | - } | ||
13372 | - else | ||
13373 | - _nlos2_localedir = LOCALEDIR; | ||
13374 | - } | ||
13375 | - | ||
13376 | - if (strlen (_nlos2_localedir) <= MAXPATHLEN) | ||
13377 | - strcpy (libintl_nl_default_dirname, _nlos2_localedir); | ||
13378 | -} | ||
13379 | --- a/intl/os2compat.h | ||
13380 | +++ /dev/null | ||
13381 | @@ -1,46 +0,0 @@ | ||
13382 | -/* OS/2 compatibility defines. | ||
13383 | - This file is intended to be included from config.h | ||
13384 | - Copyright (C) 2001-2002 Free Software Foundation, Inc. | ||
13385 | - | ||
13386 | - This program is free software; you can redistribute it and/or modify it | ||
13387 | - under the terms of the GNU Library General Public License as published | ||
13388 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13389 | - any later version. | ||
13390 | - | ||
13391 | - This program is distributed in the hope that it will be useful, | ||
13392 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13393 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13394 | - Library General Public License for more details. | ||
13395 | - | ||
13396 | - You should have received a copy of the GNU Library General Public | ||
13397 | - License along with this program; if not, write to the Free Software | ||
13398 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13399 | - USA. */ | ||
13400 | - | ||
13401 | -/* When included from os2compat.h we need all the original definitions */ | ||
13402 | -#ifndef OS2_AWARE | ||
13403 | - | ||
13404 | -#undef LIBDIR | ||
13405 | -#define LIBDIR _nlos2_libdir | ||
13406 | -extern char *_nlos2_libdir; | ||
13407 | - | ||
13408 | -#undef LOCALEDIR | ||
13409 | -#define LOCALEDIR _nlos2_localedir | ||
13410 | -extern char *_nlos2_localedir; | ||
13411 | - | ||
13412 | -#undef LOCALE_ALIAS_PATH | ||
13413 | -#define LOCALE_ALIAS_PATH _nlos2_localealiaspath | ||
13414 | -extern char *_nlos2_localealiaspath; | ||
13415 | - | ||
13416 | -#endif | ||
13417 | - | ||
13418 | -#undef HAVE_STRCASECMP | ||
13419 | -#define HAVE_STRCASECMP 1 | ||
13420 | -#define strcasecmp stricmp | ||
13421 | -#define strncasecmp strnicmp | ||
13422 | - | ||
13423 | -/* We have our own getenv() which works even if library is compiled as DLL */ | ||
13424 | -#define getenv _nl_getenv | ||
13425 | - | ||
13426 | -/* Older versions of gettext used -1 as the value of LC_MESSAGES */ | ||
13427 | -#define LC_MESSAGES_COMPAT (-1) | ||
13428 | --- a/intl/osdep.c | ||
13429 | +++ /dev/null | ||
13430 | @@ -1,26 +0,0 @@ | ||
13431 | -/* OS dependent parts of libintl. | ||
13432 | - Copyright (C) 2001-2002, 2006 Free Software Foundation, Inc. | ||
13433 | - | ||
13434 | - This program is free software; you can redistribute it and/or modify it | ||
13435 | - under the terms of the GNU Library General Public License as published | ||
13436 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13437 | - any later version. | ||
13438 | - | ||
13439 | - This program is distributed in the hope that it will be useful, | ||
13440 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13441 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13442 | - Library General Public License for more details. | ||
13443 | - | ||
13444 | - You should have received a copy of the GNU Library General Public | ||
13445 | - License along with this program; if not, write to the Free Software | ||
13446 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13447 | - USA. */ | ||
13448 | - | ||
13449 | -#if defined __CYGWIN__ | ||
13450 | -# include "intl-exports.c" | ||
13451 | -#elif defined __EMX__ | ||
13452 | -# include "os2compat.c" | ||
13453 | -#else | ||
13454 | -/* Avoid AIX compiler warning. */ | ||
13455 | -typedef int dummy; | ||
13456 | -#endif | ||
13457 | --- a/intl/plural-exp.c | ||
13458 | +++ /dev/null | ||
13459 | @@ -1,155 +0,0 @@ | ||
13460 | -/* Expression parsing for plural form selection. | ||
13461 | - Copyright (C) 2000-2001, 2003, 2005-2007 Free Software Foundation, Inc. | ||
13462 | - Written by Ulrich Drepper <drepper@cygnus.com>, 2000. | ||
13463 | - | ||
13464 | - This program is free software; you can redistribute it and/or modify it | ||
13465 | - under the terms of the GNU Library General Public License as published | ||
13466 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13467 | - any later version. | ||
13468 | - | ||
13469 | - This program is distributed in the hope that it will be useful, | ||
13470 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13471 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13472 | - Library General Public License for more details. | ||
13473 | - | ||
13474 | - You should have received a copy of the GNU Library General Public | ||
13475 | - License along with this program; if not, write to the Free Software | ||
13476 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13477 | - USA. */ | ||
13478 | - | ||
13479 | -#ifdef HAVE_CONFIG_H | ||
13480 | -# include <config.h> | ||
13481 | -#endif | ||
13482 | - | ||
13483 | -#include <ctype.h> | ||
13484 | -#include <stdlib.h> | ||
13485 | -#include <string.h> | ||
13486 | - | ||
13487 | -#include "plural-exp.h" | ||
13488 | - | ||
13489 | -#if (defined __GNUC__ && !(__APPLE_CC__ > 1) && !defined __cplusplus) \ | ||
13490 | - || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) | ||
13491 | - | ||
13492 | -/* These structs are the constant expression for the germanic plural | ||
13493 | - form determination. It represents the expression "n != 1". */ | ||
13494 | -static const struct expression plvar = | ||
13495 | -{ | ||
13496 | - .nargs = 0, | ||
13497 | - .operation = var, | ||
13498 | -}; | ||
13499 | -static const struct expression plone = | ||
13500 | -{ | ||
13501 | - .nargs = 0, | ||
13502 | - .operation = num, | ||
13503 | - .val = | ||
13504 | - { | ||
13505 | - .num = 1 | ||
13506 | - } | ||
13507 | -}; | ||
13508 | -struct expression GERMANIC_PLURAL = | ||
13509 | -{ | ||
13510 | - .nargs = 2, | ||
13511 | - .operation = not_equal, | ||
13512 | - .val = | ||
13513 | - { | ||
13514 | - .args = | ||
13515 | - { | ||
13516 | - [0] = (struct expression *) &plvar, | ||
13517 | - [1] = (struct expression *) &plone | ||
13518 | - } | ||
13519 | - } | ||
13520 | -}; | ||
13521 | - | ||
13522 | -# define INIT_GERMANIC_PLURAL() | ||
13523 | - | ||
13524 | -#else | ||
13525 | - | ||
13526 | -/* For compilers without support for ISO C 99 struct/union initializers: | ||
13527 | - Initialization at run-time. */ | ||
13528 | - | ||
13529 | -static struct expression plvar; | ||
13530 | -static struct expression plone; | ||
13531 | -struct expression GERMANIC_PLURAL; | ||
13532 | - | ||
13533 | -static void | ||
13534 | -init_germanic_plural () | ||
13535 | -{ | ||
13536 | - if (plone.val.num == 0) | ||
13537 | - { | ||
13538 | - plvar.nargs = 0; | ||
13539 | - plvar.operation = var; | ||
13540 | - | ||
13541 | - plone.nargs = 0; | ||
13542 | - plone.operation = num; | ||
13543 | - plone.val.num = 1; | ||
13544 | - | ||
13545 | - GERMANIC_PLURAL.nargs = 2; | ||
13546 | - GERMANIC_PLURAL.operation = not_equal; | ||
13547 | - GERMANIC_PLURAL.val.args[0] = &plvar; | ||
13548 | - GERMANIC_PLURAL.val.args[1] = &plone; | ||
13549 | - } | ||
13550 | -} | ||
13551 | - | ||
13552 | -# define INIT_GERMANIC_PLURAL() init_germanic_plural () | ||
13553 | - | ||
13554 | -#endif | ||
13555 | - | ||
13556 | -void | ||
13557 | -internal_function | ||
13558 | -EXTRACT_PLURAL_EXPRESSION (const char *nullentry, | ||
13559 | - const struct expression **pluralp, | ||
13560 | - unsigned long int *npluralsp) | ||
13561 | -{ | ||
13562 | - if (nullentry != NULL) | ||
13563 | - { | ||
13564 | - const char *plural; | ||
13565 | - const char *nplurals; | ||
13566 | - | ||
13567 | - plural = strstr (nullentry, "plural="); | ||
13568 | - nplurals = strstr (nullentry, "nplurals="); | ||
13569 | - if (plural == NULL || nplurals == NULL) | ||
13570 | - goto no_plural; | ||
13571 | - else | ||
13572 | - { | ||
13573 | - char *endp; | ||
13574 | - unsigned long int n; | ||
13575 | - struct parse_args args; | ||
13576 | - | ||
13577 | - /* First get the number. */ | ||
13578 | - nplurals += 9; | ||
13579 | - while (*nplurals != '\0' && isspace ((unsigned char) *nplurals)) | ||
13580 | - ++nplurals; | ||
13581 | - if (!(*nplurals >= '0' && *nplurals <= '9')) | ||
13582 | - goto no_plural; | ||
13583 | -#if defined HAVE_STRTOUL || defined _LIBC | ||
13584 | - n = strtoul (nplurals, &endp, 10); | ||
13585 | -#else | ||
13586 | - for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++) | ||
13587 | - n = n * 10 + (*endp - '0'); | ||
13588 | -#endif | ||
13589 | - if (nplurals == endp) | ||
13590 | - goto no_plural; | ||
13591 | - *npluralsp = n; | ||
13592 | - | ||
13593 | - /* Due to the restrictions bison imposes onto the interface of the | ||
13594 | - scanner function we have to put the input string and the result | ||
13595 | - passed up from the parser into the same structure which address | ||
13596 | - is passed down to the parser. */ | ||
13597 | - plural += 7; | ||
13598 | - args.cp = plural; | ||
13599 | - if (PLURAL_PARSE (&args) != 0) | ||
13600 | - goto no_plural; | ||
13601 | - *pluralp = args.res; | ||
13602 | - } | ||
13603 | - } | ||
13604 | - else | ||
13605 | - { | ||
13606 | - /* By default we are using the Germanic form: singular form only | ||
13607 | - for `one', the plural form otherwise. Yes, this is also what | ||
13608 | - English is using since English is a Germanic language. */ | ||
13609 | - no_plural: | ||
13610 | - INIT_GERMANIC_PLURAL (); | ||
13611 | - *pluralp = &GERMANIC_PLURAL; | ||
13612 | - *npluralsp = 2; | ||
13613 | - } | ||
13614 | -} | ||
13615 | --- a/intl/plural-exp.h | ||
13616 | +++ /dev/null | ||
13617 | @@ -1,129 +0,0 @@ | ||
13618 | -/* Expression parsing and evaluation for plural form selection. | ||
13619 | - Copyright (C) 2000-2003, 2005-2007 Free Software Foundation, Inc. | ||
13620 | - Written by Ulrich Drepper <drepper@cygnus.com>, 2000. | ||
13621 | - | ||
13622 | - This program is free software; you can redistribute it and/or modify it | ||
13623 | - under the terms of the GNU Library General Public License as published | ||
13624 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13625 | - any later version. | ||
13626 | - | ||
13627 | - This program is distributed in the hope that it will be useful, | ||
13628 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13629 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13630 | - Library General Public License for more details. | ||
13631 | - | ||
13632 | - You should have received a copy of the GNU Library General Public | ||
13633 | - License along with this program; if not, write to the Free Software | ||
13634 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13635 | - USA. */ | ||
13636 | - | ||
13637 | -#ifndef _PLURAL_EXP_H | ||
13638 | -#define _PLURAL_EXP_H | ||
13639 | - | ||
13640 | -#ifndef internal_function | ||
13641 | -# define internal_function | ||
13642 | -#endif | ||
13643 | - | ||
13644 | -#ifndef attribute_hidden | ||
13645 | -# define attribute_hidden | ||
13646 | -#endif | ||
13647 | - | ||
13648 | -#ifdef __cplusplus | ||
13649 | -extern "C" { | ||
13650 | -#endif | ||
13651 | - | ||
13652 | - | ||
13653 | -enum expression_operator | ||
13654 | -{ | ||
13655 | - /* Without arguments: */ | ||
13656 | - var, /* The variable "n". */ | ||
13657 | - num, /* Decimal number. */ | ||
13658 | - /* Unary operators: */ | ||
13659 | - lnot, /* Logical NOT. */ | ||
13660 | - /* Binary operators: */ | ||
13661 | - mult, /* Multiplication. */ | ||
13662 | - divide, /* Division. */ | ||
13663 | - module, /* Modulo operation. */ | ||
13664 | - plus, /* Addition. */ | ||
13665 | - minus, /* Subtraction. */ | ||
13666 | - less_than, /* Comparison. */ | ||
13667 | - greater_than, /* Comparison. */ | ||
13668 | - less_or_equal, /* Comparison. */ | ||
13669 | - greater_or_equal, /* Comparison. */ | ||
13670 | - equal, /* Comparison for equality. */ | ||
13671 | - not_equal, /* Comparison for inequality. */ | ||
13672 | - land, /* Logical AND. */ | ||
13673 | - lor, /* Logical OR. */ | ||
13674 | - /* Ternary operators: */ | ||
13675 | - qmop /* Question mark operator. */ | ||
13676 | -}; | ||
13677 | - | ||
13678 | -/* This is the representation of the expressions to determine the | ||
13679 | - plural form. */ | ||
13680 | -struct expression | ||
13681 | -{ | ||
13682 | - int nargs; /* Number of arguments. */ | ||
13683 | - enum expression_operator operation; | ||
13684 | - union | ||
13685 | - { | ||
13686 | - unsigned long int num; /* Number value for `num'. */ | ||
13687 | - struct expression *args[3]; /* Up to three arguments. */ | ||
13688 | - } val; | ||
13689 | -}; | ||
13690 | - | ||
13691 | -/* This is the data structure to pass information to the parser and get | ||
13692 | - the result in a thread-safe way. */ | ||
13693 | -struct parse_args | ||
13694 | -{ | ||
13695 | - const char *cp; | ||
13696 | - struct expression *res; | ||
13697 | -}; | ||
13698 | - | ||
13699 | - | ||
13700 | -/* Names for the libintl functions are a problem. This source code is used | ||
13701 | - 1. in the GNU C Library library, | ||
13702 | - 2. in the GNU libintl library, | ||
13703 | - 3. in the GNU gettext tools. | ||
13704 | - The function names in each situation must be different, to allow for | ||
13705 | - binary incompatible changes in 'struct expression'. Furthermore, | ||
13706 | - 1. in the GNU C Library library, the names have a __ prefix, | ||
13707 | - 2.+3. in the GNU libintl library and in the GNU gettext tools, the names | ||
13708 | - must follow ANSI C and not start with __. | ||
13709 | - So we have to distinguish the three cases. */ | ||
13710 | -#ifdef _LIBC | ||
13711 | -# define FREE_EXPRESSION __gettext_free_exp | ||
13712 | -# define PLURAL_PARSE __gettextparse | ||
13713 | -# define GERMANIC_PLURAL __gettext_germanic_plural | ||
13714 | -# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural | ||
13715 | -#elif defined (IN_LIBINTL) | ||
13716 | -# define FREE_EXPRESSION libintl_gettext_free_exp | ||
13717 | -# define PLURAL_PARSE libintl_gettextparse | ||
13718 | -# define GERMANIC_PLURAL libintl_gettext_germanic_plural | ||
13719 | -# define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural | ||
13720 | -#else | ||
13721 | -# define FREE_EXPRESSION free_plural_expression | ||
13722 | -# define PLURAL_PARSE parse_plural_expression | ||
13723 | -# define GERMANIC_PLURAL germanic_plural | ||
13724 | -# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression | ||
13725 | -#endif | ||
13726 | - | ||
13727 | -extern void FREE_EXPRESSION (struct expression *exp) | ||
13728 | - internal_function; | ||
13729 | -extern int PLURAL_PARSE (void *arg); | ||
13730 | -extern struct expression GERMANIC_PLURAL attribute_hidden; | ||
13731 | -extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry, | ||
13732 | - const struct expression **pluralp, | ||
13733 | - unsigned long int *npluralsp) | ||
13734 | - internal_function; | ||
13735 | - | ||
13736 | -#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE) | ||
13737 | -extern unsigned long int plural_eval (const struct expression *pexp, | ||
13738 | - unsigned long int n); | ||
13739 | -#endif | ||
13740 | - | ||
13741 | - | ||
13742 | -#ifdef __cplusplus | ||
13743 | -} | ||
13744 | -#endif | ||
13745 | - | ||
13746 | -#endif /* _PLURAL_EXP_H */ | ||
13747 | --- a/intl/plural.c | ||
13748 | +++ /dev/null | ||
13749 | @@ -1,1981 +0,0 @@ | ||
13750 | - | ||
13751 | -/* A Bison parser, made by GNU Bison 2.4.1. */ | ||
13752 | - | ||
13753 | -/* Skeleton implementation for Bison's Yacc-like parsers in C | ||
13754 | - | ||
13755 | - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 | ||
13756 | - Free Software Foundation, Inc. | ||
13757 | - | ||
13758 | - This program is free software: you can redistribute it and/or modify | ||
13759 | - it under the terms of the GNU General Public License as published by | ||
13760 | - the Free Software Foundation, either version 3 of the License, or | ||
13761 | - (at your option) any later version. | ||
13762 | - | ||
13763 | - This program is distributed in the hope that it will be useful, | ||
13764 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13765 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13766 | - GNU General Public License for more details. | ||
13767 | - | ||
13768 | - You should have received a copy of the GNU General Public License | ||
13769 | - along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
13770 | - | ||
13771 | -/* As a special exception, you may create a larger work that contains | ||
13772 | - part or all of the Bison parser skeleton and distribute that work | ||
13773 | - under terms of your choice, so long as that work isn't itself a | ||
13774 | - parser generator using the skeleton or a modified version thereof | ||
13775 | - as a parser skeleton. Alternatively, if you modify or redistribute | ||
13776 | - the parser skeleton itself, you may (at your option) remove this | ||
13777 | - special exception, which will cause the skeleton and the resulting | ||
13778 | - Bison output files to be licensed under the GNU General Public | ||
13779 | - License without this special exception. | ||
13780 | - | ||
13781 | - This special exception was added by the Free Software Foundation in | ||
13782 | - version 2.2 of Bison. */ | ||
13783 | - | ||
13784 | -/* C LALR(1) parser skeleton written by Richard Stallman, by | ||
13785 | - simplifying the original so-called "semantic" parser. */ | ||
13786 | - | ||
13787 | -/* All symbols defined below should begin with yy or YY, to avoid | ||
13788 | - infringing on user name space. This should be done even for local | ||
13789 | - variables, as they might otherwise be expanded by user macros. | ||
13790 | - There are some unavoidable exceptions within include files to | ||
13791 | - define necessary library symbols; they are noted "INFRINGES ON | ||
13792 | - USER NAME SPACE" below. */ | ||
13793 | - | ||
13794 | -/* Identify Bison output. */ | ||
13795 | -#define YYBISON 1 | ||
13796 | - | ||
13797 | -/* Bison version. */ | ||
13798 | -#define YYBISON_VERSION "2.4.1" | ||
13799 | - | ||
13800 | -/* Skeleton name. */ | ||
13801 | -#define YYSKELETON_NAME "yacc.c" | ||
13802 | - | ||
13803 | -/* Pure parsers. */ | ||
13804 | -#define YYPURE 1 | ||
13805 | - | ||
13806 | -/* Push parsers. */ | ||
13807 | -#define YYPUSH 0 | ||
13808 | - | ||
13809 | -/* Pull parsers. */ | ||
13810 | -#define YYPULL 1 | ||
13811 | - | ||
13812 | -/* Using locations. */ | ||
13813 | -#define YYLSP_NEEDED 0 | ||
13814 | - | ||
13815 | -/* Substitute the variable and function names. */ | ||
13816 | -#define yyparse __gettextparse | ||
13817 | -#define yylex __gettextlex | ||
13818 | -#define yyerror __gettexterror | ||
13819 | -#define yylval __gettextlval | ||
13820 | -#define yychar __gettextchar | ||
13821 | -#define yydebug __gettextdebug | ||
13822 | -#define yynerrs __gettextnerrs | ||
13823 | - | ||
13824 | - | ||
13825 | -/* Copy the first part of user declarations. */ | ||
13826 | - | ||
13827 | -/* Line 189 of yacc.c */ | ||
13828 | -#line 1 "plural.y" | ||
13829 | - | ||
13830 | -/* Expression parsing for plural form selection. | ||
13831 | - Copyright (C) 2000-2001, 2003, 2005-2006 Free Software Foundation, Inc. | ||
13832 | - Written by Ulrich Drepper <drepper@cygnus.com>, 2000. | ||
13833 | - | ||
13834 | - This program is free software; you can redistribute it and/or modify it | ||
13835 | - under the terms of the GNU Library General Public License as published | ||
13836 | - by the Free Software Foundation; either version 2, or (at your option) | ||
13837 | - any later version. | ||
13838 | - | ||
13839 | - This program is distributed in the hope that it will be useful, | ||
13840 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13841 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13842 | - Library General Public License for more details. | ||
13843 | - | ||
13844 | - You should have received a copy of the GNU Library General Public | ||
13845 | - License along with this program; if not, write to the Free Software | ||
13846 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
13847 | - USA. */ | ||
13848 | - | ||
13849 | -/* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us | ||
13850 | - to put this declaration at the beginning of the file. The declaration in | ||
13851 | - bison's skeleton file comes too late. This must come before <config.h> | ||
13852 | - because <config.h> may include arbitrary system headers. | ||
13853 | - This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */ | ||
13854 | -#if defined _AIX && !defined __GNUC__ | ||
13855 | - #pragma alloca | ||
13856 | -#endif | ||
13857 | - | ||
13858 | -#ifdef HAVE_CONFIG_H | ||
13859 | -# include <config.h> | ||
13860 | -#endif | ||
13861 | - | ||
13862 | -#include <stddef.h> | ||
13863 | -#include <stdlib.h> | ||
13864 | -#include <string.h> | ||
13865 | -#include "plural-exp.h" | ||
13866 | - | ||
13867 | -/* The main function generated by the parser is called __gettextparse, | ||
13868 | - but we want it to be called PLURAL_PARSE. */ | ||
13869 | -#ifndef _LIBC | ||
13870 | -# define __gettextparse PLURAL_PARSE | ||
13871 | -#endif | ||
13872 | - | ||
13873 | -#define YYLEX_PARAM &((struct parse_args *) arg)->cp | ||
13874 | -#define YYPARSE_PARAM arg | ||
13875 | - | ||
13876 | - | ||
13877 | -/* Line 189 of yacc.c */ | ||
13878 | -#line 130 "plural.c" | ||
13879 | - | ||
13880 | -/* Enabling traces. */ | ||
13881 | -#ifndef YYDEBUG | ||
13882 | -# define YYDEBUG 0 | ||
13883 | -#endif | ||
13884 | - | ||
13885 | -/* Enabling verbose error messages. */ | ||
13886 | -#ifdef YYERROR_VERBOSE | ||
13887 | -# undef YYERROR_VERBOSE | ||
13888 | -# define YYERROR_VERBOSE 1 | ||
13889 | -#else | ||
13890 | -# define YYERROR_VERBOSE 0 | ||
13891 | -#endif | ||
13892 | - | ||
13893 | -/* Enabling the token table. */ | ||
13894 | -#ifndef YYTOKEN_TABLE | ||
13895 | -# define YYTOKEN_TABLE 0 | ||
13896 | -#endif | ||
13897 | - | ||
13898 | - | ||
13899 | -/* Tokens. */ | ||
13900 | -#ifndef YYTOKENTYPE | ||
13901 | -# define YYTOKENTYPE | ||
13902 | - /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
13903 | - know about them. */ | ||
13904 | - enum yytokentype { | ||
13905 | - EQUOP2 = 258, | ||
13906 | - CMPOP2 = 259, | ||
13907 | - ADDOP2 = 260, | ||
13908 | - MULOP2 = 261, | ||
13909 | - NUMBER = 262 | ||
13910 | - }; | ||
13911 | -#endif | ||
13912 | -/* Tokens. */ | ||
13913 | -#define EQUOP2 258 | ||
13914 | -#define CMPOP2 259 | ||
13915 | -#define ADDOP2 260 | ||
13916 | -#define MULOP2 261 | ||
13917 | -#define NUMBER 262 | ||
13918 | - | ||
13919 | - | ||
13920 | - | ||
13921 | - | ||
13922 | -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
13923 | -typedef union YYSTYPE | ||
13924 | -{ | ||
13925 | - | ||
13926 | -/* Line 214 of yacc.c */ | ||
13927 | -#line 51 "plural.y" | ||
13928 | - | ||
13929 | - unsigned long int num; | ||
13930 | - enum expression_operator op; | ||
13931 | - struct expression *exp; | ||
13932 | - | ||
13933 | - | ||
13934 | - | ||
13935 | -/* Line 214 of yacc.c */ | ||
13936 | -#line 188 "plural.c" | ||
13937 | -} YYSTYPE; | ||
13938 | -# define YYSTYPE_IS_TRIVIAL 1 | ||
13939 | -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
13940 | -# define YYSTYPE_IS_DECLARED 1 | ||
13941 | -#endif | ||
13942 | - | ||
13943 | - | ||
13944 | -/* Copy the second part of user declarations. */ | ||
13945 | - | ||
13946 | -/* Line 264 of yacc.c */ | ||
13947 | -#line 57 "plural.y" | ||
13948 | - | ||
13949 | -/* Prototypes for local functions. */ | ||
13950 | -static int yylex (YYSTYPE *lval, const char **pexp); | ||
13951 | -static void yyerror (const char *str); | ||
13952 | - | ||
13953 | -/* Allocation of expressions. */ | ||
13954 | - | ||
13955 | -static struct expression * | ||
13956 | -new_exp (int nargs, enum expression_operator op, | ||
13957 | - struct expression * const *args) | ||
13958 | -{ | ||
13959 | - int i; | ||
13960 | - struct expression *newp; | ||
13961 | - | ||
13962 | - /* If any of the argument could not be malloc'ed, just return NULL. */ | ||
13963 | - for (i = nargs - 1; i >= 0; i--) | ||
13964 | - if (args[i] == NULL) | ||
13965 | - goto fail; | ||
13966 | - | ||
13967 | - /* Allocate a new expression. */ | ||
13968 | - newp = (struct expression *) malloc (sizeof (*newp)); | ||
13969 | - if (newp != NULL) | ||
13970 | - { | ||
13971 | - newp->nargs = nargs; | ||
13972 | - newp->operation = op; | ||
13973 | - for (i = nargs - 1; i >= 0; i--) | ||
13974 | - newp->val.args[i] = args[i]; | ||
13975 | - return newp; | ||
13976 | - } | ||
13977 | - | ||
13978 | - fail: | ||
13979 | - for (i = nargs - 1; i >= 0; i--) | ||
13980 | - FREE_EXPRESSION (args[i]); | ||
13981 | - | ||
13982 | - return NULL; | ||
13983 | -} | ||
13984 | - | ||
13985 | -static inline struct expression * | ||
13986 | -new_exp_0 (enum expression_operator op) | ||
13987 | -{ | ||
13988 | - return new_exp (0, op, NULL); | ||
13989 | -} | ||
13990 | - | ||
13991 | -static inline struct expression * | ||
13992 | -new_exp_1 (enum expression_operator op, struct expression *right) | ||
13993 | -{ | ||
13994 | - struct expression *args[1]; | ||
13995 | - | ||
13996 | - args[0] = right; | ||
13997 | - return new_exp (1, op, args); | ||
13998 | -} | ||
13999 | - | ||
14000 | -static struct expression * | ||
14001 | -new_exp_2 (enum expression_operator op, struct expression *left, | ||
14002 | - struct expression *right) | ||
14003 | -{ | ||
14004 | - struct expression *args[2]; | ||
14005 | - | ||
14006 | - args[0] = left; | ||
14007 | - args[1] = right; | ||
14008 | - return new_exp (2, op, args); | ||
14009 | -} | ||
14010 | - | ||
14011 | -static inline struct expression * | ||
14012 | -new_exp_3 (enum expression_operator op, struct expression *bexp, | ||
14013 | - struct expression *tbranch, struct expression *fbranch) | ||
14014 | -{ | ||
14015 | - struct expression *args[3]; | ||
14016 | - | ||
14017 | - args[0] = bexp; | ||
14018 | - args[1] = tbranch; | ||
14019 | - args[2] = fbranch; | ||
14020 | - return new_exp (3, op, args); | ||
14021 | -} | ||
14022 | - | ||
14023 | - | ||
14024 | - | ||
14025 | -/* Line 264 of yacc.c */ | ||
14026 | -#line 278 "plural.c" | ||
14027 | - | ||
14028 | -#ifdef short | ||
14029 | -# undef short | ||
14030 | -#endif | ||
14031 | - | ||
14032 | -#ifdef YYTYPE_UINT8 | ||
14033 | -typedef YYTYPE_UINT8 yytype_uint8; | ||
14034 | -#else | ||
14035 | -typedef unsigned char yytype_uint8; | ||
14036 | -#endif | ||
14037 | - | ||
14038 | -#ifdef YYTYPE_INT8 | ||
14039 | -typedef YYTYPE_INT8 yytype_int8; | ||
14040 | -#elif (defined __STDC__ || defined __C99__FUNC__ \ | ||
14041 | - || defined __cplusplus || defined _MSC_VER) | ||
14042 | -typedef signed char yytype_int8; | ||
14043 | -#else | ||
14044 | -typedef short int yytype_int8; | ||
14045 | -#endif | ||
14046 | - | ||
14047 | -#ifdef YYTYPE_UINT16 | ||
14048 | -typedef YYTYPE_UINT16 yytype_uint16; | ||
14049 | -#else | ||
14050 | -typedef unsigned short int yytype_uint16; | ||
14051 | -#endif | ||
14052 | - | ||
14053 | -#ifdef YYTYPE_INT16 | ||
14054 | -typedef YYTYPE_INT16 yytype_int16; | ||
14055 | -#else | ||
14056 | -typedef short int yytype_int16; | ||
14057 | -#endif | ||
14058 | - | ||
14059 | -#ifndef YYSIZE_T | ||
14060 | -# ifdef __SIZE_TYPE__ | ||
14061 | -# define YYSIZE_T __SIZE_TYPE__ | ||
14062 | -# elif defined size_t | ||
14063 | -# define YYSIZE_T size_t | ||
14064 | -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ | ||
14065 | - || defined __cplusplus || defined _MSC_VER) | ||
14066 | -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
14067 | -# define YYSIZE_T size_t | ||
14068 | -# else | ||
14069 | -# define YYSIZE_T unsigned int | ||
14070 | -# endif | ||
14071 | -#endif | ||
14072 | - | ||
14073 | -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | ||
14074 | - | ||
14075 | -#ifndef YY_ | ||
14076 | -# if YYENABLE_NLS | ||
14077 | -# if ENABLE_NLS | ||
14078 | -# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | ||
14079 | -# define YY_(msgid) dgettext ("bison-runtime", msgid) | ||
14080 | -# endif | ||
14081 | -# endif | ||
14082 | -# ifndef YY_ | ||
14083 | -# define YY_(msgid) msgid | ||
14084 | -# endif | ||
14085 | -#endif | ||
14086 | - | ||
14087 | -/* Suppress unused-variable warnings by "using" E. */ | ||
14088 | -#if ! defined lint || defined __GNUC__ | ||
14089 | -# define YYUSE(e) ((void) (e)) | ||
14090 | -#else | ||
14091 | -# define YYUSE(e) /* empty */ | ||
14092 | -#endif | ||
14093 | - | ||
14094 | -/* Identity function, used to suppress warnings about constant conditions. */ | ||
14095 | -#ifndef lint | ||
14096 | -# define YYID(n) (n) | ||
14097 | -#else | ||
14098 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14099 | - || defined __cplusplus || defined _MSC_VER) | ||
14100 | -static int | ||
14101 | -YYID (int yyi) | ||
14102 | -#else | ||
14103 | -static int | ||
14104 | -YYID (yyi) | ||
14105 | - int yyi; | ||
14106 | -#endif | ||
14107 | -{ | ||
14108 | - return yyi; | ||
14109 | -} | ||
14110 | -#endif | ||
14111 | - | ||
14112 | -#if ! defined yyoverflow || YYERROR_VERBOSE | ||
14113 | - | ||
14114 | -/* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
14115 | - | ||
14116 | -# ifdef YYSTACK_USE_ALLOCA | ||
14117 | -# if YYSTACK_USE_ALLOCA | ||
14118 | -# ifdef __GNUC__ | ||
14119 | -# define YYSTACK_ALLOC __builtin_alloca | ||
14120 | -# elif defined __BUILTIN_VA_ARG_INCR | ||
14121 | -# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ | ||
14122 | -# elif defined _AIX | ||
14123 | -# define YYSTACK_ALLOC __alloca | ||
14124 | -# elif defined _MSC_VER | ||
14125 | -# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ | ||
14126 | -# define alloca _alloca | ||
14127 | -# else | ||
14128 | -# define YYSTACK_ALLOC alloca | ||
14129 | -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | ||
14130 | - || defined __cplusplus || defined _MSC_VER) | ||
14131 | -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
14132 | -# ifndef _STDLIB_H | ||
14133 | -# define _STDLIB_H 1 | ||
14134 | -# endif | ||
14135 | -# endif | ||
14136 | -# endif | ||
14137 | -# endif | ||
14138 | -# endif | ||
14139 | - | ||
14140 | -# ifdef YYSTACK_ALLOC | ||
14141 | - /* Pacify GCC's `empty if-body' warning. */ | ||
14142 | -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) | ||
14143 | -# ifndef YYSTACK_ALLOC_MAXIMUM | ||
14144 | - /* The OS might guarantee only one guard page at the bottom of the stack, | ||
14145 | - and a page size can be as small as 4096 bytes. So we cannot safely | ||
14146 | - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number | ||
14147 | - to allow for a few compiler-allocated temporary stack slots. */ | ||
14148 | -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ | ||
14149 | -# endif | ||
14150 | -# else | ||
14151 | -# define YYSTACK_ALLOC YYMALLOC | ||
14152 | -# define YYSTACK_FREE YYFREE | ||
14153 | -# ifndef YYSTACK_ALLOC_MAXIMUM | ||
14154 | -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM | ||
14155 | -# endif | ||
14156 | -# if (defined __cplusplus && ! defined _STDLIB_H \ | ||
14157 | - && ! ((defined YYMALLOC || defined malloc) \ | ||
14158 | - && (defined YYFREE || defined free))) | ||
14159 | -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
14160 | -# ifndef _STDLIB_H | ||
14161 | -# define _STDLIB_H 1 | ||
14162 | -# endif | ||
14163 | -# endif | ||
14164 | -# ifndef YYMALLOC | ||
14165 | -# define YYMALLOC malloc | ||
14166 | -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | ||
14167 | - || defined __cplusplus || defined _MSC_VER) | ||
14168 | -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | ||
14169 | -# endif | ||
14170 | -# endif | ||
14171 | -# ifndef YYFREE | ||
14172 | -# define YYFREE free | ||
14173 | -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | ||
14174 | - || defined __cplusplus || defined _MSC_VER) | ||
14175 | -void free (void *); /* INFRINGES ON USER NAME SPACE */ | ||
14176 | -# endif | ||
14177 | -# endif | ||
14178 | -# endif | ||
14179 | -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ | ||
14180 | - | ||
14181 | - | ||
14182 | -#if (! defined yyoverflow \ | ||
14183 | - && (! defined __cplusplus \ | ||
14184 | - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | ||
14185 | - | ||
14186 | -/* A type that is properly aligned for any stack member. */ | ||
14187 | -union yyalloc | ||
14188 | -{ | ||
14189 | - yytype_int16 yyss_alloc; | ||
14190 | - YYSTYPE yyvs_alloc; | ||
14191 | -}; | ||
14192 | - | ||
14193 | -/* The size of the maximum gap between one aligned stack and the next. */ | ||
14194 | -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | ||
14195 | - | ||
14196 | -/* The size of an array large to enough to hold all stacks, each with | ||
14197 | - N elements. */ | ||
14198 | -# define YYSTACK_BYTES(N) \ | ||
14199 | - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ | ||
14200 | - + YYSTACK_GAP_MAXIMUM) | ||
14201 | - | ||
14202 | -/* Copy COUNT objects from FROM to TO. The source and destination do | ||
14203 | - not overlap. */ | ||
14204 | -# ifndef YYCOPY | ||
14205 | -# if defined __GNUC__ && 1 < __GNUC__ | ||
14206 | -# define YYCOPY(To, From, Count) \ | ||
14207 | - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | ||
14208 | -# else | ||
14209 | -# define YYCOPY(To, From, Count) \ | ||
14210 | - do \ | ||
14211 | - { \ | ||
14212 | - YYSIZE_T yyi; \ | ||
14213 | - for (yyi = 0; yyi < (Count); yyi++) \ | ||
14214 | - (To)[yyi] = (From)[yyi]; \ | ||
14215 | - } \ | ||
14216 | - while (YYID (0)) | ||
14217 | -# endif | ||
14218 | -# endif | ||
14219 | - | ||
14220 | -/* Relocate STACK from its old location to the new one. The | ||
14221 | - local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
14222 | - elements in the stack, and YYPTR gives the new location of the | ||
14223 | - stack. Advance YYPTR to a properly aligned location for the next | ||
14224 | - stack. */ | ||
14225 | -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | ||
14226 | - do \ | ||
14227 | - { \ | ||
14228 | - YYSIZE_T yynewbytes; \ | ||
14229 | - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | ||
14230 | - Stack = &yyptr->Stack_alloc; \ | ||
14231 | - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | ||
14232 | - yyptr += yynewbytes / sizeof (*yyptr); \ | ||
14233 | - } \ | ||
14234 | - while (YYID (0)) | ||
14235 | - | ||
14236 | -#endif | ||
14237 | - | ||
14238 | -/* YYFINAL -- State number of the termination state. */ | ||
14239 | -#define YYFINAL 9 | ||
14240 | -/* YYLAST -- Last index in YYTABLE. */ | ||
14241 | -#define YYLAST 54 | ||
14242 | - | ||
14243 | -/* YYNTOKENS -- Number of terminals. */ | ||
14244 | -#define YYNTOKENS 16 | ||
14245 | -/* YYNNTS -- Number of nonterminals. */ | ||
14246 | -#define YYNNTS 3 | ||
14247 | -/* YYNRULES -- Number of rules. */ | ||
14248 | -#define YYNRULES 13 | ||
14249 | -/* YYNRULES -- Number of states. */ | ||
14250 | -#define YYNSTATES 27 | ||
14251 | - | ||
14252 | -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | ||
14253 | -#define YYUNDEFTOK 2 | ||
14254 | -#define YYMAXUTOK 262 | ||
14255 | - | ||
14256 | -#define YYTRANSLATE(YYX) \ | ||
14257 | - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | ||
14258 | - | ||
14259 | -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | ||
14260 | -static const yytype_uint8 yytranslate[] = | ||
14261 | -{ | ||
14262 | - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14263 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14264 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14265 | - 2, 2, 2, 10, 2, 2, 2, 2, 5, 2, | ||
14266 | - 14, 15, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14267 | - 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, | ||
14268 | - 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, | ||
14269 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14270 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14271 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14272 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14273 | - 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14274 | - 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, | ||
14275 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14276 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14277 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14278 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14279 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14280 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14281 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14282 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14283 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14284 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14285 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14286 | - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
14287 | - 2, 2, 2, 2, 2, 2, 1, 2, 6, 7, | ||
14288 | - 8, 9, 11 | ||
14289 | -}; | ||
14290 | - | ||
14291 | -#if YYDEBUG | ||
14292 | -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | ||
14293 | - YYRHS. */ | ||
14294 | -static const yytype_uint8 yyprhs[] = | ||
14295 | -{ | ||
14296 | - 0, 0, 3, 5, 11, 15, 19, 23, 27, 31, | ||
14297 | - 35, 38, 40, 42 | ||
14298 | -}; | ||
14299 | - | ||
14300 | -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ | ||
14301 | -static const yytype_int8 yyrhs[] = | ||
14302 | -{ | ||
14303 | - 17, 0, -1, 18, -1, 18, 3, 18, 12, 18, | ||
14304 | - -1, 18, 4, 18, -1, 18, 5, 18, -1, 18, | ||
14305 | - 6, 18, -1, 18, 7, 18, -1, 18, 8, 18, | ||
14306 | - -1, 18, 9, 18, -1, 10, 18, -1, 13, -1, | ||
14307 | - 11, -1, 14, 18, 15, -1 | ||
14308 | -}; | ||
14309 | - | ||
14310 | -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | ||
14311 | -static const yytype_uint8 yyrline[] = | ||
14312 | -{ | ||
14313 | - 0, 154, 154, 162, 166, 170, 174, 178, 182, 186, | ||
14314 | - 190, 194, 198, 203 | ||
14315 | -}; | ||
14316 | -#endif | ||
14317 | - | ||
14318 | -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE | ||
14319 | -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | ||
14320 | - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | ||
14321 | -static const char *const yytname[] = | ||
14322 | -{ | ||
14323 | - "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", | ||
14324 | - "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", | ||
14325 | - "$accept", "start", "exp", 0 | ||
14326 | -}; | ||
14327 | -#endif | ||
14328 | - | ||
14329 | -# ifdef YYPRINT | ||
14330 | -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | ||
14331 | - token YYLEX-NUM. */ | ||
14332 | -static const yytype_uint16 yytoknum[] = | ||
14333 | -{ | ||
14334 | - 0, 256, 257, 63, 124, 38, 258, 259, 260, 261, | ||
14335 | - 33, 262, 58, 110, 40, 41 | ||
14336 | -}; | ||
14337 | -# endif | ||
14338 | - | ||
14339 | -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | ||
14340 | -static const yytype_uint8 yyr1[] = | ||
14341 | -{ | ||
14342 | - 0, 16, 17, 18, 18, 18, 18, 18, 18, 18, | ||
14343 | - 18, 18, 18, 18 | ||
14344 | -}; | ||
14345 | - | ||
14346 | -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | ||
14347 | -static const yytype_uint8 yyr2[] = | ||
14348 | -{ | ||
14349 | - 0, 2, 1, 5, 3, 3, 3, 3, 3, 3, | ||
14350 | - 2, 1, 1, 3 | ||
14351 | -}; | ||
14352 | - | ||
14353 | -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state | ||
14354 | - STATE-NUM when YYTABLE doesn't specify something else to do. Zero | ||
14355 | - means the default is an error. */ | ||
14356 | -static const yytype_uint8 yydefact[] = | ||
14357 | -{ | ||
14358 | - 0, 0, 12, 11, 0, 0, 2, 10, 0, 1, | ||
14359 | - 0, 0, 0, 0, 0, 0, 0, 13, 0, 4, | ||
14360 | - 5, 6, 7, 8, 9, 0, 3 | ||
14361 | -}; | ||
14362 | - | ||
14363 | -/* YYDEFGOTO[NTERM-NUM]. */ | ||
14364 | -static const yytype_int8 yydefgoto[] = | ||
14365 | -{ | ||
14366 | - -1, 5, 6 | ||
14367 | -}; | ||
14368 | - | ||
14369 | -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | ||
14370 | - STATE-NUM. */ | ||
14371 | -#define YYPACT_NINF -10 | ||
14372 | -static const yytype_int8 yypact[] = | ||
14373 | -{ | ||
14374 | - -9, -9, -10, -10, -9, 8, 36, -10, 13, -10, | ||
14375 | - -9, -9, -9, -9, -9, -9, -9, -10, 26, 41, | ||
14376 | - 45, 18, -2, 14, -10, -9, 36 | ||
14377 | -}; | ||
14378 | - | ||
14379 | -/* YYPGOTO[NTERM-NUM]. */ | ||
14380 | -static const yytype_int8 yypgoto[] = | ||
14381 | -{ | ||
14382 | - -10, -10, -1 | ||
14383 | -}; | ||
14384 | - | ||
14385 | -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | ||
14386 | - positive, shift that token. If negative, reduce the rule which | ||
14387 | - number is the opposite. If zero, do what YYDEFACT says. | ||
14388 | - If YYTABLE_NINF, syntax error. */ | ||
14389 | -#define YYTABLE_NINF -1 | ||
14390 | -static const yytype_uint8 yytable[] = | ||
14391 | -{ | ||
14392 | - 7, 1, 2, 8, 3, 4, 15, 16, 9, 18, | ||
14393 | - 19, 20, 21, 22, 23, 24, 10, 11, 12, 13, | ||
14394 | - 14, 15, 16, 16, 26, 14, 15, 16, 17, 10, | ||
14395 | - 11, 12, 13, 14, 15, 16, 0, 0, 25, 10, | ||
14396 | - 11, 12, 13, 14, 15, 16, 12, 13, 14, 15, | ||
14397 | - 16, 13, 14, 15, 16 | ||
14398 | -}; | ||
14399 | - | ||
14400 | -static const yytype_int8 yycheck[] = | ||
14401 | -{ | ||
14402 | - 1, 10, 11, 4, 13, 14, 8, 9, 0, 10, | ||
14403 | - 11, 12, 13, 14, 15, 16, 3, 4, 5, 6, | ||
14404 | - 7, 8, 9, 9, 25, 7, 8, 9, 15, 3, | ||
14405 | - 4, 5, 6, 7, 8, 9, -1, -1, 12, 3, | ||
14406 | - 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, | ||
14407 | - 9, 6, 7, 8, 9 | ||
14408 | -}; | ||
14409 | - | ||
14410 | -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | ||
14411 | - symbol of state STATE-NUM. */ | ||
14412 | -static const yytype_uint8 yystos[] = | ||
14413 | -{ | ||
14414 | - 0, 10, 11, 13, 14, 17, 18, 18, 18, 0, | ||
14415 | - 3, 4, 5, 6, 7, 8, 9, 15, 18, 18, | ||
14416 | - 18, 18, 18, 18, 18, 12, 18 | ||
14417 | -}; | ||
14418 | - | ||
14419 | -#define yyerrok (yyerrstatus = 0) | ||
14420 | -#define yyclearin (yychar = YYEMPTY) | ||
14421 | -#define YYEMPTY (-2) | ||
14422 | -#define YYEOF 0 | ||
14423 | - | ||
14424 | -#define YYACCEPT goto yyacceptlab | ||
14425 | -#define YYABORT goto yyabortlab | ||
14426 | -#define YYERROR goto yyerrorlab | ||
14427 | - | ||
14428 | - | ||
14429 | -/* Like YYERROR except do call yyerror. This remains here temporarily | ||
14430 | - to ease the transition to the new meaning of YYERROR, for GCC. | ||
14431 | - Once GCC version 2 has supplanted version 1, this can go. */ | ||
14432 | - | ||
14433 | -#define YYFAIL goto yyerrlab | ||
14434 | - | ||
14435 | -#define YYRECOVERING() (!!yyerrstatus) | ||
14436 | - | ||
14437 | -#define YYBACKUP(Token, Value) \ | ||
14438 | -do \ | ||
14439 | - if (yychar == YYEMPTY && yylen == 1) \ | ||
14440 | - { \ | ||
14441 | - yychar = (Token); \ | ||
14442 | - yylval = (Value); \ | ||
14443 | - yytoken = YYTRANSLATE (yychar); \ | ||
14444 | - YYPOPSTACK (1); \ | ||
14445 | - goto yybackup; \ | ||
14446 | - } \ | ||
14447 | - else \ | ||
14448 | - { \ | ||
14449 | - yyerror (YY_("syntax error: cannot back up")); \ | ||
14450 | - YYERROR; \ | ||
14451 | - } \ | ||
14452 | -while (YYID (0)) | ||
14453 | - | ||
14454 | - | ||
14455 | -#define YYTERROR 1 | ||
14456 | -#define YYERRCODE 256 | ||
14457 | - | ||
14458 | - | ||
14459 | -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | ||
14460 | - If N is 0, then set CURRENT to the empty location which ends | ||
14461 | - the previous symbol: RHS[0] (always defined). */ | ||
14462 | - | ||
14463 | -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) | ||
14464 | -#ifndef YYLLOC_DEFAULT | ||
14465 | -# define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
14466 | - do \ | ||
14467 | - if (YYID (N)) \ | ||
14468 | - { \ | ||
14469 | - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ | ||
14470 | - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ | ||
14471 | - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ | ||
14472 | - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ | ||
14473 | - } \ | ||
14474 | - else \ | ||
14475 | - { \ | ||
14476 | - (Current).first_line = (Current).last_line = \ | ||
14477 | - YYRHSLOC (Rhs, 0).last_line; \ | ||
14478 | - (Current).first_column = (Current).last_column = \ | ||
14479 | - YYRHSLOC (Rhs, 0).last_column; \ | ||
14480 | - } \ | ||
14481 | - while (YYID (0)) | ||
14482 | -#endif | ||
14483 | - | ||
14484 | - | ||
14485 | -/* YY_LOCATION_PRINT -- Print the location on the stream. | ||
14486 | - This macro was not mandated originally: define only if we know | ||
14487 | - we won't break user code: when these are the locations we know. */ | ||
14488 | - | ||
14489 | -#ifndef YY_LOCATION_PRINT | ||
14490 | -# if YYLTYPE_IS_TRIVIAL | ||
14491 | -# define YY_LOCATION_PRINT(File, Loc) \ | ||
14492 | - fprintf (File, "%d.%d-%d.%d", \ | ||
14493 | - (Loc).first_line, (Loc).first_column, \ | ||
14494 | - (Loc).last_line, (Loc).last_column) | ||
14495 | -# else | ||
14496 | -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) | ||
14497 | -# endif | ||
14498 | -#endif | ||
14499 | - | ||
14500 | - | ||
14501 | -/* YYLEX -- calling `yylex' with the right arguments. */ | ||
14502 | - | ||
14503 | -#ifdef YYLEX_PARAM | ||
14504 | -# define YYLEX yylex (&yylval, YYLEX_PARAM) | ||
14505 | -#else | ||
14506 | -# define YYLEX yylex (&yylval) | ||
14507 | -#endif | ||
14508 | - | ||
14509 | -/* Enable debugging if requested. */ | ||
14510 | -#if YYDEBUG | ||
14511 | - | ||
14512 | -# ifndef YYFPRINTF | ||
14513 | -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | ||
14514 | -# define YYFPRINTF fprintf | ||
14515 | -# endif | ||
14516 | - | ||
14517 | -# define YYDPRINTF(Args) \ | ||
14518 | -do { \ | ||
14519 | - if (yydebug) \ | ||
14520 | - YYFPRINTF Args; \ | ||
14521 | -} while (YYID (0)) | ||
14522 | - | ||
14523 | -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ | ||
14524 | -do { \ | ||
14525 | - if (yydebug) \ | ||
14526 | - { \ | ||
14527 | - YYFPRINTF (stderr, "%s ", Title); \ | ||
14528 | - yy_symbol_print (stderr, \ | ||
14529 | - Type, Value); \ | ||
14530 | - YYFPRINTF (stderr, "\n"); \ | ||
14531 | - } \ | ||
14532 | -} while (YYID (0)) | ||
14533 | - | ||
14534 | - | ||
14535 | -/*--------------------------------. | ||
14536 | -| Print this symbol on YYOUTPUT. | | ||
14537 | -`--------------------------------*/ | ||
14538 | - | ||
14539 | -/*ARGSUSED*/ | ||
14540 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14541 | - || defined __cplusplus || defined _MSC_VER) | ||
14542 | -static void | ||
14543 | -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | ||
14544 | -#else | ||
14545 | -static void | ||
14546 | -yy_symbol_value_print (yyoutput, yytype, yyvaluep) | ||
14547 | - FILE *yyoutput; | ||
14548 | - int yytype; | ||
14549 | - YYSTYPE const * const yyvaluep; | ||
14550 | -#endif | ||
14551 | -{ | ||
14552 | - if (!yyvaluep) | ||
14553 | - return; | ||
14554 | -# ifdef YYPRINT | ||
14555 | - if (yytype < YYNTOKENS) | ||
14556 | - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
14557 | -# else | ||
14558 | - YYUSE (yyoutput); | ||
14559 | -# endif | ||
14560 | - switch (yytype) | ||
14561 | - { | ||
14562 | - default: | ||
14563 | - break; | ||
14564 | - } | ||
14565 | -} | ||
14566 | - | ||
14567 | - | ||
14568 | -/*--------------------------------. | ||
14569 | -| Print this symbol on YYOUTPUT. | | ||
14570 | -`--------------------------------*/ | ||
14571 | - | ||
14572 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14573 | - || defined __cplusplus || defined _MSC_VER) | ||
14574 | -static void | ||
14575 | -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | ||
14576 | -#else | ||
14577 | -static void | ||
14578 | -yy_symbol_print (yyoutput, yytype, yyvaluep) | ||
14579 | - FILE *yyoutput; | ||
14580 | - int yytype; | ||
14581 | - YYSTYPE const * const yyvaluep; | ||
14582 | -#endif | ||
14583 | -{ | ||
14584 | - if (yytype < YYNTOKENS) | ||
14585 | - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | ||
14586 | - else | ||
14587 | - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | ||
14588 | - | ||
14589 | - yy_symbol_value_print (yyoutput, yytype, yyvaluep); | ||
14590 | - YYFPRINTF (yyoutput, ")"); | ||
14591 | -} | ||
14592 | - | ||
14593 | -/*------------------------------------------------------------------. | ||
14594 | -| yy_stack_print -- Print the state stack from its BOTTOM up to its | | ||
14595 | -| TOP (included). | | ||
14596 | -`------------------------------------------------------------------*/ | ||
14597 | - | ||
14598 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14599 | - || defined __cplusplus || defined _MSC_VER) | ||
14600 | -static void | ||
14601 | -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | ||
14602 | -#else | ||
14603 | -static void | ||
14604 | -yy_stack_print (yybottom, yytop) | ||
14605 | - yytype_int16 *yybottom; | ||
14606 | - yytype_int16 *yytop; | ||
14607 | -#endif | ||
14608 | -{ | ||
14609 | - YYFPRINTF (stderr, "Stack now"); | ||
14610 | - for (; yybottom <= yytop; yybottom++) | ||
14611 | - { | ||
14612 | - int yybot = *yybottom; | ||
14613 | - YYFPRINTF (stderr, " %d", yybot); | ||
14614 | - } | ||
14615 | - YYFPRINTF (stderr, "\n"); | ||
14616 | -} | ||
14617 | - | ||
14618 | -# define YY_STACK_PRINT(Bottom, Top) \ | ||
14619 | -do { \ | ||
14620 | - if (yydebug) \ | ||
14621 | - yy_stack_print ((Bottom), (Top)); \ | ||
14622 | -} while (YYID (0)) | ||
14623 | - | ||
14624 | - | ||
14625 | -/*------------------------------------------------. | ||
14626 | -| Report that the YYRULE is going to be reduced. | | ||
14627 | -`------------------------------------------------*/ | ||
14628 | - | ||
14629 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14630 | - || defined __cplusplus || defined _MSC_VER) | ||
14631 | -static void | ||
14632 | -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) | ||
14633 | -#else | ||
14634 | -static void | ||
14635 | -yy_reduce_print (yyvsp, yyrule) | ||
14636 | - YYSTYPE *yyvsp; | ||
14637 | - int yyrule; | ||
14638 | -#endif | ||
14639 | -{ | ||
14640 | - int yynrhs = yyr2[yyrule]; | ||
14641 | - int yyi; | ||
14642 | - unsigned long int yylno = yyrline[yyrule]; | ||
14643 | - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", | ||
14644 | - yyrule - 1, yylno); | ||
14645 | - /* The symbols being reduced. */ | ||
14646 | - for (yyi = 0; yyi < yynrhs; yyi++) | ||
14647 | - { | ||
14648 | - YYFPRINTF (stderr, " $%d = ", yyi + 1); | ||
14649 | - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], | ||
14650 | - &(yyvsp[(yyi + 1) - (yynrhs)]) | ||
14651 | - ); | ||
14652 | - YYFPRINTF (stderr, "\n"); | ||
14653 | - } | ||
14654 | -} | ||
14655 | - | ||
14656 | -# define YY_REDUCE_PRINT(Rule) \ | ||
14657 | -do { \ | ||
14658 | - if (yydebug) \ | ||
14659 | - yy_reduce_print (yyvsp, Rule); \ | ||
14660 | -} while (YYID (0)) | ||
14661 | - | ||
14662 | -/* Nonzero means print parse trace. It is left uninitialized so that | ||
14663 | - multiple parsers can coexist. */ | ||
14664 | -int yydebug; | ||
14665 | -#else /* !YYDEBUG */ | ||
14666 | -# define YYDPRINTF(Args) | ||
14667 | -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) | ||
14668 | -# define YY_STACK_PRINT(Bottom, Top) | ||
14669 | -# define YY_REDUCE_PRINT(Rule) | ||
14670 | -#endif /* !YYDEBUG */ | ||
14671 | - | ||
14672 | - | ||
14673 | -/* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
14674 | -#ifndef YYINITDEPTH | ||
14675 | -# define YYINITDEPTH 200 | ||
14676 | -#endif | ||
14677 | - | ||
14678 | -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | ||
14679 | - if the built-in stack extension method is used). | ||
14680 | - | ||
14681 | - Do not make this value too large; the results are undefined if | ||
14682 | - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) | ||
14683 | - evaluated with infinite-precision integer arithmetic. */ | ||
14684 | - | ||
14685 | -#ifndef YYMAXDEPTH | ||
14686 | -# define YYMAXDEPTH 10000 | ||
14687 | -#endif | ||
14688 | - | ||
14689 | - | ||
14690 | - | ||
14691 | -#if YYERROR_VERBOSE | ||
14692 | - | ||
14693 | -# ifndef yystrlen | ||
14694 | -# if defined __GLIBC__ && defined _STRING_H | ||
14695 | -# define yystrlen strlen | ||
14696 | -# else | ||
14697 | -/* Return the length of YYSTR. */ | ||
14698 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14699 | - || defined __cplusplus || defined _MSC_VER) | ||
14700 | -static YYSIZE_T | ||
14701 | -yystrlen (const char *yystr) | ||
14702 | -#else | ||
14703 | -static YYSIZE_T | ||
14704 | -yystrlen (yystr) | ||
14705 | - const char *yystr; | ||
14706 | -#endif | ||
14707 | -{ | ||
14708 | - YYSIZE_T yylen; | ||
14709 | - for (yylen = 0; yystr[yylen]; yylen++) | ||
14710 | - continue; | ||
14711 | - return yylen; | ||
14712 | -} | ||
14713 | -# endif | ||
14714 | -# endif | ||
14715 | - | ||
14716 | -# ifndef yystpcpy | ||
14717 | -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE | ||
14718 | -# define yystpcpy stpcpy | ||
14719 | -# else | ||
14720 | -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
14721 | - YYDEST. */ | ||
14722 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14723 | - || defined __cplusplus || defined _MSC_VER) | ||
14724 | -static char * | ||
14725 | -yystpcpy (char *yydest, const char *yysrc) | ||
14726 | -#else | ||
14727 | -static char * | ||
14728 | -yystpcpy (yydest, yysrc) | ||
14729 | - char *yydest; | ||
14730 | - const char *yysrc; | ||
14731 | -#endif | ||
14732 | -{ | ||
14733 | - char *yyd = yydest; | ||
14734 | - const char *yys = yysrc; | ||
14735 | - | ||
14736 | - while ((*yyd++ = *yys++) != '\0') | ||
14737 | - continue; | ||
14738 | - | ||
14739 | - return yyd - 1; | ||
14740 | -} | ||
14741 | -# endif | ||
14742 | -# endif | ||
14743 | - | ||
14744 | -# ifndef yytnamerr | ||
14745 | -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary | ||
14746 | - quotes and backslashes, so that it's suitable for yyerror. The | ||
14747 | - heuristic is that double-quoting is unnecessary unless the string | ||
14748 | - contains an apostrophe, a comma, or backslash (other than | ||
14749 | - backslash-backslash). YYSTR is taken from yytname. If YYRES is | ||
14750 | - null, do not copy; instead, return the length of what the result | ||
14751 | - would have been. */ | ||
14752 | -static YYSIZE_T | ||
14753 | -yytnamerr (char *yyres, const char *yystr) | ||
14754 | -{ | ||
14755 | - if (*yystr == '"') | ||
14756 | - { | ||
14757 | - YYSIZE_T yyn = 0; | ||
14758 | - char const *yyp = yystr; | ||
14759 | - | ||
14760 | - for (;;) | ||
14761 | - switch (*++yyp) | ||
14762 | - { | ||
14763 | - case '\'': | ||
14764 | - case ',': | ||
14765 | - goto do_not_strip_quotes; | ||
14766 | - | ||
14767 | - case '\\': | ||
14768 | - if (*++yyp != '\\') | ||
14769 | - goto do_not_strip_quotes; | ||
14770 | - /* Fall through. */ | ||
14771 | - default: | ||
14772 | - if (yyres) | ||
14773 | - yyres[yyn] = *yyp; | ||
14774 | - yyn++; | ||
14775 | - break; | ||
14776 | - | ||
14777 | - case '"': | ||
14778 | - if (yyres) | ||
14779 | - yyres[yyn] = '\0'; | ||
14780 | - return yyn; | ||
14781 | - } | ||
14782 | - do_not_strip_quotes: ; | ||
14783 | - } | ||
14784 | - | ||
14785 | - if (! yyres) | ||
14786 | - return yystrlen (yystr); | ||
14787 | - | ||
14788 | - return yystpcpy (yyres, yystr) - yyres; | ||
14789 | -} | ||
14790 | -# endif | ||
14791 | - | ||
14792 | -/* Copy into YYRESULT an error message about the unexpected token | ||
14793 | - YYCHAR while in state YYSTATE. Return the number of bytes copied, | ||
14794 | - including the terminating null byte. If YYRESULT is null, do not | ||
14795 | - copy anything; just return the number of bytes that would be | ||
14796 | - copied. As a special case, return 0 if an ordinary "syntax error" | ||
14797 | - message will do. Return YYSIZE_MAXIMUM if overflow occurs during | ||
14798 | - size calculation. */ | ||
14799 | -static YYSIZE_T | ||
14800 | -yysyntax_error (char *yyresult, int yystate, int yychar) | ||
14801 | -{ | ||
14802 | - int yyn = yypact[yystate]; | ||
14803 | - | ||
14804 | - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) | ||
14805 | - return 0; | ||
14806 | - else | ||
14807 | - { | ||
14808 | - int yytype = YYTRANSLATE (yychar); | ||
14809 | - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); | ||
14810 | - YYSIZE_T yysize = yysize0; | ||
14811 | - YYSIZE_T yysize1; | ||
14812 | - int yysize_overflow = 0; | ||
14813 | - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | ||
14814 | - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | ||
14815 | - int yyx; | ||
14816 | - | ||
14817 | -# if 0 | ||
14818 | - /* This is so xgettext sees the translatable formats that are | ||
14819 | - constructed on the fly. */ | ||
14820 | - YY_("syntax error, unexpected %s"); | ||
14821 | - YY_("syntax error, unexpected %s, expecting %s"); | ||
14822 | - YY_("syntax error, unexpected %s, expecting %s or %s"); | ||
14823 | - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); | ||
14824 | - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); | ||
14825 | -# endif | ||
14826 | - char *yyfmt; | ||
14827 | - char const *yyf; | ||
14828 | - static char const yyunexpected[] = "syntax error, unexpected %s"; | ||
14829 | - static char const yyexpecting[] = ", expecting %s"; | ||
14830 | - static char const yyor[] = " or %s"; | ||
14831 | - char yyformat[sizeof yyunexpected | ||
14832 | - + sizeof yyexpecting - 1 | ||
14833 | - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) | ||
14834 | - * (sizeof yyor - 1))]; | ||
14835 | - char const *yyprefix = yyexpecting; | ||
14836 | - | ||
14837 | - /* Start YYX at -YYN if negative to avoid negative indexes in | ||
14838 | - YYCHECK. */ | ||
14839 | - int yyxbegin = yyn < 0 ? -yyn : 0; | ||
14840 | - | ||
14841 | - /* Stay within bounds of both yycheck and yytname. */ | ||
14842 | - int yychecklim = YYLAST - yyn + 1; | ||
14843 | - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | ||
14844 | - int yycount = 1; | ||
14845 | - | ||
14846 | - yyarg[0] = yytname[yytype]; | ||
14847 | - yyfmt = yystpcpy (yyformat, yyunexpected); | ||
14848 | - | ||
14849 | - for (yyx = yyxbegin; yyx < yyxend; ++yyx) | ||
14850 | - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | ||
14851 | - { | ||
14852 | - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | ||
14853 | - { | ||
14854 | - yycount = 1; | ||
14855 | - yysize = yysize0; | ||
14856 | - yyformat[sizeof yyunexpected - 1] = '\0'; | ||
14857 | - break; | ||
14858 | - } | ||
14859 | - yyarg[yycount++] = yytname[yyx]; | ||
14860 | - yysize1 = yysize + yytnamerr (0, yytname[yyx]); | ||
14861 | - yysize_overflow |= (yysize1 < yysize); | ||
14862 | - yysize = yysize1; | ||
14863 | - yyfmt = yystpcpy (yyfmt, yyprefix); | ||
14864 | - yyprefix = yyor; | ||
14865 | - } | ||
14866 | - | ||
14867 | - yyf = YY_(yyformat); | ||
14868 | - yysize1 = yysize + yystrlen (yyf); | ||
14869 | - yysize_overflow |= (yysize1 < yysize); | ||
14870 | - yysize = yysize1; | ||
14871 | - | ||
14872 | - if (yysize_overflow) | ||
14873 | - return YYSIZE_MAXIMUM; | ||
14874 | - | ||
14875 | - if (yyresult) | ||
14876 | - { | ||
14877 | - /* Avoid sprintf, as that infringes on the user's name space. | ||
14878 | - Don't have undefined behavior even if the translation | ||
14879 | - produced a string with the wrong number of "%s"s. */ | ||
14880 | - char *yyp = yyresult; | ||
14881 | - int yyi = 0; | ||
14882 | - while ((*yyp = *yyf) != '\0') | ||
14883 | - { | ||
14884 | - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) | ||
14885 | - { | ||
14886 | - yyp += yytnamerr (yyp, yyarg[yyi++]); | ||
14887 | - yyf += 2; | ||
14888 | - } | ||
14889 | - else | ||
14890 | - { | ||
14891 | - yyp++; | ||
14892 | - yyf++; | ||
14893 | - } | ||
14894 | - } | ||
14895 | - } | ||
14896 | - return yysize; | ||
14897 | - } | ||
14898 | -} | ||
14899 | -#endif /* YYERROR_VERBOSE */ | ||
14900 | - | ||
14901 | - | ||
14902 | -/*-----------------------------------------------. | ||
14903 | -| Release the memory associated to this symbol. | | ||
14904 | -`-----------------------------------------------*/ | ||
14905 | - | ||
14906 | -/*ARGSUSED*/ | ||
14907 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14908 | - || defined __cplusplus || defined _MSC_VER) | ||
14909 | -static void | ||
14910 | -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) | ||
14911 | -#else | ||
14912 | -static void | ||
14913 | -yydestruct (yymsg, yytype, yyvaluep) | ||
14914 | - const char *yymsg; | ||
14915 | - int yytype; | ||
14916 | - YYSTYPE *yyvaluep; | ||
14917 | -#endif | ||
14918 | -{ | ||
14919 | - YYUSE (yyvaluep); | ||
14920 | - | ||
14921 | - if (!yymsg) | ||
14922 | - yymsg = "Deleting"; | ||
14923 | - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | ||
14924 | - | ||
14925 | - switch (yytype) | ||
14926 | - { | ||
14927 | - | ||
14928 | - default: | ||
14929 | - break; | ||
14930 | - } | ||
14931 | -} | ||
14932 | - | ||
14933 | -/* Prevent warnings from -Wmissing-prototypes. */ | ||
14934 | -#ifdef YYPARSE_PARAM | ||
14935 | -#if defined __STDC__ || defined __cplusplus | ||
14936 | -int yyparse (void *YYPARSE_PARAM); | ||
14937 | -#else | ||
14938 | -int yyparse (); | ||
14939 | -#endif | ||
14940 | -#else /* ! YYPARSE_PARAM */ | ||
14941 | -#if defined __STDC__ || defined __cplusplus | ||
14942 | -int yyparse (void); | ||
14943 | -#else | ||
14944 | -int yyparse (); | ||
14945 | -#endif | ||
14946 | -#endif /* ! YYPARSE_PARAM */ | ||
14947 | - | ||
14948 | - | ||
14949 | - | ||
14950 | - | ||
14951 | - | ||
14952 | -/*-------------------------. | ||
14953 | -| yyparse or yypush_parse. | | ||
14954 | -`-------------------------*/ | ||
14955 | - | ||
14956 | -#ifdef YYPARSE_PARAM | ||
14957 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14958 | - || defined __cplusplus || defined _MSC_VER) | ||
14959 | -int | ||
14960 | -yyparse (void *YYPARSE_PARAM) | ||
14961 | -#else | ||
14962 | -int | ||
14963 | -yyparse (YYPARSE_PARAM) | ||
14964 | - void *YYPARSE_PARAM; | ||
14965 | -#endif | ||
14966 | -#else /* ! YYPARSE_PARAM */ | ||
14967 | -#if (defined __STDC__ || defined __C99__FUNC__ \ | ||
14968 | - || defined __cplusplus || defined _MSC_VER) | ||
14969 | -int | ||
14970 | -yyparse (void) | ||
14971 | -#else | ||
14972 | -int | ||
14973 | -yyparse () | ||
14974 | - | ||
14975 | -#endif | ||
14976 | -#endif | ||
14977 | -{ | ||
14978 | -/* The lookahead symbol. */ | ||
14979 | -int yychar; | ||
14980 | - | ||
14981 | -/* The semantic value of the lookahead symbol. */ | ||
14982 | -YYSTYPE yylval; | ||
14983 | - | ||
14984 | - /* Number of syntax errors so far. */ | ||
14985 | - int yynerrs; | ||
14986 | - | ||
14987 | - int yystate; | ||
14988 | - /* Number of tokens to shift before error messages enabled. */ | ||
14989 | - int yyerrstatus; | ||
14990 | - | ||
14991 | - /* The stacks and their tools: | ||
14992 | - `yyss': related to states. | ||
14993 | - `yyvs': related to semantic values. | ||
14994 | - | ||
14995 | - Refer to the stacks thru separate pointers, to allow yyoverflow | ||
14996 | - to reallocate them elsewhere. */ | ||
14997 | - | ||
14998 | - /* The state stack. */ | ||
14999 | - yytype_int16 yyssa[YYINITDEPTH]; | ||
15000 | - yytype_int16 *yyss; | ||
15001 | - yytype_int16 *yyssp; | ||
15002 | - | ||
15003 | - /* The semantic value stack. */ | ||
15004 | - YYSTYPE yyvsa[YYINITDEPTH]; | ||
15005 | - YYSTYPE *yyvs; | ||
15006 | - YYSTYPE *yyvsp; | ||
15007 | - | ||
15008 | - YYSIZE_T yystacksize; | ||
15009 | - | ||
15010 | - int yyn; | ||
15011 | - int yyresult; | ||
15012 | - /* Lookahead token as an internal (translated) token number. */ | ||
15013 | - int yytoken; | ||
15014 | - /* The variables used to return semantic value and location from the | ||
15015 | - action routines. */ | ||
15016 | - YYSTYPE yyval; | ||
15017 | - | ||
15018 | -#if YYERROR_VERBOSE | ||
15019 | - /* Buffer for error messages, and its allocated size. */ | ||
15020 | - char yymsgbuf[128]; | ||
15021 | - char *yymsg = yymsgbuf; | ||
15022 | - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | ||
15023 | -#endif | ||
15024 | - | ||
15025 | -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) | ||
15026 | - | ||
15027 | - /* The number of symbols on the RHS of the reduced rule. | ||
15028 | - Keep to zero when no symbol should be popped. */ | ||
15029 | - int yylen = 0; | ||
15030 | - | ||
15031 | - yytoken = 0; | ||
15032 | - yyss = yyssa; | ||
15033 | - yyvs = yyvsa; | ||
15034 | - yystacksize = YYINITDEPTH; | ||
15035 | - | ||
15036 | - YYDPRINTF ((stderr, "Starting parse\n")); | ||
15037 | - | ||
15038 | - yystate = 0; | ||
15039 | - yyerrstatus = 0; | ||
15040 | - yynerrs = 0; | ||
15041 | - yychar = YYEMPTY; /* Cause a token to be read. */ | ||
15042 | - | ||
15043 | - /* Initialize stack pointers. | ||
15044 | - Waste one element of value and location stack | ||
15045 | - so that they stay on the same level as the state stack. | ||
15046 | - The wasted elements are never initialized. */ | ||
15047 | - yyssp = yyss; | ||
15048 | - yyvsp = yyvs; | ||
15049 | - | ||
15050 | - goto yysetstate; | ||
15051 | - | ||
15052 | -/*------------------------------------------------------------. | ||
15053 | -| yynewstate -- Push a new state, which is found in yystate. | | ||
15054 | -`------------------------------------------------------------*/ | ||
15055 | - yynewstate: | ||
15056 | - /* In all cases, when you get here, the value and location stacks | ||
15057 | - have just been pushed. So pushing a state here evens the stacks. */ | ||
15058 | - yyssp++; | ||
15059 | - | ||
15060 | - yysetstate: | ||
15061 | - *yyssp = yystate; | ||
15062 | - | ||
15063 | - if (yyss + yystacksize - 1 <= yyssp) | ||
15064 | - { | ||
15065 | - /* Get the current used size of the three stacks, in elements. */ | ||
15066 | - YYSIZE_T yysize = yyssp - yyss + 1; | ||
15067 | - | ||
15068 | -#ifdef yyoverflow | ||
15069 | - { | ||
15070 | - /* Give user a chance to reallocate the stack. Use copies of | ||
15071 | - these so that the &'s don't force the real ones into | ||
15072 | - memory. */ | ||
15073 | - YYSTYPE *yyvs1 = yyvs; | ||
15074 | - yytype_int16 *yyss1 = yyss; | ||
15075 | - | ||
15076 | - /* Each stack pointer address is followed by the size of the | ||
15077 | - data in use in that stack, in bytes. This used to be a | ||
15078 | - conditional around just the two extra args, but that might | ||
15079 | - be undefined if yyoverflow is a macro. */ | ||
15080 | - yyoverflow (YY_("memory exhausted"), | ||
15081 | - &yyss1, yysize * sizeof (*yyssp), | ||
15082 | - &yyvs1, yysize * sizeof (*yyvsp), | ||
15083 | - &yystacksize); | ||
15084 | - | ||
15085 | - yyss = yyss1; | ||
15086 | - yyvs = yyvs1; | ||
15087 | - } | ||
15088 | -#else /* no yyoverflow */ | ||
15089 | -# ifndef YYSTACK_RELOCATE | ||
15090 | - goto yyexhaustedlab; | ||
15091 | -# else | ||
15092 | - /* Extend the stack our own way. */ | ||
15093 | - if (YYMAXDEPTH <= yystacksize) | ||
15094 | - goto yyexhaustedlab; | ||
15095 | - yystacksize *= 2; | ||
15096 | - if (YYMAXDEPTH < yystacksize) | ||
15097 | - yystacksize = YYMAXDEPTH; | ||
15098 | - | ||
15099 | - { | ||
15100 | - yytype_int16 *yyss1 = yyss; | ||
15101 | - union yyalloc *yyptr = | ||
15102 | - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | ||
15103 | - if (! yyptr) | ||
15104 | - goto yyexhaustedlab; | ||
15105 | - YYSTACK_RELOCATE (yyss_alloc, yyss); | ||
15106 | - YYSTACK_RELOCATE (yyvs_alloc, yyvs); | ||
15107 | -# undef YYSTACK_RELOCATE | ||
15108 | - if (yyss1 != yyssa) | ||
15109 | - YYSTACK_FREE (yyss1); | ||
15110 | - } | ||
15111 | -# endif | ||
15112 | -#endif /* no yyoverflow */ | ||
15113 | - | ||
15114 | - yyssp = yyss + yysize - 1; | ||
15115 | - yyvsp = yyvs + yysize - 1; | ||
15116 | - | ||
15117 | - YYDPRINTF ((stderr, "Stack size increased to %lu\n", | ||
15118 | - (unsigned long int) yystacksize)); | ||
15119 | - | ||
15120 | - if (yyss + yystacksize - 1 <= yyssp) | ||
15121 | - YYABORT; | ||
15122 | - } | ||
15123 | - | ||
15124 | - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | ||
15125 | - | ||
15126 | - if (yystate == YYFINAL) | ||
15127 | - YYACCEPT; | ||
15128 | - | ||
15129 | - goto yybackup; | ||
15130 | - | ||
15131 | -/*-----------. | ||
15132 | -| yybackup. | | ||
15133 | -`-----------*/ | ||
15134 | -yybackup: | ||
15135 | - | ||
15136 | - /* Do appropriate processing given the current state. Read a | ||
15137 | - lookahead token if we need one and don't already have one. */ | ||
15138 | - | ||
15139 | - /* First try to decide what to do without reference to lookahead token. */ | ||
15140 | - yyn = yypact[yystate]; | ||
15141 | - if (yyn == YYPACT_NINF) | ||
15142 | - goto yydefault; | ||
15143 | - | ||
15144 | - /* Not known => get a lookahead token if don't already have one. */ | ||
15145 | - | ||
15146 | - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | ||
15147 | - if (yychar == YYEMPTY) | ||
15148 | - { | ||
15149 | - YYDPRINTF ((stderr, "Reading a token: ")); | ||
15150 | - yychar = YYLEX; | ||
15151 | - } | ||
15152 | - | ||
15153 | - if (yychar <= YYEOF) | ||
15154 | - { | ||
15155 | - yychar = yytoken = YYEOF; | ||
15156 | - YYDPRINTF ((stderr, "Now at end of input.\n")); | ||
15157 | - } | ||
15158 | - else | ||
15159 | - { | ||
15160 | - yytoken = YYTRANSLATE (yychar); | ||
15161 | - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | ||
15162 | - } | ||
15163 | - | ||
15164 | - /* If the proper action on seeing token YYTOKEN is to reduce or to | ||
15165 | - detect an error, take that action. */ | ||
15166 | - yyn += yytoken; | ||
15167 | - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | ||
15168 | - goto yydefault; | ||
15169 | - yyn = yytable[yyn]; | ||
15170 | - if (yyn <= 0) | ||
15171 | - { | ||
15172 | - if (yyn == 0 || yyn == YYTABLE_NINF) | ||
15173 | - goto yyerrlab; | ||
15174 | - yyn = -yyn; | ||
15175 | - goto yyreduce; | ||
15176 | - } | ||
15177 | - | ||
15178 | - /* Count tokens shifted since error; after three, turn off error | ||
15179 | - status. */ | ||
15180 | - if (yyerrstatus) | ||
15181 | - yyerrstatus--; | ||
15182 | - | ||
15183 | - /* Shift the lookahead token. */ | ||
15184 | - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | ||
15185 | - | ||
15186 | - /* Discard the shifted token. */ | ||
15187 | - yychar = YYEMPTY; | ||
15188 | - | ||
15189 | - yystate = yyn; | ||
15190 | - *++yyvsp = yylval; | ||
15191 | - | ||
15192 | - goto yynewstate; | ||
15193 | - | ||
15194 | - | ||
15195 | -/*-----------------------------------------------------------. | ||
15196 | -| yydefault -- do the default action for the current state. | | ||
15197 | -`-----------------------------------------------------------*/ | ||
15198 | -yydefault: | ||
15199 | - yyn = yydefact[yystate]; | ||
15200 | - if (yyn == 0) | ||
15201 | - goto yyerrlab; | ||
15202 | - goto yyreduce; | ||
15203 | - | ||
15204 | - | ||
15205 | -/*-----------------------------. | ||
15206 | -| yyreduce -- Do a reduction. | | ||
15207 | -`-----------------------------*/ | ||
15208 | -yyreduce: | ||
15209 | - /* yyn is the number of a rule to reduce with. */ | ||
15210 | - yylen = yyr2[yyn]; | ||
15211 | - | ||
15212 | - /* If YYLEN is nonzero, implement the default value of the action: | ||
15213 | - `$$ = $1'. | ||
15214 | - | ||
15215 | - Otherwise, the following line sets YYVAL to garbage. | ||
15216 | - This behavior is undocumented and Bison | ||
15217 | - users should not rely upon it. Assigning to YYVAL | ||
15218 | - unconditionally makes the parser a bit smaller, and it avoids a | ||
15219 | - GCC warning that YYVAL may be used uninitialized. */ | ||
15220 | - yyval = yyvsp[1-yylen]; | ||
15221 | - | ||
15222 | - | ||
15223 | - YY_REDUCE_PRINT (yyn); | ||
15224 | - switch (yyn) | ||
15225 | - { | ||
15226 | - case 2: | ||
15227 | - | ||
15228 | -/* Line 1455 of yacc.c */ | ||
15229 | -#line 155 "plural.y" | ||
15230 | - { | ||
15231 | - if ((yyvsp[(1) - (1)].exp) == NULL) | ||
15232 | - YYABORT; | ||
15233 | - ((struct parse_args *) arg)->res = (yyvsp[(1) - (1)].exp); | ||
15234 | - } | ||
15235 | - break; | ||
15236 | - | ||
15237 | - case 3: | ||
15238 | - | ||
15239 | -/* Line 1455 of yacc.c */ | ||
15240 | -#line 163 "plural.y" | ||
15241 | - { | ||
15242 | - (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp)); | ||
15243 | - } | ||
15244 | - break; | ||
15245 | - | ||
15246 | - case 4: | ||
15247 | - | ||
15248 | -/* Line 1455 of yacc.c */ | ||
15249 | -#line 167 "plural.y" | ||
15250 | - { | ||
15251 | - (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); | ||
15252 | - } | ||
15253 | - break; | ||
15254 | - | ||
15255 | - case 5: | ||
15256 | - | ||
15257 | -/* Line 1455 of yacc.c */ | ||
15258 | -#line 171 "plural.y" | ||
15259 | - { | ||
15260 | - (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); | ||
15261 | - } | ||
15262 | - break; | ||
15263 | - | ||
15264 | - case 6: | ||
15265 | - | ||
15266 | -/* Line 1455 of yacc.c */ | ||
15267 | -#line 175 "plural.y" | ||
15268 | - { | ||
15269 | - (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); | ||
15270 | - } | ||
15271 | - break; | ||
15272 | - | ||
15273 | - case 7: | ||
15274 | - | ||
15275 | -/* Line 1455 of yacc.c */ | ||
15276 | -#line 179 "plural.y" | ||
15277 | - { | ||
15278 | - (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); | ||
15279 | - } | ||
15280 | - break; | ||
15281 | - | ||
15282 | - case 8: | ||
15283 | - | ||
15284 | -/* Line 1455 of yacc.c */ | ||
15285 | -#line 183 "plural.y" | ||
15286 | - { | ||
15287 | - (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); | ||
15288 | - } | ||
15289 | - break; | ||
15290 | - | ||
15291 | - case 9: | ||
15292 | - | ||
15293 | -/* Line 1455 of yacc.c */ | ||
15294 | -#line 187 "plural.y" | ||
15295 | - { | ||
15296 | - (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); | ||
15297 | - } | ||
15298 | - break; | ||
15299 | - | ||
15300 | - case 10: | ||
15301 | - | ||
15302 | -/* Line 1455 of yacc.c */ | ||
15303 | -#line 191 "plural.y" | ||
15304 | - { | ||
15305 | - (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp)); | ||
15306 | - } | ||
15307 | - break; | ||
15308 | - | ||
15309 | - case 11: | ||
15310 | - | ||
15311 | -/* Line 1455 of yacc.c */ | ||
15312 | -#line 195 "plural.y" | ||
15313 | - { | ||
15314 | - (yyval.exp) = new_exp_0 (var); | ||
15315 | - } | ||
15316 | - break; | ||
15317 | - | ||
15318 | - case 12: | ||
15319 | - | ||
15320 | -/* Line 1455 of yacc.c */ | ||
15321 | -#line 199 "plural.y" | ||
15322 | - { | ||
15323 | - if (((yyval.exp) = new_exp_0 (num)) != NULL) | ||
15324 | - (yyval.exp)->val.num = (yyvsp[(1) - (1)].num); | ||
15325 | - } | ||
15326 | - break; | ||
15327 | - | ||
15328 | - case 13: | ||
15329 | - | ||
15330 | -/* Line 1455 of yacc.c */ | ||
15331 | -#line 204 "plural.y" | ||
15332 | - { | ||
15333 | - (yyval.exp) = (yyvsp[(2) - (3)].exp); | ||
15334 | - } | ||
15335 | - break; | ||
15336 | - | ||
15337 | - | ||
15338 | - | ||
15339 | -/* Line 1455 of yacc.c */ | ||
15340 | -#line 1592 "plural.c" | ||
15341 | - default: break; | ||
15342 | - } | ||
15343 | - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); | ||
15344 | - | ||
15345 | - YYPOPSTACK (yylen); | ||
15346 | - yylen = 0; | ||
15347 | - YY_STACK_PRINT (yyss, yyssp); | ||
15348 | - | ||
15349 | - *++yyvsp = yyval; | ||
15350 | - | ||
15351 | - /* Now `shift' the result of the reduction. Determine what state | ||
15352 | - that goes to, based on the state we popped back to and the rule | ||
15353 | - number reduced by. */ | ||
15354 | - | ||
15355 | - yyn = yyr1[yyn]; | ||
15356 | - | ||
15357 | - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | ||
15358 | - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | ||
15359 | - yystate = yytable[yystate]; | ||
15360 | - else | ||
15361 | - yystate = yydefgoto[yyn - YYNTOKENS]; | ||
15362 | - | ||
15363 | - goto yynewstate; | ||
15364 | - | ||
15365 | - | ||
15366 | -/*------------------------------------. | ||
15367 | -| yyerrlab -- here on detecting error | | ||
15368 | -`------------------------------------*/ | ||
15369 | -yyerrlab: | ||
15370 | - /* If not already recovering from an error, report this error. */ | ||
15371 | - if (!yyerrstatus) | ||
15372 | - { | ||
15373 | - ++yynerrs; | ||
15374 | -#if ! YYERROR_VERBOSE | ||
15375 | - yyerror (YY_("syntax error")); | ||
15376 | -#else | ||
15377 | - { | ||
15378 | - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); | ||
15379 | - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) | ||
15380 | - { | ||
15381 | - YYSIZE_T yyalloc = 2 * yysize; | ||
15382 | - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) | ||
15383 | - yyalloc = YYSTACK_ALLOC_MAXIMUM; | ||
15384 | - if (yymsg != yymsgbuf) | ||
15385 | - YYSTACK_FREE (yymsg); | ||
15386 | - yymsg = (char *) YYSTACK_ALLOC (yyalloc); | ||
15387 | - if (yymsg) | ||
15388 | - yymsg_alloc = yyalloc; | ||
15389 | - else | ||
15390 | - { | ||
15391 | - yymsg = yymsgbuf; | ||
15392 | - yymsg_alloc = sizeof yymsgbuf; | ||
15393 | - } | ||
15394 | - } | ||
15395 | - | ||
15396 | - if (0 < yysize && yysize <= yymsg_alloc) | ||
15397 | - { | ||
15398 | - (void) yysyntax_error (yymsg, yystate, yychar); | ||
15399 | - yyerror (yymsg); | ||
15400 | - } | ||
15401 | - else | ||
15402 | - { | ||
15403 | - yyerror (YY_("syntax error")); | ||
15404 | - if (yysize != 0) | ||
15405 | - goto yyexhaustedlab; | ||
15406 | - } | ||
15407 | - } | ||
15408 | -#endif | ||
15409 | - } | ||
15410 | - | ||
15411 | - | ||
15412 | - | ||
15413 | - if (yyerrstatus == 3) | ||
15414 | - { | ||
15415 | - /* If just tried and failed to reuse lookahead token after an | ||
15416 | - error, discard it. */ | ||
15417 | - | ||
15418 | - if (yychar <= YYEOF) | ||
15419 | - { | ||
15420 | - /* Return failure if at end of input. */ | ||
15421 | - if (yychar == YYEOF) | ||
15422 | - YYABORT; | ||
15423 | - } | ||
15424 | - else | ||
15425 | - { | ||
15426 | - yydestruct ("Error: discarding", | ||
15427 | - yytoken, &yylval); | ||
15428 | - yychar = YYEMPTY; | ||
15429 | - } | ||
15430 | - } | ||
15431 | - | ||
15432 | - /* Else will try to reuse lookahead token after shifting the error | ||
15433 | - token. */ | ||
15434 | - goto yyerrlab1; | ||
15435 | - | ||
15436 | - | ||
15437 | -/*---------------------------------------------------. | ||
15438 | -| yyerrorlab -- error raised explicitly by YYERROR. | | ||
15439 | -`---------------------------------------------------*/ | ||
15440 | -yyerrorlab: | ||
15441 | - | ||
15442 | - /* Pacify compilers like GCC when the user code never invokes | ||
15443 | - YYERROR and the label yyerrorlab therefore never appears in user | ||
15444 | - code. */ | ||
15445 | - if (/*CONSTCOND*/ 0) | ||
15446 | - goto yyerrorlab; | ||
15447 | - | ||
15448 | - /* Do not reclaim the symbols of the rule which action triggered | ||
15449 | - this YYERROR. */ | ||
15450 | - YYPOPSTACK (yylen); | ||
15451 | - yylen = 0; | ||
15452 | - YY_STACK_PRINT (yyss, yyssp); | ||
15453 | - yystate = *yyssp; | ||
15454 | - goto yyerrlab1; | ||
15455 | - | ||
15456 | - | ||
15457 | -/*-------------------------------------------------------------. | ||
15458 | -| yyerrlab1 -- common code for both syntax error and YYERROR. | | ||
15459 | -`-------------------------------------------------------------*/ | ||
15460 | -yyerrlab1: | ||
15461 | - yyerrstatus = 3; /* Each real token shifted decrements this. */ | ||
15462 | - | ||
15463 | - for (;;) | ||
15464 | - { | ||
15465 | - yyn = yypact[yystate]; | ||
15466 | - if (yyn != YYPACT_NINF) | ||
15467 | - { | ||
15468 | - yyn += YYTERROR; | ||
15469 | - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | ||
15470 | - { | ||
15471 | - yyn = yytable[yyn]; | ||
15472 | - if (0 < yyn) | ||
15473 | - break; | ||
15474 | - } | ||
15475 | - } | ||
15476 | - | ||
15477 | - /* Pop the current state because it cannot handle the error token. */ | ||
15478 | - if (yyssp == yyss) | ||
15479 | - YYABORT; | ||
15480 | - | ||
15481 | - | ||
15482 | - yydestruct ("Error: popping", | ||
15483 | - yystos[yystate], yyvsp); | ||
15484 | - YYPOPSTACK (1); | ||
15485 | - yystate = *yyssp; | ||
15486 | - YY_STACK_PRINT (yyss, yyssp); | ||
15487 | - } | ||
15488 | - | ||
15489 | - *++yyvsp = yylval; | ||
15490 | - | ||
15491 | - | ||
15492 | - /* Shift the error token. */ | ||
15493 | - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); | ||
15494 | - | ||
15495 | - yystate = yyn; | ||
15496 | - goto yynewstate; | ||
15497 | - | ||
15498 | - | ||
15499 | -/*-------------------------------------. | ||
15500 | -| yyacceptlab -- YYACCEPT comes here. | | ||
15501 | -`-------------------------------------*/ | ||
15502 | -yyacceptlab: | ||
15503 | - yyresult = 0; | ||
15504 | - goto yyreturn; | ||
15505 | - | ||
15506 | -/*-----------------------------------. | ||
15507 | -| yyabortlab -- YYABORT comes here. | | ||
15508 | -`-----------------------------------*/ | ||
15509 | -yyabortlab: | ||
15510 | - yyresult = 1; | ||
15511 | - goto yyreturn; | ||
15512 | - | ||
15513 | -#if !defined(yyoverflow) || YYERROR_VERBOSE | ||
15514 | -/*-------------------------------------------------. | ||
15515 | -| yyexhaustedlab -- memory exhaustion comes here. | | ||
15516 | -`-------------------------------------------------*/ | ||
15517 | -yyexhaustedlab: | ||
15518 | - yyerror (YY_("memory exhausted")); | ||
15519 | - yyresult = 2; | ||
15520 | - /* Fall through. */ | ||
15521 | -#endif | ||
15522 | - | ||
15523 | -yyreturn: | ||
15524 | - if (yychar != YYEMPTY) | ||
15525 | - yydestruct ("Cleanup: discarding lookahead", | ||
15526 | - yytoken, &yylval); | ||
15527 | - /* Do not reclaim the symbols of the rule which action triggered | ||
15528 | - this YYABORT or YYACCEPT. */ | ||
15529 | - YYPOPSTACK (yylen); | ||
15530 | - YY_STACK_PRINT (yyss, yyssp); | ||
15531 | - while (yyssp != yyss) | ||
15532 | - { | ||
15533 | - yydestruct ("Cleanup: popping", | ||
15534 | - yystos[*yyssp], yyvsp); | ||
15535 | - YYPOPSTACK (1); | ||
15536 | - } | ||
15537 | -#ifndef yyoverflow | ||
15538 | - if (yyss != yyssa) | ||
15539 | - YYSTACK_FREE (yyss); | ||
15540 | -#endif | ||
15541 | -#if YYERROR_VERBOSE | ||
15542 | - if (yymsg != yymsgbuf) | ||
15543 | - YYSTACK_FREE (yymsg); | ||
15544 | -#endif | ||
15545 | - /* Make sure YYID is used. */ | ||
15546 | - return YYID (yyresult); | ||
15547 | -} | ||
15548 | - | ||
15549 | - | ||
15550 | - | ||
15551 | -/* Line 1675 of yacc.c */ | ||
15552 | -#line 209 "plural.y" | ||
15553 | - | ||
15554 | - | ||
15555 | -void | ||
15556 | -internal_function | ||
15557 | -FREE_EXPRESSION (struct expression *exp) | ||
15558 | -{ | ||
15559 | - if (exp == NULL) | ||
15560 | - return; | ||
15561 | - | ||
15562 | - /* Handle the recursive case. */ | ||
15563 | - switch (exp->nargs) | ||
15564 | - { | ||
15565 | - case 3: | ||
15566 | - FREE_EXPRESSION (exp->val.args[2]); | ||
15567 | - /* FALLTHROUGH */ | ||
15568 | - case 2: | ||
15569 | - FREE_EXPRESSION (exp->val.args[1]); | ||
15570 | - /* FALLTHROUGH */ | ||
15571 | - case 1: | ||
15572 | - FREE_EXPRESSION (exp->val.args[0]); | ||
15573 | - /* FALLTHROUGH */ | ||
15574 | - default: | ||
15575 | - break; | ||
15576 | - } | ||
15577 | - | ||
15578 | - free (exp); | ||
15579 | -} | ||
15580 | - | ||
15581 | - | ||
15582 | -static int | ||
15583 | -yylex (YYSTYPE *lval, const char **pexp) | ||
15584 | -{ | ||
15585 | - const char *exp = *pexp; | ||
15586 | - int result; | ||
15587 | - | ||
15588 | - while (1) | ||
15589 | - { | ||
15590 | - if (exp[0] == '\0') | ||
15591 | - { | ||
15592 | - *pexp = exp; | ||
15593 | - return YYEOF; | ||
15594 | - } | ||
15595 | - | ||
15596 | - if (exp[0] != ' ' && exp[0] != '\t') | ||
15597 | - break; | ||
15598 | - | ||
15599 | - ++exp; | ||
15600 | - } | ||
15601 | - | ||
15602 | - result = *exp++; | ||
15603 | - switch (result) | ||
15604 | - { | ||
15605 | - case '0': case '1': case '2': case '3': case '4': | ||
15606 | - case '5': case '6': case '7': case '8': case '9': | ||
15607 | - { | ||
15608 | - unsigned long int n = result - '0'; | ||
15609 | - while (exp[0] >= '0' && exp[0] <= '9') | ||
15610 | - { | ||
15611 | - n *= 10; | ||
15612 | - n += exp[0] - '0'; | ||
15613 | - ++exp; | ||
15614 | - } | ||
15615 | - lval->num = n; | ||
15616 | - result = NUMBER; | ||
15617 | - } | ||
15618 | - break; | ||
15619 | - | ||
15620 | - case '=': | ||
15621 | - if (exp[0] == '=') | ||
15622 | - { | ||
15623 | - ++exp; | ||
15624 | - lval->op = equal; | ||
15625 | - result = EQUOP2; | ||
15626 | - } | ||
15627 | - else | ||
15628 | - result = YYERRCODE; | ||
15629 | - break; | ||
15630 | - | ||
15631 | - case '!': | ||
15632 | - if (exp[0] == '=') | ||
15633 | - { | ||
15634 | - ++exp; | ||
15635 | - lval->op = not_equal; | ||
15636 | - result = EQUOP2; | ||
15637 | - } | ||
15638 | - break; | ||
15639 | - | ||
15640 | - case '&': | ||
15641 | - case '|': | ||
15642 | - if (exp[0] == result) | ||
15643 | - ++exp; | ||
15644 | - else | ||
15645 | - result = YYERRCODE; | ||
15646 | - break; | ||
15647 | - | ||
15648 | - case '<': | ||
15649 | - if (exp[0] == '=') | ||
15650 | - { | ||
15651 | - ++exp; | ||
15652 | - lval->op = less_or_equal; | ||
15653 | - } | ||
15654 | - else | ||
15655 | - lval->op = less_than; | ||
15656 | - result = CMPOP2; | ||
15657 | - break; | ||
15658 | - | ||
15659 | - case '>': | ||
15660 | - if (exp[0] == '=') | ||
15661 | - { | ||
15662 | - ++exp; | ||
15663 | - lval->op = greater_or_equal; | ||
15664 | - } | ||
15665 | - else | ||
15666 | - lval->op = greater_than; | ||
15667 | - result = CMPOP2; | ||
15668 | - break; | ||
15669 | - | ||
15670 | - case '*': | ||
15671 | - lval->op = mult; | ||
15672 | - result = MULOP2; | ||
15673 | - break; | ||
15674 | - | ||
15675 | - case '/': | ||
15676 | - lval->op = divide; | ||
15677 | - result = MULOP2; | ||
15678 | - break; | ||
15679 | - | ||
15680 | - case '%': | ||
15681 | - lval->op = module; | ||
15682 | - result = MULOP2; | ||
15683 | - break; | ||
15684 | - | ||
15685 | - case '+': | ||
15686 | - lval->op = plus; | ||
15687 | - result = ADDOP2; | ||
15688 | - break; | ||
15689 | - | ||
15690 | - case '-': | ||
15691 | - lval->op = minus; | ||
15692 | - result = ADDOP2; | ||
15693 | - break; | ||
15694 | - | ||
15695 | - case 'n': | ||
15696 | - case '?': | ||
15697 | - case ':': | ||
15698 | - case '(': | ||
15699 | - case ')': | ||
15700 | - /* Nothing, just return the character. */ | ||
15701 | - break; | ||
15702 | - | ||
15703 | - case ';': | ||
15704 | - case '\n': | ||
15705 | - case '\0': | ||
15706 | - /* Be safe and let the user call this function again. */ | ||
15707 | - --exp; | ||
15708 | - result = YYEOF; | ||
15709 | - break; | ||
15710 | - | ||
15711 | - default: | ||
15712 | - result = YYERRCODE; | ||
15713 | -#if YYDEBUG != 0 | ||
15714 | - --exp; | ||
15715 | -#endif | ||
15716 | - break; | ||
15717 | - } | ||
15718 | - | ||
15719 | - *pexp = exp; | ||
15720 | - | ||
15721 | - return result; | ||
15722 | -} | ||
15723 | - | ||
15724 | - | ||
15725 | -static void | ||
15726 | -yyerror (const char *str) | ||
15727 | -{ | ||
15728 | - /* Do nothing. We don't print error messages here. */ | ||
15729 | -} | ||
15730 | - | ||
15731 | --- a/intl/plural.y | ||
15732 | +++ /dev/null | ||
15733 | @@ -1,385 +0,0 @@ | ||
15734 | -%{ | ||
15735 | -/* Expression parsing for plural form selection. | ||
15736 | - Copyright (C) 2000-2001, 2003, 2005-2006 Free Software Foundation, Inc. | ||
15737 | - Written by Ulrich Drepper <drepper@cygnus.com>, 2000. | ||
15738 | - | ||
15739 | - This program is free software; you can redistribute it and/or modify it | ||
15740 | - under the terms of the GNU Library General Public License as published | ||
15741 | - by the Free Software Foundation; either version 2, or (at your option) | ||
15742 | - any later version. | ||
15743 | - | ||
15744 | - This program is distributed in the hope that it will be useful, | ||
15745 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15746 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15747 | - Library General Public License for more details. | ||
15748 | - | ||
15749 | - You should have received a copy of the GNU Library General Public | ||
15750 | - License along with this program; if not, write to the Free Software | ||
15751 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
15752 | - USA. */ | ||
15753 | - | ||
15754 | -/* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us | ||
15755 | - to put this declaration at the beginning of the file. The declaration in | ||
15756 | - bison's skeleton file comes too late. This must come before <config.h> | ||
15757 | - because <config.h> may include arbitrary system headers. | ||
15758 | - This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */ | ||
15759 | -#if defined _AIX && !defined __GNUC__ | ||
15760 | - #pragma alloca | ||
15761 | -#endif | ||
15762 | - | ||
15763 | -#ifdef HAVE_CONFIG_H | ||
15764 | -# include <config.h> | ||
15765 | -#endif | ||
15766 | - | ||
15767 | -#include <stddef.h> | ||
15768 | -#include <stdlib.h> | ||
15769 | -#include <string.h> | ||
15770 | -#include "plural-exp.h" | ||
15771 | - | ||
15772 | -/* The main function generated by the parser is called __gettextparse, | ||
15773 | - but we want it to be called PLURAL_PARSE. */ | ||
15774 | -#ifndef _LIBC | ||
15775 | -# define __gettextparse PLURAL_PARSE | ||
15776 | -#endif | ||
15777 | - | ||
15778 | -#define YYLEX_PARAM &((struct parse_args *) arg)->cp | ||
15779 | -#define YYPARSE_PARAM arg | ||
15780 | -%} | ||
15781 | -%pure_parser | ||
15782 | -%expect 7 | ||
15783 | - | ||
15784 | -%union { | ||
15785 | - unsigned long int num; | ||
15786 | - enum expression_operator op; | ||
15787 | - struct expression *exp; | ||
15788 | -} | ||
15789 | - | ||
15790 | -%{ | ||
15791 | -/* Prototypes for local functions. */ | ||
15792 | -static int yylex (YYSTYPE *lval, const char **pexp); | ||
15793 | -static void yyerror (const char *str); | ||
15794 | - | ||
15795 | -/* Allocation of expressions. */ | ||
15796 | - | ||
15797 | -static struct expression * | ||
15798 | -new_exp (int nargs, enum expression_operator op, | ||
15799 | - struct expression * const *args) | ||
15800 | -{ | ||
15801 | - int i; | ||
15802 | - struct expression *newp; | ||
15803 | - | ||
15804 | - /* If any of the argument could not be malloc'ed, just return NULL. */ | ||
15805 | - for (i = nargs - 1; i >= 0; i--) | ||
15806 | - if (args[i] == NULL) | ||
15807 | - goto fail; | ||
15808 | - | ||
15809 | - /* Allocate a new expression. */ | ||
15810 | - newp = (struct expression *) malloc (sizeof (*newp)); | ||
15811 | - if (newp != NULL) | ||
15812 | - { | ||
15813 | - newp->nargs = nargs; | ||
15814 | - newp->operation = op; | ||
15815 | - for (i = nargs - 1; i >= 0; i--) | ||
15816 | - newp->val.args[i] = args[i]; | ||
15817 | - return newp; | ||
15818 | - } | ||
15819 | - | ||
15820 | - fail: | ||
15821 | - for (i = nargs - 1; i >= 0; i--) | ||
15822 | - FREE_EXPRESSION (args[i]); | ||
15823 | - | ||
15824 | - return NULL; | ||
15825 | -} | ||
15826 | - | ||
15827 | -static inline struct expression * | ||
15828 | -new_exp_0 (enum expression_operator op) | ||
15829 | -{ | ||
15830 | - return new_exp (0, op, NULL); | ||
15831 | -} | ||
15832 | - | ||
15833 | -static inline struct expression * | ||
15834 | -new_exp_1 (enum expression_operator op, struct expression *right) | ||
15835 | -{ | ||
15836 | - struct expression *args[1]; | ||
15837 | - | ||
15838 | - args[0] = right; | ||
15839 | - return new_exp (1, op, args); | ||
15840 | -} | ||
15841 | - | ||
15842 | -static struct expression * | ||
15843 | -new_exp_2 (enum expression_operator op, struct expression *left, | ||
15844 | - struct expression *right) | ||
15845 | -{ | ||
15846 | - struct expression *args[2]; | ||
15847 | - | ||
15848 | - args[0] = left; | ||
15849 | - args[1] = right; | ||
15850 | - return new_exp (2, op, args); | ||
15851 | -} | ||
15852 | - | ||
15853 | -static inline struct expression * | ||
15854 | -new_exp_3 (enum expression_operator op, struct expression *bexp, | ||
15855 | - struct expression *tbranch, struct expression *fbranch) | ||
15856 | -{ | ||
15857 | - struct expression *args[3]; | ||
15858 | - | ||
15859 | - args[0] = bexp; | ||
15860 | - args[1] = tbranch; | ||
15861 | - args[2] = fbranch; | ||
15862 | - return new_exp (3, op, args); | ||
15863 | -} | ||
15864 | - | ||
15865 | -%} | ||
15866 | - | ||
15867 | -/* This declares that all operators have the same associativity and the | ||
15868 | - precedence order as in C. See [Harbison, Steele: C, A Reference Manual]. | ||
15869 | - There is no unary minus and no bitwise operators. | ||
15870 | - Operators with the same syntactic behaviour have been merged into a single | ||
15871 | - token, to save space in the array generated by bison. */ | ||
15872 | -%right '?' /* ? */ | ||
15873 | -%left '|' /* || */ | ||
15874 | -%left '&' /* && */ | ||
15875 | -%left EQUOP2 /* == != */ | ||
15876 | -%left CMPOP2 /* < > <= >= */ | ||
15877 | -%left ADDOP2 /* + - */ | ||
15878 | -%left MULOP2 /* * / % */ | ||
15879 | -%right '!' /* ! */ | ||
15880 | - | ||
15881 | -%token <op> EQUOP2 CMPOP2 ADDOP2 MULOP2 | ||
15882 | -%token <num> NUMBER | ||
15883 | -%type <exp> exp | ||
15884 | - | ||
15885 | -%% | ||
15886 | - | ||
15887 | -start: exp | ||
15888 | - { | ||
15889 | - if ($1 == NULL) | ||
15890 | - YYABORT; | ||
15891 | - ((struct parse_args *) arg)->res = $1; | ||
15892 | - } | ||
15893 | - ; | ||
15894 | - | ||
15895 | -exp: exp '?' exp ':' exp | ||
15896 | - { | ||
15897 | - $$ = new_exp_3 (qmop, $1, $3, $5); | ||
15898 | - } | ||
15899 | - | exp '|' exp | ||
15900 | - { | ||
15901 | - $$ = new_exp_2 (lor, $1, $3); | ||
15902 | - } | ||
15903 | - | exp '&' exp | ||
15904 | - { | ||
15905 | - $$ = new_exp_2 (land, $1, $3); | ||
15906 | - } | ||
15907 | - | exp EQUOP2 exp | ||
15908 | - { | ||
15909 | - $$ = new_exp_2 ($2, $1, $3); | ||
15910 | - } | ||
15911 | - | exp CMPOP2 exp | ||
15912 | - { | ||
15913 | - $$ = new_exp_2 ($2, $1, $3); | ||
15914 | - } | ||
15915 | - | exp ADDOP2 exp | ||
15916 | - { | ||
15917 | - $$ = new_exp_2 ($2, $1, $3); | ||
15918 | - } | ||
15919 | - | exp MULOP2 exp | ||
15920 | - { | ||
15921 | - $$ = new_exp_2 ($2, $1, $3); | ||
15922 | - } | ||
15923 | - | '!' exp | ||
15924 | - { | ||
15925 | - $$ = new_exp_1 (lnot, $2); | ||
15926 | - } | ||
15927 | - | 'n' | ||
15928 | - { | ||
15929 | - $$ = new_exp_0 (var); | ||
15930 | - } | ||
15931 | - | NUMBER | ||
15932 | - { | ||
15933 | - if (($$ = new_exp_0 (num)) != NULL) | ||
15934 | - $$->val.num = $1; | ||
15935 | - } | ||
15936 | - | '(' exp ')' | ||
15937 | - { | ||
15938 | - $$ = $2; | ||
15939 | - } | ||
15940 | - ; | ||
15941 | - | ||
15942 | -%% | ||
15943 | - | ||
15944 | -void | ||
15945 | -internal_function | ||
15946 | -FREE_EXPRESSION (struct expression *exp) | ||
15947 | -{ | ||
15948 | - if (exp == NULL) | ||
15949 | - return; | ||
15950 | - | ||
15951 | - /* Handle the recursive case. */ | ||
15952 | - switch (exp->nargs) | ||
15953 | - { | ||
15954 | - case 3: | ||
15955 | - FREE_EXPRESSION (exp->val.args[2]); | ||
15956 | - /* FALLTHROUGH */ | ||
15957 | - case 2: | ||
15958 | - FREE_EXPRESSION (exp->val.args[1]); | ||
15959 | - /* FALLTHROUGH */ | ||
15960 | - case 1: | ||
15961 | - FREE_EXPRESSION (exp->val.args[0]); | ||
15962 | - /* FALLTHROUGH */ | ||
15963 | - default: | ||
15964 | - break; | ||
15965 | - } | ||
15966 | - | ||
15967 | - free (exp); | ||
15968 | -} | ||
15969 | - | ||
15970 | - | ||
15971 | -static int | ||
15972 | -yylex (YYSTYPE *lval, const char **pexp) | ||
15973 | -{ | ||
15974 | - const char *exp = *pexp; | ||
15975 | - int result; | ||
15976 | - | ||
15977 | - while (1) | ||
15978 | - { | ||
15979 | - if (exp[0] == '\0') | ||
15980 | - { | ||
15981 | - *pexp = exp; | ||
15982 | - return YYEOF; | ||
15983 | - } | ||
15984 | - | ||
15985 | - if (exp[0] != ' ' && exp[0] != '\t') | ||
15986 | - break; | ||
15987 | - | ||
15988 | - ++exp; | ||
15989 | - } | ||
15990 | - | ||
15991 | - result = *exp++; | ||
15992 | - switch (result) | ||
15993 | - { | ||
15994 | - case '0': case '1': case '2': case '3': case '4': | ||
15995 | - case '5': case '6': case '7': case '8': case '9': | ||
15996 | - { | ||
15997 | - unsigned long int n = result - '0'; | ||
15998 | - while (exp[0] >= '0' && exp[0] <= '9') | ||
15999 | - { | ||
16000 | - n *= 10; | ||
16001 | - n += exp[0] - '0'; | ||
16002 | - ++exp; | ||
16003 | - } | ||
16004 | - lval->num = n; | ||
16005 | - result = NUMBER; | ||
16006 | - } | ||
16007 | - break; | ||
16008 | - | ||
16009 | - case '=': | ||
16010 | - if (exp[0] == '=') | ||
16011 | - { | ||
16012 | - ++exp; | ||
16013 | - lval->op = equal; | ||
16014 | - result = EQUOP2; | ||
16015 | - } | ||
16016 | - else | ||
16017 | - result = YYERRCODE; | ||
16018 | - break; | ||
16019 | - | ||
16020 | - case '!': | ||
16021 | - if (exp[0] == '=') | ||
16022 | - { | ||
16023 | - ++exp; | ||
16024 | - lval->op = not_equal; | ||
16025 | - result = EQUOP2; | ||
16026 | - } | ||
16027 | - break; | ||
16028 | - | ||
16029 | - case '&': | ||
16030 | - case '|': | ||
16031 | - if (exp[0] == result) | ||
16032 | - ++exp; | ||
16033 | - else | ||
16034 | - result = YYERRCODE; | ||
16035 | - break; | ||
16036 | - | ||
16037 | - case '<': | ||
16038 | - if (exp[0] == '=') | ||
16039 | - { | ||
16040 | - ++exp; | ||
16041 | - lval->op = less_or_equal; | ||
16042 | - } | ||
16043 | - else | ||
16044 | - lval->op = less_than; | ||
16045 | - result = CMPOP2; | ||
16046 | - break; | ||
16047 | - | ||
16048 | - case '>': | ||
16049 | - if (exp[0] == '=') | ||
16050 | - { | ||
16051 | - ++exp; | ||
16052 | - lval->op = greater_or_equal; | ||
16053 | - } | ||
16054 | - else | ||
16055 | - lval->op = greater_than; | ||
16056 | - result = CMPOP2; | ||
16057 | - break; | ||
16058 | - | ||
16059 | - case '*': | ||
16060 | - lval->op = mult; | ||
16061 | - result = MULOP2; | ||
16062 | - break; | ||
16063 | - | ||
16064 | - case '/': | ||
16065 | - lval->op = divide; | ||
16066 | - result = MULOP2; | ||
16067 | - break; | ||
16068 | - | ||
16069 | - case '%': | ||
16070 | - lval->op = module; | ||
16071 | - result = MULOP2; | ||
16072 | - break; | ||
16073 | - | ||
16074 | - case '+': | ||
16075 | - lval->op = plus; | ||
16076 | - result = ADDOP2; | ||
16077 | - break; | ||
16078 | - | ||
16079 | - case '-': | ||
16080 | - lval->op = minus; | ||
16081 | - result = ADDOP2; | ||
16082 | - break; | ||
16083 | - | ||
16084 | - case 'n': | ||
16085 | - case '?': | ||
16086 | - case ':': | ||
16087 | - case '(': | ||
16088 | - case ')': | ||
16089 | - /* Nothing, just return the character. */ | ||
16090 | - break; | ||
16091 | - | ||
16092 | - case ';': | ||
16093 | - case '\n': | ||
16094 | - case '\0': | ||
16095 | - /* Be safe and let the user call this function again. */ | ||
16096 | - --exp; | ||
16097 | - result = YYEOF; | ||
16098 | - break; | ||
16099 | - | ||
16100 | - default: | ||
16101 | - result = YYERRCODE; | ||
16102 | -#if YYDEBUG != 0 | ||
16103 | - --exp; | ||
16104 | -#endif | ||
16105 | - break; | ||
16106 | - } | ||
16107 | - | ||
16108 | - *pexp = exp; | ||
16109 | - | ||
16110 | - return result; | ||
16111 | -} | ||
16112 | - | ||
16113 | - | ||
16114 | -static void | ||
16115 | -yyerror (const char *str) | ||
16116 | -{ | ||
16117 | - /* Do nothing. We don't print error messages here. */ | ||
16118 | -} | ||
16119 | --- a/intl/printf-args.c | ||
16120 | +++ /dev/null | ||
16121 | @@ -1,188 +0,0 @@ | ||
16122 | -/* Decomposed printf argument list. | ||
16123 | - Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc. | ||
16124 | - | ||
16125 | - This program is free software; you can redistribute it and/or modify it | ||
16126 | - under the terms of the GNU Library General Public License as published | ||
16127 | - by the Free Software Foundation; either version 2, or (at your option) | ||
16128 | - any later version. | ||
16129 | - | ||
16130 | - This program is distributed in the hope that it will be useful, | ||
16131 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16132 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16133 | - Library General Public License for more details. | ||
16134 | - | ||
16135 | - You should have received a copy of the GNU Library General Public | ||
16136 | - License along with this program; if not, write to the Free Software | ||
16137 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
16138 | - USA. */ | ||
16139 | - | ||
16140 | -/* This file can be parametrized with the following macros: | ||
16141 | - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. | ||
16142 | - PRINTF_FETCHARGS Name of the function to be defined. | ||
16143 | - STATIC Set to 'static' to declare the function static. */ | ||
16144 | - | ||
16145 | -#ifndef PRINTF_FETCHARGS | ||
16146 | -# include <config.h> | ||
16147 | -#endif | ||
16148 | - | ||
16149 | -/* Specification. */ | ||
16150 | -#ifndef PRINTF_FETCHARGS | ||
16151 | -# include "printf-args.h" | ||
16152 | -#endif | ||
16153 | - | ||
16154 | -#ifdef STATIC | ||
16155 | -STATIC | ||
16156 | -#endif | ||
16157 | -int | ||
16158 | -PRINTF_FETCHARGS (va_list args, arguments *a) | ||
16159 | -{ | ||
16160 | - size_t i; | ||
16161 | - argument *ap; | ||
16162 | - | ||
16163 | - for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++) | ||
16164 | - switch (ap->type) | ||
16165 | - { | ||
16166 | - case TYPE_SCHAR: | ||
16167 | - ap->a.a_schar = va_arg (args, /*signed char*/ int); | ||
16168 | - break; | ||
16169 | - case TYPE_UCHAR: | ||
16170 | - ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); | ||
16171 | - break; | ||
16172 | - case TYPE_SHORT: | ||
16173 | - ap->a.a_short = va_arg (args, /*short*/ int); | ||
16174 | - break; | ||
16175 | - case TYPE_USHORT: | ||
16176 | - ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); | ||
16177 | - break; | ||
16178 | - case TYPE_INT: | ||
16179 | - ap->a.a_int = va_arg (args, int); | ||
16180 | - break; | ||
16181 | - case TYPE_UINT: | ||
16182 | - ap->a.a_uint = va_arg (args, unsigned int); | ||
16183 | - break; | ||
16184 | - case TYPE_LONGINT: | ||
16185 | - ap->a.a_longint = va_arg (args, long int); | ||
16186 | - break; | ||
16187 | - case TYPE_ULONGINT: | ||
16188 | - ap->a.a_ulongint = va_arg (args, unsigned long int); | ||
16189 | - break; | ||
16190 | -#if HAVE_LONG_LONG_INT | ||
16191 | - case TYPE_LONGLONGINT: | ||
16192 | - ap->a.a_longlongint = va_arg (args, long long int); | ||
16193 | - break; | ||
16194 | - case TYPE_ULONGLONGINT: | ||
16195 | - ap->a.a_ulonglongint = va_arg (args, unsigned long long int); | ||
16196 | - break; | ||
16197 | -#endif | ||
16198 | - case TYPE_DOUBLE: | ||
16199 | - ap->a.a_double = va_arg (args, double); | ||
16200 | - break; | ||
16201 | - case TYPE_LONGDOUBLE: | ||
16202 | - ap->a.a_longdouble = va_arg (args, long double); | ||
16203 | - break; | ||
16204 | - case TYPE_CHAR: | ||
16205 | - ap->a.a_char = va_arg (args, int); | ||
16206 | - break; | ||
16207 | -#if HAVE_WINT_T | ||
16208 | - case TYPE_WIDE_CHAR: | ||
16209 | - /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by | ||
16210 | - default argument promotions", this is not the case in mingw32, | ||
16211 | - where wint_t is 'unsigned short'. */ | ||
16212 | - ap->a.a_wide_char = | ||
16213 | - (sizeof (wint_t) < sizeof (int) | ||
16214 | - ? va_arg (args, int) | ||
16215 | - : va_arg (args, wint_t)); | ||
16216 | - break; | ||
16217 | -#endif | ||
16218 | - case TYPE_STRING: | ||
16219 | - ap->a.a_string = va_arg (args, const char *); | ||
16220 | - /* A null pointer is an invalid argument for "%s", but in practice | ||
16221 | - it occurs quite frequently in printf statements that produce | ||
16222 | - debug output. Use a fallback in this case. */ | ||
16223 | - if (ap->a.a_string == NULL) | ||
16224 | - ap->a.a_string = "(NULL)"; | ||
16225 | - break; | ||
16226 | -#if HAVE_WCHAR_T | ||
16227 | - case TYPE_WIDE_STRING: | ||
16228 | - ap->a.a_wide_string = va_arg (args, const wchar_t *); | ||
16229 | - /* A null pointer is an invalid argument for "%ls", but in practice | ||
16230 | - it occurs quite frequently in printf statements that produce | ||
16231 | - debug output. Use a fallback in this case. */ | ||
16232 | - if (ap->a.a_wide_string == NULL) | ||
16233 | - { | ||
16234 | - static const wchar_t wide_null_string[] = | ||
16235 | - { | ||
16236 | - (wchar_t)'(', | ||
16237 | - (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', | ||
16238 | - (wchar_t)')', | ||
16239 | - (wchar_t)0 | ||
16240 | - }; | ||
16241 | - ap->a.a_wide_string = wide_null_string; | ||
16242 | - } | ||
16243 | - break; | ||
16244 | -#endif | ||
16245 | - case TYPE_POINTER: | ||
16246 | - ap->a.a_pointer = va_arg (args, void *); | ||
16247 | - break; | ||
16248 | - case TYPE_COUNT_SCHAR_POINTER: | ||
16249 | - ap->a.a_count_schar_pointer = va_arg (args, signed char *); | ||
16250 | - break; | ||
16251 | - case TYPE_COUNT_SHORT_POINTER: | ||
16252 | - ap->a.a_count_short_pointer = va_arg (args, short *); | ||
16253 | - break; | ||
16254 | - case TYPE_COUNT_INT_POINTER: | ||
16255 | - ap->a.a_count_int_pointer = va_arg (args, int *); | ||
16256 | - break; | ||
16257 | - case TYPE_COUNT_LONGINT_POINTER: | ||
16258 | - ap->a.a_count_longint_pointer = va_arg (args, long int *); | ||
16259 | - break; | ||
16260 | -#if HAVE_LONG_LONG_INT | ||
16261 | - case TYPE_COUNT_LONGLONGINT_POINTER: | ||
16262 | - ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); | ||
16263 | - break; | ||
16264 | -#endif | ||
16265 | -#if ENABLE_UNISTDIO | ||
16266 | - /* The unistdio extensions. */ | ||
16267 | - case TYPE_U8_STRING: | ||
16268 | - ap->a.a_u8_string = va_arg (args, const uint8_t *); | ||
16269 | - /* A null pointer is an invalid argument for "%U", but in practice | ||
16270 | - it occurs quite frequently in printf statements that produce | ||
16271 | - debug output. Use a fallback in this case. */ | ||
16272 | - if (ap->a.a_u8_string == NULL) | ||
16273 | - { | ||
16274 | - static const uint8_t u8_null_string[] = | ||
16275 | - { '(', 'N', 'U', 'L', 'L', ')', 0 }; | ||
16276 | - ap->a.a_u8_string = u8_null_string; | ||
16277 | - } | ||
16278 | - break; | ||
16279 | - case TYPE_U16_STRING: | ||
16280 | - ap->a.a_u16_string = va_arg (args, const uint16_t *); | ||
16281 | - /* A null pointer is an invalid argument for "%lU", but in practice | ||
16282 | - it occurs quite frequently in printf statements that produce | ||
16283 | - debug output. Use a fallback in this case. */ | ||
16284 | - if (ap->a.a_u16_string == NULL) | ||
16285 | - { | ||
16286 | - static const uint16_t u16_null_string[] = | ||
16287 | - { '(', 'N', 'U', 'L', 'L', ')', 0 }; | ||
16288 | - ap->a.a_u16_string = u16_null_string; | ||
16289 | - } | ||
16290 | - break; | ||
16291 | - case TYPE_U32_STRING: | ||
16292 | - ap->a.a_u32_string = va_arg (args, const uint32_t *); | ||
16293 | - /* A null pointer is an invalid argument for "%llU", but in practice | ||
16294 | - it occurs quite frequently in printf statements that produce | ||
16295 | - debug output. Use a fallback in this case. */ | ||
16296 | - if (ap->a.a_u32_string == NULL) | ||
16297 | - { | ||
16298 | - static const uint32_t u32_null_string[] = | ||
16299 | - { '(', 'N', 'U', 'L', 'L', ')', 0 }; | ||
16300 | - ap->a.a_u32_string = u32_null_string; | ||
16301 | - } | ||
16302 | - break; | ||
16303 | -#endif | ||
16304 | - default: | ||
16305 | - /* Unknown type. */ | ||
16306 | - return -1; | ||
16307 | - } | ||
16308 | - return 0; | ||
16309 | -} | ||
16310 | --- a/intl/printf-args.h | ||
16311 | +++ /dev/null | ||
16312 | @@ -1,155 +0,0 @@ | ||
16313 | -/* Decomposed printf argument list. | ||
16314 | - Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc. | ||
16315 | - | ||
16316 | - This program is free software; you can redistribute it and/or modify it | ||
16317 | - under the terms of the GNU Library General Public License as published | ||
16318 | - by the Free Software Foundation; either version 2, or (at your option) | ||
16319 | - any later version. | ||
16320 | - | ||
16321 | - This program is distributed in the hope that it will be useful, | ||
16322 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16323 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16324 | - Library General Public License for more details. | ||
16325 | - | ||
16326 | - You should have received a copy of the GNU Library General Public | ||
16327 | - License along with this program; if not, write to the Free Software | ||
16328 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
16329 | - USA. */ | ||
16330 | - | ||
16331 | -#ifndef _PRINTF_ARGS_H | ||
16332 | -#define _PRINTF_ARGS_H | ||
16333 | - | ||
16334 | -/* This file can be parametrized with the following macros: | ||
16335 | - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. | ||
16336 | - PRINTF_FETCHARGS Name of the function to be declared. | ||
16337 | - STATIC Set to 'static' to declare the function static. */ | ||
16338 | - | ||
16339 | -/* Default parameters. */ | ||
16340 | -#ifndef PRINTF_FETCHARGS | ||
16341 | -# define PRINTF_FETCHARGS printf_fetchargs | ||
16342 | -#endif | ||
16343 | - | ||
16344 | -/* Get size_t. */ | ||
16345 | -#include <stddef.h> | ||
16346 | - | ||
16347 | -/* Get wchar_t. */ | ||
16348 | -#if HAVE_WCHAR_T | ||
16349 | -# include <stddef.h> | ||
16350 | -#endif | ||
16351 | - | ||
16352 | -/* Get wint_t. */ | ||
16353 | -#if HAVE_WINT_T | ||
16354 | -# include <wchar.h> | ||
16355 | -#endif | ||
16356 | - | ||
16357 | -/* Get va_list. */ | ||
16358 | -#include <stdarg.h> | ||
16359 | - | ||
16360 | - | ||
16361 | -/* Argument types */ | ||
16362 | -typedef enum | ||
16363 | -{ | ||
16364 | - TYPE_NONE, | ||
16365 | - TYPE_SCHAR, | ||
16366 | - TYPE_UCHAR, | ||
16367 | - TYPE_SHORT, | ||
16368 | - TYPE_USHORT, | ||
16369 | - TYPE_INT, | ||
16370 | - TYPE_UINT, | ||
16371 | - TYPE_LONGINT, | ||
16372 | - TYPE_ULONGINT, | ||
16373 | -#if HAVE_LONG_LONG_INT | ||
16374 | - TYPE_LONGLONGINT, | ||
16375 | - TYPE_ULONGLONGINT, | ||
16376 | -#endif | ||
16377 | - TYPE_DOUBLE, | ||
16378 | - TYPE_LONGDOUBLE, | ||
16379 | - TYPE_CHAR, | ||
16380 | -#if HAVE_WINT_T | ||
16381 | - TYPE_WIDE_CHAR, | ||
16382 | -#endif | ||
16383 | - TYPE_STRING, | ||
16384 | -#if HAVE_WCHAR_T | ||
16385 | - TYPE_WIDE_STRING, | ||
16386 | -#endif | ||
16387 | - TYPE_POINTER, | ||
16388 | - TYPE_COUNT_SCHAR_POINTER, | ||
16389 | - TYPE_COUNT_SHORT_POINTER, | ||
16390 | - TYPE_COUNT_INT_POINTER, | ||
16391 | - TYPE_COUNT_LONGINT_POINTER | ||
16392 | -#if HAVE_LONG_LONG_INT | ||
16393 | -, TYPE_COUNT_LONGLONGINT_POINTER | ||
16394 | -#endif | ||
16395 | -#if ENABLE_UNISTDIO | ||
16396 | - /* The unistdio extensions. */ | ||
16397 | -, TYPE_U8_STRING | ||
16398 | -, TYPE_U16_STRING | ||
16399 | -, TYPE_U32_STRING | ||
16400 | -#endif | ||
16401 | -} arg_type; | ||
16402 | - | ||
16403 | -/* Polymorphic argument */ | ||
16404 | -typedef struct | ||
16405 | -{ | ||
16406 | - arg_type type; | ||
16407 | - union | ||
16408 | - { | ||
16409 | - signed char a_schar; | ||
16410 | - unsigned char a_uchar; | ||
16411 | - short a_short; | ||
16412 | - unsigned short a_ushort; | ||
16413 | - int a_int; | ||
16414 | - unsigned int a_uint; | ||
16415 | - long int a_longint; | ||
16416 | - unsigned long int a_ulongint; | ||
16417 | -#if HAVE_LONG_LONG_INT | ||
16418 | - long long int a_longlongint; | ||
16419 | - unsigned long long int a_ulonglongint; | ||
16420 | -#endif | ||
16421 | - float a_float; | ||
16422 | - double a_double; | ||
16423 | - long double a_longdouble; | ||
16424 | - int a_char; | ||
16425 | -#if HAVE_WINT_T | ||
16426 | - wint_t a_wide_char; | ||
16427 | -#endif | ||
16428 | - const char* a_string; | ||
16429 | -#if HAVE_WCHAR_T | ||
16430 | - const wchar_t* a_wide_string; | ||
16431 | -#endif | ||
16432 | - void* a_pointer; | ||
16433 | - signed char * a_count_schar_pointer; | ||
16434 | - short * a_count_short_pointer; | ||
16435 | - int * a_count_int_pointer; | ||
16436 | - long int * a_count_longint_pointer; | ||
16437 | -#if HAVE_LONG_LONG_INT | ||
16438 | - long long int * a_count_longlongint_pointer; | ||
16439 | -#endif | ||
16440 | -#if ENABLE_UNISTDIO | ||
16441 | - /* The unistdio extensions. */ | ||
16442 | - const uint8_t * a_u8_string; | ||
16443 | - const uint16_t * a_u16_string; | ||
16444 | - const uint32_t * a_u32_string; | ||
16445 | -#endif | ||
16446 | - } | ||
16447 | - a; | ||
16448 | -} | ||
16449 | -argument; | ||
16450 | - | ||
16451 | -typedef struct | ||
16452 | -{ | ||
16453 | - size_t count; | ||
16454 | - argument *arg; | ||
16455 | -} | ||
16456 | -arguments; | ||
16457 | - | ||
16458 | - | ||
16459 | -/* Fetch the arguments, putting them into a. */ | ||
16460 | -#ifdef STATIC | ||
16461 | -STATIC | ||
16462 | -#else | ||
16463 | -extern | ||
16464 | -#endif | ||
16465 | -int PRINTF_FETCHARGS (va_list args, arguments *a); | ||
16466 | - | ||
16467 | -#endif /* _PRINTF_ARGS_H */ | ||
16468 | --- a/intl/printf-parse.c | ||
16469 | +++ /dev/null | ||
16470 | @@ -1,590 +0,0 @@ | ||
16471 | -/* Formatted output to strings. | ||
16472 | - Copyright (C) 1999-2000, 2002-2003, 2006-2007 Free Software Foundation, Inc. | ||
16473 | - | ||
16474 | - This program is free software; you can redistribute it and/or modify it | ||
16475 | - under the terms of the GNU Library General Public License as published | ||
16476 | - by the Free Software Foundation; either version 2, or (at your option) | ||
16477 | - any later version. | ||
16478 | - | ||
16479 | - This program is distributed in the hope that it will be useful, | ||
16480 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16481 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16482 | - Library General Public License for more details. | ||
16483 | - | ||
16484 | - You should have received a copy of the GNU Library General Public | ||
16485 | - License along with this program; if not, write to the Free Software | ||
16486 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
16487 | - USA. */ | ||
16488 | - | ||
16489 | -/* This file can be parametrized with the following macros: | ||
16490 | - CHAR_T The element type of the format string. | ||
16491 | - CHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters | ||
16492 | - in the format string are ASCII. | ||
16493 | - DIRECTIVE Structure denoting a format directive. | ||
16494 | - Depends on CHAR_T. | ||
16495 | - DIRECTIVES Structure denoting the set of format directives of a | ||
16496 | - format string. Depends on CHAR_T. | ||
16497 | - PRINTF_PARSE Function that parses a format string. | ||
16498 | - Depends on CHAR_T. | ||
16499 | - STATIC Set to 'static' to declare the function static. | ||
16500 | - ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. */ | ||
16501 | - | ||
16502 | -#ifndef PRINTF_PARSE | ||
16503 | -# include <config.h> | ||
16504 | -#endif | ||
16505 | - | ||
16506 | -/* Specification. */ | ||
16507 | -#ifndef PRINTF_PARSE | ||
16508 | -# include "printf-parse.h" | ||
16509 | -#endif | ||
16510 | - | ||
16511 | -/* Default parameters. */ | ||
16512 | -#ifndef PRINTF_PARSE | ||
16513 | -# define PRINTF_PARSE printf_parse | ||
16514 | -# define CHAR_T char | ||
16515 | -# define DIRECTIVE char_directive | ||
16516 | -# define DIRECTIVES char_directives | ||
16517 | -#endif | ||
16518 | - | ||
16519 | -/* Get size_t, NULL. */ | ||
16520 | -#include <stddef.h> | ||
16521 | - | ||
16522 | -/* Get intmax_t. */ | ||
16523 | -#if defined IN_LIBINTL || defined IN_LIBASPRINTF | ||
16524 | -# if HAVE_STDINT_H_WITH_UINTMAX | ||
16525 | -# include <stdint.h> | ||
16526 | -# endif | ||
16527 | -# if HAVE_INTTYPES_H_WITH_UINTMAX | ||
16528 | -# include <inttypes.h> | ||
16529 | -# endif | ||
16530 | -#else | ||
16531 | -# include <stdint.h> | ||
16532 | -#endif | ||
16533 | - | ||
16534 | -/* malloc(), realloc(), free(). */ | ||
16535 | -#include <stdlib.h> | ||
16536 | - | ||
16537 | -/* errno. */ | ||
16538 | -#include <errno.h> | ||
16539 | - | ||
16540 | -/* Checked size_t computations. */ | ||
16541 | -#include "xsize.h" | ||
16542 | - | ||
16543 | -#if CHAR_T_ONLY_ASCII | ||
16544 | -/* c_isascii(). */ | ||
16545 | -# include "c-ctype.h" | ||
16546 | -#endif | ||
16547 | - | ||
16548 | -#ifdef STATIC | ||
16549 | -STATIC | ||
16550 | -#endif | ||
16551 | -int | ||
16552 | -PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) | ||
16553 | -{ | ||
16554 | - const CHAR_T *cp = format; /* pointer into format */ | ||
16555 | - size_t arg_posn = 0; /* number of regular arguments consumed */ | ||
16556 | - size_t d_allocated; /* allocated elements of d->dir */ | ||
16557 | - size_t a_allocated; /* allocated elements of a->arg */ | ||
16558 | - size_t max_width_length = 0; | ||
16559 | - size_t max_precision_length = 0; | ||
16560 | - | ||
16561 | - d->count = 0; | ||
16562 | - d_allocated = 1; | ||
16563 | - d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE)); | ||
16564 | - if (d->dir == NULL) | ||
16565 | - /* Out of memory. */ | ||
16566 | - goto out_of_memory_1; | ||
16567 | - | ||
16568 | - a->count = 0; | ||
16569 | - a_allocated = 0; | ||
16570 | - a->arg = NULL; | ||
16571 | - | ||
16572 | -#define REGISTER_ARG(_index_,_type_) \ | ||
16573 | - { \ | ||
16574 | - size_t n = (_index_); \ | ||
16575 | - if (n >= a_allocated) \ | ||
16576 | - { \ | ||
16577 | - size_t memory_size; \ | ||
16578 | - argument *memory; \ | ||
16579 | - \ | ||
16580 | - a_allocated = xtimes (a_allocated, 2); \ | ||
16581 | - if (a_allocated <= n) \ | ||
16582 | - a_allocated = xsum (n, 1); \ | ||
16583 | - memory_size = xtimes (a_allocated, sizeof (argument)); \ | ||
16584 | - if (size_overflow_p (memory_size)) \ | ||
16585 | - /* Overflow, would lead to out of memory. */ \ | ||
16586 | - goto out_of_memory; \ | ||
16587 | - memory = (argument *) (a->arg \ | ||
16588 | - ? realloc (a->arg, memory_size) \ | ||
16589 | - : malloc (memory_size)); \ | ||
16590 | - if (memory == NULL) \ | ||
16591 | - /* Out of memory. */ \ | ||
16592 | - goto out_of_memory; \ | ||
16593 | - a->arg = memory; \ | ||
16594 | - } \ | ||
16595 | - while (a->count <= n) \ | ||
16596 | - a->arg[a->count++].type = TYPE_NONE; \ | ||
16597 | - if (a->arg[n].type == TYPE_NONE) \ | ||
16598 | - a->arg[n].type = (_type_); \ | ||
16599 | - else if (a->arg[n].type != (_type_)) \ | ||
16600 | - /* Ambiguous type for positional argument. */ \ | ||
16601 | - goto error; \ | ||
16602 | - } | ||
16603 | - | ||
16604 | - while (*cp != '\0') | ||
16605 | - { | ||
16606 | - CHAR_T c = *cp++; | ||
16607 | - if (c == '%') | ||
16608 | - { | ||
16609 | - size_t arg_index = ARG_NONE; | ||
16610 | - DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ | ||
16611 | - | ||
16612 | - /* Initialize the next directive. */ | ||
16613 | - dp->dir_start = cp - 1; | ||
16614 | - dp->flags = 0; | ||
16615 | - dp->width_start = NULL; | ||
16616 | - dp->width_end = NULL; | ||
16617 | - dp->width_arg_index = ARG_NONE; | ||
16618 | - dp->precision_start = NULL; | ||
16619 | - dp->precision_end = NULL; | ||
16620 | - dp->precision_arg_index = ARG_NONE; | ||
16621 | - dp->arg_index = ARG_NONE; | ||
16622 | - | ||
16623 | - /* Test for positional argument. */ | ||
16624 | - if (*cp >= '0' && *cp <= '9') | ||
16625 | - { | ||
16626 | - const CHAR_T *np; | ||
16627 | - | ||
16628 | - for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
16629 | - ; | ||
16630 | - if (*np == '$') | ||
16631 | - { | ||
16632 | - size_t n = 0; | ||
16633 | - | ||
16634 | - for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
16635 | - n = xsum (xtimes (n, 10), *np - '0'); | ||
16636 | - if (n == 0) | ||
16637 | - /* Positional argument 0. */ | ||
16638 | - goto error; | ||
16639 | - if (size_overflow_p (n)) | ||
16640 | - /* n too large, would lead to out of memory later. */ | ||
16641 | - goto error; | ||
16642 | - arg_index = n - 1; | ||
16643 | - cp = np + 1; | ||
16644 | - } | ||
16645 | - } | ||
16646 | - | ||
16647 | - /* Read the flags. */ | ||
16648 | - for (;;) | ||
16649 | - { | ||
16650 | - if (*cp == '\'') | ||
16651 | - { | ||
16652 | - dp->flags |= FLAG_GROUP; | ||
16653 | - cp++; | ||
16654 | - } | ||
16655 | - else if (*cp == '-') | ||
16656 | - { | ||
16657 | - dp->flags |= FLAG_LEFT; | ||
16658 | - cp++; | ||
16659 | - } | ||
16660 | - else if (*cp == '+') | ||
16661 | - { | ||
16662 | - dp->flags |= FLAG_SHOWSIGN; | ||
16663 | - cp++; | ||
16664 | - } | ||
16665 | - else if (*cp == ' ') | ||
16666 | - { | ||
16667 | - dp->flags |= FLAG_SPACE; | ||
16668 | - cp++; | ||
16669 | - } | ||
16670 | - else if (*cp == '#') | ||
16671 | - { | ||
16672 | - dp->flags |= FLAG_ALT; | ||
16673 | - cp++; | ||
16674 | - } | ||
16675 | - else if (*cp == '0') | ||
16676 | - { | ||
16677 | - dp->flags |= FLAG_ZERO; | ||
16678 | - cp++; | ||
16679 | - } | ||
16680 | - else | ||
16681 | - break; | ||
16682 | - } | ||
16683 | - | ||
16684 | - /* Parse the field width. */ | ||
16685 | - if (*cp == '*') | ||
16686 | - { | ||
16687 | - dp->width_start = cp; | ||
16688 | - cp++; | ||
16689 | - dp->width_end = cp; | ||
16690 | - if (max_width_length < 1) | ||
16691 | - max_width_length = 1; | ||
16692 | - | ||
16693 | - /* Test for positional argument. */ | ||
16694 | - if (*cp >= '0' && *cp <= '9') | ||
16695 | - { | ||
16696 | - const CHAR_T *np; | ||
16697 | - | ||
16698 | - for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
16699 | - ; | ||
16700 | - if (*np == '$') | ||
16701 | - { | ||
16702 | - size_t n = 0; | ||
16703 | - | ||
16704 | - for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
16705 | - n = xsum (xtimes (n, 10), *np - '0'); | ||
16706 | - if (n == 0) | ||
16707 | - /* Positional argument 0. */ | ||
16708 | - goto error; | ||
16709 | - if (size_overflow_p (n)) | ||
16710 | - /* n too large, would lead to out of memory later. */ | ||
16711 | - goto error; | ||
16712 | - dp->width_arg_index = n - 1; | ||
16713 | - cp = np + 1; | ||
16714 | - } | ||
16715 | - } | ||
16716 | - if (dp->width_arg_index == ARG_NONE) | ||
16717 | - { | ||
16718 | - dp->width_arg_index = arg_posn++; | ||
16719 | - if (dp->width_arg_index == ARG_NONE) | ||
16720 | - /* arg_posn wrapped around. */ | ||
16721 | - goto error; | ||
16722 | - } | ||
16723 | - REGISTER_ARG (dp->width_arg_index, TYPE_INT); | ||
16724 | - } | ||
16725 | - else if (*cp >= '0' && *cp <= '9') | ||
16726 | - { | ||
16727 | - size_t width_length; | ||
16728 | - | ||
16729 | - dp->width_start = cp; | ||
16730 | - for (; *cp >= '0' && *cp <= '9'; cp++) | ||
16731 | - ; | ||
16732 | - dp->width_end = cp; | ||
16733 | - width_length = dp->width_end - dp->width_start; | ||
16734 | - if (max_width_length < width_length) | ||
16735 | - max_width_length = width_length; | ||
16736 | - } | ||
16737 | - | ||
16738 | - /* Parse the precision. */ | ||
16739 | - if (*cp == '.') | ||
16740 | - { | ||
16741 | - cp++; | ||
16742 | - if (*cp == '*') | ||
16743 | - { | ||
16744 | - dp->precision_start = cp - 1; | ||
16745 | - cp++; | ||
16746 | - dp->precision_end = cp; | ||
16747 | - if (max_precision_length < 2) | ||
16748 | - max_precision_length = 2; | ||
16749 | - | ||
16750 | - /* Test for positional argument. */ | ||
16751 | - if (*cp >= '0' && *cp <= '9') | ||
16752 | - { | ||
16753 | - const CHAR_T *np; | ||
16754 | - | ||
16755 | - for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
16756 | - ; | ||
16757 | - if (*np == '$') | ||
16758 | - { | ||
16759 | - size_t n = 0; | ||
16760 | - | ||
16761 | - for (np = cp; *np >= '0' && *np <= '9'; np++) | ||
16762 | - n = xsum (xtimes (n, 10), *np - '0'); | ||
16763 | - if (n == 0) | ||
16764 | - /* Positional argument 0. */ | ||
16765 | - goto error; | ||
16766 | - if (size_overflow_p (n)) | ||
16767 | - /* n too large, would lead to out of memory | ||
16768 | - later. */ | ||
16769 | - goto error; | ||
16770 | - dp->precision_arg_index = n - 1; | ||
16771 | - cp = np + 1; | ||
16772 | - } | ||
16773 | - } | ||
16774 | - if (dp->precision_arg_index == ARG_NONE) | ||
16775 | - { | ||
16776 | - dp->precision_arg_index = arg_posn++; | ||
16777 | - if (dp->precision_arg_index == ARG_NONE) | ||
16778 | - /* arg_posn wrapped around. */ | ||
16779 | - goto error; | ||
16780 | - } | ||
16781 | - REGISTER_ARG (dp->precision_arg_index, TYPE_INT); | ||
16782 | - } | ||
16783 | - else | ||
16784 | - { | ||
16785 | - size_t precision_length; | ||
16786 | - | ||
16787 | - dp->precision_start = cp - 1; | ||
16788 | - for (; *cp >= '0' && *cp <= '9'; cp++) | ||
16789 | - ; | ||
16790 | - dp->precision_end = cp; | ||
16791 | - precision_length = dp->precision_end - dp->precision_start; | ||
16792 | - if (max_precision_length < precision_length) | ||
16793 | - max_precision_length = precision_length; | ||
16794 | - } | ||
16795 | - } | ||
16796 | - | ||
16797 | - { | ||
16798 | - arg_type type; | ||
16799 | - | ||
16800 | - /* Parse argument type/size specifiers. */ | ||
16801 | - { | ||
16802 | - int flags = 0; | ||
16803 | - | ||
16804 | - for (;;) | ||
16805 | - { | ||
16806 | - if (*cp == 'h') | ||
16807 | - { | ||
16808 | - flags |= (1 << (flags & 1)); | ||
16809 | - cp++; | ||
16810 | - } | ||
16811 | - else if (*cp == 'L') | ||
16812 | - { | ||
16813 | - flags |= 4; | ||
16814 | - cp++; | ||
16815 | - } | ||
16816 | - else if (*cp == 'l') | ||
16817 | - { | ||
16818 | - flags += 8; | ||
16819 | - cp++; | ||
16820 | - } | ||
16821 | - else if (*cp == 'j') | ||
16822 | - { | ||
16823 | - if (sizeof (intmax_t) > sizeof (long)) | ||
16824 | - { | ||
16825 | - /* intmax_t = long long */ | ||
16826 | - flags += 16; | ||
16827 | - } | ||
16828 | - else if (sizeof (intmax_t) > sizeof (int)) | ||
16829 | - { | ||
16830 | - /* intmax_t = long */ | ||
16831 | - flags += 8; | ||
16832 | - } | ||
16833 | - cp++; | ||
16834 | - } | ||
16835 | - else if (*cp == 'z' || *cp == 'Z') | ||
16836 | - { | ||
16837 | - /* 'z' is standardized in ISO C 99, but glibc uses 'Z' | ||
16838 | - because the warning facility in gcc-2.95.2 understands | ||
16839 | - only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ | ||
16840 | - if (sizeof (size_t) > sizeof (long)) | ||
16841 | - { | ||
16842 | - /* size_t = long long */ | ||
16843 | - flags += 16; | ||
16844 | - } | ||
16845 | - else if (sizeof (size_t) > sizeof (int)) | ||
16846 | - { | ||
16847 | - /* size_t = long */ | ||
16848 | - flags += 8; | ||
16849 | - } | ||
16850 | - cp++; | ||
16851 | - } | ||
16852 | - else if (*cp == 't') | ||
16853 | - { | ||
16854 | - if (sizeof (ptrdiff_t) > sizeof (long)) | ||
16855 | - { | ||
16856 | - /* ptrdiff_t = long long */ | ||
16857 | - flags += 16; | ||
16858 | - } | ||
16859 | - else if (sizeof (ptrdiff_t) > sizeof (int)) | ||
16860 | - { | ||
16861 | - /* ptrdiff_t = long */ | ||
16862 | - flags += 8; | ||
16863 | - } | ||
16864 | - cp++; | ||
16865 | - } | ||
16866 | - else | ||
16867 | - break; | ||
16868 | - } | ||
16869 | - | ||
16870 | - /* Read the conversion character. */ | ||
16871 | - c = *cp++; | ||
16872 | - switch (c) | ||
16873 | - { | ||
16874 | - case 'd': case 'i': | ||
16875 | -#if HAVE_LONG_LONG_INT | ||
16876 | - /* If 'long long' exists and is larger than 'long': */ | ||
16877 | - if (flags >= 16 || (flags & 4)) | ||
16878 | - type = TYPE_LONGLONGINT; | ||
16879 | - else | ||
16880 | -#endif | ||
16881 | - /* If 'long long' exists and is the same as 'long', we parse | ||
16882 | - "lld" into TYPE_LONGINT. */ | ||
16883 | - if (flags >= 8) | ||
16884 | - type = TYPE_LONGINT; | ||
16885 | - else if (flags & 2) | ||
16886 | - type = TYPE_SCHAR; | ||
16887 | - else if (flags & 1) | ||
16888 | - type = TYPE_SHORT; | ||
16889 | - else | ||
16890 | - type = TYPE_INT; | ||
16891 | - break; | ||
16892 | - case 'o': case 'u': case 'x': case 'X': | ||
16893 | -#if HAVE_LONG_LONG_INT | ||
16894 | - /* If 'long long' exists and is larger than 'long': */ | ||
16895 | - if (flags >= 16 || (flags & 4)) | ||
16896 | - type = TYPE_ULONGLONGINT; | ||
16897 | - else | ||
16898 | -#endif | ||
16899 | - /* If 'unsigned long long' exists and is the same as | ||
16900 | - 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ | ||
16901 | - if (flags >= 8) | ||
16902 | - type = TYPE_ULONGINT; | ||
16903 | - else if (flags & 2) | ||
16904 | - type = TYPE_UCHAR; | ||
16905 | - else if (flags & 1) | ||
16906 | - type = TYPE_USHORT; | ||
16907 | - else | ||
16908 | - type = TYPE_UINT; | ||
16909 | - break; | ||
16910 | - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': | ||
16911 | - case 'a': case 'A': | ||
16912 | - if (flags >= 16 || (flags & 4)) | ||
16913 | - type = TYPE_LONGDOUBLE; | ||
16914 | - else | ||
16915 | - type = TYPE_DOUBLE; | ||
16916 | - break; | ||
16917 | - case 'c': | ||
16918 | - if (flags >= 8) | ||
16919 | -#if HAVE_WINT_T | ||
16920 | - type = TYPE_WIDE_CHAR; | ||
16921 | -#else | ||
16922 | - goto error; | ||
16923 | -#endif | ||
16924 | - else | ||
16925 | - type = TYPE_CHAR; | ||
16926 | - break; | ||
16927 | -#if HAVE_WINT_T | ||
16928 | - case 'C': | ||
16929 | - type = TYPE_WIDE_CHAR; | ||
16930 | - c = 'c'; | ||
16931 | - break; | ||
16932 | -#endif | ||
16933 | - case 's': | ||
16934 | - if (flags >= 8) | ||
16935 | -#if HAVE_WCHAR_T | ||
16936 | - type = TYPE_WIDE_STRING; | ||
16937 | -#else | ||
16938 | - goto error; | ||
16939 | -#endif | ||
16940 | - else | ||
16941 | - type = TYPE_STRING; | ||
16942 | - break; | ||
16943 | -#if HAVE_WCHAR_T | ||
16944 | - case 'S': | ||
16945 | - type = TYPE_WIDE_STRING; | ||
16946 | - c = 's'; | ||
16947 | - break; | ||
16948 | -#endif | ||
16949 | - case 'p': | ||
16950 | - type = TYPE_POINTER; | ||
16951 | - break; | ||
16952 | - case 'n': | ||
16953 | -#if HAVE_LONG_LONG_INT | ||
16954 | - /* If 'long long' exists and is larger than 'long': */ | ||
16955 | - if (flags >= 16 || (flags & 4)) | ||
16956 | - type = TYPE_COUNT_LONGLONGINT_POINTER; | ||
16957 | - else | ||
16958 | -#endif | ||
16959 | - /* If 'long long' exists and is the same as 'long', we parse | ||
16960 | - "lln" into TYPE_COUNT_LONGINT_POINTER. */ | ||
16961 | - if (flags >= 8) | ||
16962 | - type = TYPE_COUNT_LONGINT_POINTER; | ||
16963 | - else if (flags & 2) | ||
16964 | - type = TYPE_COUNT_SCHAR_POINTER; | ||
16965 | - else if (flags & 1) | ||
16966 | - type = TYPE_COUNT_SHORT_POINTER; | ||
16967 | - else | ||
16968 | - type = TYPE_COUNT_INT_POINTER; | ||
16969 | - break; | ||
16970 | -#if ENABLE_UNISTDIO | ||
16971 | - /* The unistdio extensions. */ | ||
16972 | - case 'U': | ||
16973 | - if (flags >= 16) | ||
16974 | - type = TYPE_U32_STRING; | ||
16975 | - else if (flags >= 8) | ||
16976 | - type = TYPE_U16_STRING; | ||
16977 | - else | ||
16978 | - type = TYPE_U8_STRING; | ||
16979 | - break; | ||
16980 | -#endif | ||
16981 | - case '%': | ||
16982 | - type = TYPE_NONE; | ||
16983 | - break; | ||
16984 | - default: | ||
16985 | - /* Unknown conversion character. */ | ||
16986 | - goto error; | ||
16987 | - } | ||
16988 | - } | ||
16989 | - | ||
16990 | - if (type != TYPE_NONE) | ||
16991 | - { | ||
16992 | - dp->arg_index = arg_index; | ||
16993 | - if (dp->arg_index == ARG_NONE) | ||
16994 | - { | ||
16995 | - dp->arg_index = arg_posn++; | ||
16996 | - if (dp->arg_index == ARG_NONE) | ||
16997 | - /* arg_posn wrapped around. */ | ||
16998 | - goto error; | ||
16999 | - } | ||
17000 | - REGISTER_ARG (dp->arg_index, type); | ||
17001 | - } | ||
17002 | - dp->conversion = c; | ||
17003 | - dp->dir_end = cp; | ||
17004 | - } | ||
17005 | - | ||
17006 | - d->count++; | ||
17007 | - if (d->count >= d_allocated) | ||
17008 | - { | ||
17009 | - size_t memory_size; | ||
17010 | - DIRECTIVE *memory; | ||
17011 | - | ||
17012 | - d_allocated = xtimes (d_allocated, 2); | ||
17013 | - memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); | ||
17014 | - if (size_overflow_p (memory_size)) | ||
17015 | - /* Overflow, would lead to out of memory. */ | ||
17016 | - goto out_of_memory; | ||
17017 | - memory = (DIRECTIVE *) realloc (d->dir, memory_size); | ||
17018 | - if (memory == NULL) | ||
17019 | - /* Out of memory. */ | ||
17020 | - goto out_of_memory; | ||
17021 | - d->dir = memory; | ||
17022 | - } | ||
17023 | - } | ||
17024 | -#if CHAR_T_ONLY_ASCII | ||
17025 | - else if (!c_isascii (c)) | ||
17026 | - { | ||
17027 | - /* Non-ASCII character. Not supported. */ | ||
17028 | - goto error; | ||
17029 | - } | ||
17030 | -#endif | ||
17031 | - } | ||
17032 | - d->dir[d->count].dir_start = cp; | ||
17033 | - | ||
17034 | - d->max_width_length = max_width_length; | ||
17035 | - d->max_precision_length = max_precision_length; | ||
17036 | - return 0; | ||
17037 | - | ||
17038 | -error: | ||
17039 | - if (a->arg) | ||
17040 | - free (a->arg); | ||
17041 | - if (d->dir) | ||
17042 | - free (d->dir); | ||
17043 | - errno = EINVAL; | ||
17044 | - return -1; | ||
17045 | - | ||
17046 | -out_of_memory: | ||
17047 | - if (a->arg) | ||
17048 | - free (a->arg); | ||
17049 | - if (d->dir) | ||
17050 | - free (d->dir); | ||
17051 | -out_of_memory_1: | ||
17052 | - errno = ENOMEM; | ||
17053 | - return -1; | ||
17054 | -} | ||
17055 | - | ||
17056 | -#undef PRINTF_PARSE | ||
17057 | -#undef DIRECTIVES | ||
17058 | -#undef DIRECTIVE | ||
17059 | -#undef CHAR_T_ONLY_ASCII | ||
17060 | -#undef CHAR_T | ||
17061 | --- a/intl/printf-parse.h | ||
17062 | +++ /dev/null | ||
17063 | @@ -1,75 +0,0 @@ | ||
17064 | -/* Parse printf format string. | ||
17065 | - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. | ||
17066 | - | ||
17067 | - This program is free software; you can redistribute it and/or modify it | ||
17068 | - under the terms of the GNU Library General Public License as published | ||
17069 | - by the Free Software Foundation; either version 2, or (at your option) | ||
17070 | - any later version. | ||
17071 | - | ||
17072 | - This program is distributed in the hope that it will be useful, | ||
17073 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17074 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17075 | - Library General Public License for more details. | ||
17076 | - | ||
17077 | - You should have received a copy of the GNU Library General Public | ||
17078 | - License along with this program; if not, write to the Free Software | ||
17079 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
17080 | - USA. */ | ||
17081 | - | ||
17082 | -#ifndef _PRINTF_PARSE_H | ||
17083 | -#define _PRINTF_PARSE_H | ||
17084 | - | ||
17085 | -#include "printf-args.h" | ||
17086 | - | ||
17087 | - | ||
17088 | -/* Flags */ | ||
17089 | -#define FLAG_GROUP 1 /* ' flag */ | ||
17090 | -#define FLAG_LEFT 2 /* - flag */ | ||
17091 | -#define FLAG_SHOWSIGN 4 /* + flag */ | ||
17092 | -#define FLAG_SPACE 8 /* space flag */ | ||
17093 | -#define FLAG_ALT 16 /* # flag */ | ||
17094 | -#define FLAG_ZERO 32 | ||
17095 | - | ||
17096 | -/* arg_index value indicating that no argument is consumed. */ | ||
17097 | -#define ARG_NONE (~(size_t)0) | ||
17098 | - | ||
17099 | -/* A parsed directive. */ | ||
17100 | -typedef struct | ||
17101 | -{ | ||
17102 | - const char* dir_start; | ||
17103 | - const char* dir_end; | ||
17104 | - int flags; | ||
17105 | - const char* width_start; | ||
17106 | - const char* width_end; | ||
17107 | - size_t width_arg_index; | ||
17108 | - const char* precision_start; | ||
17109 | - const char* precision_end; | ||
17110 | - size_t precision_arg_index; | ||
17111 | - char conversion; /* d i o u x X f e E g G c s p n U % but not C S */ | ||
17112 | - size_t arg_index; | ||
17113 | -} | ||
17114 | -char_directive; | ||
17115 | - | ||
17116 | -/* A parsed format string. */ | ||
17117 | -typedef struct | ||
17118 | -{ | ||
17119 | - size_t count; | ||
17120 | - char_directive *dir; | ||
17121 | - size_t max_width_length; | ||
17122 | - size_t max_precision_length; | ||
17123 | -} | ||
17124 | -char_directives; | ||
17125 | - | ||
17126 | - | ||
17127 | -/* Parses the format string. Fills in the number N of directives, and fills | ||
17128 | - in directives[0], ..., directives[N-1], and sets directives[N].dir_start | ||
17129 | - to the end of the format string. Also fills in the arg_type fields of the | ||
17130 | - arguments and the needed count of arguments. */ | ||
17131 | -#ifdef STATIC | ||
17132 | -STATIC | ||
17133 | -#else | ||
17134 | -extern | ||
17135 | -#endif | ||
17136 | -int printf_parse (const char *format, char_directives *d, arguments *a); | ||
17137 | - | ||
17138 | -#endif /* _PRINTF_PARSE_H */ | ||
17139 | --- a/intl/printf.c | ||
17140 | +++ /dev/null | ||
17141 | @@ -1,427 +0,0 @@ | ||
17142 | -/* Formatted output to strings, using POSIX/XSI format strings with positions. | ||
17143 | - Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. | ||
17144 | - Written by Bruno Haible <bruno@clisp.org>, 2003. | ||
17145 | - | ||
17146 | - This program is free software; you can redistribute it and/or modify it | ||
17147 | - under the terms of the GNU Library General Public License as published | ||
17148 | - by the Free Software Foundation; either version 2, or (at your option) | ||
17149 | - any later version. | ||
17150 | - | ||
17151 | - This program is distributed in the hope that it will be useful, | ||
17152 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17153 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17154 | - Library General Public License for more details. | ||
17155 | - | ||
17156 | - You should have received a copy of the GNU Library General Public | ||
17157 | - License along with this program; if not, write to the Free Software | ||
17158 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
17159 | - USA. */ | ||
17160 | - | ||
17161 | -#ifdef HAVE_CONFIG_H | ||
17162 | -# include <config.h> | ||
17163 | -#endif | ||
17164 | - | ||
17165 | -#ifdef __GNUC__ | ||
17166 | -# define alloca __builtin_alloca | ||
17167 | -# define HAVE_ALLOCA 1 | ||
17168 | -#else | ||
17169 | -# ifdef _MSC_VER | ||
17170 | -# include <malloc.h> | ||
17171 | -# define alloca _alloca | ||
17172 | -# else | ||
17173 | -# if defined HAVE_ALLOCA_H || defined _LIBC | ||
17174 | -# include <alloca.h> | ||
17175 | -# else | ||
17176 | -# ifdef _AIX | ||
17177 | - #pragma alloca | ||
17178 | -# else | ||
17179 | -# ifndef alloca | ||
17180 | -char *alloca (); | ||
17181 | -# endif | ||
17182 | -# endif | ||
17183 | -# endif | ||
17184 | -# endif | ||
17185 | -#endif | ||
17186 | - | ||
17187 | -#include <stdio.h> | ||
17188 | - | ||
17189 | -#if !HAVE_POSIX_PRINTF | ||
17190 | - | ||
17191 | -#include <errno.h> | ||
17192 | -#include <limits.h> | ||
17193 | -#include <stdlib.h> | ||
17194 | -#include <string.h> | ||
17195 | - | ||
17196 | -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
17197 | -#ifndef EOVERFLOW | ||
17198 | -# define EOVERFLOW E2BIG | ||
17199 | -#endif | ||
17200 | - | ||
17201 | -/* When building a DLL, we must export some functions. Note that because | ||
17202 | - the functions are only defined for binary backward compatibility, we | ||
17203 | - don't need to use __declspec(dllimport) in any case. */ | ||
17204 | -#if defined _MSC_VER && BUILDING_DLL | ||
17205 | -# define DLL_EXPORTED __declspec(dllexport) | ||
17206 | -#else | ||
17207 | -# define DLL_EXPORTED | ||
17208 | -#endif | ||
17209 | - | ||
17210 | -#define STATIC static | ||
17211 | - | ||
17212 | -/* This needs to be consistent with libgnuintl.h.in. */ | ||
17213 | -#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ | ||
17214 | -/* Don't break __attribute__((format(printf,M,N))). | ||
17215 | - This redefinition is only possible because the libc in NetBSD, Cygwin, | ||
17216 | - mingw does not have a function __printf__. */ | ||
17217 | -# define libintl_printf __printf__ | ||
17218 | -#endif | ||
17219 | - | ||
17220 | -/* Define auxiliary functions declared in "printf-args.h". */ | ||
17221 | -#include "printf-args.c" | ||
17222 | - | ||
17223 | -/* Define auxiliary functions declared in "printf-parse.h". */ | ||
17224 | -#include "printf-parse.c" | ||
17225 | - | ||
17226 | -/* Define functions declared in "vasnprintf.h". */ | ||
17227 | -#define vasnprintf libintl_vasnprintf | ||
17228 | -#include "vasnprintf.c" | ||
17229 | -#if 0 /* not needed */ | ||
17230 | -#define asnprintf libintl_asnprintf | ||
17231 | -#include "asnprintf.c" | ||
17232 | -#endif | ||
17233 | - | ||
17234 | -DLL_EXPORTED | ||
17235 | -int | ||
17236 | -libintl_vfprintf (FILE *stream, const char *format, va_list args) | ||
17237 | -{ | ||
17238 | - if (strchr (format, '$') == NULL) | ||
17239 | - return vfprintf (stream, format, args); | ||
17240 | - else | ||
17241 | - { | ||
17242 | - size_t length; | ||
17243 | - char *result = libintl_vasnprintf (NULL, &length, format, args); | ||
17244 | - int retval = -1; | ||
17245 | - if (result != NULL) | ||
17246 | - { | ||
17247 | - size_t written = fwrite (result, 1, length, stream); | ||
17248 | - free (result); | ||
17249 | - if (written == length) | ||
17250 | - { | ||
17251 | - if (length > INT_MAX) | ||
17252 | - errno = EOVERFLOW; | ||
17253 | - else | ||
17254 | - retval = length; | ||
17255 | - } | ||
17256 | - } | ||
17257 | - return retval; | ||
17258 | - } | ||
17259 | -} | ||
17260 | - | ||
17261 | -DLL_EXPORTED | ||
17262 | -int | ||
17263 | -libintl_fprintf (FILE *stream, const char *format, ...) | ||
17264 | -{ | ||
17265 | - va_list args; | ||
17266 | - int retval; | ||
17267 | - | ||
17268 | - va_start (args, format); | ||
17269 | - retval = libintl_vfprintf (stream, format, args); | ||
17270 | - va_end (args); | ||
17271 | - return retval; | ||
17272 | -} | ||
17273 | - | ||
17274 | -DLL_EXPORTED | ||
17275 | -int | ||
17276 | -libintl_vprintf (const char *format, va_list args) | ||
17277 | -{ | ||
17278 | - return libintl_vfprintf (stdout, format, args); | ||
17279 | -} | ||
17280 | - | ||
17281 | -DLL_EXPORTED | ||
17282 | -int | ||
17283 | -libintl_printf (const char *format, ...) | ||
17284 | -{ | ||
17285 | - va_list args; | ||
17286 | - int retval; | ||
17287 | - | ||
17288 | - va_start (args, format); | ||
17289 | - retval = libintl_vprintf (format, args); | ||
17290 | - va_end (args); | ||
17291 | - return retval; | ||
17292 | -} | ||
17293 | - | ||
17294 | -DLL_EXPORTED | ||
17295 | -int | ||
17296 | -libintl_vsprintf (char *resultbuf, const char *format, va_list args) | ||
17297 | -{ | ||
17298 | - if (strchr (format, '$') == NULL) | ||
17299 | - return vsprintf (resultbuf, format, args); | ||
17300 | - else | ||
17301 | - { | ||
17302 | - size_t length = (size_t) ~0 / (4 * sizeof (char)); | ||
17303 | - char *result = libintl_vasnprintf (resultbuf, &length, format, args); | ||
17304 | - if (result != resultbuf) | ||
17305 | - { | ||
17306 | - free (result); | ||
17307 | - return -1; | ||
17308 | - } | ||
17309 | - if (length > INT_MAX) | ||
17310 | - { | ||
17311 | - errno = EOVERFLOW; | ||
17312 | - return -1; | ||
17313 | - } | ||
17314 | - else | ||
17315 | - return length; | ||
17316 | - } | ||
17317 | -} | ||
17318 | - | ||
17319 | -DLL_EXPORTED | ||
17320 | -int | ||
17321 | -libintl_sprintf (char *resultbuf, const char *format, ...) | ||
17322 | -{ | ||
17323 | - va_list args; | ||
17324 | - int retval; | ||
17325 | - | ||
17326 | - va_start (args, format); | ||
17327 | - retval = libintl_vsprintf (resultbuf, format, args); | ||
17328 | - va_end (args); | ||
17329 | - return retval; | ||
17330 | -} | ||
17331 | - | ||
17332 | -#if HAVE_SNPRINTF | ||
17333 | - | ||
17334 | -# if HAVE_DECL__SNPRINTF | ||
17335 | - /* Windows. */ | ||
17336 | -# define system_vsnprintf _vsnprintf | ||
17337 | -# else | ||
17338 | - /* Unix. */ | ||
17339 | -# define system_vsnprintf vsnprintf | ||
17340 | -# endif | ||
17341 | - | ||
17342 | -DLL_EXPORTED | ||
17343 | -int | ||
17344 | -libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args) | ||
17345 | -{ | ||
17346 | - if (strchr (format, '$') == NULL) | ||
17347 | - return system_vsnprintf (resultbuf, length, format, args); | ||
17348 | - else | ||
17349 | - { | ||
17350 | - size_t maxlength = length; | ||
17351 | - char *result = libintl_vasnprintf (resultbuf, &length, format, args); | ||
17352 | - if (result != resultbuf) | ||
17353 | - { | ||
17354 | - if (maxlength > 0) | ||
17355 | - { | ||
17356 | - size_t pruned_length = | ||
17357 | - (length < maxlength ? length : maxlength - 1); | ||
17358 | - memcpy (resultbuf, result, pruned_length); | ||
17359 | - resultbuf[pruned_length] = '\0'; | ||
17360 | - } | ||
17361 | - free (result); | ||
17362 | - } | ||
17363 | - if (length > INT_MAX) | ||
17364 | - { | ||
17365 | - errno = EOVERFLOW; | ||
17366 | - return -1; | ||
17367 | - } | ||
17368 | - else | ||
17369 | - return length; | ||
17370 | - } | ||
17371 | -} | ||
17372 | - | ||
17373 | -DLL_EXPORTED | ||
17374 | -int | ||
17375 | -libintl_snprintf (char *resultbuf, size_t length, const char *format, ...) | ||
17376 | -{ | ||
17377 | - va_list args; | ||
17378 | - int retval; | ||
17379 | - | ||
17380 | - va_start (args, format); | ||
17381 | - retval = libintl_vsnprintf (resultbuf, length, format, args); | ||
17382 | - va_end (args); | ||
17383 | - return retval; | ||
17384 | -} | ||
17385 | - | ||
17386 | -#endif | ||
17387 | - | ||
17388 | -#if HAVE_ASPRINTF | ||
17389 | - | ||
17390 | -DLL_EXPORTED | ||
17391 | -int | ||
17392 | -libintl_vasprintf (char **resultp, const char *format, va_list args) | ||
17393 | -{ | ||
17394 | - size_t length; | ||
17395 | - char *result = libintl_vasnprintf (NULL, &length, format, args); | ||
17396 | - if (result == NULL) | ||
17397 | - return -1; | ||
17398 | - if (length > INT_MAX) | ||
17399 | - { | ||
17400 | - free (result); | ||
17401 | - errno = EOVERFLOW; | ||
17402 | - return -1; | ||
17403 | - } | ||
17404 | - *resultp = result; | ||
17405 | - return length; | ||
17406 | -} | ||
17407 | - | ||
17408 | -DLL_EXPORTED | ||
17409 | -int | ||
17410 | -libintl_asprintf (char **resultp, const char *format, ...) | ||
17411 | -{ | ||
17412 | - va_list args; | ||
17413 | - int retval; | ||
17414 | - | ||
17415 | - va_start (args, format); | ||
17416 | - retval = libintl_vasprintf (resultp, format, args); | ||
17417 | - va_end (args); | ||
17418 | - return retval; | ||
17419 | -} | ||
17420 | - | ||
17421 | -#endif | ||
17422 | - | ||
17423 | -#if HAVE_FWPRINTF | ||
17424 | - | ||
17425 | -#include <wchar.h> | ||
17426 | - | ||
17427 | -#define WIDE_CHAR_VERSION 1 | ||
17428 | - | ||
17429 | -#include "wprintf-parse.h" | ||
17430 | -/* Define auxiliary functions declared in "wprintf-parse.h". */ | ||
17431 | -#define CHAR_T wchar_t | ||
17432 | -#define DIRECTIVE wchar_t_directive | ||
17433 | -#define DIRECTIVES wchar_t_directives | ||
17434 | -#define PRINTF_PARSE wprintf_parse | ||
17435 | -#include "printf-parse.c" | ||
17436 | - | ||
17437 | -/* Define functions declared in "vasnprintf.h". */ | ||
17438 | -#define vasnwprintf libintl_vasnwprintf | ||
17439 | -#include "vasnprintf.c" | ||
17440 | -#if 0 /* not needed */ | ||
17441 | -#define asnwprintf libintl_asnwprintf | ||
17442 | -#include "asnprintf.c" | ||
17443 | -#endif | ||
17444 | - | ||
17445 | -# if HAVE_DECL__SNWPRINTF | ||
17446 | - /* Windows. */ | ||
17447 | -# define system_vswprintf _vsnwprintf | ||
17448 | -# else | ||
17449 | - /* Unix. */ | ||
17450 | -# define system_vswprintf vswprintf | ||
17451 | -# endif | ||
17452 | - | ||
17453 | -DLL_EXPORTED | ||
17454 | -int | ||
17455 | -libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args) | ||
17456 | -{ | ||
17457 | - if (wcschr (format, '$') == NULL) | ||
17458 | - return vfwprintf (stream, format, args); | ||
17459 | - else | ||
17460 | - { | ||
17461 | - size_t length; | ||
17462 | - wchar_t *result = libintl_vasnwprintf (NULL, &length, format, args); | ||
17463 | - int retval = -1; | ||
17464 | - if (result != NULL) | ||
17465 | - { | ||
17466 | - size_t i; | ||
17467 | - for (i = 0; i < length; i++) | ||
17468 | - if (fputwc (result[i], stream) == WEOF) | ||
17469 | - break; | ||
17470 | - free (result); | ||
17471 | - if (i == length) | ||
17472 | - { | ||
17473 | - if (length > INT_MAX) | ||
17474 | - errno = EOVERFLOW; | ||
17475 | - else | ||
17476 | - retval = length; | ||
17477 | - } | ||
17478 | - } | ||
17479 | - return retval; | ||
17480 | - } | ||
17481 | -} | ||
17482 | - | ||
17483 | -DLL_EXPORTED | ||
17484 | -int | ||
17485 | -libintl_fwprintf (FILE *stream, const wchar_t *format, ...) | ||
17486 | -{ | ||
17487 | - va_list args; | ||
17488 | - int retval; | ||
17489 | - | ||
17490 | - va_start (args, format); | ||
17491 | - retval = libintl_vfwprintf (stream, format, args); | ||
17492 | - va_end (args); | ||
17493 | - return retval; | ||
17494 | -} | ||
17495 | - | ||
17496 | -DLL_EXPORTED | ||
17497 | -int | ||
17498 | -libintl_vwprintf (const wchar_t *format, va_list args) | ||
17499 | -{ | ||
17500 | - return libintl_vfwprintf (stdout, format, args); | ||
17501 | -} | ||
17502 | - | ||
17503 | -DLL_EXPORTED | ||
17504 | -int | ||
17505 | -libintl_wprintf (const wchar_t *format, ...) | ||
17506 | -{ | ||
17507 | - va_list args; | ||
17508 | - int retval; | ||
17509 | - | ||
17510 | - va_start (args, format); | ||
17511 | - retval = libintl_vwprintf (format, args); | ||
17512 | - va_end (args); | ||
17513 | - return retval; | ||
17514 | -} | ||
17515 | - | ||
17516 | -DLL_EXPORTED | ||
17517 | -int | ||
17518 | -libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_list args) | ||
17519 | -{ | ||
17520 | - if (wcschr (format, '$') == NULL) | ||
17521 | - return system_vswprintf (resultbuf, length, format, args); | ||
17522 | - else | ||
17523 | - { | ||
17524 | - size_t maxlength = length; | ||
17525 | - wchar_t *result = libintl_vasnwprintf (resultbuf, &length, format, args); | ||
17526 | - if (result != resultbuf) | ||
17527 | - { | ||
17528 | - if (maxlength > 0) | ||
17529 | - { | ||
17530 | - size_t pruned_length = | ||
17531 | - (length < maxlength ? length : maxlength - 1); | ||
17532 | - memcpy (resultbuf, result, pruned_length * sizeof (wchar_t)); | ||
17533 | - resultbuf[pruned_length] = 0; | ||
17534 | - } | ||
17535 | - free (result); | ||
17536 | - /* Unlike vsnprintf, which has to return the number of character that | ||
17537 | - would have been produced if the resultbuf had been sufficiently | ||
17538 | - large, the vswprintf function has to return a negative value if | ||
17539 | - the resultbuf was not sufficiently large. */ | ||
17540 | - if (length >= maxlength) | ||
17541 | - return -1; | ||
17542 | - } | ||
17543 | - if (length > INT_MAX) | ||
17544 | - { | ||
17545 | - errno = EOVERFLOW; | ||
17546 | - return -1; | ||
17547 | - } | ||
17548 | - else | ||
17549 | - return length; | ||
17550 | - } | ||
17551 | -} | ||
17552 | - | ||
17553 | -DLL_EXPORTED | ||
17554 | -int | ||
17555 | -libintl_swprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, ...) | ||
17556 | -{ | ||
17557 | - va_list args; | ||
17558 | - int retval; | ||
17559 | - | ||
17560 | - va_start (args, format); | ||
17561 | - retval = libintl_vswprintf (resultbuf, length, format, args); | ||
17562 | - va_end (args); | ||
17563 | - return retval; | ||
17564 | -} | ||
17565 | - | ||
17566 | -#endif | ||
17567 | - | ||
17568 | -#endif | ||
17569 | --- a/intl/ref-add.sin | ||
17570 | +++ /dev/null | ||
17571 | @@ -1,31 +0,0 @@ | ||
17572 | -# Add this package to a list of references stored in a text file. | ||
17573 | -# | ||
17574 | -# Copyright (C) 2000 Free Software Foundation, Inc. | ||
17575 | -# | ||
17576 | -# This program is free software; you can redistribute it and/or modify it | ||
17577 | -# under the terms of the GNU Library General Public License as published | ||
17578 | -# by the Free Software Foundation; either version 2, or (at your option) | ||
17579 | -# any later version. | ||
17580 | -# | ||
17581 | -# This program is distributed in the hope that it will be useful, | ||
17582 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17583 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17584 | -# Library General Public License for more details. | ||
17585 | -# | ||
17586 | -# You should have received a copy of the GNU Library General Public | ||
17587 | -# License along with this program; if not, write to the Free Software | ||
17588 | -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
17589 | -# USA. | ||
17590 | -# | ||
17591 | -# Written by Bruno Haible <haible@clisp.cons.org>. | ||
17592 | -# | ||
17593 | -/^# Packages using this file: / { | ||
17594 | - s/# Packages using this file:// | ||
17595 | - ta | ||
17596 | - :a | ||
17597 | - s/ @PACKAGE@ / @PACKAGE@ / | ||
17598 | - tb | ||
17599 | - s/ $/ @PACKAGE@ / | ||
17600 | - :b | ||
17601 | - s/^/# Packages using this file:/ | ||
17602 | -} | ||
17603 | --- a/intl/ref-del.sin | ||
17604 | +++ /dev/null | ||
17605 | @@ -1,26 +0,0 @@ | ||
17606 | -# Remove this package from a list of references stored in a text file. | ||
17607 | -# | ||
17608 | -# Copyright (C) 2000 Free Software Foundation, Inc. | ||
17609 | -# | ||
17610 | -# This program is free software; you can redistribute it and/or modify it | ||
17611 | -# under the terms of the GNU Library General Public License as published | ||
17612 | -# by the Free Software Foundation; either version 2, or (at your option) | ||
17613 | -# any later version. | ||
17614 | -# | ||
17615 | -# This program is distributed in the hope that it will be useful, | ||
17616 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17617 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17618 | -# Library General Public License for more details. | ||
17619 | -# | ||
17620 | -# You should have received a copy of the GNU Library General Public | ||
17621 | -# License along with this program; if not, write to the Free Software | ||
17622 | -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
17623 | -# USA. | ||
17624 | -# | ||
17625 | -# Written by Bruno Haible <haible@clisp.cons.org>. | ||
17626 | -# | ||
17627 | -/^# Packages using this file: / { | ||
17628 | - s/# Packages using this file:// | ||
17629 | - s/ @PACKAGE@ / / | ||
17630 | - s/^/# Packages using this file:/ | ||
17631 | -} | ||
17632 | --- a/intl/relocatable.c | ||
17633 | +++ /dev/null | ||
17634 | @@ -1,468 +0,0 @@ | ||
17635 | -/* Provide relocatable packages. | ||
17636 | - Copyright (C) 2003-2006 Free Software Foundation, Inc. | ||
17637 | - Written by Bruno Haible <bruno@clisp.org>, 2003. | ||
17638 | - | ||
17639 | - This program is free software; you can redistribute it and/or modify it | ||
17640 | - under the terms of the GNU Library General Public License as published | ||
17641 | - by the Free Software Foundation; either version 2, or (at your option) | ||
17642 | - any later version. | ||
17643 | - | ||
17644 | - This program is distributed in the hope that it will be useful, | ||
17645 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17646 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17647 | - Library General Public License for more details. | ||
17648 | - | ||
17649 | - You should have received a copy of the GNU Library General Public | ||
17650 | - License along with this program; if not, write to the Free Software | ||
17651 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
17652 | - USA. */ | ||
17653 | - | ||
17654 | - | ||
17655 | -/* Tell glibc's <stdio.h> to provide a prototype for getline(). | ||
17656 | - This must come before <config.h> because <config.h> may include | ||
17657 | - <features.h>, and once <features.h> has been included, it's too late. */ | ||
17658 | -#ifndef _GNU_SOURCE | ||
17659 | -# define _GNU_SOURCE 1 | ||
17660 | -#endif | ||
17661 | - | ||
17662 | -#include <config.h> | ||
17663 | - | ||
17664 | -/* Specification. */ | ||
17665 | -#include "relocatable.h" | ||
17666 | - | ||
17667 | -#if ENABLE_RELOCATABLE | ||
17668 | - | ||
17669 | -#include <stddef.h> | ||
17670 | -#include <stdio.h> | ||
17671 | -#include <stdlib.h> | ||
17672 | -#include <string.h> | ||
17673 | - | ||
17674 | -#ifdef NO_XMALLOC | ||
17675 | -# define xmalloc malloc | ||
17676 | -#else | ||
17677 | -# include "xalloc.h" | ||
17678 | -#endif | ||
17679 | - | ||
17680 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ | ||
17681 | -# define WIN32_LEAN_AND_MEAN | ||
17682 | -# include <windows.h> | ||
17683 | -#endif | ||
17684 | - | ||
17685 | -#if DEPENDS_ON_LIBCHARSET | ||
17686 | -# include <libcharset.h> | ||
17687 | -#endif | ||
17688 | -#if DEPENDS_ON_LIBICONV && HAVE_ICONV | ||
17689 | -# include <iconv.h> | ||
17690 | -#endif | ||
17691 | -#if DEPENDS_ON_LIBINTL && ENABLE_NLS | ||
17692 | -# include <libintl.h> | ||
17693 | -#endif | ||
17694 | - | ||
17695 | -/* Faked cheap 'bool'. */ | ||
17696 | -#undef bool | ||
17697 | -#undef false | ||
17698 | -#undef true | ||
17699 | -#define bool int | ||
17700 | -#define false 0 | ||
17701 | -#define true 1 | ||
17702 | - | ||
17703 | -/* Pathname support. | ||
17704 | - ISSLASH(C) tests whether C is a directory separator character. | ||
17705 | - IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. | ||
17706 | - */ | ||
17707 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | ||
17708 | - /* Win32, Cygwin, OS/2, DOS */ | ||
17709 | -# define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||
17710 | -# define HAS_DEVICE(P) \ | ||
17711 | - ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ | ||
17712 | - && (P)[1] == ':') | ||
17713 | -# define IS_PATH_WITH_DIR(P) \ | ||
17714 | - (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P)) | ||
17715 | -# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0) | ||
17716 | -#else | ||
17717 | - /* Unix */ | ||
17718 | -# define ISSLASH(C) ((C) == '/') | ||
17719 | -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) | ||
17720 | -# define FILE_SYSTEM_PREFIX_LEN(P) 0 | ||
17721 | -#endif | ||
17722 | - | ||
17723 | -/* Original installation prefix. */ | ||
17724 | -static char *orig_prefix; | ||
17725 | -static size_t orig_prefix_len; | ||
17726 | -/* Current installation prefix. */ | ||
17727 | -static char *curr_prefix; | ||
17728 | -static size_t curr_prefix_len; | ||
17729 | -/* These prefixes do not end in a slash. Anything that will be concatenated | ||
17730 | - to them must start with a slash. */ | ||
17731 | - | ||
17732 | -/* Sets the original and the current installation prefix of this module. | ||
17733 | - Relocation simply replaces a pathname starting with the original prefix | ||
17734 | - by the corresponding pathname with the current prefix instead. Both | ||
17735 | - prefixes should be directory names without trailing slash (i.e. use "" | ||
17736 | - instead of "/"). */ | ||
17737 | -static void | ||
17738 | -set_this_relocation_prefix (const char *orig_prefix_arg, | ||
17739 | - const char *curr_prefix_arg) | ||
17740 | -{ | ||
17741 | - if (orig_prefix_arg != NULL && curr_prefix_arg != NULL | ||
17742 | - /* Optimization: if orig_prefix and curr_prefix are equal, the | ||
17743 | - relocation is a nop. */ | ||
17744 | - && strcmp (orig_prefix_arg, curr_prefix_arg) != 0) | ||
17745 | - { | ||
17746 | - /* Duplicate the argument strings. */ | ||
17747 | - char *memory; | ||
17748 | - | ||
17749 | - orig_prefix_len = strlen (orig_prefix_arg); | ||
17750 | - curr_prefix_len = strlen (curr_prefix_arg); | ||
17751 | - memory = (char *) xmalloc (orig_prefix_len + 1 + curr_prefix_len + 1); | ||
17752 | -#ifdef NO_XMALLOC | ||
17753 | - if (memory != NULL) | ||
17754 | -#endif | ||
17755 | - { | ||
17756 | - memcpy (memory, orig_prefix_arg, orig_prefix_len + 1); | ||
17757 | - orig_prefix = memory; | ||
17758 | - memory += orig_prefix_len + 1; | ||
17759 | - memcpy (memory, curr_prefix_arg, curr_prefix_len + 1); | ||
17760 | - curr_prefix = memory; | ||
17761 | - return; | ||
17762 | - } | ||
17763 | - } | ||
17764 | - orig_prefix = NULL; | ||
17765 | - curr_prefix = NULL; | ||
17766 | - /* Don't worry about wasted memory here - this function is usually only | ||
17767 | - called once. */ | ||
17768 | -} | ||
17769 | - | ||
17770 | -/* Sets the original and the current installation prefix of the package. | ||
17771 | - Relocation simply replaces a pathname starting with the original prefix | ||
17772 | - by the corresponding pathname with the current prefix instead. Both | ||
17773 | - prefixes should be directory names without trailing slash (i.e. use "" | ||
17774 | - instead of "/"). */ | ||
17775 | -void | ||
17776 | -set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg) | ||
17777 | -{ | ||
17778 | - set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg); | ||
17779 | - | ||
17780 | - /* Now notify all dependent libraries. */ | ||
17781 | -#if DEPENDS_ON_LIBCHARSET | ||
17782 | - libcharset_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg); | ||
17783 | -#endif | ||
17784 | -#if DEPENDS_ON_LIBICONV && HAVE_ICONV && _LIBICONV_VERSION >= 0x0109 | ||
17785 | - libiconv_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg); | ||
17786 | -#endif | ||
17787 | -#if DEPENDS_ON_LIBINTL && ENABLE_NLS && defined libintl_set_relocation_prefix | ||
17788 | - libintl_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg); | ||
17789 | -#endif | ||
17790 | -} | ||
17791 | - | ||
17792 | -#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR) | ||
17793 | - | ||
17794 | -/* Convenience function: | ||
17795 | - Computes the current installation prefix, based on the original | ||
17796 | - installation prefix, the original installation directory of a particular | ||
17797 | - file, and the current pathname of this file. Returns NULL upon failure. */ | ||
17798 | -#ifdef IN_LIBRARY | ||
17799 | -#define compute_curr_prefix local_compute_curr_prefix | ||
17800 | -static | ||
17801 | -#endif | ||
17802 | -const char * | ||
17803 | -compute_curr_prefix (const char *orig_installprefix, | ||
17804 | - const char *orig_installdir, | ||
17805 | - const char *curr_pathname) | ||
17806 | -{ | ||
17807 | - const char *curr_installdir; | ||
17808 | - const char *rel_installdir; | ||
17809 | - | ||
17810 | - if (curr_pathname == NULL) | ||
17811 | - return NULL; | ||
17812 | - | ||
17813 | - /* Determine the relative installation directory, relative to the prefix. | ||
17814 | - This is simply the difference between orig_installprefix and | ||
17815 | - orig_installdir. */ | ||
17816 | - if (strncmp (orig_installprefix, orig_installdir, strlen (orig_installprefix)) | ||
17817 | - != 0) | ||
17818 | - /* Shouldn't happen - nothing should be installed outside $(prefix). */ | ||
17819 | - return NULL; | ||
17820 | - rel_installdir = orig_installdir + strlen (orig_installprefix); | ||
17821 | - | ||
17822 | - /* Determine the current installation directory. */ | ||
17823 | - { | ||
17824 | - const char *p_base = curr_pathname + FILE_SYSTEM_PREFIX_LEN (curr_pathname); | ||
17825 | - const char *p = curr_pathname + strlen (curr_pathname); | ||
17826 | - char *q; | ||
17827 | - | ||
17828 | - while (p > p_base) | ||
17829 | - { | ||
17830 | - p--; | ||
17831 | - if (ISSLASH (*p)) | ||
17832 | - break; | ||
17833 | - } | ||
17834 | - | ||
17835 | - q = (char *) xmalloc (p - curr_pathname + 1); | ||
17836 | -#ifdef NO_XMALLOC | ||
17837 | - if (q == NULL) | ||
17838 | - return NULL; | ||
17839 | -#endif | ||
17840 | - memcpy (q, curr_pathname, p - curr_pathname); | ||
17841 | - q[p - curr_pathname] = '\0'; | ||
17842 | - curr_installdir = q; | ||
17843 | - } | ||
17844 | - | ||
17845 | - /* Compute the current installation prefix by removing the trailing | ||
17846 | - rel_installdir from it. */ | ||
17847 | - { | ||
17848 | - const char *rp = rel_installdir + strlen (rel_installdir); | ||
17849 | - const char *cp = curr_installdir + strlen (curr_installdir); | ||
17850 | - const char *cp_base = | ||
17851 | - curr_installdir + FILE_SYSTEM_PREFIX_LEN (curr_installdir); | ||
17852 | - | ||
17853 | - while (rp > rel_installdir && cp > cp_base) | ||
17854 | - { | ||
17855 | - bool same = false; | ||
17856 | - const char *rpi = rp; | ||
17857 | - const char *cpi = cp; | ||
17858 | - | ||
17859 | - while (rpi > rel_installdir && cpi > cp_base) | ||
17860 | - { | ||
17861 | - rpi--; | ||
17862 | - cpi--; | ||
17863 | - if (ISSLASH (*rpi) || ISSLASH (*cpi)) | ||
17864 | - { | ||
17865 | - if (ISSLASH (*rpi) && ISSLASH (*cpi)) | ||
17866 | - same = true; | ||
17867 | - break; | ||
17868 | - } | ||
17869 | - /* Do case-insensitive comparison if the filesystem is always or | ||
17870 | - often case-insensitive. It's better to accept the comparison | ||
17871 | - if the difference is only in case, rather than to fail. */ | ||
17872 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | ||
17873 | - /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */ | ||
17874 | - if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi) | ||
17875 | - != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi)) | ||
17876 | - break; | ||
17877 | -#else | ||
17878 | - if (*rpi != *cpi) | ||
17879 | - break; | ||
17880 | -#endif | ||
17881 | - } | ||
17882 | - if (!same) | ||
17883 | - break; | ||
17884 | - /* The last pathname component was the same. opi and cpi now point | ||
17885 | - to the slash before it. */ | ||
17886 | - rp = rpi; | ||
17887 | - cp = cpi; | ||
17888 | - } | ||
17889 | - | ||
17890 | - if (rp > rel_installdir) | ||
17891 | - /* Unexpected: The curr_installdir does not end with rel_installdir. */ | ||
17892 | - return NULL; | ||
17893 | - | ||
17894 | - { | ||
17895 | - size_t curr_prefix_len = cp - curr_installdir; | ||
17896 | - char *curr_prefix; | ||
17897 | - | ||
17898 | - curr_prefix = (char *) xmalloc (curr_prefix_len + 1); | ||
17899 | -#ifdef NO_XMALLOC | ||
17900 | - if (curr_prefix == NULL) | ||
17901 | - return NULL; | ||
17902 | -#endif | ||
17903 | - memcpy (curr_prefix, curr_installdir, curr_prefix_len); | ||
17904 | - curr_prefix[curr_prefix_len] = '\0'; | ||
17905 | - | ||
17906 | - return curr_prefix; | ||
17907 | - } | ||
17908 | - } | ||
17909 | -} | ||
17910 | - | ||
17911 | -#endif /* !IN_LIBRARY || PIC */ | ||
17912 | - | ||
17913 | -#if defined PIC && defined INSTALLDIR | ||
17914 | - | ||
17915 | -/* Full pathname of shared library, or NULL. */ | ||
17916 | -static char *shared_library_fullname; | ||
17917 | - | ||
17918 | -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ | ||
17919 | - | ||
17920 | -/* Determine the full pathname of the shared library when it is loaded. */ | ||
17921 | - | ||
17922 | -BOOL WINAPI | ||
17923 | -DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved) | ||
17924 | -{ | ||
17925 | - (void) reserved; | ||
17926 | - | ||
17927 | - if (event == DLL_PROCESS_ATTACH) | ||
17928 | - { | ||
17929 | - /* The DLL is being loaded into an application's address range. */ | ||
17930 | - static char location[MAX_PATH]; | ||
17931 | - | ||
17932 | - if (!GetModuleFileName (module_handle, location, sizeof (location))) | ||
17933 | - /* Shouldn't happen. */ | ||
17934 | - return FALSE; | ||
17935 | - | ||
17936 | - if (!IS_PATH_WITH_DIR (location)) | ||
17937 | - /* Shouldn't happen. */ | ||
17938 | - return FALSE; | ||
17939 | - | ||
17940 | - { | ||
17941 | -#if defined __CYGWIN__ | ||
17942 | - /* On Cygwin, we need to convert paths coming from Win32 system calls | ||
17943 | - to the Unix-like slashified notation. */ | ||
17944 | - static char location_as_posix_path[2 * MAX_PATH]; | ||
17945 | - /* There's no error return defined for cygwin_conv_to_posix_path. | ||
17946 | - See cygwin-api/func-cygwin-conv-to-posix-path.html. | ||
17947 | - Does it overflow the buffer of expected size MAX_PATH or does it | ||
17948 | - truncate the path? I don't know. Let's catch both. */ | ||
17949 | - cygwin_conv_to_posix_path (location, location_as_posix_path); | ||
17950 | - location_as_posix_path[MAX_PATH - 1] = '\0'; | ||
17951 | - if (strlen (location_as_posix_path) >= MAX_PATH - 1) | ||
17952 | - /* A sign of buffer overflow or path truncation. */ | ||
17953 | - return FALSE; | ||
17954 | - shared_library_fullname = strdup (location_as_posix_path); | ||
17955 | -#else | ||
17956 | - shared_library_fullname = strdup (location); | ||
17957 | -#endif | ||
17958 | - } | ||
17959 | - } | ||
17960 | - | ||
17961 | - return TRUE; | ||
17962 | -} | ||
17963 | - | ||
17964 | -#else /* Unix except Cygwin */ | ||
17965 | - | ||
17966 | -static void | ||
17967 | -find_shared_library_fullname () | ||
17968 | -{ | ||
17969 | -#if defined __linux__ && __GLIBC__ >= 2 | ||
17970 | - /* Linux has /proc/self/maps. glibc 2 has the getline() function. */ | ||
17971 | - FILE *fp; | ||
17972 | - | ||
17973 | - /* Open the current process' maps file. It describes one VMA per line. */ | ||
17974 | - fp = fopen ("/proc/self/maps", "r"); | ||
17975 | - if (fp) | ||
17976 | - { | ||
17977 | - unsigned long address = (unsigned long) &find_shared_library_fullname; | ||
17978 | - for (;;) | ||
17979 | - { | ||
17980 | - unsigned long start, end; | ||
17981 | - int c; | ||
17982 | - | ||
17983 | - if (fscanf (fp, "%lx-%lx", &start, &end) != 2) | ||
17984 | - break; | ||
17985 | - if (address >= start && address <= end - 1) | ||
17986 | - { | ||
17987 | - /* Found it. Now see if this line contains a filename. */ | ||
17988 | - while (c = getc (fp), c != EOF && c != '\n' && c != '/') | ||
17989 | - continue; | ||
17990 | - if (c == '/') | ||
17991 | - { | ||
17992 | - size_t size; | ||
17993 | - int len; | ||
17994 | - | ||
17995 | - ungetc (c, fp); | ||
17996 | - shared_library_fullname = NULL; size = 0; | ||
17997 | - len = getline (&shared_library_fullname, &size, fp); | ||
17998 | - if (len >= 0) | ||
17999 | - { | ||
18000 | - /* Success: filled shared_library_fullname. */ | ||
18001 | - if (len > 0 && shared_library_fullname[len - 1] == '\n') | ||
18002 | - shared_library_fullname[len - 1] = '\0'; | ||
18003 | - } | ||
18004 | - } | ||
18005 | - break; | ||
18006 | - } | ||
18007 | - while (c = getc (fp), c != EOF && c != '\n') | ||
18008 | - continue; | ||
18009 | - } | ||
18010 | - fclose (fp); | ||
18011 | - } | ||
18012 | -#endif | ||
18013 | -} | ||
18014 | - | ||
18015 | -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ | ||
18016 | - | ||
18017 | -/* Return the full pathname of the current shared library. | ||
18018 | - Return NULL if unknown. | ||
18019 | - Guaranteed to work only on Linux, Cygwin and Woe32. */ | ||
18020 | -static char * | ||
18021 | -get_shared_library_fullname () | ||
18022 | -{ | ||
18023 | -#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) | ||
18024 | - static bool tried_find_shared_library_fullname; | ||
18025 | - if (!tried_find_shared_library_fullname) | ||
18026 | - { | ||
18027 | - find_shared_library_fullname (); | ||
18028 | - tried_find_shared_library_fullname = true; | ||
18029 | - } | ||
18030 | -#endif | ||
18031 | - return shared_library_fullname; | ||
18032 | -} | ||
18033 | - | ||
18034 | -#endif /* PIC */ | ||
18035 | - | ||
18036 | -/* Returns the pathname, relocated according to the current installation | ||
18037 | - directory. */ | ||
18038 | -const char * | ||
18039 | -relocate (const char *pathname) | ||
18040 | -{ | ||
18041 | -#if defined PIC && defined INSTALLDIR | ||
18042 | - static int initialized; | ||
18043 | - | ||
18044 | - /* Initialization code for a shared library. */ | ||
18045 | - if (!initialized) | ||
18046 | - { | ||
18047 | - /* At this point, orig_prefix and curr_prefix likely have already been | ||
18048 | - set through the main program's set_program_name_and_installdir | ||
18049 | - function. This is sufficient in the case that the library has | ||
18050 | - initially been installed in the same orig_prefix. But we can do | ||
18051 | - better, to also cover the cases that 1. it has been installed | ||
18052 | - in a different prefix before being moved to orig_prefix and (later) | ||
18053 | - to curr_prefix, 2. unlike the program, it has not moved away from | ||
18054 | - orig_prefix. */ | ||
18055 | - const char *orig_installprefix = INSTALLPREFIX; | ||
18056 | - const char *orig_installdir = INSTALLDIR; | ||
18057 | - const char *curr_prefix_better; | ||
18058 | - | ||
18059 | - curr_prefix_better = | ||
18060 | - compute_curr_prefix (orig_installprefix, orig_installdir, | ||
18061 | - get_shared_library_fullname ()); | ||
18062 | - if (curr_prefix_better == NULL) | ||
18063 | - curr_prefix_better = curr_prefix; | ||
18064 | - | ||
18065 | - set_relocation_prefix (orig_installprefix, curr_prefix_better); | ||
18066 | - | ||
18067 | - initialized = 1; | ||
18068 | - } | ||
18069 | -#endif | ||
18070 | - | ||
18071 | - /* Note: It is not necessary to perform case insensitive comparison here, | ||
18072 | - even for DOS-like filesystems, because the pathname argument was | ||
18073 | - typically created from the same Makefile variable as orig_prefix came | ||
18074 | - from. */ | ||
18075 | - if (orig_prefix != NULL && curr_prefix != NULL | ||
18076 | - && strncmp (pathname, orig_prefix, orig_prefix_len) == 0) | ||
18077 | - { | ||
18078 | - if (pathname[orig_prefix_len] == '\0') | ||
18079 | - /* pathname equals orig_prefix. */ | ||
18080 | - return curr_prefix; | ||
18081 | - if (ISSLASH (pathname[orig_prefix_len])) | ||
18082 | - { | ||
18083 | - /* pathname starts with orig_prefix. */ | ||
18084 | - const char *pathname_tail = &pathname[orig_prefix_len]; | ||
18085 | - char *result = | ||
18086 | - (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1); | ||
18087 | - | ||
18088 | -#ifdef NO_XMALLOC | ||
18089 | - if (result != NULL) | ||
18090 | -#endif | ||
18091 | - { | ||
18092 | - memcpy (result, curr_prefix, curr_prefix_len); | ||
18093 | - strcpy (result + curr_prefix_len, pathname_tail); | ||
18094 | - return result; | ||
18095 | - } | ||
18096 | - } | ||
18097 | - } | ||
18098 | - /* Nothing to relocate. */ | ||
18099 | - return pathname; | ||
18100 | -} | ||
18101 | - | ||
18102 | -#endif | ||
18103 | --- a/intl/relocatable.h | ||
18104 | +++ /dev/null | ||
18105 | @@ -1,79 +0,0 @@ | ||
18106 | -/* Provide relocatable packages. | ||
18107 | - Copyright (C) 2003, 2005 Free Software Foundation, Inc. | ||
18108 | - Written by Bruno Haible <bruno@clisp.org>, 2003. | ||
18109 | - | ||
18110 | - This program is free software; you can redistribute it and/or modify it | ||
18111 | - under the terms of the GNU Library General Public License as published | ||
18112 | - by the Free Software Foundation; either version 2, or (at your option) | ||
18113 | - any later version. | ||
18114 | - | ||
18115 | - This program is distributed in the hope that it will be useful, | ||
18116 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18117 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18118 | - Library General Public License for more details. | ||
18119 | - | ||
18120 | - You should have received a copy of the GNU Library General Public | ||
18121 | - License along with this program; if not, write to the Free Software | ||
18122 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
18123 | - USA. */ | ||
18124 | - | ||
18125 | -#ifndef _RELOCATABLE_H | ||
18126 | -#define _RELOCATABLE_H | ||
18127 | - | ||
18128 | -#ifdef __cplusplus | ||
18129 | -extern "C" { | ||
18130 | -#endif | ||
18131 | - | ||
18132 | - | ||
18133 | -/* This can be enabled through the configure --enable-relocatable option. */ | ||
18134 | -#if ENABLE_RELOCATABLE | ||
18135 | - | ||
18136 | -/* When building a DLL, we must export some functions. Note that because | ||
18137 | - this is a private .h file, we don't need to use __declspec(dllimport) | ||
18138 | - in any case. */ | ||
18139 | -#if HAVE_VISIBILITY && BUILDING_DLL | ||
18140 | -# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default"))) | ||
18141 | -#elif defined _MSC_VER && BUILDING_DLL | ||
18142 | -# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport) | ||
18143 | -#else | ||
18144 | -# define RELOCATABLE_DLL_EXPORTED | ||
18145 | -#endif | ||
18146 | - | ||
18147 | -/* Sets the original and the current installation prefix of the package. | ||
18148 | - Relocation simply replaces a pathname starting with the original prefix | ||
18149 | - by the corresponding pathname with the current prefix instead. Both | ||
18150 | - prefixes should be directory names without trailing slash (i.e. use "" | ||
18151 | - instead of "/"). */ | ||
18152 | -extern RELOCATABLE_DLL_EXPORTED void | ||
18153 | - set_relocation_prefix (const char *orig_prefix, | ||
18154 | - const char *curr_prefix); | ||
18155 | - | ||
18156 | -/* Returns the pathname, relocated according to the current installation | ||
18157 | - directory. */ | ||
18158 | -extern const char * relocate (const char *pathname); | ||
18159 | - | ||
18160 | -/* Memory management: relocate() leaks memory, because it has to construct | ||
18161 | - a fresh pathname. If this is a problem because your program calls | ||
18162 | - relocate() frequently, think about caching the result. */ | ||
18163 | - | ||
18164 | -/* Convenience function: | ||
18165 | - Computes the current installation prefix, based on the original | ||
18166 | - installation prefix, the original installation directory of a particular | ||
18167 | - file, and the current pathname of this file. Returns NULL upon failure. */ | ||
18168 | -extern const char * compute_curr_prefix (const char *orig_installprefix, | ||
18169 | - const char *orig_installdir, | ||
18170 | - const char *curr_pathname); | ||
18171 | - | ||
18172 | -#else | ||
18173 | - | ||
18174 | -/* By default, we use the hardwired pathnames. */ | ||
18175 | -#define relocate(pathname) (pathname) | ||
18176 | - | ||
18177 | -#endif | ||
18178 | - | ||
18179 | - | ||
18180 | -#ifdef __cplusplus | ||
18181 | -} | ||
18182 | -#endif | ||
18183 | - | ||
18184 | -#endif /* _RELOCATABLE_H */ | ||
18185 | --- a/intl/textdomain.c | ||
18186 | +++ /dev/null | ||
18187 | @@ -1,127 +0,0 @@ | ||
18188 | -/* Implementation of the textdomain(3) function. | ||
18189 | - Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc. | ||
18190 | - | ||
18191 | - This program is free software; you can redistribute it and/or modify it | ||
18192 | - under the terms of the GNU Library General Public License as published | ||
18193 | - by the Free Software Foundation; either version 2, or (at your option) | ||
18194 | - any later version. | ||
18195 | - | ||
18196 | - This program is distributed in the hope that it will be useful, | ||
18197 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18198 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18199 | - Library General Public License for more details. | ||
18200 | - | ||
18201 | - You should have received a copy of the GNU Library General Public | ||
18202 | - License along with this program; if not, write to the Free Software | ||
18203 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
18204 | - USA. */ | ||
18205 | - | ||
18206 | -#ifdef HAVE_CONFIG_H | ||
18207 | -# include <config.h> | ||
18208 | -#endif | ||
18209 | - | ||
18210 | -#include <stdlib.h> | ||
18211 | -#include <string.h> | ||
18212 | - | ||
18213 | -#include "gettextP.h" | ||
18214 | -#ifdef _LIBC | ||
18215 | -# include <libintl.h> | ||
18216 | -#else | ||
18217 | -# include "libgnuintl.h" | ||
18218 | -#endif | ||
18219 | - | ||
18220 | -/* Handle multi-threaded applications. */ | ||
18221 | -#ifdef _LIBC | ||
18222 | -# include <bits/libc-lock.h> | ||
18223 | -# define gl_rwlock_define __libc_rwlock_define | ||
18224 | -# define gl_rwlock_wrlock __libc_rwlock_wrlock | ||
18225 | -# define gl_rwlock_unlock __libc_rwlock_unlock | ||
18226 | -#else | ||
18227 | -# include "lock.h" | ||
18228 | -#endif | ||
18229 | - | ||
18230 | -/* @@ end of prolog @@ */ | ||
18231 | - | ||
18232 | - | ||
18233 | -/* Names for the libintl functions are a problem. They must not clash | ||
18234 | - with existing names and they should follow ANSI C. But this source | ||
18235 | - code is also used in GNU C Library where the names have a __ | ||
18236 | - prefix. So we have to make a difference here. */ | ||
18237 | -#ifdef _LIBC | ||
18238 | -# define TEXTDOMAIN __textdomain | ||
18239 | -# ifndef strdup | ||
18240 | -# define strdup(str) __strdup (str) | ||
18241 | -# endif | ||
18242 | -#else | ||
18243 | -# define TEXTDOMAIN libintl_textdomain | ||
18244 | -#endif | ||
18245 | - | ||
18246 | -/* Lock variable to protect the global data in the gettext implementation. */ | ||
18247 | -gl_rwlock_define (extern, _nl_state_lock attribute_hidden) | ||
18248 | - | ||
18249 | -/* Set the current default message catalog to DOMAINNAME. | ||
18250 | - If DOMAINNAME is null, return the current default. | ||
18251 | - If DOMAINNAME is "", reset to the default of "messages". */ | ||
18252 | -char * | ||
18253 | -TEXTDOMAIN (const char *domainname) | ||
18254 | -{ | ||
18255 | - char *new_domain; | ||
18256 | - char *old_domain; | ||
18257 | - | ||
18258 | - /* A NULL pointer requests the current setting. */ | ||
18259 | - if (domainname == NULL) | ||
18260 | - return (char *) _nl_current_default_domain; | ||
18261 | - | ||
18262 | - gl_rwlock_wrlock (_nl_state_lock); | ||
18263 | - | ||
18264 | - old_domain = (char *) _nl_current_default_domain; | ||
18265 | - | ||
18266 | - /* If domain name is the null string set to default domain "messages". */ | ||
18267 | - if (domainname[0] == '\0' | ||
18268 | - || strcmp (domainname, _nl_default_default_domain) == 0) | ||
18269 | - { | ||
18270 | - _nl_current_default_domain = _nl_default_default_domain; | ||
18271 | - new_domain = (char *) _nl_current_default_domain; | ||
18272 | - } | ||
18273 | - else if (strcmp (domainname, old_domain) == 0) | ||
18274 | - /* This can happen and people will use it to signal that some | ||
18275 | - environment variable changed. */ | ||
18276 | - new_domain = old_domain; | ||
18277 | - else | ||
18278 | - { | ||
18279 | - /* If the following malloc fails `_nl_current_default_domain' | ||
18280 | - will be NULL. This value will be returned and so signals we | ||
18281 | - are out of core. */ | ||
18282 | -#if defined _LIBC || defined HAVE_STRDUP | ||
18283 | - new_domain = strdup (domainname); | ||
18284 | -#else | ||
18285 | - size_t len = strlen (domainname) + 1; | ||
18286 | - new_domain = (char *) malloc (len); | ||
18287 | - if (new_domain != NULL) | ||
18288 | - memcpy (new_domain, domainname, len); | ||
18289 | -#endif | ||
18290 | - | ||
18291 | - if (new_domain != NULL) | ||
18292 | - _nl_current_default_domain = new_domain; | ||
18293 | - } | ||
18294 | - | ||
18295 | - /* We use this possibility to signal a change of the loaded catalogs | ||
18296 | - since this is most likely the case and there is no other easy we | ||
18297 | - to do it. Do it only when the call was successful. */ | ||
18298 | - if (new_domain != NULL) | ||
18299 | - { | ||
18300 | - ++_nl_msg_cat_cntr; | ||
18301 | - | ||
18302 | - if (old_domain != new_domain && old_domain != _nl_default_default_domain) | ||
18303 | - free (old_domain); | ||
18304 | - } | ||
18305 | - | ||
18306 | - gl_rwlock_unlock (_nl_state_lock); | ||
18307 | - | ||
18308 | - return new_domain; | ||
18309 | -} | ||
18310 | - | ||
18311 | -#ifdef _LIBC | ||
18312 | -/* Alias for function name in GNU C Library. */ | ||
18313 | -weak_alias (__textdomain, textdomain); | ||
18314 | -#endif | ||
18315 | --- a/intl/tsearch.c | ||
18316 | +++ /dev/null | ||
18317 | @@ -1,684 +0,0 @@ | ||
18318 | -/* Copyright (C) 1995, 1996, 1997, 2000, 2006 Free Software Foundation, Inc. | ||
18319 | - Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997. | ||
18320 | - | ||
18321 | - NOTE: The canonical source of this file is maintained with the GNU C | ||
18322 | - Library. Bugs can be reported to bug-glibc@gnu.org. | ||
18323 | - | ||
18324 | - This program is free software; you can redistribute it and/or modify it | ||
18325 | - under the terms of the GNU Library General Public License as published | ||
18326 | - by the Free Software Foundation; either version 2, or (at your option) | ||
18327 | - any later version. | ||
18328 | - | ||
18329 | - This program is distributed in the hope that it will be useful, | ||
18330 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18331 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18332 | - Library General Public License for more details. | ||
18333 | - | ||
18334 | - You should have received a copy of the GNU Library General Public | ||
18335 | - License along with this program; if not, write to the Free Software | ||
18336 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
18337 | - USA. */ | ||
18338 | - | ||
18339 | -/* Tree search for red/black trees. | ||
18340 | - The algorithm for adding nodes is taken from one of the many "Algorithms" | ||
18341 | - books by Robert Sedgewick, although the implementation differs. | ||
18342 | - The algorithm for deleting nodes can probably be found in a book named | ||
18343 | - "Introduction to Algorithms" by Cormen/Leiserson/Rivest. At least that's | ||
18344 | - the book that my professor took most algorithms from during the "Data | ||
18345 | - Structures" course... | ||
18346 | - | ||
18347 | - Totally public domain. */ | ||
18348 | - | ||
18349 | -/* Red/black trees are binary trees in which the edges are colored either red | ||
18350 | - or black. They have the following properties: | ||
18351 | - 1. The number of black edges on every path from the root to a leaf is | ||
18352 | - constant. | ||
18353 | - 2. No two red edges are adjacent. | ||
18354 | - Therefore there is an upper bound on the length of every path, it's | ||
18355 | - O(log n) where n is the number of nodes in the tree. No path can be longer | ||
18356 | - than 1+2*P where P is the length of the shortest path in the tree. | ||
18357 | - Useful for the implementation: | ||
18358 | - 3. If one of the children of a node is NULL, then the other one is red | ||
18359 | - (if it exists). | ||
18360 | - | ||
18361 | - In the implementation, not the edges are colored, but the nodes. The color | ||
18362 | - interpreted as the color of the edge leading to this node. The color is | ||
18363 | - meaningless for the root node, but we color the root node black for | ||
18364 | - convenience. All added nodes are red initially. | ||
18365 | - | ||
18366 | - Adding to a red/black tree is rather easy. The right place is searched | ||
18367 | - with a usual binary tree search. Additionally, whenever a node N is | ||
18368 | - reached that has two red successors, the successors are colored black and | ||
18369 | - the node itself colored red. This moves red edges up the tree where they | ||
18370 | - pose less of a problem once we get to really insert the new node. Changing | ||
18371 | - N's color to red may violate rule 2, however, so rotations may become | ||
18372 | - necessary to restore the invariants. Adding a new red leaf may violate | ||
18373 | - the same rule, so afterwards an additional check is run and the tree | ||
18374 | - possibly rotated. | ||
18375 | - | ||
18376 | - Deleting is hairy. There are mainly two nodes involved: the node to be | ||
18377 | - deleted (n1), and another node that is to be unchained from the tree (n2). | ||
18378 | - If n1 has a successor (the node with a smallest key that is larger than | ||
18379 | - n1), then the successor becomes n2 and its contents are copied into n1, | ||
18380 | - otherwise n1 becomes n2. | ||
18381 | - Unchaining a node may violate rule 1: if n2 is black, one subtree is | ||
18382 | - missing one black edge afterwards. The algorithm must try to move this | ||
18383 | - error upwards towards the root, so that the subtree that does not have | ||
18384 | - enough black edges becomes the whole tree. Once that happens, the error | ||
18385 | - has disappeared. It may not be necessary to go all the way up, since it | ||
18386 | - is possible that rotations and recoloring can fix the error before that. | ||
18387 | - | ||
18388 | - Although the deletion algorithm must walk upwards through the tree, we | ||
18389 | - do not store parent pointers in the nodes. Instead, delete allocates a | ||
18390 | - small array of parent pointers and fills it while descending the tree. | ||
18391 | - Since we know that the length of a path is O(log n), where n is the number | ||
18392 | - of nodes, this is likely to use less memory. */ | ||
18393 | - | ||
18394 | -/* Tree rotations look like this: | ||
18395 | - A C | ||
18396 | - / \ / \ | ||
18397 | - B C A G | ||
18398 | - / \ / \ --> / \ | ||
18399 | - D E F G B F | ||
18400 | - / \ | ||
18401 | - D E | ||
18402 | - | ||
18403 | - In this case, A has been rotated left. This preserves the ordering of the | ||
18404 | - binary tree. */ | ||
18405 | - | ||
18406 | -#include <config.h> | ||
18407 | - | ||
18408 | -/* Specification. */ | ||
18409 | -#ifdef IN_LIBINTL | ||
18410 | -# include "tsearch.h" | ||
18411 | -#else | ||
18412 | -# include <search.h> | ||
18413 | -#endif | ||
18414 | - | ||
18415 | -#include <stdlib.h> | ||
18416 | - | ||
18417 | -typedef int (*__compar_fn_t) (const void *, const void *); | ||
18418 | -typedef void (*__action_fn_t) (const void *, VISIT, int); | ||
18419 | - | ||
18420 | -#ifndef weak_alias | ||
18421 | -# define __tsearch tsearch | ||
18422 | -# define __tfind tfind | ||
18423 | -# define __tdelete tdelete | ||
18424 | -# define __twalk twalk | ||
18425 | -#endif | ||
18426 | - | ||
18427 | -#ifndef internal_function | ||
18428 | -/* Inside GNU libc we mark some function in a special way. In other | ||
18429 | - environments simply ignore the marking. */ | ||
18430 | -# define internal_function | ||
18431 | -#endif | ||
18432 | - | ||
18433 | -typedef struct node_t | ||
18434 | -{ | ||
18435 | - /* Callers expect this to be the first element in the structure - do not | ||
18436 | - move! */ | ||
18437 | - const void *key; | ||
18438 | - struct node_t *left; | ||
18439 | - struct node_t *right; | ||
18440 | - unsigned int red:1; | ||
18441 | -} *node; | ||
18442 | -typedef const struct node_t *const_node; | ||
18443 | - | ||
18444 | -#undef DEBUGGING | ||
18445 | - | ||
18446 | -#ifdef DEBUGGING | ||
18447 | - | ||
18448 | -/* Routines to check tree invariants. */ | ||
18449 | - | ||
18450 | -#include <assert.h> | ||
18451 | - | ||
18452 | -#define CHECK_TREE(a) check_tree(a) | ||
18453 | - | ||
18454 | -static void | ||
18455 | -check_tree_recurse (node p, int d_sofar, int d_total) | ||
18456 | -{ | ||
18457 | - if (p == NULL) | ||
18458 | - { | ||
18459 | - assert (d_sofar == d_total); | ||
18460 | - return; | ||
18461 | - } | ||
18462 | - | ||
18463 | - check_tree_recurse (p->left, d_sofar + (p->left && !p->left->red), d_total); | ||
18464 | - check_tree_recurse (p->right, d_sofar + (p->right && !p->right->red), d_total); | ||
18465 | - if (p->left) | ||
18466 | - assert (!(p->left->red && p->red)); | ||
18467 | - if (p->right) | ||
18468 | - assert (!(p->right->red && p->red)); | ||
18469 | -} | ||
18470 | - | ||
18471 | -static void | ||
18472 | -check_tree (node root) | ||
18473 | -{ | ||
18474 | - int cnt = 0; | ||
18475 | - node p; | ||
18476 | - if (root == NULL) | ||
18477 | - return; | ||
18478 | - root->red = 0; | ||
18479 | - for(p = root->left; p; p = p->left) | ||
18480 | - cnt += !p->red; | ||
18481 | - check_tree_recurse (root, 0, cnt); | ||
18482 | -} | ||
18483 | - | ||
18484 | - | ||
18485 | -#else | ||
18486 | - | ||
18487 | -#define CHECK_TREE(a) | ||
18488 | - | ||
18489 | -#endif | ||
18490 | - | ||
18491 | -/* Possibly "split" a node with two red successors, and/or fix up two red | ||
18492 | - edges in a row. ROOTP is a pointer to the lowest node we visited, PARENTP | ||
18493 | - and GPARENTP pointers to its parent/grandparent. P_R and GP_R contain the | ||
18494 | - comparison values that determined which way was taken in the tree to reach | ||
18495 | - ROOTP. MODE is 1 if we need not do the split, but must check for two red | ||
18496 | - edges between GPARENTP and ROOTP. */ | ||
18497 | -static void | ||
18498 | -maybe_split_for_insert (node *rootp, node *parentp, node *gparentp, | ||
18499 | - int p_r, int gp_r, int mode) | ||
18500 | -{ | ||
18501 | - node root = *rootp; | ||
18502 | - node *rp, *lp; | ||
18503 | - rp = &(*rootp)->right; | ||
18504 | - lp = &(*rootp)->left; | ||
18505 | - | ||
18506 | - /* See if we have to split this node (both successors red). */ | ||
18507 | - if (mode == 1 | ||
18508 | - || ((*rp) != NULL && (*lp) != NULL && (*rp)->red && (*lp)->red)) | ||
18509 | - { | ||
18510 | - /* This node becomes red, its successors black. */ | ||
18511 | - root->red = 1; | ||
18512 | - if (*rp) | ||
18513 | - (*rp)->red = 0; | ||
18514 | - if (*lp) | ||
18515 | - (*lp)->red = 0; | ||
18516 | - | ||
18517 | - /* If the parent of this node is also red, we have to do | ||
18518 | - rotations. */ | ||
18519 | - if (parentp != NULL && (*parentp)->red) | ||
18520 | - { | ||
18521 | - node gp = *gparentp; | ||
18522 | - node p = *parentp; | ||
18523 | - /* There are two main cases: | ||
18524 | - 1. The edge types (left or right) of the two red edges differ. | ||
18525 | - 2. Both red edges are of the same type. | ||
18526 | - There exist two symmetries of each case, so there is a total of | ||
18527 | - 4 cases. */ | ||
18528 | - if ((p_r > 0) != (gp_r > 0)) | ||
18529 | - { | ||
18530 | - /* Put the child at the top of the tree, with its parent | ||
18531 | - and grandparent as successors. */ | ||
18532 | - p->red = 1; | ||
18533 | - gp->red = 1; | ||
18534 | - root->red = 0; | ||
18535 | - if (p_r < 0) | ||
18536 | - { | ||
18537 | - /* Child is left of parent. */ | ||
18538 | - p->left = *rp; | ||
18539 | - *rp = p; | ||
18540 | - gp->right = *lp; | ||
18541 | - *lp = gp; | ||
18542 | - } | ||
18543 | - else | ||
18544 | - { | ||
18545 | - /* Child is right of parent. */ | ||
18546 | - p->right = *lp; | ||
18547 | - *lp = p; | ||
18548 | - gp->left = *rp; | ||
18549 | - *rp = gp; | ||
18550 | - } | ||
18551 | - *gparentp = root; | ||
18552 | - } | ||
18553 | - else | ||
18554 | - { | ||
18555 | - *gparentp = *parentp; | ||
18556 | - /* Parent becomes the top of the tree, grandparent and | ||
18557 | - child are its successors. */ | ||
18558 | - p->red = 0; | ||
18559 | - gp->red = 1; | ||
18560 | - if (p_r < 0) | ||
18561 | - { | ||
18562 | - /* Left edges. */ | ||
18563 | - gp->left = p->right; | ||
18564 | - p->right = gp; | ||
18565 | - } | ||
18566 | - else | ||
18567 | - { | ||
18568 | - /* Right edges. */ | ||
18569 | - gp->right = p->left; | ||
18570 | - p->left = gp; | ||
18571 | - } | ||
18572 | - } | ||
18573 | - } | ||
18574 | - } | ||
18575 | -} | ||
18576 | - | ||
18577 | -/* Find or insert datum into search tree. | ||
18578 | - KEY is the key to be located, ROOTP is the address of tree root, | ||
18579 | - COMPAR the ordering function. */ | ||
18580 | -void * | ||
18581 | -__tsearch (const void *key, void **vrootp, __compar_fn_t compar) | ||
18582 | -{ | ||
18583 | - node q; | ||
18584 | - node *parentp = NULL, *gparentp = NULL; | ||
18585 | - node *rootp = (node *) vrootp; | ||
18586 | - node *nextp; | ||
18587 | - int r = 0, p_r = 0, gp_r = 0; /* No they might not, Mr Compiler. */ | ||
18588 | - | ||
18589 | - if (rootp == NULL) | ||
18590 | - return NULL; | ||
18591 | - | ||
18592 | - /* This saves some additional tests below. */ | ||
18593 | - if (*rootp != NULL) | ||
18594 | - (*rootp)->red = 0; | ||
18595 | - | ||
18596 | - CHECK_TREE (*rootp); | ||
18597 | - | ||
18598 | - nextp = rootp; | ||
18599 | - while (*nextp != NULL) | ||
18600 | - { | ||
18601 | - node root = *rootp; | ||
18602 | - r = (*compar) (key, root->key); | ||
18603 | - if (r == 0) | ||
18604 | - return root; | ||
18605 | - | ||
18606 | - maybe_split_for_insert (rootp, parentp, gparentp, p_r, gp_r, 0); | ||
18607 | - /* If that did any rotations, parentp and gparentp are now garbage. | ||
18608 | - That doesn't matter, because the values they contain are never | ||
18609 | - used again in that case. */ | ||
18610 | - | ||
18611 | - nextp = r < 0 ? &root->left : &root->right; | ||
18612 | - if (*nextp == NULL) | ||
18613 | - break; | ||
18614 | - | ||
18615 | - gparentp = parentp; | ||
18616 | - parentp = rootp; | ||
18617 | - rootp = nextp; | ||
18618 | - | ||
18619 | - gp_r = p_r; | ||
18620 | - p_r = r; | ||
18621 | - } | ||
18622 | - | ||
18623 | - q = (struct node_t *) malloc (sizeof (struct node_t)); | ||
18624 | - if (q != NULL) | ||
18625 | - { | ||
18626 | - *nextp = q; /* link new node to old */ | ||
18627 | - q->key = key; /* initialize new node */ | ||
18628 | - q->red = 1; | ||
18629 | - q->left = q->right = NULL; | ||
18630 | - | ||
18631 | - if (nextp != rootp) | ||
18632 | - /* There may be two red edges in a row now, which we must avoid by | ||
18633 | - rotating the tree. */ | ||
18634 | - maybe_split_for_insert (nextp, rootp, parentp, r, p_r, 1); | ||
18635 | - } | ||
18636 | - | ||
18637 | - return q; | ||
18638 | -} | ||
18639 | -#ifdef weak_alias | ||
18640 | -weak_alias (__tsearch, tsearch) | ||
18641 | -#endif | ||
18642 | - | ||
18643 | - | ||
18644 | -/* Find datum in search tree. | ||
18645 | - KEY is the key to be located, ROOTP is the address of tree root, | ||
18646 | - COMPAR the ordering function. */ | ||
18647 | -void * | ||
18648 | -__tfind (key, vrootp, compar) | ||
18649 | - const void *key; | ||
18650 | - void *const *vrootp; | ||
18651 | - __compar_fn_t compar; | ||
18652 | -{ | ||
18653 | - node *rootp = (node *) vrootp; | ||
18654 | - | ||
18655 | - if (rootp == NULL) | ||
18656 | - return NULL; | ||
18657 | - | ||
18658 | - CHECK_TREE (*rootp); | ||
18659 | - | ||
18660 | - while (*rootp != NULL) | ||
18661 | - { | ||
18662 | - node root = *rootp; | ||
18663 | - int r; | ||
18664 | - | ||
18665 | - r = (*compar) (key, root->key); | ||
18666 | - if (r == 0) | ||
18667 | - return root; | ||
18668 | - | ||
18669 | - rootp = r < 0 ? &root->left : &root->right; | ||
18670 | - } | ||
18671 | - return NULL; | ||
18672 | -} | ||
18673 | -#ifdef weak_alias | ||
18674 | -weak_alias (__tfind, tfind) | ||
18675 | -#endif | ||
18676 | - | ||
18677 | - | ||
18678 | -/* Delete node with given key. | ||
18679 | - KEY is the key to be deleted, ROOTP is the address of the root of tree, | ||
18680 | - COMPAR the comparison function. */ | ||
18681 | -void * | ||
18682 | -__tdelete (const void *key, void **vrootp, __compar_fn_t compar) | ||
18683 | -{ | ||
18684 | - node p, q, r, retval; | ||
18685 | - int cmp; | ||
18686 | - node *rootp = (node *) vrootp; | ||
18687 | - node root, unchained; | ||
18688 | - /* Stack of nodes so we remember the parents without recursion. It's | ||
18689 | - _very_ unlikely that there are paths longer than 40 nodes. The tree | ||
18690 | - would need to have around 250.000 nodes. */ | ||
18691 | - int stacksize = 100; | ||
18692 | - int sp = 0; | ||
18693 | - node *nodestack[100]; | ||
18694 | - | ||
18695 | - if (rootp == NULL) | ||
18696 | - return NULL; | ||
18697 | - p = *rootp; | ||
18698 | - if (p == NULL) | ||
18699 | - return NULL; | ||
18700 | - | ||
18701 | - CHECK_TREE (p); | ||
18702 | - | ||
18703 | - while ((cmp = (*compar) (key, (*rootp)->key)) != 0) | ||
18704 | - { | ||
18705 | - if (sp == stacksize) | ||
18706 | - abort (); | ||
18707 | - | ||
18708 | - nodestack[sp++] = rootp; | ||
18709 | - p = *rootp; | ||
18710 | - rootp = ((cmp < 0) | ||
18711 | - ? &(*rootp)->left | ||
18712 | - : &(*rootp)->right); | ||
18713 | - if (*rootp == NULL) | ||
18714 | - return NULL; | ||
18715 | - } | ||
18716 | - | ||
18717 | - /* This is bogus if the node to be deleted is the root... this routine | ||
18718 | - really should return an integer with 0 for success, -1 for failure | ||
18719 | - and errno = ESRCH or something. */ | ||
18720 | - retval = p; | ||
18721 | - | ||
18722 | - /* We don't unchain the node we want to delete. Instead, we overwrite | ||
18723 | - it with its successor and unchain the successor. If there is no | ||
18724 | - successor, we really unchain the node to be deleted. */ | ||
18725 | - | ||
18726 | - root = *rootp; | ||
18727 | - | ||
18728 | - r = root->right; | ||
18729 | - q = root->left; | ||
18730 | - | ||
18731 | - if (q == NULL || r == NULL) | ||
18732 | - unchained = root; | ||
18733 | - else | ||
18734 | - { | ||
18735 | - node *parent = rootp, *up = &root->right; | ||
18736 | - for (;;) | ||
18737 | - { | ||
18738 | - if (sp == stacksize) | ||
18739 | - abort (); | ||
18740 | - nodestack[sp++] = parent; | ||
18741 | - parent = up; | ||
18742 | - if ((*up)->left == NULL) | ||
18743 | - break; | ||
18744 | - up = &(*up)->left; | ||
18745 | - } | ||
18746 | - unchained = *up; | ||
18747 | - } | ||
18748 | - | ||
18749 | - /* We know that either the left or right successor of UNCHAINED is NULL. | ||
18750 | - R becomes the other one, it is chained into the parent of UNCHAINED. */ | ||
18751 | - r = unchained->left; | ||
18752 | - if (r == NULL) | ||
18753 | - r = unchained->right; | ||
18754 | - if (sp == 0) | ||
18755 | - *rootp = r; | ||
18756 | - else | ||
18757 | - { | ||
18758 | - q = *nodestack[sp-1]; | ||
18759 | - if (unchained == q->right) | ||
18760 | - q->right = r; | ||
18761 | - else | ||
18762 | - q->left = r; | ||
18763 | - } | ||
18764 | - | ||
18765 | - if (unchained != root) | ||
18766 | - root->key = unchained->key; | ||
18767 | - if (!unchained->red) | ||
18768 | - { | ||
18769 | - /* Now we lost a black edge, which means that the number of black | ||
18770 | - edges on every path is no longer constant. We must balance the | ||
18771 | - tree. */ | ||
18772 | - /* NODESTACK now contains all parents of R. R is likely to be NULL | ||
18773 | - in the first iteration. */ | ||
18774 | - /* NULL nodes are considered black throughout - this is necessary for | ||
18775 | - correctness. */ | ||
18776 | - while (sp > 0 && (r == NULL || !r->red)) | ||
18777 | - { | ||
18778 | - node *pp = nodestack[sp - 1]; | ||
18779 | - p = *pp; | ||
18780 | - /* Two symmetric cases. */ | ||
18781 | - if (r == p->left) | ||
18782 | - { | ||
18783 | - /* Q is R's brother, P is R's parent. The subtree with root | ||
18784 | - R has one black edge less than the subtree with root Q. */ | ||
18785 | - q = p->right; | ||
18786 | - if (q->red) | ||
18787 | - { | ||
18788 | - /* If Q is red, we know that P is black. We rotate P left | ||
18789 | - so that Q becomes the top node in the tree, with P below | ||
18790 | - it. P is colored red, Q is colored black. | ||
18791 | - This action does not change the black edge count for any | ||
18792 | - leaf in the tree, but we will be able to recognize one | ||
18793 | - of the following situations, which all require that Q | ||
18794 | - is black. */ | ||
18795 | - q->red = 0; | ||
18796 | - p->red = 1; | ||
18797 | - /* Left rotate p. */ | ||
18798 | - p->right = q->left; | ||
18799 | - q->left = p; | ||
18800 | - *pp = q; | ||
18801 | - /* Make sure pp is right if the case below tries to use | ||
18802 | - it. */ | ||
18803 | - nodestack[sp++] = pp = &q->left; | ||
18804 | - q = p->right; | ||
18805 | - } | ||
18806 | - /* We know that Q can't be NULL here. We also know that Q is | ||
18807 | - black. */ | ||
18808 | - if ((q->left == NULL || !q->left->red) | ||
18809 | - && (q->right == NULL || !q->right->red)) | ||
18810 | - { | ||
18811 | - /* Q has two black successors. We can simply color Q red. | ||
18812 | - The whole subtree with root P is now missing one black | ||
18813 | - edge. Note that this action can temporarily make the | ||
18814 | - tree invalid (if P is red). But we will exit the loop | ||
18815 | - in that case and set P black, which both makes the tree | ||
18816 | - valid and also makes the black edge count come out | ||
18817 | - right. If P is black, we are at least one step closer | ||
18818 | - to the root and we'll try again the next iteration. */ | ||
18819 | - q->red = 1; | ||
18820 | - r = p; | ||
18821 | - } | ||
18822 | - else | ||
18823 | - { | ||
18824 | - /* Q is black, one of Q's successors is red. We can | ||
18825 | - repair the tree with one operation and will exit the | ||
18826 | - loop afterwards. */ | ||
18827 | - if (q->right == NULL || !q->right->red) | ||
18828 | - { | ||
18829 | - /* The left one is red. We perform the same action as | ||
18830 | - in maybe_split_for_insert where two red edges are | ||
18831 | - adjacent but point in different directions: | ||
18832 | - Q's left successor (let's call it Q2) becomes the | ||
18833 | - top of the subtree we are looking at, its parent (Q) | ||
18834 | - and grandparent (P) become its successors. The former | ||
18835 | - successors of Q2 are placed below P and Q. | ||
18836 | - P becomes black, and Q2 gets the color that P had. | ||
18837 | - This changes the black edge count only for node R and | ||
18838 | - its successors. */ | ||
18839 | - node q2 = q->left; | ||
18840 | - q2->red = p->red; | ||
18841 | - p->right = q2->left; | ||
18842 | - q->left = q2->right; | ||
18843 | - q2->right = q; | ||
18844 | - q2->left = p; | ||
18845 | - *pp = q2; | ||
18846 | - p->red = 0; | ||
18847 | - } | ||
18848 | - else | ||
18849 | - { | ||
18850 | - /* It's the right one. Rotate P left. P becomes black, | ||
18851 | - and Q gets the color that P had. Q's right successor | ||
18852 | - also becomes black. This changes the black edge | ||
18853 | - count only for node R and its successors. */ | ||
18854 | - q->red = p->red; | ||
18855 | - p->red = 0; | ||
18856 | - | ||
18857 | - q->right->red = 0; | ||
18858 | - | ||
18859 | - /* left rotate p */ | ||
18860 | - p->right = q->left; | ||
18861 | - q->left = p; | ||
18862 | - *pp = q; | ||
18863 | - } | ||
18864 | - | ||
18865 | - /* We're done. */ | ||
18866 | - sp = 1; | ||
18867 | - r = NULL; | ||
18868 | - } | ||
18869 | - } | ||
18870 | - else | ||
18871 | - { | ||
18872 | - /* Comments: see above. */ | ||
18873 | - q = p->left; | ||
18874 | - if (q->red) | ||
18875 | - { | ||
18876 | - q->red = 0; | ||
18877 | - p->red = 1; | ||
18878 | - p->left = q->right; | ||
18879 | - q->right = p; | ||
18880 | - *pp = q; | ||
18881 | - nodestack[sp++] = pp = &q->right; | ||
18882 | - q = p->left; | ||
18883 | - } | ||
18884 | - if ((q->right == NULL || !q->right->red) | ||
18885 | - && (q->left == NULL || !q->left->red)) | ||
18886 | - { | ||
18887 | - q->red = 1; | ||
18888 | - r = p; | ||
18889 | - } | ||
18890 | - else | ||
18891 | - { | ||
18892 | - if (q->left == NULL || !q->left->red) | ||
18893 | - { | ||
18894 | - node q2 = q->right; | ||
18895 | - q2->red = p->red; | ||
18896 | - p->left = q2->right; | ||
18897 | - q->right = q2->left; | ||
18898 | - q2->left = q; | ||
18899 | - q2->right = p; | ||
18900 | - *pp = q2; | ||
18901 | - p->red = 0; | ||
18902 | - } | ||
18903 | - else | ||
18904 | - { | ||
18905 | - q->red = p->red; | ||
18906 | - p->red = 0; | ||
18907 | - q->left->red = 0; | ||
18908 | - p->left = q->right; | ||
18909 | - q->right = p; | ||
18910 | - *pp = q; | ||
18911 | - } | ||
18912 | - sp = 1; | ||
18913 | - r = NULL; | ||
18914 | - } | ||
18915 | - } | ||
18916 | - --sp; | ||
18917 | - } | ||
18918 | - if (r != NULL) | ||
18919 | - r->red = 0; | ||
18920 | - } | ||
18921 | - | ||
18922 | - free (unchained); | ||
18923 | - return retval; | ||
18924 | -} | ||
18925 | -#ifdef weak_alias | ||
18926 | -weak_alias (__tdelete, tdelete) | ||
18927 | -#endif | ||
18928 | - | ||
18929 | - | ||
18930 | -/* Walk the nodes of a tree. | ||
18931 | - ROOT is the root of the tree to be walked, ACTION the function to be | ||
18932 | - called at each node. LEVEL is the level of ROOT in the whole tree. */ | ||
18933 | -static void | ||
18934 | -internal_function | ||
18935 | -trecurse (const void *vroot, __action_fn_t action, int level) | ||
18936 | -{ | ||
18937 | - const_node root = (const_node) vroot; | ||
18938 | - | ||
18939 | - if (root->left == NULL && root->right == NULL) | ||
18940 | - (*action) (root, leaf, level); | ||
18941 | - else | ||
18942 | - { | ||
18943 | - (*action) (root, preorder, level); | ||
18944 | - if (root->left != NULL) | ||
18945 | - trecurse (root->left, action, level + 1); | ||
18946 | - (*action) (root, postorder, level); | ||
18947 | - if (root->right != NULL) | ||
18948 | - trecurse (root->right, action, level + 1); | ||
18949 | - (*action) (root, endorder, level); | ||
18950 | - } | ||
18951 | -} | ||
18952 | - | ||
18953 | - | ||
18954 | -/* Walk the nodes of a tree. | ||
18955 | - ROOT is the root of the tree to be walked, ACTION the function to be | ||
18956 | - called at each node. */ | ||
18957 | -void | ||
18958 | -__twalk (const void *vroot, __action_fn_t action) | ||
18959 | -{ | ||
18960 | - const_node root = (const_node) vroot; | ||
18961 | - | ||
18962 | - CHECK_TREE (root); | ||
18963 | - | ||
18964 | - if (root != NULL && action != NULL) | ||
18965 | - trecurse (root, action, 0); | ||
18966 | -} | ||
18967 | -#ifdef weak_alias | ||
18968 | -weak_alias (__twalk, twalk) | ||
18969 | -#endif | ||
18970 | - | ||
18971 | - | ||
18972 | -#ifdef _LIBC | ||
18973 | - | ||
18974 | -/* The standardized functions miss an important functionality: the | ||
18975 | - tree cannot be removed easily. We provide a function to do this. */ | ||
18976 | -static void | ||
18977 | -internal_function | ||
18978 | -tdestroy_recurse (node root, __free_fn_t freefct) | ||
18979 | -{ | ||
18980 | - if (root->left != NULL) | ||
18981 | - tdestroy_recurse (root->left, freefct); | ||
18982 | - if (root->right != NULL) | ||
18983 | - tdestroy_recurse (root->right, freefct); | ||
18984 | - (*freefct) ((void *) root->key); | ||
18985 | - /* Free the node itself. */ | ||
18986 | - free (root); | ||
18987 | -} | ||
18988 | - | ||
18989 | -void | ||
18990 | -__tdestroy (void *vroot, __free_fn_t freefct) | ||
18991 | -{ | ||
18992 | - node root = (node) vroot; | ||
18993 | - | ||
18994 | - CHECK_TREE (root); | ||
18995 | - | ||
18996 | - if (root != NULL) | ||
18997 | - tdestroy_recurse (root, freefct); | ||
18998 | -} | ||
18999 | -weak_alias (__tdestroy, tdestroy) | ||
19000 | - | ||
19001 | -#endif /* _LIBC */ | ||
19002 | --- a/intl/tsearch.h | ||
19003 | +++ /dev/null | ||
19004 | @@ -1,83 +0,0 @@ | ||
19005 | -/* Binary tree data structure. | ||
19006 | - Copyright (C) 2006 Free Software Foundation, Inc. | ||
19007 | - | ||
19008 | - This program is free software; you can redistribute it and/or modify it | ||
19009 | - under the terms of the GNU Library General Public License as published | ||
19010 | - by the Free Software Foundation; either version 2, or (at your option) | ||
19011 | - any later version. | ||
19012 | - | ||
19013 | - This program is distributed in the hope that it will be useful, | ||
19014 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19015 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19016 | - Library General Public License for more details. | ||
19017 | - | ||
19018 | - You should have received a copy of the GNU Library General Public | ||
19019 | - License along with this program; if not, write to the Free Software | ||
19020 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
19021 | - USA. */ | ||
19022 | - | ||
19023 | -#ifndef _TSEARCH_H | ||
19024 | -#define _TSEARCH_H | ||
19025 | - | ||
19026 | -#if HAVE_TSEARCH | ||
19027 | - | ||
19028 | -/* Get tseach(), tfind(), tdelete(), twalk() declarations. */ | ||
19029 | -#include <search.h> | ||
19030 | - | ||
19031 | -#else | ||
19032 | - | ||
19033 | -#ifdef __cplusplus | ||
19034 | -extern "C" { | ||
19035 | -#endif | ||
19036 | - | ||
19037 | -/* See <http://www.opengroup.org/susv3xbd/search.h.html>, | ||
19038 | - <http://www.opengroup.org/susv3xsh/tsearch.html> | ||
19039 | - for details. */ | ||
19040 | - | ||
19041 | -typedef enum | ||
19042 | -{ | ||
19043 | - preorder, | ||
19044 | - postorder, | ||
19045 | - endorder, | ||
19046 | - leaf | ||
19047 | -} | ||
19048 | -VISIT; | ||
19049 | - | ||
19050 | -/* Searches an element in the tree *VROOTP that compares equal to KEY. | ||
19051 | - If one is found, it is returned. Otherwise, a new element equal to KEY | ||
19052 | - is inserted in the tree and is returned. */ | ||
19053 | -extern void * tsearch (const void *key, void **vrootp, | ||
19054 | - int (*compar) (const void *, const void *)); | ||
19055 | - | ||
19056 | -/* Searches an element in the tree *VROOTP that compares equal to KEY. | ||
19057 | - If one is found, it is returned. Otherwise, NULL is returned. */ | ||
19058 | -extern void * tfind (const void *key, void *const *vrootp, | ||
19059 | - int (*compar) (const void *, const void *)); | ||
19060 | - | ||
19061 | -/* Searches an element in the tree *VROOTP that compares equal to KEY. | ||
19062 | - If one is found, it is removed from the tree, and its parent node is | ||
19063 | - returned. Otherwise, NULL is returned. */ | ||
19064 | -extern void * tdelete (const void *key, void **vrootp, | ||
19065 | - int (*compar) (const void *, const void *)); | ||
19066 | - | ||
19067 | -/* Perform a depth-first, left-to-right traversal of the tree VROOT. | ||
19068 | - The ACTION function is called: | ||
19069 | - - for non-leaf nodes: 3 times, before the left subtree traversal, | ||
19070 | - after the left subtree traversal but before the right subtree traversal, | ||
19071 | - and after the right subtree traversal, | ||
19072 | - - for leaf nodes: once. | ||
19073 | - The arguments passed to ACTION are: | ||
19074 | - 1. the node; it can be casted to a 'const void * const *', i.e. into a | ||
19075 | - pointer to the key, | ||
19076 | - 2. an indicator which visit of the node this is, | ||
19077 | - 3. the level of the node in the tree (0 for the root). */ | ||
19078 | -extern void twalk (const void *vroot, | ||
19079 | - void (*action) (const void *, VISIT, int)); | ||
19080 | - | ||
19081 | -#ifdef __cplusplus | ||
19082 | -} | ||
19083 | -#endif | ||
19084 | - | ||
19085 | -#endif | ||
19086 | - | ||
19087 | -#endif /* _TSEARCH_H */ | ||
19088 | --- a/intl/vasnprintf.c | ||
19089 | +++ /dev/null | ||
19090 | @@ -1,4677 +0,0 @@ | ||
19091 | -/* vsprintf with automatic memory allocation. | ||
19092 | - Copyright (C) 1999, 2002-2007 Free Software Foundation, Inc. | ||
19093 | - | ||
19094 | - This program is free software; you can redistribute it and/or modify it | ||
19095 | - under the terms of the GNU Library General Public License as published | ||
19096 | - by the Free Software Foundation; either version 2, or (at your option) | ||
19097 | - any later version. | ||
19098 | - | ||
19099 | - This program is distributed in the hope that it will be useful, | ||
19100 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19101 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19102 | - Library General Public License for more details. | ||
19103 | - | ||
19104 | - You should have received a copy of the GNU Library General Public | ||
19105 | - License along with this program; if not, write to the Free Software | ||
19106 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
19107 | - USA. */ | ||
19108 | - | ||
19109 | -/* This file can be parametrized with the following macros: | ||
19110 | - VASNPRINTF The name of the function being defined. | ||
19111 | - FCHAR_T The element type of the format string. | ||
19112 | - DCHAR_T The element type of the destination (result) string. | ||
19113 | - FCHAR_T_ONLY_ASCII Set to 1 to enable verification that all characters | ||
19114 | - in the format string are ASCII. MUST be set if | ||
19115 | - FCHAR_T and DCHAR_T are not the same type. | ||
19116 | - DIRECTIVE Structure denoting a format directive. | ||
19117 | - Depends on FCHAR_T. | ||
19118 | - DIRECTIVES Structure denoting the set of format directives of a | ||
19119 | - format string. Depends on FCHAR_T. | ||
19120 | - PRINTF_PARSE Function that parses a format string. | ||
19121 | - Depends on FCHAR_T. | ||
19122 | - DCHAR_CPY memcpy like function for DCHAR_T[] arrays. | ||
19123 | - DCHAR_SET memset like function for DCHAR_T[] arrays. | ||
19124 | - DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays. | ||
19125 | - SNPRINTF The system's snprintf (or similar) function. | ||
19126 | - This may be either snprintf or swprintf. | ||
19127 | - TCHAR_T The element type of the argument and result string | ||
19128 | - of the said SNPRINTF function. This may be either | ||
19129 | - char or wchar_t. The code exploits that | ||
19130 | - sizeof (TCHAR_T) | sizeof (DCHAR_T) and | ||
19131 | - alignof (TCHAR_T) <= alignof (DCHAR_T). | ||
19132 | - DCHAR_IS_TCHAR Set to 1 if DCHAR_T and TCHAR_T are the same type. | ||
19133 | - DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. | ||
19134 | - DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. | ||
19135 | - DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. | ||
19136 | - DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */ | ||
19137 | - | ||
19138 | -/* Tell glibc's <stdio.h> to provide a prototype for snprintf(). | ||
19139 | - This must come before <config.h> because <config.h> may include | ||
19140 | - <features.h>, and once <features.h> has been included, it's too late. */ | ||
19141 | -#ifndef _GNU_SOURCE | ||
19142 | -# define _GNU_SOURCE 1 | ||
19143 | -#endif | ||
19144 | - | ||
19145 | -#ifndef VASNPRINTF | ||
19146 | -# include <config.h> | ||
19147 | -#endif | ||
19148 | -#ifndef IN_LIBINTL | ||
19149 | -# include <alloca.h> | ||
19150 | -#endif | ||
19151 | - | ||
19152 | -/* Specification. */ | ||
19153 | -#ifndef VASNPRINTF | ||
19154 | -# if WIDE_CHAR_VERSION | ||
19155 | -# include "vasnwprintf.h" | ||
19156 | -# else | ||
19157 | -# include "vasnprintf.h" | ||
19158 | -# endif | ||
19159 | -#endif | ||
19160 | - | ||
19161 | -#include <locale.h> /* localeconv() */ | ||
19162 | -#include <stdio.h> /* snprintf(), sprintf() */ | ||
19163 | -#include <stdlib.h> /* abort(), malloc(), realloc(), free() */ | ||
19164 | -#include <string.h> /* memcpy(), strlen() */ | ||
19165 | -#include <errno.h> /* errno */ | ||
19166 | -#include <limits.h> /* CHAR_BIT */ | ||
19167 | -#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ | ||
19168 | -#if HAVE_NL_LANGINFO | ||
19169 | -# include <langinfo.h> | ||
19170 | -#endif | ||
19171 | -#ifndef VASNPRINTF | ||
19172 | -# if WIDE_CHAR_VERSION | ||
19173 | -# include "wprintf-parse.h" | ||
19174 | -# else | ||
19175 | -# include "printf-parse.h" | ||
19176 | -# endif | ||
19177 | -#endif | ||
19178 | - | ||
19179 | -/* Checked size_t computations. */ | ||
19180 | -#include "xsize.h" | ||
19181 | - | ||
19182 | -#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL | ||
19183 | -# include <math.h> | ||
19184 | -# include "float+.h" | ||
19185 | -#endif | ||
19186 | - | ||
19187 | -#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL | ||
19188 | -# include <math.h> | ||
19189 | -# include "isnan.h" | ||
19190 | -#endif | ||
19191 | - | ||
19192 | -#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL | ||
19193 | -# include <math.h> | ||
19194 | -# include "isnanl-nolibm.h" | ||
19195 | -# include "fpucw.h" | ||
19196 | -#endif | ||
19197 | - | ||
19198 | -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL | ||
19199 | -# include <math.h> | ||
19200 | -# include "isnan.h" | ||
19201 | -# include "printf-frexp.h" | ||
19202 | -#endif | ||
19203 | - | ||
19204 | -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL | ||
19205 | -# include <math.h> | ||
19206 | -# include "isnanl-nolibm.h" | ||
19207 | -# include "printf-frexpl.h" | ||
19208 | -# include "fpucw.h" | ||
19209 | -#endif | ||
19210 | - | ||
19211 | -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ | ||
19212 | -#ifndef EOVERFLOW | ||
19213 | -# define EOVERFLOW E2BIG | ||
19214 | -#endif | ||
19215 | - | ||
19216 | -#if HAVE_WCHAR_T | ||
19217 | -# if HAVE_WCSLEN | ||
19218 | -# define local_wcslen wcslen | ||
19219 | -# else | ||
19220 | - /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid | ||
19221 | - a dependency towards this library, here is a local substitute. | ||
19222 | - Define this substitute only once, even if this file is included | ||
19223 | - twice in the same compilation unit. */ | ||
19224 | -# ifndef local_wcslen_defined | ||
19225 | -# define local_wcslen_defined 1 | ||
19226 | -static size_t | ||
19227 | -local_wcslen (const wchar_t *s) | ||
19228 | -{ | ||
19229 | - const wchar_t *ptr; | ||
19230 | - | ||
19231 | - for (ptr = s; *ptr != (wchar_t) 0; ptr++) | ||
19232 | - ; | ||
19233 | - return ptr - s; | ||
19234 | -} | ||
19235 | -# endif | ||
19236 | -# endif | ||
19237 | -#endif | ||
19238 | - | ||
19239 | -/* Default parameters. */ | ||
19240 | -#ifndef VASNPRINTF | ||
19241 | -# if WIDE_CHAR_VERSION | ||
19242 | -# define VASNPRINTF vasnwprintf | ||
19243 | -# define FCHAR_T wchar_t | ||
19244 | -# define DCHAR_T wchar_t | ||
19245 | -# define TCHAR_T wchar_t | ||
19246 | -# define DCHAR_IS_TCHAR 1 | ||
19247 | -# define DIRECTIVE wchar_t_directive | ||
19248 | -# define DIRECTIVES wchar_t_directives | ||
19249 | -# define PRINTF_PARSE wprintf_parse | ||
19250 | -# define DCHAR_CPY wmemcpy | ||
19251 | -# else | ||
19252 | -# define VASNPRINTF vasnprintf | ||
19253 | -# define FCHAR_T char | ||
19254 | -# define DCHAR_T char | ||
19255 | -# define TCHAR_T char | ||
19256 | -# define DCHAR_IS_TCHAR 1 | ||
19257 | -# define DIRECTIVE char_directive | ||
19258 | -# define DIRECTIVES char_directives | ||
19259 | -# define PRINTF_PARSE printf_parse | ||
19260 | -# define DCHAR_CPY memcpy | ||
19261 | -# endif | ||
19262 | -#endif | ||
19263 | -#if WIDE_CHAR_VERSION | ||
19264 | - /* TCHAR_T is wchar_t. */ | ||
19265 | -# define USE_SNPRINTF 1 | ||
19266 | -# if HAVE_DECL__SNWPRINTF | ||
19267 | - /* On Windows, the function swprintf() has a different signature than | ||
19268 | - on Unix; we use the _snwprintf() function instead. */ | ||
19269 | -# define SNPRINTF _snwprintf | ||
19270 | -# else | ||
19271 | - /* Unix. */ | ||
19272 | -# define SNPRINTF swprintf | ||
19273 | -# endif | ||
19274 | -#else | ||
19275 | - /* TCHAR_T is char. */ | ||
19276 | -# /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. | ||
19277 | - But don't use it on BeOS, since BeOS snprintf produces no output if the | ||
19278 | - size argument is >= 0x3000000. */ | ||
19279 | -# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ | ||
19280 | -# define USE_SNPRINTF 1 | ||
19281 | -# else | ||
19282 | -# define USE_SNPRINTF 0 | ||
19283 | -# endif | ||
19284 | -# if HAVE_DECL__SNPRINTF | ||
19285 | - /* Windows. */ | ||
19286 | -# define SNPRINTF _snprintf | ||
19287 | -# else | ||
19288 | - /* Unix. */ | ||
19289 | -# define SNPRINTF snprintf | ||
19290 | - /* Here we need to call the native snprintf, not rpl_snprintf. */ | ||
19291 | -# undef snprintf | ||
19292 | -# endif | ||
19293 | -#endif | ||
19294 | -/* Here we need to call the native sprintf, not rpl_sprintf. */ | ||
19295 | -#undef sprintf | ||
19296 | - | ||
19297 | -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL | ||
19298 | -/* Determine the decimal-point character according to the current locale. */ | ||
19299 | -# ifndef decimal_point_char_defined | ||
19300 | -# define decimal_point_char_defined 1 | ||
19301 | -static char | ||
19302 | -decimal_point_char () | ||
19303 | -{ | ||
19304 | - const char *point; | ||
19305 | - /* Determine it in a multithread-safe way. We know nl_langinfo is | ||
19306 | - multithread-safe on glibc systems, but is not required to be multithread- | ||
19307 | - safe by POSIX. sprintf(), however, is multithread-safe. localeconv() | ||
19308 | - is rarely multithread-safe. */ | ||
19309 | -# if HAVE_NL_LANGINFO && __GLIBC__ | ||
19310 | - point = nl_langinfo (RADIXCHAR); | ||
19311 | -# elif 1 | ||
19312 | - char pointbuf[5]; | ||
19313 | - sprintf (pointbuf, "%#.0f", 1.0); | ||
19314 | - point = &pointbuf[1]; | ||
19315 | -# else | ||
19316 | - point = localeconv () -> decimal_point; | ||
19317 | -# endif | ||
19318 | - /* The decimal point is always a single byte: either '.' or ','. */ | ||
19319 | - return (point[0] != '\0' ? point[0] : '.'); | ||
19320 | -} | ||
19321 | -# endif | ||
19322 | -#endif | ||
19323 | - | ||
19324 | -#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL | ||
19325 | - | ||
19326 | -/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ | ||
19327 | -static int | ||
19328 | -is_infinite_or_zero (double x) | ||
19329 | -{ | ||
19330 | - return isnan (x) || x + x == x; | ||
19331 | -} | ||
19332 | - | ||
19333 | -#endif | ||
19334 | - | ||
19335 | -#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL | ||
19336 | - | ||
19337 | -/* Equivalent to !isfinite(x), but does not require libm. */ | ||
19338 | -static int | ||
19339 | -is_infinitel (long double x) | ||
19340 | -{ | ||
19341 | - return isnanl (x) || (x + x == x && x != 0.0L); | ||
19342 | -} | ||
19343 | - | ||
19344 | -#endif | ||
19345 | - | ||
19346 | -#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL | ||
19347 | - | ||
19348 | -/* Converting 'long double' to decimal without rare rounding bugs requires | ||
19349 | - real bignums. We use the naming conventions of GNU gmp, but vastly simpler | ||
19350 | - (and slower) algorithms. */ | ||
19351 | - | ||
19352 | -typedef unsigned int mp_limb_t; | ||
19353 | -# define GMP_LIMB_BITS 32 | ||
19354 | -typedef int mp_limb_verify[2 * (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS) - 1]; | ||
19355 | - | ||
19356 | -typedef unsigned long long mp_twolimb_t; | ||
19357 | -# define GMP_TWOLIMB_BITS 64 | ||
19358 | -typedef int mp_twolimb_verify[2 * (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS) - 1]; | ||
19359 | - | ||
19360 | -/* Representation of a bignum >= 0. */ | ||
19361 | -typedef struct | ||
19362 | -{ | ||
19363 | - size_t nlimbs; | ||
19364 | - mp_limb_t *limbs; /* Bits in little-endian order, allocated with malloc(). */ | ||
19365 | -} mpn_t; | ||
19366 | - | ||
19367 | -/* Compute the product of two bignums >= 0. | ||
19368 | - Return the allocated memory in case of success, NULL in case of memory | ||
19369 | - allocation failure. */ | ||
19370 | -static void * | ||
19371 | -multiply (mpn_t src1, mpn_t src2, mpn_t *dest) | ||
19372 | -{ | ||
19373 | - const mp_limb_t *p1; | ||
19374 | - const mp_limb_t *p2; | ||
19375 | - size_t len1; | ||
19376 | - size_t len2; | ||
19377 | - | ||
19378 | - if (src1.nlimbs <= src2.nlimbs) | ||
19379 | - { | ||
19380 | - len1 = src1.nlimbs; | ||
19381 | - p1 = src1.limbs; | ||
19382 | - len2 = src2.nlimbs; | ||
19383 | - p2 = src2.limbs; | ||
19384 | - } | ||
19385 | - else | ||
19386 | - { | ||
19387 | - len1 = src2.nlimbs; | ||
19388 | - p1 = src2.limbs; | ||
19389 | - len2 = src1.nlimbs; | ||
19390 | - p2 = src1.limbs; | ||
19391 | - } | ||
19392 | - /* Now 0 <= len1 <= len2. */ | ||
19393 | - if (len1 == 0) | ||
19394 | - { | ||
19395 | - /* src1 or src2 is zero. */ | ||
19396 | - dest->nlimbs = 0; | ||
19397 | - dest->limbs = (mp_limb_t *) malloc (1); | ||
19398 | - } | ||
19399 | - else | ||
19400 | - { | ||
19401 | - /* Here 1 <= len1 <= len2. */ | ||
19402 | - size_t dlen; | ||
19403 | - mp_limb_t *dp; | ||
19404 | - size_t k, i, j; | ||
19405 | - | ||
19406 | - dlen = len1 + len2; | ||
19407 | - dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t)); | ||
19408 | - if (dp == NULL) | ||
19409 | - return NULL; | ||
19410 | - for (k = len2; k > 0; ) | ||
19411 | - dp[--k] = 0; | ||
19412 | - for (i = 0; i < len1; i++) | ||
19413 | - { | ||
19414 | - mp_limb_t digit1 = p1[i]; | ||
19415 | - mp_twolimb_t carry = 0; | ||
19416 | - for (j = 0; j < len2; j++) | ||
19417 | - { | ||
19418 | - mp_limb_t digit2 = p2[j]; | ||
19419 | - carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; | ||
19420 | - carry += dp[i + j]; | ||
19421 | - dp[i + j] = (mp_limb_t) carry; | ||
19422 | - carry = carry >> GMP_LIMB_BITS; | ||
19423 | - } | ||
19424 | - dp[i + len2] = (mp_limb_t) carry; | ||
19425 | - } | ||
19426 | - /* Normalise. */ | ||
19427 | - while (dlen > 0 && dp[dlen - 1] == 0) | ||
19428 | - dlen--; | ||
19429 | - dest->nlimbs = dlen; | ||
19430 | - dest->limbs = dp; | ||
19431 | - } | ||
19432 | - return dest->limbs; | ||
19433 | -} | ||
19434 | - | ||
19435 | -/* Compute the quotient of a bignum a >= 0 and a bignum b > 0. | ||
19436 | - a is written as a = q * b + r with 0 <= r < b. q is the quotient, r | ||
19437 | - the remainder. | ||
19438 | - Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd, | ||
19439 | - q is incremented. | ||
19440 | - Return the allocated memory in case of success, NULL in case of memory | ||
19441 | - allocation failure. */ | ||
19442 | -static void * | ||
19443 | -divide (mpn_t a, mpn_t b, mpn_t *q) | ||
19444 | -{ | ||
19445 | - /* Algorithm: | ||
19446 | - First normalise a and b: a=[a[m-1],...,a[0]], b=[b[n-1],...,b[0]] | ||
19447 | - with m>=0 and n>0 (in base beta = 2^GMP_LIMB_BITS). | ||
19448 | - If m<n, then q:=0 and r:=a. | ||
19449 | - If m>=n=1, perform a single-precision division: | ||
19450 | - r:=0, j:=m, | ||
19451 | - while j>0 do | ||
19452 | - {Here (q[m-1]*beta^(m-1)+...+q[j]*beta^j) * b[0] + r*beta^j = | ||
19453 | - = a[m-1]*beta^(m-1)+...+a[j]*beta^j und 0<=r<b[0]<beta} | ||
19454 | - j:=j-1, r:=r*beta+a[j], q[j]:=floor(r/b[0]), r:=r-b[0]*q[j]. | ||
19455 | - Normalise [q[m-1],...,q[0]], yields q. | ||
19456 | - If m>=n>1, perform a multiple-precision division: | ||
19457 | - We have a/b < beta^(m-n+1). | ||
19458 | - s:=intDsize-1-(hightest bit in b[n-1]), 0<=s<intDsize. | ||
19459 | - Shift a and b left by s bits, copying them. r:=a. | ||
19460 | - r=[r[m],...,r[0]], b=[b[n-1],...,b[0]] with b[n-1]>=beta/2. | ||
19461 | - For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).} | ||
19462 | - Compute q* : | ||
19463 | - q* := floor((r[j+n]*beta+r[j+n-1])/b[n-1]). | ||
19464 | - In case of overflow (q* >= beta) set q* := beta-1. | ||
19465 | - Compute c2 := ((r[j+n]*beta+r[j+n-1]) - q* * b[n-1])*beta + r[j+n-2] | ||
19466 | - and c3 := b[n-2] * q*. | ||
19467 | - {We have 0 <= c2 < 2*beta^2, even 0 <= c2 < beta^2 if no overflow | ||
19468 | - occurred. Furthermore 0 <= c3 < beta^2. | ||
19469 | - If there was overflow and | ||
19470 | - r[j+n]*beta+r[j+n-1] - q* * b[n-1] >= beta, i.e. c2 >= beta^2, | ||
19471 | - the next test can be skipped.} | ||
19472 | - While c3 > c2, {Here 0 <= c2 < c3 < beta^2} | ||
19473 | - Put q* := q* - 1, c2 := c2 + b[n-1]*beta, c3 := c3 - b[n-2]. | ||
19474 | - If q* > 0: | ||
19475 | - Put r := r - b * q* * beta^j. In detail: | ||
19476 | - [r[n+j],...,r[j]] := [r[n+j],...,r[j]] - q* * [b[n-1],...,b[0]]. | ||
19477 | - hence: u:=0, for i:=0 to n-1 do | ||
19478 | - u := u + q* * b[i], | ||
19479 | - r[j+i]:=r[j+i]-(u mod beta) (+ beta, if carry), | ||
19480 | - u:=u div beta (+ 1, if carry in subtraction) | ||
19481 | - r[n+j]:=r[n+j]-u. | ||
19482 | - {Since always u = (q* * [b[i-1],...,b[0]] div beta^i) + 1 | ||
19483 | - < q* + 1 <= beta, | ||
19484 | - the carry u does not overflow.} | ||
19485 | - If a negative carry occurs, put q* := q* - 1 | ||
19486 | - and [r[n+j],...,r[j]] := [r[n+j],...,r[j]] + [0,b[n-1],...,b[0]]. | ||
19487 | - Set q[j] := q*. | ||
19488 | - Normalise [q[m-n],..,q[0]]; this yields the quotient q. | ||
19489 | - Shift [r[n-1],...,r[0]] right by s bits and normalise; this yields the | ||
19490 | - rest r. | ||
19491 | - The room for q[j] can be allocated at the memory location of r[n+j]. | ||
19492 | - Finally, round-to-even: | ||
19493 | - Shift r left by 1 bit. | ||
19494 | - If r > b or if r = b and q[0] is odd, q := q+1. | ||
19495 | - */ | ||
19496 | - const mp_limb_t *a_ptr = a.limbs; | ||
19497 | - size_t a_len = a.nlimbs; | ||
19498 | - const mp_limb_t *b_ptr = b.limbs; | ||
19499 | - size_t b_len = b.nlimbs; | ||
19500 | - mp_limb_t *roomptr; | ||
19501 | - mp_limb_t *tmp_roomptr = NULL; | ||
19502 | - mp_limb_t *q_ptr; | ||
19503 | - size_t q_len; | ||
19504 | - mp_limb_t *r_ptr; | ||
19505 | - size_t r_len; | ||
19506 | - | ||
19507 | - /* Allocate room for a_len+2 digits. | ||
19508 | - (Need a_len+1 digits for the real division and 1 more digit for the | ||
19509 | - final rounding of q.) */ | ||
19510 | - roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t)); | ||
19511 | - if (roomptr == NULL) | ||
19512 | - return NULL; | ||
19513 | - | ||
19514 | - /* Normalise a. */ | ||
19515 | - while (a_len > 0 && a_ptr[a_len - 1] == 0) | ||
19516 | - a_len--; | ||
19517 | - | ||
19518 | - /* Normalise b. */ | ||
19519 | - for (;;) | ||
19520 | - { | ||
19521 | - if (b_len == 0) | ||
19522 | - /* Division by zero. */ | ||
19523 | - abort (); | ||
19524 | - if (b_ptr[b_len - 1] == 0) | ||
19525 | - b_len--; | ||
19526 | - else | ||
19527 | - break; | ||
19528 | - } | ||
19529 | - | ||
19530 | - /* Here m = a_len >= 0 and n = b_len > 0. */ | ||
19531 | - | ||
19532 | - if (a_len < b_len) | ||
19533 | - { | ||
19534 | - /* m<n: trivial case. q=0, r := copy of a. */ | ||
19535 | - r_ptr = roomptr; | ||
19536 | - r_len = a_len; | ||
19537 | - memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); | ||
19538 | - q_ptr = roomptr + a_len; | ||
19539 | - q_len = 0; | ||
19540 | - } | ||
19541 | - else if (b_len == 1) | ||
19542 | - { | ||
19543 | - /* n=1: single precision division. | ||
19544 | - beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */ | ||
19545 | - r_ptr = roomptr; | ||
19546 | - q_ptr = roomptr + 1; | ||
19547 | - { | ||
19548 | - mp_limb_t den = b_ptr[0]; | ||
19549 | - mp_limb_t remainder = 0; | ||
19550 | - const mp_limb_t *sourceptr = a_ptr + a_len; | ||
19551 | - mp_limb_t *destptr = q_ptr + a_len; | ||
19552 | - size_t count; | ||
19553 | - for (count = a_len; count > 0; count--) | ||
19554 | - { | ||
19555 | - mp_twolimb_t num = | ||
19556 | - ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; | ||
19557 | - *--destptr = num / den; | ||
19558 | - remainder = num % den; | ||
19559 | - } | ||
19560 | - /* Normalise and store r. */ | ||
19561 | - if (remainder > 0) | ||
19562 | - { | ||
19563 | - r_ptr[0] = remainder; | ||
19564 | - r_len = 1; | ||
19565 | - } | ||
19566 | - else | ||
19567 | - r_len = 0; | ||
19568 | - /* Normalise q. */ | ||
19569 | - q_len = a_len; | ||
19570 | - if (q_ptr[q_len - 1] == 0) | ||
19571 | - q_len--; | ||
19572 | - } | ||
19573 | - } | ||
19574 | - else | ||
19575 | - { | ||
19576 | - /* n>1: multiple precision division. | ||
19577 | - beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==> | ||
19578 | - beta^(m-n-1) <= a/b < beta^(m-n+1). */ | ||
19579 | - /* Determine s. */ | ||
19580 | - size_t s; | ||
19581 | - { | ||
19582 | - mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ | ||
19583 | - s = 31; | ||
19584 | - if (msd >= 0x10000) | ||
19585 | - { | ||
19586 | - msd = msd >> 16; | ||
19587 | - s -= 16; | ||
19588 | - } | ||
19589 | - if (msd >= 0x100) | ||
19590 | - { | ||
19591 | - msd = msd >> 8; | ||
19592 | - s -= 8; | ||
19593 | - } | ||
19594 | - if (msd >= 0x10) | ||
19595 | - { | ||
19596 | - msd = msd >> 4; | ||
19597 | - s -= 4; | ||
19598 | - } | ||
19599 | - if (msd >= 0x4) | ||
19600 | - { | ||
19601 | - msd = msd >> 2; | ||
19602 | - s -= 2; | ||
19603 | - } | ||
19604 | - if (msd >= 0x2) | ||
19605 | - { | ||
19606 | - msd = msd >> 1; | ||
19607 | - s -= 1; | ||
19608 | - } | ||
19609 | - } | ||
19610 | - /* 0 <= s < GMP_LIMB_BITS. | ||
19611 | - Copy b, shifting it left by s bits. */ | ||
19612 | - if (s > 0) | ||
19613 | - { | ||
19614 | - tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t)); | ||
19615 | - if (tmp_roomptr == NULL) | ||
19616 | - { | ||
19617 | - free (roomptr); | ||
19618 | - return NULL; | ||
19619 | - } | ||
19620 | - { | ||
19621 | - const mp_limb_t *sourceptr = b_ptr; | ||
19622 | - mp_limb_t *destptr = tmp_roomptr; | ||
19623 | - mp_twolimb_t accu = 0; | ||
19624 | - size_t count; | ||
19625 | - for (count = b_len; count > 0; count--) | ||
19626 | - { | ||
19627 | - accu += (mp_twolimb_t) *sourceptr++ << s; | ||
19628 | - *destptr++ = (mp_limb_t) accu; | ||
19629 | - accu = accu >> GMP_LIMB_BITS; | ||
19630 | - } | ||
19631 | - /* accu must be zero, since that was how s was determined. */ | ||
19632 | - if (accu != 0) | ||
19633 | - abort (); | ||
19634 | - } | ||
19635 | - b_ptr = tmp_roomptr; | ||
19636 | - } | ||
19637 | - /* Copy a, shifting it left by s bits, yields r. | ||
19638 | - Memory layout: | ||
19639 | - At the beginning: r = roomptr[0..a_len], | ||
19640 | - at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */ | ||
19641 | - r_ptr = roomptr; | ||
19642 | - if (s == 0) | ||
19643 | - { | ||
19644 | - memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); | ||
19645 | - r_ptr[a_len] = 0; | ||
19646 | - } | ||
19647 | - else | ||
19648 | - { | ||
19649 | - const mp_limb_t *sourceptr = a_ptr; | ||
19650 | - mp_limb_t *destptr = r_ptr; | ||
19651 | - mp_twolimb_t accu = 0; | ||
19652 | - size_t count; | ||
19653 | - for (count = a_len; count > 0; count--) | ||
19654 | - { | ||
19655 | - accu += (mp_twolimb_t) *sourceptr++ << s; | ||
19656 | - *destptr++ = (mp_limb_t) accu; | ||
19657 | - accu = accu >> GMP_LIMB_BITS; | ||
19658 | - } | ||
19659 | - *destptr++ = (mp_limb_t) accu; | ||
19660 | - } | ||
19661 | - q_ptr = roomptr + b_len; | ||
19662 | - q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */ | ||
19663 | - { | ||
19664 | - size_t j = a_len - b_len; /* m-n */ | ||
19665 | - mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */ | ||
19666 | - mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */ | ||
19667 | - mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */ | ||
19668 | - ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd; | ||
19669 | - /* Division loop, traversed m-n+1 times. | ||
19670 | - j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */ | ||
19671 | - for (;;) | ||
19672 | - { | ||
19673 | - mp_limb_t q_star; | ||
19674 | - mp_limb_t c1; | ||
19675 | - if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */ | ||
19676 | - { | ||
19677 | - /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */ | ||
19678 | - mp_twolimb_t num = | ||
19679 | - ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS) | ||
19680 | - | r_ptr[j + b_len - 1]; | ||
19681 | - q_star = num / b_msd; | ||
19682 | - c1 = num % b_msd; | ||
19683 | - } | ||
19684 | - else | ||
19685 | - { | ||
19686 | - /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */ | ||
19687 | - q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */ | ||
19688 | - /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta | ||
19689 | - <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta | ||
19690 | - <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) | ||
19691 | - {<= beta !}. | ||
19692 | - If yes, jump directly to the subtraction loop. | ||
19693 | - (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta | ||
19694 | - <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */ | ||
19695 | - if (r_ptr[j + b_len] > b_msd | ||
19696 | - || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd) | ||
19697 | - /* r[j+n] >= b[n-1]+1 or | ||
19698 | - r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a | ||
19699 | - carry. */ | ||
19700 | - goto subtract; | ||
19701 | - } | ||
19702 | - /* q_star = q*, | ||
19703 | - c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */ | ||
19704 | - { | ||
19705 | - mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */ | ||
19706 | - ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2]; | ||
19707 | - mp_twolimb_t c3 = /* b[n-2] * q* */ | ||
19708 | - (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star; | ||
19709 | - /* While c2 < c3, increase c2 and decrease c3. | ||
19710 | - Consider c3-c2. While it is > 0, decrease it by | ||
19711 | - b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2 | ||
19712 | - this can happen only twice. */ | ||
19713 | - if (c3 > c2) | ||
19714 | - { | ||
19715 | - q_star = q_star - 1; /* q* := q* - 1 */ | ||
19716 | - if (c3 - c2 > b_msdd) | ||
19717 | - q_star = q_star - 1; /* q* := q* - 1 */ | ||
19718 | - } | ||
19719 | - } | ||
19720 | - if (q_star > 0) | ||
19721 | - subtract: | ||
19722 | - { | ||
19723 | - /* Subtract r := r - b * q* * beta^j. */ | ||
19724 | - mp_limb_t cr; | ||
19725 | - { | ||
19726 | - const mp_limb_t *sourceptr = b_ptr; | ||
19727 | - mp_limb_t *destptr = r_ptr + j; | ||
19728 | - mp_twolimb_t carry = 0; | ||
19729 | - size_t count; | ||
19730 | - for (count = b_len; count > 0; count--) | ||
19731 | - { | ||
19732 | - /* Here 0 <= carry <= q*. */ | ||
19733 | - carry = | ||
19734 | - carry | ||
19735 | - + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++ | ||
19736 | - + (mp_limb_t) ~(*destptr); | ||
19737 | - /* Here 0 <= carry <= beta*q* + beta-1. */ | ||
19738 | - *destptr++ = ~(mp_limb_t) carry; | ||
19739 | - carry = carry >> GMP_LIMB_BITS; /* <= q* */ | ||
19740 | - } | ||
19741 | - cr = (mp_limb_t) carry; | ||
19742 | - } | ||
19743 | - /* Subtract cr from r_ptr[j + b_len], then forget about | ||
19744 | - r_ptr[j + b_len]. */ | ||
19745 | - if (cr > r_ptr[j + b_len]) | ||
19746 | - { | ||
19747 | - /* Subtraction gave a carry. */ | ||
19748 | - q_star = q_star - 1; /* q* := q* - 1 */ | ||
19749 | - /* Add b back. */ | ||
19750 | - { | ||
19751 | - const mp_limb_t *sourceptr = b_ptr; | ||
19752 | - mp_limb_t *destptr = r_ptr + j; | ||
19753 | - mp_limb_t carry = 0; | ||
19754 | - size_t count; | ||
19755 | - for (count = b_len; count > 0; count--) | ||
19756 | - { | ||
19757 | - mp_limb_t source1 = *sourceptr++; | ||
19758 | - mp_limb_t source2 = *destptr; | ||
19759 | - *destptr++ = source1 + source2 + carry; | ||
19760 | - carry = | ||
19761 | - (carry | ||
19762 | - ? source1 >= (mp_limb_t) ~source2 | ||
19763 | - : source1 > (mp_limb_t) ~source2); | ||
19764 | - } | ||
19765 | - } | ||
19766 | - /* Forget about the carry and about r[j+n]. */ | ||
19767 | - } | ||
19768 | - } | ||
19769 | - /* q* is determined. Store it as q[j]. */ | ||
19770 | - q_ptr[j] = q_star; | ||
19771 | - if (j == 0) | ||
19772 | - break; | ||
19773 | - j--; | ||
19774 | - } | ||
19775 | - } | ||
19776 | - r_len = b_len; | ||
19777 | - /* Normalise q. */ | ||
19778 | - if (q_ptr[q_len - 1] == 0) | ||
19779 | - q_len--; | ||
19780 | -# if 0 /* Not needed here, since we need r only to compare it with b/2, and | ||
19781 | - b is shifted left by s bits. */ | ||
19782 | - /* Shift r right by s bits. */ | ||
19783 | - if (s > 0) | ||
19784 | - { | ||
19785 | - mp_limb_t ptr = r_ptr + r_len; | ||
19786 | - mp_twolimb_t accu = 0; | ||
19787 | - size_t count; | ||
19788 | - for (count = r_len; count > 0; count--) | ||
19789 | - { | ||
19790 | - accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; | ||
19791 | - accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); | ||
19792 | - *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS); | ||
19793 | - } | ||
19794 | - } | ||
19795 | -# endif | ||
19796 | - /* Normalise r. */ | ||
19797 | - while (r_len > 0 && r_ptr[r_len - 1] == 0) | ||
19798 | - r_len--; | ||
19799 | - } | ||
19800 | - /* Compare r << 1 with b. */ | ||
19801 | - if (r_len > b_len) | ||
19802 | - goto increment_q; | ||
19803 | - { | ||
19804 | - size_t i; | ||
19805 | - for (i = b_len;;) | ||
19806 | - { | ||
19807 | - mp_limb_t r_i = | ||
19808 | - (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) | ||
19809 | - | (i < r_len ? r_ptr[i] << 1 : 0); | ||
19810 | - mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); | ||
19811 | - if (r_i > b_i) | ||
19812 | - goto increment_q; | ||
19813 | - if (r_i < b_i) | ||
19814 | - goto keep_q; | ||
19815 | - if (i == 0) | ||
19816 | - break; | ||
19817 | - i--; | ||
19818 | - } | ||
19819 | - } | ||
19820 | - if (q_len > 0 && ((q_ptr[0] & 1) != 0)) | ||
19821 | - /* q is odd. */ | ||
19822 | - increment_q: | ||
19823 | - { | ||
19824 | - size_t i; | ||
19825 | - for (i = 0; i < q_len; i++) | ||
19826 | - if (++(q_ptr[i]) != 0) | ||
19827 | - goto keep_q; | ||
19828 | - q_ptr[q_len++] = 1; | ||
19829 | - } | ||
19830 | - keep_q: | ||
19831 | - if (tmp_roomptr != NULL) | ||
19832 | - free (tmp_roomptr); | ||
19833 | - q->limbs = q_ptr; | ||
19834 | - q->nlimbs = q_len; | ||
19835 | - return roomptr; | ||
19836 | -} | ||
19837 | - | ||
19838 | -/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal | ||
19839 | - representation. | ||
19840 | - Destroys the contents of a. | ||
19841 | - Return the allocated memory - containing the decimal digits in low-to-high | ||
19842 | - order, terminated with a NUL character - in case of success, NULL in case | ||
19843 | - of memory allocation failure. */ | ||
19844 | -static char * | ||
19845 | -convert_to_decimal (mpn_t a, size_t extra_zeroes) | ||
19846 | -{ | ||
19847 | - mp_limb_t *a_ptr = a.limbs; | ||
19848 | - size_t a_len = a.nlimbs; | ||
19849 | - /* 0.03345 is slightly larger than log(2)/(9*log(10)). */ | ||
19850 | - size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1); | ||
19851 | - char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes)); | ||
19852 | - if (c_ptr != NULL) | ||
19853 | - { | ||
19854 | - char *d_ptr = c_ptr; | ||
19855 | - for (; extra_zeroes > 0; extra_zeroes--) | ||
19856 | - *d_ptr++ = '0'; | ||
19857 | - while (a_len > 0) | ||
19858 | - { | ||
19859 | - /* Divide a by 10^9, in-place. */ | ||
19860 | - mp_limb_t remainder = 0; | ||
19861 | - mp_limb_t *ptr = a_ptr + a_len; | ||
19862 | - size_t count; | ||
19863 | - for (count = a_len; count > 0; count--) | ||
19864 | - { | ||
19865 | - mp_twolimb_t num = | ||
19866 | - ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; | ||
19867 | - *ptr = num / 1000000000; | ||
19868 | - remainder = num % 1000000000; | ||
19869 | - } | ||
19870 | - /* Store the remainder as 9 decimal digits. */ | ||
19871 | - for (count = 9; count > 0; count--) | ||
19872 | - { | ||
19873 | - *d_ptr++ = '0' + (remainder % 10); | ||
19874 | - remainder = remainder / 10; | ||
19875 | - } | ||
19876 | - /* Normalize a. */ | ||
19877 | - if (a_ptr[a_len - 1] == 0) | ||
19878 | - a_len--; | ||
19879 | - } | ||
19880 | - /* Remove leading zeroes. */ | ||
19881 | - while (d_ptr > c_ptr && d_ptr[-1] == '0') | ||
19882 | - d_ptr--; | ||
19883 | - /* But keep at least one zero. */ | ||
19884 | - if (d_ptr == c_ptr) | ||
19885 | - *d_ptr++ = '0'; | ||
19886 | - /* Terminate the string. */ | ||
19887 | - *d_ptr = '\0'; | ||
19888 | - } | ||
19889 | - return c_ptr; | ||
19890 | -} | ||
19891 | - | ||
19892 | -# if NEED_PRINTF_LONG_DOUBLE | ||
19893 | - | ||
19894 | -/* Assuming x is finite and >= 0: | ||
19895 | - write x as x = 2^e * m, where m is a bignum. | ||
19896 | - Return the allocated memory in case of success, NULL in case of memory | ||
19897 | - allocation failure. */ | ||
19898 | -static void * | ||
19899 | -decode_long_double (long double x, int *ep, mpn_t *mp) | ||
19900 | -{ | ||
19901 | - mpn_t m; | ||
19902 | - int exp; | ||
19903 | - long double y; | ||
19904 | - size_t i; | ||
19905 | - | ||
19906 | - /* Allocate memory for result. */ | ||
19907 | - m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; | ||
19908 | - m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); | ||
19909 | - if (m.limbs == NULL) | ||
19910 | - return NULL; | ||
19911 | - /* Split into exponential part and mantissa. */ | ||
19912 | - y = frexpl (x, &exp); | ||
19913 | - if (!(y >= 0.0L && y < 1.0L)) | ||
19914 | - abort (); | ||
19915 | - /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * LDBL_MANT_BIT), and the | ||
19916 | - latter is an integer. */ | ||
19917 | - /* Convert the mantissa (y * LDBL_MANT_BIT) to a sequence of limbs. | ||
19918 | - I'm not sure whether it's safe to cast a 'long double' value between | ||
19919 | - 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only | ||
19920 | - 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int', | ||
19921 | - doesn't matter). */ | ||
19922 | -# if (LDBL_MANT_BIT % GMP_LIMB_BITS) != 0 | ||
19923 | -# if (LDBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 | ||
19924 | - { | ||
19925 | - mp_limb_t hi, lo; | ||
19926 | - y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % (GMP_LIMB_BITS / 2)); | ||
19927 | - hi = (int) y; | ||
19928 | - y -= hi; | ||
19929 | - if (!(y >= 0.0L && y < 1.0L)) | ||
19930 | - abort (); | ||
19931 | - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); | ||
19932 | - lo = (int) y; | ||
19933 | - y -= lo; | ||
19934 | - if (!(y >= 0.0L && y < 1.0L)) | ||
19935 | - abort (); | ||
19936 | - m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; | ||
19937 | - } | ||
19938 | -# else | ||
19939 | - { | ||
19940 | - mp_limb_t d; | ||
19941 | - y *= (mp_limb_t) 1 << (LDBL_MANT_BIT % GMP_LIMB_BITS); | ||
19942 | - d = (int) y; | ||
19943 | - y -= d; | ||
19944 | - if (!(y >= 0.0L && y < 1.0L)) | ||
19945 | - abort (); | ||
19946 | - m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d; | ||
19947 | - } | ||
19948 | -# endif | ||
19949 | -# endif | ||
19950 | - for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) | ||
19951 | - { | ||
19952 | - mp_limb_t hi, lo; | ||
19953 | - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); | ||
19954 | - hi = (int) y; | ||
19955 | - y -= hi; | ||
19956 | - if (!(y >= 0.0L && y < 1.0L)) | ||
19957 | - abort (); | ||
19958 | - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); | ||
19959 | - lo = (int) y; | ||
19960 | - y -= lo; | ||
19961 | - if (!(y >= 0.0L && y < 1.0L)) | ||
19962 | - abort (); | ||
19963 | - m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; | ||
19964 | - } | ||
19965 | - if (!(y == 0.0L)) | ||
19966 | - abort (); | ||
19967 | - /* Normalise. */ | ||
19968 | - while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) | ||
19969 | - m.nlimbs--; | ||
19970 | - *mp = m; | ||
19971 | - *ep = exp - LDBL_MANT_BIT; | ||
19972 | - return m.limbs; | ||
19973 | -} | ||
19974 | - | ||
19975 | -# endif | ||
19976 | - | ||
19977 | -# if NEED_PRINTF_DOUBLE | ||
19978 | - | ||
19979 | -/* Assuming x is finite and >= 0: | ||
19980 | - write x as x = 2^e * m, where m is a bignum. | ||
19981 | - Return the allocated memory in case of success, NULL in case of memory | ||
19982 | - allocation failure. */ | ||
19983 | -static void * | ||
19984 | -decode_double (double x, int *ep, mpn_t *mp) | ||
19985 | -{ | ||
19986 | - mpn_t m; | ||
19987 | - int exp; | ||
19988 | - double y; | ||
19989 | - size_t i; | ||
19990 | - | ||
19991 | - /* Allocate memory for result. */ | ||
19992 | - m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; | ||
19993 | - m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); | ||
19994 | - if (m.limbs == NULL) | ||
19995 | - return NULL; | ||
19996 | - /* Split into exponential part and mantissa. */ | ||
19997 | - y = frexp (x, &exp); | ||
19998 | - if (!(y >= 0.0 && y < 1.0)) | ||
19999 | - abort (); | ||
20000 | - /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * DBL_MANT_BIT), and the | ||
20001 | - latter is an integer. */ | ||
20002 | - /* Convert the mantissa (y * DBL_MANT_BIT) to a sequence of limbs. | ||
20003 | - I'm not sure whether it's safe to cast a 'double' value between | ||
20004 | - 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only | ||
20005 | - 'double' values between 0 and 2^16 (to 'unsigned int' or 'int', | ||
20006 | - doesn't matter). */ | ||
20007 | -# if (DBL_MANT_BIT % GMP_LIMB_BITS) != 0 | ||
20008 | -# if (DBL_MANT_BIT % GMP_LIMB_BITS) > GMP_LIMB_BITS / 2 | ||
20009 | - { | ||
20010 | - mp_limb_t hi, lo; | ||
20011 | - y *= (mp_limb_t) 1 << (DBL_MANT_BIT % (GMP_LIMB_BITS / 2)); | ||
20012 | - hi = (int) y; | ||
20013 | - y -= hi; | ||
20014 | - if (!(y >= 0.0 && y < 1.0)) | ||
20015 | - abort (); | ||
20016 | - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); | ||
20017 | - lo = (int) y; | ||
20018 | - y -= lo; | ||
20019 | - if (!(y >= 0.0 && y < 1.0)) | ||
20020 | - abort (); | ||
20021 | - m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; | ||
20022 | - } | ||
20023 | -# else | ||
20024 | - { | ||
20025 | - mp_limb_t d; | ||
20026 | - y *= (mp_limb_t) 1 << (DBL_MANT_BIT % GMP_LIMB_BITS); | ||
20027 | - d = (int) y; | ||
20028 | - y -= d; | ||
20029 | - if (!(y >= 0.0 && y < 1.0)) | ||
20030 | - abort (); | ||
20031 | - m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d; | ||
20032 | - } | ||
20033 | -# endif | ||
20034 | -# endif | ||
20035 | - for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) | ||
20036 | - { | ||
20037 | - mp_limb_t hi, lo; | ||
20038 | - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); | ||
20039 | - hi = (int) y; | ||
20040 | - y -= hi; | ||
20041 | - if (!(y >= 0.0 && y < 1.0)) | ||
20042 | - abort (); | ||
20043 | - y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); | ||
20044 | - lo = (int) y; | ||
20045 | - y -= lo; | ||
20046 | - if (!(y >= 0.0 && y < 1.0)) | ||
20047 | - abort (); | ||
20048 | - m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; | ||
20049 | - } | ||
20050 | - if (!(y == 0.0)) | ||
20051 | - abort (); | ||
20052 | - /* Normalise. */ | ||
20053 | - while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) | ||
20054 | - m.nlimbs--; | ||
20055 | - *mp = m; | ||
20056 | - *ep = exp - DBL_MANT_BIT; | ||
20057 | - return m.limbs; | ||
20058 | -} | ||
20059 | - | ||
20060 | -# endif | ||
20061 | - | ||
20062 | -/* Assuming x = 2^e * m is finite and >= 0, and n is an integer: | ||
20063 | - Returns the decimal representation of round (x * 10^n). | ||
20064 | - Return the allocated memory - containing the decimal digits in low-to-high | ||
20065 | - order, terminated with a NUL character - in case of success, NULL in case | ||
20066 | - of memory allocation failure. */ | ||
20067 | -static char * | ||
20068 | -scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) | ||
20069 | -{ | ||
20070 | - int s; | ||
20071 | - size_t extra_zeroes; | ||
20072 | - unsigned int abs_n; | ||
20073 | - unsigned int abs_s; | ||
20074 | - mp_limb_t *pow5_ptr; | ||
20075 | - size_t pow5_len; | ||
20076 | - unsigned int s_limbs; | ||
20077 | - unsigned int s_bits; | ||
20078 | - mpn_t pow5; | ||
20079 | - mpn_t z; | ||
20080 | - void *z_memory; | ||
20081 | - char *digits; | ||
20082 | - | ||
20083 | - if (memory == NULL) | ||
20084 | - return NULL; | ||
20085 | - /* x = 2^e * m, hence | ||
20086 | - y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m) | ||
20087 | - = round (2^s * 5^n * m). */ | ||
20088 | - s = e + n; | ||
20089 | - extra_zeroes = 0; | ||
20090 | - /* Factor out a common power of 10 if possible. */ | ||
20091 | - if (s > 0 && n > 0) | ||
20092 | - { | ||
20093 | - extra_zeroes = (s < n ? s : n); | ||
20094 | - s -= extra_zeroes; | ||
20095 | - n -= extra_zeroes; | ||
20096 | - } | ||
20097 | - /* Here y = round (2^s * 5^n * m) * 10^extra_zeroes. | ||
20098 | - Before converting to decimal, we need to compute | ||
20099 | - z = round (2^s * 5^n * m). */ | ||
20100 | - /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same | ||
20101 | - sign. 2.322 is slightly larger than log(5)/log(2). */ | ||
20102 | - abs_n = (n >= 0 ? n : -n); | ||
20103 | - abs_s = (s >= 0 ? s : -s); | ||
20104 | - pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1 | ||
20105 | - + abs_s / GMP_LIMB_BITS + 1) | ||
20106 | - * sizeof (mp_limb_t)); | ||
20107 | - if (pow5_ptr == NULL) | ||
20108 | - { | ||
20109 | - free (memory); | ||
20110 | - return NULL; | ||
20111 | - } | ||
20112 | - /* Initialize with 1. */ | ||
20113 | - pow5_ptr[0] = 1; | ||
20114 | - pow5_len = 1; | ||
20115 | - /* Multiply with 5^|n|. */ | ||
20116 | - if (abs_n > 0) | ||
20117 | - { | ||
20118 | - static mp_limb_t const small_pow5[13 + 1] = | ||
20119 | - { | ||
20120 | - 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, | ||
20121 | - 48828125, 244140625, 1220703125 | ||
20122 | - }; | ||
20123 | - unsigned int n13; | ||
20124 | - for (n13 = 0; n13 <= abs_n; n13 += 13) | ||
20125 | - { | ||
20126 | - mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; | ||
20127 | - size_t j; | ||
20128 | - mp_twolimb_t carry = 0; | ||
20129 | - for (j = 0; j < pow5_len; j++) | ||
20130 | - { | ||
20131 | - mp_limb_t digit2 = pow5_ptr[j]; | ||
20132 | - carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; | ||
20133 | - pow5_ptr[j] = (mp_limb_t) carry; | ||
20134 | - carry = carry >> GMP_LIMB_BITS; | ||
20135 | - } | ||
20136 | - if (carry > 0) | ||
20137 | - pow5_ptr[pow5_len++] = (mp_limb_t) carry; | ||
20138 | - } | ||
20139 | - } | ||
20140 | - s_limbs = abs_s / GMP_LIMB_BITS; | ||
20141 | - s_bits = abs_s % GMP_LIMB_BITS; | ||
20142 | - if (n >= 0 ? s >= 0 : s <= 0) | ||
20143 | - { | ||
20144 | - /* Multiply with 2^|s|. */ | ||
20145 | - if (s_bits > 0) | ||
20146 | - { | ||
20147 | - mp_limb_t *ptr = pow5_ptr; | ||
20148 | - mp_twolimb_t accu = 0; | ||
20149 | - size_t count; | ||
20150 | - for (count = pow5_len; count > 0; count--) | ||
20151 | - { | ||
20152 | - accu += (mp_twolimb_t) *ptr << s_bits; | ||
20153 | - *ptr++ = (mp_limb_t) accu; | ||
20154 | - accu = accu >> GMP_LIMB_BITS; | ||
20155 | - } | ||
20156 | - if (accu > 0) | ||
20157 | - { | ||
20158 | - *ptr = (mp_limb_t) accu; | ||
20159 | - pow5_len++; | ||
20160 | - } | ||
20161 | - } | ||
20162 | - if (s_limbs > 0) | ||
20163 | - { | ||
20164 | - size_t count; | ||
20165 | - for (count = pow5_len; count > 0;) | ||
20166 | - { | ||
20167 | - count--; | ||
20168 | - pow5_ptr[s_limbs + count] = pow5_ptr[count]; | ||
20169 | - } | ||
20170 | - for (count = s_limbs; count > 0;) | ||
20171 | - { | ||
20172 | - count--; | ||
20173 | - pow5_ptr[count] = 0; | ||
20174 | - } | ||
20175 | - pow5_len += s_limbs; | ||
20176 | - } | ||
20177 | - pow5.limbs = pow5_ptr; | ||
20178 | - pow5.nlimbs = pow5_len; | ||
20179 | - if (n >= 0) | ||
20180 | - { | ||
20181 | - /* Multiply m with pow5. No division needed. */ | ||
20182 | - z_memory = multiply (m, pow5, &z); | ||
20183 | - } | ||
20184 | - else | ||
20185 | - { | ||
20186 | - /* Divide m by pow5 and round. */ | ||
20187 | - z_memory = divide (m, pow5, &z); | ||
20188 | - } | ||
20189 | - } | ||
20190 | - else | ||
20191 | - { | ||
20192 | - pow5.limbs = pow5_ptr; | ||
20193 | - pow5.nlimbs = pow5_len; | ||
20194 | - if (n >= 0) | ||
20195 | - { | ||
20196 | - /* n >= 0, s < 0. | ||
20197 | - Multiply m with pow5, then divide by 2^|s|. */ | ||
20198 | - mpn_t numerator; | ||
20199 | - mpn_t denominator; | ||
20200 | - void *tmp_memory; | ||
20201 | - tmp_memory = multiply (m, pow5, &numerator); | ||
20202 | - if (tmp_memory == NULL) | ||
20203 | - { | ||
20204 | - free (pow5_ptr); | ||
20205 | - free (memory); | ||
20206 | - return NULL; | ||
20207 | - } | ||
20208 | - /* Construct 2^|s|. */ | ||
20209 | - { | ||
20210 | - mp_limb_t *ptr = pow5_ptr + pow5_len; | ||
20211 | - size_t i; | ||
20212 | - for (i = 0; i < s_limbs; i++) | ||
20213 | - ptr[i] = 0; | ||
20214 | - ptr[s_limbs] = (mp_limb_t) 1 << s_bits; | ||
20215 | - denominator.limbs = ptr; | ||
20216 | - denominator.nlimbs = s_limbs + 1; | ||
20217 | - } | ||
20218 | - z_memory = divide (numerator, denominator, &z); | ||
20219 | - free (tmp_memory); | ||
20220 | - } | ||
20221 | - else | ||
20222 | - { | ||
20223 | - /* n < 0, s > 0. | ||
20224 | - Multiply m with 2^s, then divide by pow5. */ | ||
20225 | - mpn_t numerator; | ||
20226 | - mp_limb_t *num_ptr; | ||
20227 | - num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1) | ||
20228 | - * sizeof (mp_limb_t)); | ||
20229 | - if (num_ptr == NULL) | ||
20230 | - { | ||
20231 | - free (pow5_ptr); | ||
20232 | - free (memory); | ||
20233 | - return NULL; | ||
20234 | - } | ||
20235 | - { | ||
20236 | - mp_limb_t *destptr = num_ptr; | ||
20237 | - { | ||
20238 | - size_t i; | ||
20239 | - for (i = 0; i < s_limbs; i++) | ||
20240 | - *destptr++ = 0; | ||
20241 | - } | ||
20242 | - if (s_bits > 0) | ||
20243 | - { | ||
20244 | - const mp_limb_t *sourceptr = m.limbs; | ||
20245 | - mp_twolimb_t accu = 0; | ||
20246 | - size_t count; | ||
20247 | - for (count = m.nlimbs; count > 0; count--) | ||
20248 | - { | ||
20249 | - accu += (mp_twolimb_t) *sourceptr++ << s_bits; | ||
20250 | - *destptr++ = (mp_limb_t) accu; | ||
20251 | - accu = accu >> GMP_LIMB_BITS; | ||
20252 | - } | ||
20253 | - if (accu > 0) | ||
20254 | - *destptr++ = (mp_limb_t) accu; | ||
20255 | - } | ||
20256 | - else | ||
20257 | - { | ||
20258 | - const mp_limb_t *sourceptr = m.limbs; | ||
20259 | - size_t count; | ||
20260 | - for (count = m.nlimbs; count > 0; count--) | ||
20261 | - *destptr++ = *sourceptr++; | ||
20262 | - } | ||
20263 | - numerator.limbs = num_ptr; | ||
20264 | - numerator.nlimbs = destptr - num_ptr; | ||
20265 | - } | ||
20266 | - z_memory = divide (numerator, pow5, &z); | ||
20267 | - free (num_ptr); | ||
20268 | - } | ||
20269 | - } | ||
20270 | - free (pow5_ptr); | ||
20271 | - free (memory); | ||
20272 | - | ||
20273 | - /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */ | ||
20274 | - | ||
20275 | - if (z_memory == NULL) | ||
20276 | - return NULL; | ||
20277 | - digits = convert_to_decimal (z, extra_zeroes); | ||
20278 | - free (z_memory); | ||
20279 | - return digits; | ||
20280 | -} | ||
20281 | - | ||
20282 | -# if NEED_PRINTF_LONG_DOUBLE | ||
20283 | - | ||
20284 | -/* Assuming x is finite and >= 0, and n is an integer: | ||
20285 | - Returns the decimal representation of round (x * 10^n). | ||
20286 | - Return the allocated memory - containing the decimal digits in low-to-high | ||
20287 | - order, terminated with a NUL character - in case of success, NULL in case | ||
20288 | - of memory allocation failure. */ | ||
20289 | -static char * | ||
20290 | -scale10_round_decimal_long_double (long double x, int n) | ||
20291 | -{ | ||
20292 | - int e; | ||
20293 | - mpn_t m; | ||
20294 | - void *memory = decode_long_double (x, &e, &m); | ||
20295 | - return scale10_round_decimal_decoded (e, m, memory, n); | ||
20296 | -} | ||
20297 | - | ||
20298 | -# endif | ||
20299 | - | ||
20300 | -# if NEED_PRINTF_DOUBLE | ||
20301 | - | ||
20302 | -/* Assuming x is finite and >= 0, and n is an integer: | ||
20303 | - Returns the decimal representation of round (x * 10^n). | ||
20304 | - Return the allocated memory - containing the decimal digits in low-to-high | ||
20305 | - order, terminated with a NUL character - in case of success, NULL in case | ||
20306 | - of memory allocation failure. */ | ||
20307 | -static char * | ||
20308 | -scale10_round_decimal_double (double x, int n) | ||
20309 | -{ | ||
20310 | - int e; | ||
20311 | - mpn_t m; | ||
20312 | - void *memory = decode_double (x, &e, &m); | ||
20313 | - return scale10_round_decimal_decoded (e, m, memory, n); | ||
20314 | -} | ||
20315 | - | ||
20316 | -# endif | ||
20317 | - | ||
20318 | -# if NEED_PRINTF_LONG_DOUBLE | ||
20319 | - | ||
20320 | -/* Assuming x is finite and > 0: | ||
20321 | - Return an approximation for n with 10^n <= x < 10^(n+1). | ||
20322 | - The approximation is usually the right n, but may be off by 1 sometimes. */ | ||
20323 | -static int | ||
20324 | -floorlog10l (long double x) | ||
20325 | -{ | ||
20326 | - int exp; | ||
20327 | - long double y; | ||
20328 | - double z; | ||
20329 | - double l; | ||
20330 | - | ||
20331 | - /* Split into exponential part and mantissa. */ | ||
20332 | - y = frexpl (x, &exp); | ||
20333 | - if (!(y >= 0.0L && y < 1.0L)) | ||
20334 | - abort (); | ||
20335 | - if (y == 0.0L) | ||
20336 | - return INT_MIN; | ||
20337 | - if (y < 0.5L) | ||
20338 | - { | ||
20339 | - while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) | ||
20340 | - { | ||
20341 | - y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); | ||
20342 | - exp -= GMP_LIMB_BITS; | ||
20343 | - } | ||
20344 | - if (y < (1.0L / (1 << 16))) | ||
20345 | - { | ||
20346 | - y *= 1.0L * (1 << 16); | ||
20347 | - exp -= 16; | ||
20348 | - } | ||
20349 | - if (y < (1.0L / (1 << 8))) | ||
20350 | - { | ||
20351 | - y *= 1.0L * (1 << 8); | ||
20352 | - exp -= 8; | ||
20353 | - } | ||
20354 | - if (y < (1.0L / (1 << 4))) | ||
20355 | - { | ||
20356 | - y *= 1.0L * (1 << 4); | ||
20357 | - exp -= 4; | ||
20358 | - } | ||
20359 | - if (y < (1.0L / (1 << 2))) | ||
20360 | - { | ||
20361 | - y *= 1.0L * (1 << 2); | ||
20362 | - exp -= 2; | ||
20363 | - } | ||
20364 | - if (y < (1.0L / (1 << 1))) | ||
20365 | - { | ||
20366 | - y *= 1.0L * (1 << 1); | ||
20367 | - exp -= 1; | ||
20368 | - } | ||
20369 | - } | ||
20370 | - if (!(y >= 0.5L && y < 1.0L)) | ||
20371 | - abort (); | ||
20372 | - /* Compute an approximation for l = log2(x) = exp + log2(y). */ | ||
20373 | - l = exp; | ||
20374 | - z = y; | ||
20375 | - if (z < 0.70710678118654752444) | ||
20376 | - { | ||
20377 | - z *= 1.4142135623730950488; | ||
20378 | - l -= 0.5; | ||
20379 | - } | ||
20380 | - if (z < 0.8408964152537145431) | ||
20381 | - { | ||
20382 | - z *= 1.1892071150027210667; | ||
20383 | - l -= 0.25; | ||
20384 | - } | ||
20385 | - if (z < 0.91700404320467123175) | ||
20386 | - { | ||
20387 | - z *= 1.0905077326652576592; | ||
20388 | - l -= 0.125; | ||
20389 | - } | ||
20390 | - if (z < 0.9576032806985736469) | ||
20391 | - { | ||
20392 | - z *= 1.0442737824274138403; | ||
20393 | - l -= 0.0625; | ||
20394 | - } | ||
20395 | - /* Now 0.95 <= z <= 1.01. */ | ||
20396 | - z = 1 - z; | ||
20397 | - /* log(1-z) = - z - z^2/2 - z^3/3 - z^4/4 - ... | ||
20398 | - Four terms are enough to get an approximation with error < 10^-7. */ | ||
20399 | - l -= z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); | ||
20400 | - /* Finally multiply with log(2)/log(10), yields an approximation for | ||
20401 | - log10(x). */ | ||
20402 | - l *= 0.30102999566398119523; | ||
20403 | - /* Round down to the next integer. */ | ||
20404 | - return (int) l + (l < 0 ? -1 : 0); | ||
20405 | -} | ||
20406 | - | ||
20407 | -# endif | ||
20408 | - | ||
20409 | -# if NEED_PRINTF_DOUBLE | ||
20410 | - | ||
20411 | -/* Assuming x is finite and > 0: | ||
20412 | - Return an approximation for n with 10^n <= x < 10^(n+1). | ||
20413 | - The approximation is usually the right n, but may be off by 1 sometimes. */ | ||
20414 | -static int | ||
20415 | -floorlog10 (double x) | ||
20416 | -{ | ||
20417 | - int exp; | ||
20418 | - double y; | ||
20419 | - double z; | ||
20420 | - double l; | ||
20421 | - | ||
20422 | - /* Split into exponential part and mantissa. */ | ||
20423 | - y = frexp (x, &exp); | ||
20424 | - if (!(y >= 0.0 && y < 1.0)) | ||
20425 | - abort (); | ||
20426 | - if (y == 0.0) | ||
20427 | - return INT_MIN; | ||
20428 | - if (y < 0.5) | ||
20429 | - { | ||
20430 | - while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) | ||
20431 | - { | ||
20432 | - y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); | ||
20433 | - exp -= GMP_LIMB_BITS; | ||
20434 | - } | ||
20435 | - if (y < (1.0 / (1 << 16))) | ||
20436 | - { | ||
20437 | - y *= 1.0 * (1 << 16); | ||
20438 | - exp -= 16; | ||
20439 | - } | ||
20440 | - if (y < (1.0 / (1 << 8))) | ||
20441 | - { | ||
20442 | - y *= 1.0 * (1 << 8); | ||
20443 | - exp -= 8; | ||
20444 | - } | ||
20445 | - if (y < (1.0 / (1 << 4))) | ||
20446 | - { | ||
20447 | - y *= 1.0 * (1 << 4); | ||
20448 | - exp -= 4; | ||
20449 | - } | ||
20450 | - if (y < (1.0 / (1 << 2))) | ||
20451 | - { | ||
20452 | - y *= 1.0 * (1 << 2); | ||
20453 | - exp -= 2; | ||
20454 | - } | ||
20455 | - if (y < (1.0 / (1 << 1))) | ||
20456 | - { | ||
20457 | - y *= 1.0 * (1 << 1); | ||
20458 | - exp -= 1; | ||
20459 | - } | ||
20460 | - } | ||
20461 | - if (!(y >= 0.5 && y < 1.0)) | ||
20462 | - abort (); | ||
20463 | - /* Compute an approximation for l = log2(x) = exp + log2(y). */ | ||
20464 | - l = exp; | ||
20465 | - z = y; | ||
20466 | - if (z < 0.70710678118654752444) | ||
20467 | - { | ||
20468 | - z *= 1.4142135623730950488; | ||
20469 | - l -= 0.5; | ||
20470 | - } | ||
20471 | - if (z < 0.8408964152537145431) | ||
20472 | - { | ||
20473 | - z *= 1.1892071150027210667; | ||
20474 | - l -= 0.25; | ||
20475 | - } | ||
20476 | - if (z < 0.91700404320467123175) | ||
20477 | - { | ||
20478 | - z *= 1.0905077326652576592; | ||
20479 | - l -= 0.125; | ||
20480 | - } | ||
20481 | - if (z < 0.9576032806985736469) | ||
20482 | - { | ||
20483 | - z *= 1.0442737824274138403; | ||
20484 | - l -= 0.0625; | ||
20485 | - } | ||
20486 | - /* Now 0.95 <= z <= 1.01. */ | ||
20487 | - z = 1 - z; | ||
20488 | - /* log(1-z) = - z - z^2/2 - z^3/3 - z^4/4 - ... | ||
20489 | - Four terms are enough to get an approximation with error < 10^-7. */ | ||
20490 | - l -= z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); | ||
20491 | - /* Finally multiply with log(2)/log(10), yields an approximation for | ||
20492 | - log10(x). */ | ||
20493 | - l *= 0.30102999566398119523; | ||
20494 | - /* Round down to the next integer. */ | ||
20495 | - return (int) l + (l < 0 ? -1 : 0); | ||
20496 | -} | ||
20497 | - | ||
20498 | -# endif | ||
20499 | - | ||
20500 | -#endif | ||
20501 | - | ||
20502 | -DCHAR_T * | ||
20503 | -VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, | ||
20504 | - const FCHAR_T *format, va_list args) | ||
20505 | -{ | ||
20506 | - DIRECTIVES d; | ||
20507 | - arguments a; | ||
20508 | - | ||
20509 | - if (PRINTF_PARSE (format, &d, &a) < 0) | ||
20510 | - /* errno is already set. */ | ||
20511 | - return NULL; | ||
20512 | - | ||
20513 | -#define CLEANUP() \ | ||
20514 | - free (d.dir); \ | ||
20515 | - if (a.arg) \ | ||
20516 | - free (a.arg); | ||
20517 | - | ||
20518 | - if (PRINTF_FETCHARGS (args, &a) < 0) | ||
20519 | - { | ||
20520 | - CLEANUP (); | ||
20521 | - errno = EINVAL; | ||
20522 | - return NULL; | ||
20523 | - } | ||
20524 | - | ||
20525 | - { | ||
20526 | - size_t buf_neededlength; | ||
20527 | - TCHAR_T *buf; | ||
20528 | - TCHAR_T *buf_malloced; | ||
20529 | - const FCHAR_T *cp; | ||
20530 | - size_t i; | ||
20531 | - DIRECTIVE *dp; | ||
20532 | - /* Output string accumulator. */ | ||
20533 | - DCHAR_T *result; | ||
20534 | - size_t allocated; | ||
20535 | - size_t length; | ||
20536 | - | ||
20537 | - /* Allocate a small buffer that will hold a directive passed to | ||
20538 | - sprintf or snprintf. */ | ||
20539 | - buf_neededlength = | ||
20540 | - xsum4 (7, d.max_width_length, d.max_precision_length, 6); | ||
20541 | -#if HAVE_ALLOCA | ||
20542 | - if (buf_neededlength < 4000 / sizeof (TCHAR_T)) | ||
20543 | - { | ||
20544 | - buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T)); | ||
20545 | - buf_malloced = NULL; | ||
20546 | - } | ||
20547 | - else | ||
20548 | -#endif | ||
20549 | - { | ||
20550 | - size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T)); | ||
20551 | - if (size_overflow_p (buf_memsize)) | ||
20552 | - goto out_of_memory_1; | ||
20553 | - buf = (TCHAR_T *) malloc (buf_memsize); | ||
20554 | - if (buf == NULL) | ||
20555 | - goto out_of_memory_1; | ||
20556 | - buf_malloced = buf; | ||
20557 | - } | ||
20558 | - | ||
20559 | - if (resultbuf != NULL) | ||
20560 | - { | ||
20561 | - result = resultbuf; | ||
20562 | - allocated = *lengthp; | ||
20563 | - } | ||
20564 | - else | ||
20565 | - { | ||
20566 | - result = NULL; | ||
20567 | - allocated = 0; | ||
20568 | - } | ||
20569 | - length = 0; | ||
20570 | - /* Invariants: | ||
20571 | - result is either == resultbuf or == NULL or malloc-allocated. | ||
20572 | - If length > 0, then result != NULL. */ | ||
20573 | - | ||
20574 | - /* Ensures that allocated >= needed. Aborts through a jump to | ||
20575 | - out_of_memory if needed is SIZE_MAX or otherwise too big. */ | ||
20576 | -#define ENSURE_ALLOCATION(needed) \ | ||
20577 | - if ((needed) > allocated) \ | ||
20578 | - { \ | ||
20579 | - size_t memory_size; \ | ||
20580 | - DCHAR_T *memory; \ | ||
20581 | - \ | ||
20582 | - allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ | ||
20583 | - if ((needed) > allocated) \ | ||
20584 | - allocated = (needed); \ | ||
20585 | - memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ | ||
20586 | - if (size_overflow_p (memory_size)) \ | ||
20587 | - goto out_of_memory; \ | ||
20588 | - if (result == resultbuf || result == NULL) \ | ||
20589 | - memory = (DCHAR_T *) malloc (memory_size); \ | ||
20590 | - else \ | ||
20591 | - memory = (DCHAR_T *) realloc (result, memory_size); \ | ||
20592 | - if (memory == NULL) \ | ||
20593 | - goto out_of_memory; \ | ||
20594 | - if (result == resultbuf && length > 0) \ | ||
20595 | - DCHAR_CPY (memory, result, length); \ | ||
20596 | - result = memory; \ | ||
20597 | - } | ||
20598 | - | ||
20599 | - for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) | ||
20600 | - { | ||
20601 | - if (cp != dp->dir_start) | ||
20602 | - { | ||
20603 | - size_t n = dp->dir_start - cp; | ||
20604 | - size_t augmented_length = xsum (length, n); | ||
20605 | - | ||
20606 | - ENSURE_ALLOCATION (augmented_length); | ||
20607 | - /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we | ||
20608 | - need that the format string contains only ASCII characters | ||
20609 | - if FCHAR_T and DCHAR_T are not the same type. */ | ||
20610 | - if (sizeof (FCHAR_T) == sizeof (DCHAR_T)) | ||
20611 | - { | ||
20612 | - DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); | ||
20613 | - length = augmented_length; | ||
20614 | - } | ||
20615 | - else | ||
20616 | - { | ||
20617 | - do | ||
20618 | - result[length++] = (unsigned char) *cp++; | ||
20619 | - while (--n > 0); | ||
20620 | - } | ||
20621 | - } | ||
20622 | - if (i == d.count) | ||
20623 | - break; | ||
20624 | - | ||
20625 | - /* Execute a single directive. */ | ||
20626 | - if (dp->conversion == '%') | ||
20627 | - { | ||
20628 | - size_t augmented_length; | ||
20629 | - | ||
20630 | - if (!(dp->arg_index == ARG_NONE)) | ||
20631 | - abort (); | ||
20632 | - augmented_length = xsum (length, 1); | ||
20633 | - ENSURE_ALLOCATION (augmented_length); | ||
20634 | - result[length] = '%'; | ||
20635 | - length = augmented_length; | ||
20636 | - } | ||
20637 | - else | ||
20638 | - { | ||
20639 | - if (!(dp->arg_index != ARG_NONE)) | ||
20640 | - abort (); | ||
20641 | - | ||
20642 | - if (dp->conversion == 'n') | ||
20643 | - { | ||
20644 | - switch (a.arg[dp->arg_index].type) | ||
20645 | - { | ||
20646 | - case TYPE_COUNT_SCHAR_POINTER: | ||
20647 | - *a.arg[dp->arg_index].a.a_count_schar_pointer = length; | ||
20648 | - break; | ||
20649 | - case TYPE_COUNT_SHORT_POINTER: | ||
20650 | - *a.arg[dp->arg_index].a.a_count_short_pointer = length; | ||
20651 | - break; | ||
20652 | - case TYPE_COUNT_INT_POINTER: | ||
20653 | - *a.arg[dp->arg_index].a.a_count_int_pointer = length; | ||
20654 | - break; | ||
20655 | - case TYPE_COUNT_LONGINT_POINTER: | ||
20656 | - *a.arg[dp->arg_index].a.a_count_longint_pointer = length; | ||
20657 | - break; | ||
20658 | -#if HAVE_LONG_LONG_INT | ||
20659 | - case TYPE_COUNT_LONGLONGINT_POINTER: | ||
20660 | - *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; | ||
20661 | - break; | ||
20662 | -#endif | ||
20663 | - default: | ||
20664 | - abort (); | ||
20665 | - } | ||
20666 | - } | ||
20667 | -#if ENABLE_UNISTDIO | ||
20668 | - /* The unistdio extensions. */ | ||
20669 | - else if (dp->conversion == 'U') | ||
20670 | - { | ||
20671 | - arg_type type = a.arg[dp->arg_index].type; | ||
20672 | - int flags = dp->flags; | ||
20673 | - int has_width; | ||
20674 | - size_t width; | ||
20675 | - int has_precision; | ||
20676 | - size_t precision; | ||
20677 | - | ||
20678 | - has_width = 0; | ||
20679 | - width = 0; | ||
20680 | - if (dp->width_start != dp->width_end) | ||
20681 | - { | ||
20682 | - if (dp->width_arg_index != ARG_NONE) | ||
20683 | - { | ||
20684 | - int arg; | ||
20685 | - | ||
20686 | - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) | ||
20687 | - abort (); | ||
20688 | - arg = a.arg[dp->width_arg_index].a.a_int; | ||
20689 | - if (arg < 0) | ||
20690 | - { | ||
20691 | - /* "A negative field width is taken as a '-' flag | ||
20692 | - followed by a positive field width." */ | ||
20693 | - flags |= FLAG_LEFT; | ||
20694 | - width = (unsigned int) (-arg); | ||
20695 | - } | ||
20696 | - else | ||
20697 | - width = arg; | ||
20698 | - } | ||
20699 | - else | ||
20700 | - { | ||
20701 | - const FCHAR_T *digitp = dp->width_start; | ||
20702 | - | ||
20703 | - do | ||
20704 | - width = xsum (xtimes (width, 10), *digitp++ - '0'); | ||
20705 | - while (digitp != dp->width_end); | ||
20706 | - } | ||
20707 | - has_width = 1; | ||
20708 | - } | ||
20709 | - | ||
20710 | - has_precision = 0; | ||
20711 | - precision = 0; | ||
20712 | - if (dp->precision_start != dp->precision_end) | ||
20713 | - { | ||
20714 | - if (dp->precision_arg_index != ARG_NONE) | ||
20715 | - { | ||
20716 | - int arg; | ||
20717 | - | ||
20718 | - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) | ||
20719 | - abort (); | ||
20720 | - arg = a.arg[dp->precision_arg_index].a.a_int; | ||
20721 | - /* "A negative precision is taken as if the precision | ||
20722 | - were omitted." */ | ||
20723 | - if (arg >= 0) | ||
20724 | - { | ||
20725 | - precision = arg; | ||
20726 | - has_precision = 1; | ||
20727 | - } | ||
20728 | - } | ||
20729 | - else | ||
20730 | - { | ||
20731 | - const FCHAR_T *digitp = dp->precision_start + 1; | ||
20732 | - | ||
20733 | - precision = 0; | ||
20734 | - while (digitp != dp->precision_end) | ||
20735 | - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); | ||
20736 | - has_precision = 1; | ||
20737 | - } | ||
20738 | - } | ||
20739 | - | ||
20740 | - switch (type) | ||
20741 | - { | ||
20742 | - case TYPE_U8_STRING: | ||
20743 | - { | ||
20744 | - const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string; | ||
20745 | - const uint8_t *arg_end; | ||
20746 | - size_t characters; | ||
20747 | - | ||
20748 | - if (has_precision) | ||
20749 | - { | ||
20750 | - /* Use only PRECISION characters, from the left. */ | ||
20751 | - arg_end = arg; | ||
20752 | - characters = 0; | ||
20753 | - for (; precision > 0; precision--) | ||
20754 | - { | ||
20755 | - int count = u8_strmblen (arg_end); | ||
20756 | - if (count == 0) | ||
20757 | - break; | ||
20758 | - if (count < 0) | ||
20759 | - { | ||
20760 | - if (!(result == resultbuf || result == NULL)) | ||
20761 | - free (result); | ||
20762 | - if (buf_malloced != NULL) | ||
20763 | - free (buf_malloced); | ||
20764 | - CLEANUP (); | ||
20765 | - errno = EILSEQ; | ||
20766 | - return NULL; | ||
20767 | - } | ||
20768 | - arg_end += count; | ||
20769 | - characters++; | ||
20770 | - } | ||
20771 | - } | ||
20772 | - else if (has_width) | ||
20773 | - { | ||
20774 | - /* Use the entire string, and count the number of | ||
20775 | - characters. */ | ||
20776 | - arg_end = arg; | ||
20777 | - characters = 0; | ||
20778 | - for (;;) | ||
20779 | - { | ||
20780 | - int count = u8_strmblen (arg_end); | ||
20781 | - if (count == 0) | ||
20782 | - break; | ||
20783 | - if (count < 0) | ||
20784 | - { | ||
20785 | - if (!(result == resultbuf || result == NULL)) | ||
20786 | - free (result); | ||
20787 | - if (buf_malloced != NULL) | ||
20788 | - free (buf_malloced); | ||
20789 | - CLEANUP (); | ||
20790 | - errno = EILSEQ; | ||
20791 | - return NULL; | ||
20792 | - } | ||
20793 | - arg_end += count; | ||
20794 | - characters++; | ||
20795 | - } | ||
20796 | - } | ||
20797 | - else | ||
20798 | - { | ||
20799 | - /* Use the entire string. */ | ||
20800 | - arg_end = arg + u8_strlen (arg); | ||
20801 | - /* The number of characters doesn't matter. */ | ||
20802 | - characters = 0; | ||
20803 | - } | ||
20804 | - | ||
20805 | - if (has_width && width > characters | ||
20806 | - && !(dp->flags & FLAG_LEFT)) | ||
20807 | - { | ||
20808 | - size_t n = width - characters; | ||
20809 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
20810 | - DCHAR_SET (result + length, ' ', n); | ||
20811 | - length += n; | ||
20812 | - } | ||
20813 | - | ||
20814 | -# if DCHAR_IS_UINT8_T | ||
20815 | - { | ||
20816 | - size_t n = arg_end - arg; | ||
20817 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
20818 | - DCHAR_CPY (result + length, arg, n); | ||
20819 | - length += n; | ||
20820 | - } | ||
20821 | -# else | ||
20822 | - { /* Convert. */ | ||
20823 | - DCHAR_T *converted = result + length; | ||
20824 | - size_t converted_len = allocated - length; | ||
20825 | -# if DCHAR_IS_TCHAR | ||
20826 | - /* Convert from UTF-8 to locale encoding. */ | ||
20827 | - if (u8_conv_to_encoding (locale_charset (), | ||
20828 | - iconveh_question_mark, | ||
20829 | - arg, arg_end - arg, NULL, | ||
20830 | - &converted, &converted_len) | ||
20831 | - < 0) | ||
20832 | -# else | ||
20833 | - /* Convert from UTF-8 to UTF-16/UTF-32. */ | ||
20834 | - converted = | ||
20835 | - U8_TO_DCHAR (arg, arg_end - arg, | ||
20836 | - converted, &converted_len); | ||
20837 | - if (converted == NULL) | ||
20838 | -# endif | ||
20839 | - { | ||
20840 | - int saved_errno = errno; | ||
20841 | - if (!(result == resultbuf || result == NULL)) | ||
20842 | - free (result); | ||
20843 | - if (buf_malloced != NULL) | ||
20844 | - free (buf_malloced); | ||
20845 | - CLEANUP (); | ||
20846 | - errno = saved_errno; | ||
20847 | - return NULL; | ||
20848 | - } | ||
20849 | - if (converted != result + length) | ||
20850 | - { | ||
20851 | - ENSURE_ALLOCATION (xsum (length, converted_len)); | ||
20852 | - DCHAR_CPY (result + length, converted, converted_len); | ||
20853 | - free (converted); | ||
20854 | - } | ||
20855 | - length += converted_len; | ||
20856 | - } | ||
20857 | -# endif | ||
20858 | - | ||
20859 | - if (has_width && width > characters | ||
20860 | - && (dp->flags & FLAG_LEFT)) | ||
20861 | - { | ||
20862 | - size_t n = width - characters; | ||
20863 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
20864 | - DCHAR_SET (result + length, ' ', n); | ||
20865 | - length += n; | ||
20866 | - } | ||
20867 | - } | ||
20868 | - break; | ||
20869 | - | ||
20870 | - case TYPE_U16_STRING: | ||
20871 | - { | ||
20872 | - const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string; | ||
20873 | - const uint16_t *arg_end; | ||
20874 | - size_t characters; | ||
20875 | - | ||
20876 | - if (has_precision) | ||
20877 | - { | ||
20878 | - /* Use only PRECISION characters, from the left. */ | ||
20879 | - arg_end = arg; | ||
20880 | - characters = 0; | ||
20881 | - for (; precision > 0; precision--) | ||
20882 | - { | ||
20883 | - int count = u16_strmblen (arg_end); | ||
20884 | - if (count == 0) | ||
20885 | - break; | ||
20886 | - if (count < 0) | ||
20887 | - { | ||
20888 | - if (!(result == resultbuf || result == NULL)) | ||
20889 | - free (result); | ||
20890 | - if (buf_malloced != NULL) | ||
20891 | - free (buf_malloced); | ||
20892 | - CLEANUP (); | ||
20893 | - errno = EILSEQ; | ||
20894 | - return NULL; | ||
20895 | - } | ||
20896 | - arg_end += count; | ||
20897 | - characters++; | ||
20898 | - } | ||
20899 | - } | ||
20900 | - else if (has_width) | ||
20901 | - { | ||
20902 | - /* Use the entire string, and count the number of | ||
20903 | - characters. */ | ||
20904 | - arg_end = arg; | ||
20905 | - characters = 0; | ||
20906 | - for (;;) | ||
20907 | - { | ||
20908 | - int count = u16_strmblen (arg_end); | ||
20909 | - if (count == 0) | ||
20910 | - break; | ||
20911 | - if (count < 0) | ||
20912 | - { | ||
20913 | - if (!(result == resultbuf || result == NULL)) | ||
20914 | - free (result); | ||
20915 | - if (buf_malloced != NULL) | ||
20916 | - free (buf_malloced); | ||
20917 | - CLEANUP (); | ||
20918 | - errno = EILSEQ; | ||
20919 | - return NULL; | ||
20920 | - } | ||
20921 | - arg_end += count; | ||
20922 | - characters++; | ||
20923 | - } | ||
20924 | - } | ||
20925 | - else | ||
20926 | - { | ||
20927 | - /* Use the entire string. */ | ||
20928 | - arg_end = arg + u16_strlen (arg); | ||
20929 | - /* The number of characters doesn't matter. */ | ||
20930 | - characters = 0; | ||
20931 | - } | ||
20932 | - | ||
20933 | - if (has_width && width > characters | ||
20934 | - && !(dp->flags & FLAG_LEFT)) | ||
20935 | - { | ||
20936 | - size_t n = width - characters; | ||
20937 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
20938 | - DCHAR_SET (result + length, ' ', n); | ||
20939 | - length += n; | ||
20940 | - } | ||
20941 | - | ||
20942 | -# if DCHAR_IS_UINT16_T | ||
20943 | - { | ||
20944 | - size_t n = arg_end - arg; | ||
20945 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
20946 | - DCHAR_CPY (result + length, arg, n); | ||
20947 | - length += n; | ||
20948 | - } | ||
20949 | -# else | ||
20950 | - { /* Convert. */ | ||
20951 | - DCHAR_T *converted = result + length; | ||
20952 | - size_t converted_len = allocated - length; | ||
20953 | -# if DCHAR_IS_TCHAR | ||
20954 | - /* Convert from UTF-16 to locale encoding. */ | ||
20955 | - if (u16_conv_to_encoding (locale_charset (), | ||
20956 | - iconveh_question_mark, | ||
20957 | - arg, arg_end - arg, NULL, | ||
20958 | - &converted, &converted_len) | ||
20959 | - < 0) | ||
20960 | -# else | ||
20961 | - /* Convert from UTF-16 to UTF-8/UTF-32. */ | ||
20962 | - converted = | ||
20963 | - U16_TO_DCHAR (arg, arg_end - arg, | ||
20964 | - converted, &converted_len); | ||
20965 | - if (converted == NULL) | ||
20966 | -# endif | ||
20967 | - { | ||
20968 | - int saved_errno = errno; | ||
20969 | - if (!(result == resultbuf || result == NULL)) | ||
20970 | - free (result); | ||
20971 | - if (buf_malloced != NULL) | ||
20972 | - free (buf_malloced); | ||
20973 | - CLEANUP (); | ||
20974 | - errno = saved_errno; | ||
20975 | - return NULL; | ||
20976 | - } | ||
20977 | - if (converted != result + length) | ||
20978 | - { | ||
20979 | - ENSURE_ALLOCATION (xsum (length, converted_len)); | ||
20980 | - DCHAR_CPY (result + length, converted, converted_len); | ||
20981 | - free (converted); | ||
20982 | - } | ||
20983 | - length += converted_len; | ||
20984 | - } | ||
20985 | -# endif | ||
20986 | - | ||
20987 | - if (has_width && width > characters | ||
20988 | - && (dp->flags & FLAG_LEFT)) | ||
20989 | - { | ||
20990 | - size_t n = width - characters; | ||
20991 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
20992 | - DCHAR_SET (result + length, ' ', n); | ||
20993 | - length += n; | ||
20994 | - } | ||
20995 | - } | ||
20996 | - break; | ||
20997 | - | ||
20998 | - case TYPE_U32_STRING: | ||
20999 | - { | ||
21000 | - const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string; | ||
21001 | - const uint32_t *arg_end; | ||
21002 | - size_t characters; | ||
21003 | - | ||
21004 | - if (has_precision) | ||
21005 | - { | ||
21006 | - /* Use only PRECISION characters, from the left. */ | ||
21007 | - arg_end = arg; | ||
21008 | - characters = 0; | ||
21009 | - for (; precision > 0; precision--) | ||
21010 | - { | ||
21011 | - int count = u32_strmblen (arg_end); | ||
21012 | - if (count == 0) | ||
21013 | - break; | ||
21014 | - if (count < 0) | ||
21015 | - { | ||
21016 | - if (!(result == resultbuf || result == NULL)) | ||
21017 | - free (result); | ||
21018 | - if (buf_malloced != NULL) | ||
21019 | - free (buf_malloced); | ||
21020 | - CLEANUP (); | ||
21021 | - errno = EILSEQ; | ||
21022 | - return NULL; | ||
21023 | - } | ||
21024 | - arg_end += count; | ||
21025 | - characters++; | ||
21026 | - } | ||
21027 | - } | ||
21028 | - else if (has_width) | ||
21029 | - { | ||
21030 | - /* Use the entire string, and count the number of | ||
21031 | - characters. */ | ||
21032 | - arg_end = arg; | ||
21033 | - characters = 0; | ||
21034 | - for (;;) | ||
21035 | - { | ||
21036 | - int count = u32_strmblen (arg_end); | ||
21037 | - if (count == 0) | ||
21038 | - break; | ||
21039 | - if (count < 0) | ||
21040 | - { | ||
21041 | - if (!(result == resultbuf || result == NULL)) | ||
21042 | - free (result); | ||
21043 | - if (buf_malloced != NULL) | ||
21044 | - free (buf_malloced); | ||
21045 | - CLEANUP (); | ||
21046 | - errno = EILSEQ; | ||
21047 | - return NULL; | ||
21048 | - } | ||
21049 | - arg_end += count; | ||
21050 | - characters++; | ||
21051 | - } | ||
21052 | - } | ||
21053 | - else | ||
21054 | - { | ||
21055 | - /* Use the entire string. */ | ||
21056 | - arg_end = arg + u32_strlen (arg); | ||
21057 | - /* The number of characters doesn't matter. */ | ||
21058 | - characters = 0; | ||
21059 | - } | ||
21060 | - | ||
21061 | - if (has_width && width > characters | ||
21062 | - && !(dp->flags & FLAG_LEFT)) | ||
21063 | - { | ||
21064 | - size_t n = width - characters; | ||
21065 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
21066 | - DCHAR_SET (result + length, ' ', n); | ||
21067 | - length += n; | ||
21068 | - } | ||
21069 | - | ||
21070 | -# if DCHAR_IS_UINT32_T | ||
21071 | - { | ||
21072 | - size_t n = arg_end - arg; | ||
21073 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
21074 | - DCHAR_CPY (result + length, arg, n); | ||
21075 | - length += n; | ||
21076 | - } | ||
21077 | -# else | ||
21078 | - { /* Convert. */ | ||
21079 | - DCHAR_T *converted = result + length; | ||
21080 | - size_t converted_len = allocated - length; | ||
21081 | -# if DCHAR_IS_TCHAR | ||
21082 | - /* Convert from UTF-32 to locale encoding. */ | ||
21083 | - if (u32_conv_to_encoding (locale_charset (), | ||
21084 | - iconveh_question_mark, | ||
21085 | - arg, arg_end - arg, NULL, | ||
21086 | - &converted, &converted_len) | ||
21087 | - < 0) | ||
21088 | -# else | ||
21089 | - /* Convert from UTF-32 to UTF-8/UTF-16. */ | ||
21090 | - converted = | ||
21091 | - U32_TO_DCHAR (arg, arg_end - arg, | ||
21092 | - converted, &converted_len); | ||
21093 | - if (converted == NULL) | ||
21094 | -# endif | ||
21095 | - { | ||
21096 | - int saved_errno = errno; | ||
21097 | - if (!(result == resultbuf || result == NULL)) | ||
21098 | - free (result); | ||
21099 | - if (buf_malloced != NULL) | ||
21100 | - free (buf_malloced); | ||
21101 | - CLEANUP (); | ||
21102 | - errno = saved_errno; | ||
21103 | - return NULL; | ||
21104 | - } | ||
21105 | - if (converted != result + length) | ||
21106 | - { | ||
21107 | - ENSURE_ALLOCATION (xsum (length, converted_len)); | ||
21108 | - DCHAR_CPY (result + length, converted, converted_len); | ||
21109 | - free (converted); | ||
21110 | - } | ||
21111 | - length += converted_len; | ||
21112 | - } | ||
21113 | -# endif | ||
21114 | - | ||
21115 | - if (has_width && width > characters | ||
21116 | - && (dp->flags & FLAG_LEFT)) | ||
21117 | - { | ||
21118 | - size_t n = width - characters; | ||
21119 | - ENSURE_ALLOCATION (xsum (length, n)); | ||
21120 | - DCHAR_SET (result + length, ' ', n); | ||
21121 | - length += n; | ||
21122 | - } | ||
21123 | - } | ||
21124 | - break; | ||
21125 | - | ||
21126 | - default: | ||
21127 | - abort (); | ||
21128 | - } | ||
21129 | - } | ||
21130 | -#endif | ||
21131 | -#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL | ||
21132 | - else if ((dp->conversion == 'a' || dp->conversion == 'A') | ||
21133 | -# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) | ||
21134 | - && (0 | ||
21135 | -# if NEED_PRINTF_DOUBLE | ||
21136 | - || a.arg[dp->arg_index].type == TYPE_DOUBLE | ||
21137 | -# endif | ||
21138 | -# if NEED_PRINTF_LONG_DOUBLE | ||
21139 | - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE | ||
21140 | -# endif | ||
21141 | - ) | ||
21142 | -# endif | ||
21143 | - ) | ||
21144 | - { | ||
21145 | - arg_type type = a.arg[dp->arg_index].type; | ||
21146 | - int flags = dp->flags; | ||
21147 | - int has_width; | ||
21148 | - size_t width; | ||
21149 | - int has_precision; | ||
21150 | - size_t precision; | ||
21151 | - size_t tmp_length; | ||
21152 | - DCHAR_T tmpbuf[700]; | ||
21153 | - DCHAR_T *tmp; | ||
21154 | - DCHAR_T *pad_ptr; | ||
21155 | - DCHAR_T *p; | ||
21156 | - | ||
21157 | - has_width = 0; | ||
21158 | - width = 0; | ||
21159 | - if (dp->width_start != dp->width_end) | ||
21160 | - { | ||
21161 | - if (dp->width_arg_index != ARG_NONE) | ||
21162 | - { | ||
21163 | - int arg; | ||
21164 | - | ||
21165 | - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) | ||
21166 | - abort (); | ||
21167 | - arg = a.arg[dp->width_arg_index].a.a_int; | ||
21168 | - if (arg < 0) | ||
21169 | - { | ||
21170 | - /* "A negative field width is taken as a '-' flag | ||
21171 | - followed by a positive field width." */ | ||
21172 | - flags |= FLAG_LEFT; | ||
21173 | - width = (unsigned int) (-arg); | ||
21174 | - } | ||
21175 | - else | ||
21176 | - width = arg; | ||
21177 | - } | ||
21178 | - else | ||
21179 | - { | ||
21180 | - const FCHAR_T *digitp = dp->width_start; | ||
21181 | - | ||
21182 | - do | ||
21183 | - width = xsum (xtimes (width, 10), *digitp++ - '0'); | ||
21184 | - while (digitp != dp->width_end); | ||
21185 | - } | ||
21186 | - has_width = 1; | ||
21187 | - } | ||
21188 | - | ||
21189 | - has_precision = 0; | ||
21190 | - precision = 0; | ||
21191 | - if (dp->precision_start != dp->precision_end) | ||
21192 | - { | ||
21193 | - if (dp->precision_arg_index != ARG_NONE) | ||
21194 | - { | ||
21195 | - int arg; | ||
21196 | - | ||
21197 | - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) | ||
21198 | - abort (); | ||
21199 | - arg = a.arg[dp->precision_arg_index].a.a_int; | ||
21200 | - /* "A negative precision is taken as if the precision | ||
21201 | - were omitted." */ | ||
21202 | - if (arg >= 0) | ||
21203 | - { | ||
21204 | - precision = arg; | ||
21205 | - has_precision = 1; | ||
21206 | - } | ||
21207 | - } | ||
21208 | - else | ||
21209 | - { | ||
21210 | - const FCHAR_T *digitp = dp->precision_start + 1; | ||
21211 | - | ||
21212 | - precision = 0; | ||
21213 | - while (digitp != dp->precision_end) | ||
21214 | - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); | ||
21215 | - has_precision = 1; | ||
21216 | - } | ||
21217 | - } | ||
21218 | - | ||
21219 | - /* Allocate a temporary buffer of sufficient size. */ | ||
21220 | - if (type == TYPE_LONGDOUBLE) | ||
21221 | - tmp_length = | ||
21222 | - (unsigned int) ((LDBL_DIG + 1) | ||
21223 | - * 0.831 /* decimal -> hexadecimal */ | ||
21224 | - ) | ||
21225 | - + 1; /* turn floor into ceil */ | ||
21226 | - else | ||
21227 | - tmp_length = | ||
21228 | - (unsigned int) ((DBL_DIG + 1) | ||
21229 | - * 0.831 /* decimal -> hexadecimal */ | ||
21230 | - ) | ||
21231 | - + 1; /* turn floor into ceil */ | ||
21232 | - if (tmp_length < precision) | ||
21233 | - tmp_length = precision; | ||
21234 | - /* Account for sign, decimal point etc. */ | ||
21235 | - tmp_length = xsum (tmp_length, 12); | ||
21236 | - | ||
21237 | - if (tmp_length < width) | ||
21238 | - tmp_length = width; | ||
21239 | - | ||
21240 | - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ | ||
21241 | - | ||
21242 | - if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) | ||
21243 | - tmp = tmpbuf; | ||
21244 | - else | ||
21245 | - { | ||
21246 | - size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); | ||
21247 | - | ||
21248 | - if (size_overflow_p (tmp_memsize)) | ||
21249 | - /* Overflow, would lead to out of memory. */ | ||
21250 | - goto out_of_memory; | ||
21251 | - tmp = (DCHAR_T *) malloc (tmp_memsize); | ||
21252 | - if (tmp == NULL) | ||
21253 | - /* Out of memory. */ | ||
21254 | - goto out_of_memory; | ||
21255 | - } | ||
21256 | - | ||
21257 | - pad_ptr = NULL; | ||
21258 | - p = tmp; | ||
21259 | - if (type == TYPE_LONGDOUBLE) | ||
21260 | - { | ||
21261 | -# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE | ||
21262 | - long double arg = a.arg[dp->arg_index].a.a_longdouble; | ||
21263 | - | ||
21264 | - if (isnanl (arg)) | ||
21265 | - { | ||
21266 | - if (dp->conversion == 'A') | ||
21267 | - { | ||
21268 | - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; | ||
21269 | - } | ||
21270 | - else | ||
21271 | - { | ||
21272 | - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; | ||
21273 | - } | ||
21274 | - } | ||
21275 | - else | ||
21276 | - { | ||
21277 | - int sign = 0; | ||
21278 | - DECL_LONG_DOUBLE_ROUNDING | ||
21279 | - | ||
21280 | - BEGIN_LONG_DOUBLE_ROUNDING (); | ||
21281 | - | ||
21282 | - if (signbit (arg)) /* arg < 0.0L or negative zero */ | ||
21283 | - { | ||
21284 | - sign = -1; | ||
21285 | - arg = -arg; | ||
21286 | - } | ||
21287 | - | ||
21288 | - if (sign < 0) | ||
21289 | - *p++ = '-'; | ||
21290 | - else if (flags & FLAG_SHOWSIGN) | ||
21291 | - *p++ = '+'; | ||
21292 | - else if (flags & FLAG_SPACE) | ||
21293 | - *p++ = ' '; | ||
21294 | - | ||
21295 | - if (arg > 0.0L && arg + arg == arg) | ||
21296 | - { | ||
21297 | - if (dp->conversion == 'A') | ||
21298 | - { | ||
21299 | - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; | ||
21300 | - } | ||
21301 | - else | ||
21302 | - { | ||
21303 | - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; | ||
21304 | - } | ||
21305 | - } | ||
21306 | - else | ||
21307 | - { | ||
21308 | - int exponent; | ||
21309 | - long double mantissa; | ||
21310 | - | ||
21311 | - if (arg > 0.0L) | ||
21312 | - mantissa = printf_frexpl (arg, &exponent); | ||
21313 | - else | ||
21314 | - { | ||
21315 | - exponent = 0; | ||
21316 | - mantissa = 0.0L; | ||
21317 | - } | ||
21318 | - | ||
21319 | - if (has_precision | ||
21320 | - && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1) | ||
21321 | - { | ||
21322 | - /* Round the mantissa. */ | ||
21323 | - long double tail = mantissa; | ||
21324 | - size_t q; | ||
21325 | - | ||
21326 | - for (q = precision; ; q--) | ||
21327 | - { | ||
21328 | - int digit = (int) tail; | ||
21329 | - tail -= digit; | ||
21330 | - if (q == 0) | ||
21331 | - { | ||
21332 | - if (digit & 1 ? tail >= 0.5L : tail > 0.5L) | ||
21333 | - tail = 1 - tail; | ||
21334 | - else | ||
21335 | - tail = - tail; | ||
21336 | - break; | ||
21337 | - } | ||
21338 | - tail *= 16.0L; | ||
21339 | - } | ||
21340 | - if (tail != 0.0L) | ||
21341 | - for (q = precision; q > 0; q--) | ||
21342 | - tail *= 0.0625L; | ||
21343 | - mantissa += tail; | ||
21344 | - } | ||
21345 | - | ||
21346 | - *p++ = '0'; | ||
21347 | - *p++ = dp->conversion - 'A' + 'X'; | ||
21348 | - pad_ptr = p; | ||
21349 | - { | ||
21350 | - int digit; | ||
21351 | - | ||
21352 | - digit = (int) mantissa; | ||
21353 | - mantissa -= digit; | ||
21354 | - *p++ = '0' + digit; | ||
21355 | - if ((flags & FLAG_ALT) | ||
21356 | - || mantissa > 0.0L || precision > 0) | ||
21357 | - { | ||
21358 | - *p++ = decimal_point_char (); | ||
21359 | - /* This loop terminates because we assume | ||
21360 | - that FLT_RADIX is a power of 2. */ | ||
21361 | - while (mantissa > 0.0L) | ||
21362 | - { | ||
21363 | - mantissa *= 16.0L; | ||
21364 | - digit = (int) mantissa; | ||
21365 | - mantissa -= digit; | ||
21366 | - *p++ = digit | ||
21367 | - + (digit < 10 | ||
21368 | - ? '0' | ||
21369 | - : dp->conversion - 10); | ||
21370 | - if (precision > 0) | ||
21371 | - precision--; | ||
21372 | - } | ||
21373 | - while (precision > 0) | ||
21374 | - { | ||
21375 | - *p++ = '0'; | ||
21376 | - precision--; | ||
21377 | - } | ||
21378 | - } | ||
21379 | - } | ||
21380 | - *p++ = dp->conversion - 'A' + 'P'; | ||
21381 | -# if WIDE_CHAR_VERSION | ||
21382 | - { | ||
21383 | - static const wchar_t decimal_format[] = | ||
21384 | - { '%', '+', 'd', '\0' }; | ||
21385 | - SNPRINTF (p, 6 + 1, decimal_format, exponent); | ||
21386 | - } | ||
21387 | - while (*p != '\0') | ||
21388 | - p++; | ||
21389 | -# else | ||
21390 | - if (sizeof (DCHAR_T) == 1) | ||
21391 | - { | ||
21392 | - sprintf ((char *) p, "%+d", exponent); | ||
21393 | - while (*p != '\0') | ||
21394 | - p++; | ||
21395 | - } | ||
21396 | - else | ||
21397 | - { | ||
21398 | - char expbuf[6 + 1]; | ||
21399 | - const char *ep; | ||
21400 | - sprintf (expbuf, "%+d", exponent); | ||
21401 | - for (ep = expbuf; (*p = *ep) != '\0'; ep++) | ||
21402 | - p++; | ||
21403 | - } | ||
21404 | -# endif | ||
21405 | - } | ||
21406 | - | ||
21407 | - END_LONG_DOUBLE_ROUNDING (); | ||
21408 | - } | ||
21409 | -# else | ||
21410 | - abort (); | ||
21411 | -# endif | ||
21412 | - } | ||
21413 | - else | ||
21414 | - { | ||
21415 | -# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE | ||
21416 | - double arg = a.arg[dp->arg_index].a.a_double; | ||
21417 | - | ||
21418 | - if (isnan (arg)) | ||
21419 | - { | ||
21420 | - if (dp->conversion == 'A') | ||
21421 | - { | ||
21422 | - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; | ||
21423 | - } | ||
21424 | - else | ||
21425 | - { | ||
21426 | - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; | ||
21427 | - } | ||
21428 | - } | ||
21429 | - else | ||
21430 | - { | ||
21431 | - int sign = 0; | ||
21432 | - | ||
21433 | - if (signbit (arg)) /* arg < 0.0 or negative zero */ | ||
21434 | - { | ||
21435 | - sign = -1; | ||
21436 | - arg = -arg; | ||
21437 | - } | ||
21438 | - | ||
21439 | - if (sign < 0) | ||
21440 | - *p++ = '-'; | ||
21441 | - else if (flags & FLAG_SHOWSIGN) | ||
21442 | - *p++ = '+'; | ||
21443 | - else if (flags & FLAG_SPACE) | ||
21444 | - *p++ = ' '; | ||
21445 | - | ||
21446 | - if (arg > 0.0 && arg + arg == arg) | ||
21447 | - { | ||
21448 | - if (dp->conversion == 'A') | ||
21449 | - { | ||
21450 | - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; | ||
21451 | - } | ||
21452 | - else | ||
21453 | - { | ||
21454 | - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; | ||
21455 | - } | ||
21456 | - } | ||
21457 | - else | ||
21458 | - { | ||
21459 | - int exponent; | ||
21460 | - double mantissa; | ||
21461 | - | ||
21462 | - if (arg > 0.0) | ||
21463 | - mantissa = printf_frexp (arg, &exponent); | ||
21464 | - else | ||
21465 | - { | ||
21466 | - exponent = 0; | ||
21467 | - mantissa = 0.0; | ||
21468 | - } | ||
21469 | - | ||
21470 | - if (has_precision | ||
21471 | - && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1) | ||
21472 | - { | ||
21473 | - /* Round the mantissa. */ | ||
21474 | - double tail = mantissa; | ||
21475 | - size_t q; | ||
21476 | - | ||
21477 | - for (q = precision; ; q--) | ||
21478 | - { | ||
21479 | - int digit = (int) tail; | ||
21480 | - tail -= digit; | ||
21481 | - if (q == 0) | ||
21482 | - { | ||
21483 | - if (digit & 1 ? tail >= 0.5 : tail > 0.5) | ||
21484 | - tail = 1 - tail; | ||
21485 | - else | ||
21486 | - tail = - tail; | ||
21487 | - break; | ||
21488 | - } | ||
21489 | - tail *= 16.0; | ||
21490 | - } | ||
21491 | - if (tail != 0.0) | ||
21492 | - for (q = precision; q > 0; q--) | ||
21493 | - tail *= 0.0625; | ||
21494 | - mantissa += tail; | ||
21495 | - } | ||
21496 | - | ||
21497 | - *p++ = '0'; | ||
21498 | - *p++ = dp->conversion - 'A' + 'X'; | ||
21499 | - pad_ptr = p; | ||
21500 | - { | ||
21501 | - int digit; | ||
21502 | - | ||
21503 | - digit = (int) mantissa; | ||
21504 | - mantissa -= digit; | ||
21505 | - *p++ = '0' + digit; | ||
21506 | - if ((flags & FLAG_ALT) | ||
21507 | - || mantissa > 0.0 || precision > 0) | ||
21508 | - { | ||
21509 | - *p++ = decimal_point_char (); | ||
21510 | - /* This loop terminates because we assume | ||
21511 | - that FLT_RADIX is a power of 2. */ | ||
21512 | - while (mantissa > 0.0) | ||
21513 | - { | ||
21514 | - mantissa *= 16.0; | ||
21515 | - digit = (int) mantissa; | ||
21516 | - mantissa -= digit; | ||
21517 | - *p++ = digit | ||
21518 | - + (digit < 10 | ||
21519 | - ? '0' | ||
21520 | - : dp->conversion - 10); | ||
21521 | - if (precision > 0) | ||
21522 | - precision--; | ||
21523 | - } | ||
21524 | - while (precision > 0) | ||
21525 | - { | ||
21526 | - *p++ = '0'; | ||
21527 | - precision--; | ||
21528 | - } | ||
21529 | - } | ||
21530 | - } | ||
21531 | - *p++ = dp->conversion - 'A' + 'P'; | ||
21532 | -# if WIDE_CHAR_VERSION | ||
21533 | - { | ||
21534 | - static const wchar_t decimal_format[] = | ||
21535 | - { '%', '+', 'd', '\0' }; | ||
21536 | - SNPRINTF (p, 6 + 1, decimal_format, exponent); | ||
21537 | - } | ||
21538 | - while (*p != '\0') | ||
21539 | - p++; | ||
21540 | -# else | ||
21541 | - if (sizeof (DCHAR_T) == 1) | ||
21542 | - { | ||
21543 | - sprintf ((char *) p, "%+d", exponent); | ||
21544 | - while (*p != '\0') | ||
21545 | - p++; | ||
21546 | - } | ||
21547 | - else | ||
21548 | - { | ||
21549 | - char expbuf[6 + 1]; | ||
21550 | - const char *ep; | ||
21551 | - sprintf (expbuf, "%+d", exponent); | ||
21552 | - for (ep = expbuf; (*p = *ep) != '\0'; ep++) | ||
21553 | - p++; | ||
21554 | - } | ||
21555 | -# endif | ||
21556 | - } | ||
21557 | - } | ||
21558 | -# else | ||
21559 | - abort (); | ||
21560 | -# endif | ||
21561 | - } | ||
21562 | - /* The generated string now extends from tmp to p, with the | ||
21563 | - zero padding insertion point being at pad_ptr. */ | ||
21564 | - if (has_width && p - tmp < width) | ||
21565 | - { | ||
21566 | - size_t pad = width - (p - tmp); | ||
21567 | - DCHAR_T *end = p + pad; | ||
21568 | - | ||
21569 | - if (flags & FLAG_LEFT) | ||
21570 | - { | ||
21571 | - /* Pad with spaces on the right. */ | ||
21572 | - for (; pad > 0; pad--) | ||
21573 | - *p++ = ' '; | ||
21574 | - } | ||
21575 | - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) | ||
21576 | - { | ||
21577 | - /* Pad with zeroes. */ | ||
21578 | - DCHAR_T *q = end; | ||
21579 | - | ||
21580 | - while (p > pad_ptr) | ||
21581 | - *--q = *--p; | ||
21582 | - for (; pad > 0; pad--) | ||
21583 | - *p++ = '0'; | ||
21584 | - } | ||
21585 | - else | ||
21586 | - { | ||
21587 | - /* Pad with spaces on the left. */ | ||
21588 | - DCHAR_T *q = end; | ||
21589 | - | ||
21590 | - while (p > tmp) | ||
21591 | - *--q = *--p; | ||
21592 | - for (; pad > 0; pad--) | ||
21593 | - *p++ = ' '; | ||
21594 | - } | ||
21595 | - | ||
21596 | - p = end; | ||
21597 | - } | ||
21598 | - | ||
21599 | - { | ||
21600 | - size_t count = p - tmp; | ||
21601 | - | ||
21602 | - if (count >= tmp_length) | ||
21603 | - /* tmp_length was incorrectly calculated - fix the | ||
21604 | - code above! */ | ||
21605 | - abort (); | ||
21606 | - | ||
21607 | - /* Make room for the result. */ | ||
21608 | - if (count >= allocated - length) | ||
21609 | - { | ||
21610 | - size_t n = xsum (length, count); | ||
21611 | - | ||
21612 | - ENSURE_ALLOCATION (n); | ||
21613 | - } | ||
21614 | - | ||
21615 | - /* Append the result. */ | ||
21616 | - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); | ||
21617 | - if (tmp != tmpbuf) | ||
21618 | - free (tmp); | ||
21619 | - length += count; | ||
21620 | - } | ||
21621 | - } | ||
21622 | -#endif | ||
21623 | -#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL | ||
21624 | - else if ((dp->conversion == 'f' || dp->conversion == 'F' | ||
21625 | - || dp->conversion == 'e' || dp->conversion == 'E' | ||
21626 | - || dp->conversion == 'g' || dp->conversion == 'G' | ||
21627 | - || dp->conversion == 'a' || dp->conversion == 'A') | ||
21628 | - && (0 | ||
21629 | -# if NEED_PRINTF_DOUBLE | ||
21630 | - || a.arg[dp->arg_index].type == TYPE_DOUBLE | ||
21631 | -# elif NEED_PRINTF_INFINITE_DOUBLE | ||
21632 | - || (a.arg[dp->arg_index].type == TYPE_DOUBLE | ||
21633 | - /* The systems (mingw) which produce wrong output | ||
21634 | - for Inf, -Inf, and NaN also do so for -0.0. | ||
21635 | - Therefore we treat this case here as well. */ | ||
21636 | - && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double)) | ||
21637 | -# endif | ||
21638 | -# if NEED_PRINTF_LONG_DOUBLE | ||
21639 | - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE | ||
21640 | -# elif NEED_PRINTF_INFINITE_LONG_DOUBLE | ||
21641 | - || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE | ||
21642 | - /* Some systems produce wrong output for Inf, | ||
21643 | - -Inf, and NaN. */ | ||
21644 | - && is_infinitel (a.arg[dp->arg_index].a.a_longdouble)) | ||
21645 | -# endif | ||
21646 | - )) | ||
21647 | - { | ||
21648 | -# if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) | ||
21649 | - arg_type type = a.arg[dp->arg_index].type; | ||
21650 | -# endif | ||
21651 | - int flags = dp->flags; | ||
21652 | - int has_width; | ||
21653 | - size_t width; | ||
21654 | - int has_precision; | ||
21655 | - size_t precision; | ||
21656 | - size_t tmp_length; | ||
21657 | - DCHAR_T tmpbuf[700]; | ||
21658 | - DCHAR_T *tmp; | ||
21659 | - DCHAR_T *pad_ptr; | ||
21660 | - DCHAR_T *p; | ||
21661 | - | ||
21662 | - has_width = 0; | ||
21663 | - width = 0; | ||
21664 | - if (dp->width_start != dp->width_end) | ||
21665 | - { | ||
21666 | - if (dp->width_arg_index != ARG_NONE) | ||
21667 | - { | ||
21668 | - int arg; | ||
21669 | - | ||
21670 | - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) | ||
21671 | - abort (); | ||
21672 | - arg = a.arg[dp->width_arg_index].a.a_int; | ||
21673 | - if (arg < 0) | ||
21674 | - { | ||
21675 | - /* "A negative field width is taken as a '-' flag | ||
21676 | - followed by a positive field width." */ | ||
21677 | - flags |= FLAG_LEFT; | ||
21678 | - width = (unsigned int) (-arg); | ||
21679 | - } | ||
21680 | - else | ||
21681 | - width = arg; | ||
21682 | - } | ||
21683 | - else | ||
21684 | - { | ||
21685 | - const FCHAR_T *digitp = dp->width_start; | ||
21686 | - | ||
21687 | - do | ||
21688 | - width = xsum (xtimes (width, 10), *digitp++ - '0'); | ||
21689 | - while (digitp != dp->width_end); | ||
21690 | - } | ||
21691 | - has_width = 1; | ||
21692 | - } | ||
21693 | - | ||
21694 | - has_precision = 0; | ||
21695 | - precision = 0; | ||
21696 | - if (dp->precision_start != dp->precision_end) | ||
21697 | - { | ||
21698 | - if (dp->precision_arg_index != ARG_NONE) | ||
21699 | - { | ||
21700 | - int arg; | ||
21701 | - | ||
21702 | - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) | ||
21703 | - abort (); | ||
21704 | - arg = a.arg[dp->precision_arg_index].a.a_int; | ||
21705 | - /* "A negative precision is taken as if the precision | ||
21706 | - were omitted." */ | ||
21707 | - if (arg >= 0) | ||
21708 | - { | ||
21709 | - precision = arg; | ||
21710 | - has_precision = 1; | ||
21711 | - } | ||
21712 | - } | ||
21713 | - else | ||
21714 | - { | ||
21715 | - const FCHAR_T *digitp = dp->precision_start + 1; | ||
21716 | - | ||
21717 | - precision = 0; | ||
21718 | - while (digitp != dp->precision_end) | ||
21719 | - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); | ||
21720 | - has_precision = 1; | ||
21721 | - } | ||
21722 | - } | ||
21723 | - | ||
21724 | - /* POSIX specifies the default precision to be 6 for %f, %F, | ||
21725 | - %e, %E, but not for %g, %G. Implementations appear to use | ||
21726 | - the same default precision also for %g, %G. */ | ||
21727 | - if (!has_precision) | ||
21728 | - precision = 6; | ||
21729 | - | ||
21730 | - /* Allocate a temporary buffer of sufficient size. */ | ||
21731 | -# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE | ||
21732 | - tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); | ||
21733 | -# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE | ||
21734 | - tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); | ||
21735 | -# elif NEED_PRINTF_LONG_DOUBLE | ||
21736 | - tmp_length = LDBL_DIG + 1; | ||
21737 | -# elif NEED_PRINTF_DOUBLE | ||
21738 | - tmp_length = DBL_DIG + 1; | ||
21739 | -# else | ||
21740 | - tmp_length = 0; | ||
21741 | -# endif | ||
21742 | - if (tmp_length < precision) | ||
21743 | - tmp_length = precision; | ||
21744 | -# if NEED_PRINTF_LONG_DOUBLE | ||
21745 | -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE | ||
21746 | - if (type == TYPE_LONGDOUBLE) | ||
21747 | -# endif | ||
21748 | - if (dp->conversion == 'f' || dp->conversion == 'F') | ||
21749 | - { | ||
21750 | - long double arg = a.arg[dp->arg_index].a.a_longdouble; | ||
21751 | - if (!(isnanl (arg) || arg + arg == arg)) | ||
21752 | - { | ||
21753 | - /* arg is finite and nonzero. */ | ||
21754 | - int exponent = floorlog10l (arg < 0 ? -arg : arg); | ||
21755 | - if (exponent >= 0 && tmp_length < exponent + precision) | ||
21756 | - tmp_length = exponent + precision; | ||
21757 | - } | ||
21758 | - } | ||
21759 | -# endif | ||
21760 | -# if NEED_PRINTF_DOUBLE | ||
21761 | -# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE | ||
21762 | - if (type == TYPE_DOUBLE) | ||
21763 | -# endif | ||
21764 | - if (dp->conversion == 'f' || dp->conversion == 'F') | ||
21765 | - { | ||
21766 | - double arg = a.arg[dp->arg_index].a.a_double; | ||
21767 | - if (!(isnan (arg) || arg + arg == arg)) | ||
21768 | - { | ||
21769 | - /* arg is finite and nonzero. */ | ||
21770 | - int exponent = floorlog10 (arg < 0 ? -arg : arg); | ||
21771 | - if (exponent >= 0 && tmp_length < exponent + precision) | ||
21772 | - tmp_length = exponent + precision; | ||
21773 | - } | ||
21774 | - } | ||
21775 | -# endif | ||
21776 | - /* Account for sign, decimal point etc. */ | ||
21777 | - tmp_length = xsum (tmp_length, 12); | ||
21778 | - | ||
21779 | - if (tmp_length < width) | ||
21780 | - tmp_length = width; | ||
21781 | - | ||
21782 | - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ | ||
21783 | - | ||
21784 | - if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) | ||
21785 | - tmp = tmpbuf; | ||
21786 | - else | ||
21787 | - { | ||
21788 | - size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); | ||
21789 | - | ||
21790 | - if (size_overflow_p (tmp_memsize)) | ||
21791 | - /* Overflow, would lead to out of memory. */ | ||
21792 | - goto out_of_memory; | ||
21793 | - tmp = (DCHAR_T *) malloc (tmp_memsize); | ||
21794 | - if (tmp == NULL) | ||
21795 | - /* Out of memory. */ | ||
21796 | - goto out_of_memory; | ||
21797 | - } | ||
21798 | - | ||
21799 | - pad_ptr = NULL; | ||
21800 | - p = tmp; | ||
21801 | - | ||
21802 | -# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE | ||
21803 | -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE | ||
21804 | - if (type == TYPE_LONGDOUBLE) | ||
21805 | -# endif | ||
21806 | - { | ||
21807 | - long double arg = a.arg[dp->arg_index].a.a_longdouble; | ||
21808 | - | ||
21809 | - if (isnanl (arg)) | ||
21810 | - { | ||
21811 | - if (dp->conversion >= 'A' && dp->conversion <= 'Z') | ||
21812 | - { | ||
21813 | - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; | ||
21814 | - } | ||
21815 | - else | ||
21816 | - { | ||
21817 | - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; | ||
21818 | - } | ||
21819 | - } | ||
21820 | - else | ||
21821 | - { | ||
21822 | - int sign = 0; | ||
21823 | - DECL_LONG_DOUBLE_ROUNDING | ||
21824 | - | ||
21825 | - BEGIN_LONG_DOUBLE_ROUNDING (); | ||
21826 | - | ||
21827 | - if (signbit (arg)) /* arg < 0.0L or negative zero */ | ||
21828 | - { | ||
21829 | - sign = -1; | ||
21830 | - arg = -arg; | ||
21831 | - } | ||
21832 | - | ||
21833 | - if (sign < 0) | ||
21834 | - *p++ = '-'; | ||
21835 | - else if (flags & FLAG_SHOWSIGN) | ||
21836 | - *p++ = '+'; | ||
21837 | - else if (flags & FLAG_SPACE) | ||
21838 | - *p++ = ' '; | ||
21839 | - | ||
21840 | - if (arg > 0.0L && arg + arg == arg) | ||
21841 | - { | ||
21842 | - if (dp->conversion >= 'A' && dp->conversion <= 'Z') | ||
21843 | - { | ||
21844 | - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; | ||
21845 | - } | ||
21846 | - else | ||
21847 | - { | ||
21848 | - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; | ||
21849 | - } | ||
21850 | - } | ||
21851 | - else | ||
21852 | - { | ||
21853 | -# if NEED_PRINTF_LONG_DOUBLE | ||
21854 | - pad_ptr = p; | ||
21855 | - | ||
21856 | - if (dp->conversion == 'f' || dp->conversion == 'F') | ||
21857 | - { | ||
21858 | - char *digits; | ||
21859 | - size_t ndigits; | ||
21860 | - | ||
21861 | - digits = | ||
21862 | - scale10_round_decimal_long_double (arg, precision); | ||
21863 | - if (digits == NULL) | ||
21864 | - { | ||
21865 | - END_LONG_DOUBLE_ROUNDING (); | ||
21866 | - goto out_of_memory; | ||
21867 | - } | ||
21868 | - ndigits = strlen (digits); | ||
21869 | - | ||
21870 | - if (ndigits > precision) | ||
21871 | - do | ||
21872 | - { | ||
21873 | - --ndigits; | ||
21874 | - *p++ = digits[ndigits]; | ||
21875 | - } | ||
21876 | - while (ndigits > precision); | ||
21877 | - else | ||
21878 | - *p++ = '0'; | ||
21879 | - /* Here ndigits <= precision. */ | ||
21880 | - if ((flags & FLAG_ALT) || precision > 0) | ||
21881 | - { | ||
21882 | - *p++ = decimal_point_char (); | ||
21883 | - for (; precision > ndigits; precision--) | ||
21884 | - *p++ = '0'; | ||
21885 | - while (ndigits > 0) | ||
21886 | - { | ||
21887 | - --ndigits; | ||
21888 | - *p++ = digits[ndigits]; | ||
21889 | - } | ||
21890 | - } | ||
21891 | - | ||
21892 | - free (digits); | ||
21893 | - } | ||
21894 | - else if (dp->conversion == 'e' || dp->conversion == 'E') | ||
21895 | - { | ||
21896 | - int exponent; | ||
21897 | - | ||
21898 | - if (arg == 0.0L) | ||
21899 | - { | ||
21900 | - exponent = 0; | ||
21901 | - *p++ = '0'; | ||
21902 | - if ((flags & FLAG_ALT) || precision > 0) | ||
21903 | - { | ||
21904 | - *p++ = decimal_point_char (); | ||
21905 | - for (; precision > 0; precision--) | ||
21906 | - *p++ = '0'; | ||
21907 | - } | ||
21908 | - } | ||
21909 | - else | ||
21910 | - { | ||
21911 | - /* arg > 0.0L. */ | ||
21912 | - int adjusted; | ||
21913 | - char *digits; | ||
21914 | - size_t ndigits; | ||
21915 | - | ||
21916 | - exponent = floorlog10l (arg); | ||
21917 | - adjusted = 0; | ||
21918 | - for (;;) | ||
21919 | - { | ||
21920 | - digits = | ||
21921 | - scale10_round_decimal_long_double (arg, | ||
21922 | - (int)precision - exponent); | ||
21923 | - if (digits == NULL) | ||
21924 | - { | ||
21925 | - END_LONG_DOUBLE_ROUNDING (); | ||
21926 | - goto out_of_memory; | ||
21927 | - } | ||
21928 | - ndigits = strlen (digits); | ||
21929 | - | ||
21930 | - if (ndigits == precision + 1) | ||
21931 | - break; | ||
21932 | - if (ndigits < precision | ||
21933 | - || ndigits > precision + 2) | ||
21934 | - /* The exponent was not guessed | ||
21935 | - precisely enough. */ | ||
21936 | - abort (); | ||
21937 | - if (adjusted) | ||
21938 | - /* None of two values of exponent is | ||
21939 | - the right one. Prevent an endless | ||
21940 | - loop. */ | ||
21941 | - abort (); | ||
21942 | - free (digits); | ||
21943 | - if (ndigits == precision) | ||
21944 | - exponent -= 1; | ||
21945 | - else | ||
21946 | - exponent += 1; | ||
21947 | - adjusted = 1; | ||
21948 | - } | ||
21949 | - | ||
21950 | - /* Here ndigits = precision+1. */ | ||
21951 | - *p++ = digits[--ndigits]; | ||
21952 | - if ((flags & FLAG_ALT) || precision > 0) | ||
21953 | - { | ||
21954 | - *p++ = decimal_point_char (); | ||
21955 | - while (ndigits > 0) | ||
21956 | - { | ||
21957 | - --ndigits; | ||
21958 | - *p++ = digits[ndigits]; | ||
21959 | - } | ||
21960 | - } | ||
21961 | - | ||
21962 | - free (digits); | ||
21963 | - } | ||
21964 | - | ||
21965 | - *p++ = dp->conversion; /* 'e' or 'E' */ | ||
21966 | -# if WIDE_CHAR_VERSION | ||
21967 | - { | ||
21968 | - static const wchar_t decimal_format[] = | ||
21969 | - { '%', '+', '.', '2', 'd', '\0' }; | ||
21970 | - SNPRINTF (p, 6 + 1, decimal_format, exponent); | ||
21971 | - } | ||
21972 | - while (*p != '\0') | ||
21973 | - p++; | ||
21974 | -# else | ||
21975 | - if (sizeof (DCHAR_T) == 1) | ||
21976 | - { | ||
21977 | - sprintf ((char *) p, "%+.2d", exponent); | ||
21978 | - while (*p != '\0') | ||
21979 | - p++; | ||
21980 | - } | ||
21981 | - else | ||
21982 | - { | ||
21983 | - char expbuf[6 + 1]; | ||
21984 | - const char *ep; | ||
21985 | - sprintf (expbuf, "%+.2d", exponent); | ||
21986 | - for (ep = expbuf; (*p = *ep) != '\0'; ep++) | ||
21987 | - p++; | ||
21988 | - } | ||
21989 | -# endif | ||
21990 | - } | ||
21991 | - else if (dp->conversion == 'g' || dp->conversion == 'G') | ||
21992 | - { | ||
21993 | - if (precision == 0) | ||
21994 | - precision = 1; | ||
21995 | - /* precision >= 1. */ | ||
21996 | - | ||
21997 | - if (arg == 0.0L) | ||
21998 | - /* The exponent is 0, >= -4, < precision. | ||
21999 | - Use fixed-point notation. */ | ||
22000 | - { | ||
22001 | - size_t ndigits = precision; | ||
22002 | - /* Number of trailing zeroes that have to be | ||
22003 | - dropped. */ | ||
22004 | - size_t nzeroes = | ||
22005 | - (flags & FLAG_ALT ? 0 : precision - 1); | ||
22006 | - | ||
22007 | - --ndigits; | ||
22008 | - *p++ = '0'; | ||
22009 | - if ((flags & FLAG_ALT) || ndigits > nzeroes) | ||
22010 | - { | ||
22011 | - *p++ = decimal_point_char (); | ||
22012 | - while (ndigits > nzeroes) | ||
22013 | - { | ||
22014 | - --ndigits; | ||
22015 | - *p++ = '0'; | ||
22016 | - } | ||
22017 | - } | ||
22018 | - } | ||
22019 | - else | ||
22020 | - { | ||
22021 | - /* arg > 0.0L. */ | ||
22022 | - int exponent; | ||
22023 | - int adjusted; | ||
22024 | - char *digits; | ||
22025 | - size_t ndigits; | ||
22026 | - size_t nzeroes; | ||
22027 | - | ||
22028 | - exponent = floorlog10l (arg); | ||
22029 | - adjusted = 0; | ||
22030 | - for (;;) | ||
22031 | - { | ||
22032 | - digits = | ||
22033 | - scale10_round_decimal_long_double (arg, | ||
22034 | - (int)(precision - 1) - exponent); | ||
22035 | - if (digits == NULL) | ||
22036 | - { | ||
22037 | - END_LONG_DOUBLE_ROUNDING (); | ||
22038 | - goto out_of_memory; | ||
22039 | - } | ||
22040 | - ndigits = strlen (digits); | ||
22041 | - | ||
22042 | - if (ndigits == precision) | ||
22043 | - break; | ||
22044 | - if (ndigits < precision - 1 | ||
22045 | - || ndigits > precision + 1) | ||
22046 | - /* The exponent was not guessed | ||
22047 | - precisely enough. */ | ||
22048 | - abort (); | ||
22049 | - if (adjusted) | ||
22050 | - /* None of two values of exponent is | ||
22051 | - the right one. Prevent an endless | ||
22052 | - loop. */ | ||
22053 | - abort (); | ||
22054 | - free (digits); | ||
22055 | - if (ndigits < precision) | ||
22056 | - exponent -= 1; | ||
22057 | - else | ||
22058 | - exponent += 1; | ||
22059 | - adjusted = 1; | ||
22060 | - } | ||
22061 | - /* Here ndigits = precision. */ | ||
22062 | - | ||
22063 | - /* Determine the number of trailing zeroes | ||
22064 | - that have to be dropped. */ | ||
22065 | - nzeroes = 0; | ||
22066 | - if ((flags & FLAG_ALT) == 0) | ||
22067 | - while (nzeroes < ndigits | ||
22068 | - && digits[nzeroes] == '0') | ||
22069 | - nzeroes++; | ||
22070 | - | ||
22071 | - /* The exponent is now determined. */ | ||
22072 | - if (exponent >= -4 | ||
22073 | - && exponent < (long)precision) | ||
22074 | - { | ||
22075 | - /* Fixed-point notation: | ||
22076 | - max(exponent,0)+1 digits, then the | ||
22077 | - decimal point, then the remaining | ||
22078 | - digits without trailing zeroes. */ | ||
22079 | - if (exponent >= 0) | ||
22080 | - { | ||
22081 | - size_t count = exponent + 1; | ||
22082 | - /* Note: count <= precision = ndigits. */ | ||
22083 | - for (; count > 0; count--) | ||
22084 | - *p++ = digits[--ndigits]; | ||
22085 | - if ((flags & FLAG_ALT) || ndigits > nzeroes) | ||
22086 | - { | ||
22087 | - *p++ = decimal_point_char (); | ||
22088 | - while (ndigits > nzeroes) | ||
22089 | - { | ||
22090 | - --ndigits; | ||
22091 | - *p++ = digits[ndigits]; | ||
22092 | - } | ||
22093 | - } | ||
22094 | - } | ||
22095 | - else | ||
22096 | - { | ||
22097 | - size_t count = -exponent - 1; | ||
22098 | - *p++ = '0'; | ||
22099 | - *p++ = decimal_point_char (); | ||
22100 | - for (; count > 0; count--) | ||
22101 | - *p++ = '0'; | ||
22102 | - while (ndigits > nzeroes) | ||
22103 | - { | ||
22104 | - --ndigits; | ||
22105 | - *p++ = digits[ndigits]; | ||
22106 | - } | ||
22107 | - } | ||
22108 | - } | ||
22109 | - else | ||
22110 | - { | ||
22111 | - /* Exponential notation. */ | ||
22112 | - *p++ = digits[--ndigits]; | ||
22113 | - if ((flags & FLAG_ALT) || ndigits > nzeroes) | ||
22114 | - { | ||
22115 | - *p++ = decimal_point_char (); | ||
22116 | - while (ndigits > nzeroes) | ||
22117 | - { | ||
22118 | - --ndigits; | ||
22119 | - *p++ = digits[ndigits]; | ||
22120 | - } | ||
22121 | - } | ||
22122 | - *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ | ||
22123 | -# if WIDE_CHAR_VERSION | ||
22124 | - { | ||
22125 | - static const wchar_t decimal_format[] = | ||
22126 | - { '%', '+', '.', '2', 'd', '\0' }; | ||
22127 | - SNPRINTF (p, 6 + 1, decimal_format, exponent); | ||
22128 | - } | ||
22129 | - while (*p != '\0') | ||
22130 | - p++; | ||
22131 | -# else | ||
22132 | - if (sizeof (DCHAR_T) == 1) | ||
22133 | - { | ||
22134 | - sprintf ((char *) p, "%+.2d", exponent); | ||
22135 | - while (*p != '\0') | ||
22136 | - p++; | ||
22137 | - } | ||
22138 | - else | ||
22139 | - { | ||
22140 | - char expbuf[6 + 1]; | ||
22141 | - const char *ep; | ||
22142 | - sprintf (expbuf, "%+.2d", exponent); | ||
22143 | - for (ep = expbuf; (*p = *ep) != '\0'; ep++) | ||
22144 | - p++; | ||
22145 | - } | ||
22146 | -# endif | ||
22147 | - } | ||
22148 | - | ||
22149 | - free (digits); | ||
22150 | - } | ||
22151 | - } | ||
22152 | - else | ||
22153 | - abort (); | ||
22154 | -# else | ||
22155 | - /* arg is finite. */ | ||
22156 | - abort (); | ||
22157 | -# endif | ||
22158 | - } | ||
22159 | - | ||
22160 | - END_LONG_DOUBLE_ROUNDING (); | ||
22161 | - } | ||
22162 | - } | ||
22163 | -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE | ||
22164 | - else | ||
22165 | -# endif | ||
22166 | -# endif | ||
22167 | -# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE | ||
22168 | - { | ||
22169 | - double arg = a.arg[dp->arg_index].a.a_double; | ||
22170 | - | ||
22171 | - if (isnan (arg)) | ||
22172 | - { | ||
22173 | - if (dp->conversion >= 'A' && dp->conversion <= 'Z') | ||
22174 | - { | ||
22175 | - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; | ||
22176 | - } | ||
22177 | - else | ||
22178 | - { | ||
22179 | - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; | ||
22180 | - } | ||
22181 | - } | ||
22182 | - else | ||
22183 | - { | ||
22184 | - int sign = 0; | ||
22185 | - | ||
22186 | - if (signbit (arg)) /* arg < 0.0 or negative zero */ | ||
22187 | - { | ||
22188 | - sign = -1; | ||
22189 | - arg = -arg; | ||
22190 | - } | ||
22191 | - | ||
22192 | - if (sign < 0) | ||
22193 | - *p++ = '-'; | ||
22194 | - else if (flags & FLAG_SHOWSIGN) | ||
22195 | - *p++ = '+'; | ||
22196 | - else if (flags & FLAG_SPACE) | ||
22197 | - *p++ = ' '; | ||
22198 | - | ||
22199 | - if (arg > 0.0 && arg + arg == arg) | ||
22200 | - { | ||
22201 | - if (dp->conversion >= 'A' && dp->conversion <= 'Z') | ||
22202 | - { | ||
22203 | - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; | ||
22204 | - } | ||
22205 | - else | ||
22206 | - { | ||
22207 | - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; | ||
22208 | - } | ||
22209 | - } | ||
22210 | - else | ||
22211 | - { | ||
22212 | -# if NEED_PRINTF_DOUBLE | ||
22213 | - pad_ptr = p; | ||
22214 | - | ||
22215 | - if (dp->conversion == 'f' || dp->conversion == 'F') | ||
22216 | - { | ||
22217 | - char *digits; | ||
22218 | - size_t ndigits; | ||
22219 | - | ||
22220 | - digits = | ||
22221 | - scale10_round_decimal_double (arg, precision); | ||
22222 | - if (digits == NULL) | ||
22223 | - goto out_of_memory; | ||
22224 | - ndigits = strlen (digits); | ||
22225 | - | ||
22226 | - if (ndigits > precision) | ||
22227 | - do | ||
22228 | - { | ||
22229 | - --ndigits; | ||
22230 | - *p++ = digits[ndigits]; | ||
22231 | - } | ||
22232 | - while (ndigits > precision); | ||
22233 | - else | ||
22234 | - *p++ = '0'; | ||
22235 | - /* Here ndigits <= precision. */ | ||
22236 | - if ((flags & FLAG_ALT) || precision > 0) | ||
22237 | - { | ||
22238 | - *p++ = decimal_point_char (); | ||
22239 | - for (; precision > ndigits; precision--) | ||
22240 | - *p++ = '0'; | ||
22241 | - while (ndigits > 0) | ||
22242 | - { | ||
22243 | - --ndigits; | ||
22244 | - *p++ = digits[ndigits]; | ||
22245 | - } | ||
22246 | - } | ||
22247 | - | ||
22248 | - free (digits); | ||
22249 | - } | ||
22250 | - else if (dp->conversion == 'e' || dp->conversion == 'E') | ||
22251 | - { | ||
22252 | - int exponent; | ||
22253 | - | ||
22254 | - if (arg == 0.0) | ||
22255 | - { | ||
22256 | - exponent = 0; | ||
22257 | - *p++ = '0'; | ||
22258 | - if ((flags & FLAG_ALT) || precision > 0) | ||
22259 | - { | ||
22260 | - *p++ = decimal_point_char (); | ||
22261 | - for (; precision > 0; precision--) | ||
22262 | - *p++ = '0'; | ||
22263 | - } | ||
22264 | - } | ||
22265 | - else | ||
22266 | - { | ||
22267 | - /* arg > 0.0. */ | ||
22268 | - int adjusted; | ||
22269 | - char *digits; | ||
22270 | - size_t ndigits; | ||
22271 | - | ||
22272 | - exponent = floorlog10 (arg); | ||
22273 | - adjusted = 0; | ||
22274 | - for (;;) | ||
22275 | - { | ||
22276 | - digits = | ||
22277 | - scale10_round_decimal_double (arg, | ||
22278 | - (int)precision - exponent); | ||
22279 | - if (digits == NULL) | ||
22280 | - goto out_of_memory; | ||
22281 | - ndigits = strlen (digits); | ||
22282 | - | ||
22283 | - if (ndigits == precision + 1) | ||
22284 | - break; | ||
22285 | - if (ndigits < precision | ||
22286 | - || ndigits > precision + 2) | ||
22287 | - /* The exponent was not guessed | ||
22288 | - precisely enough. */ | ||
22289 | - abort (); | ||
22290 | - if (adjusted) | ||
22291 | - /* None of two values of exponent is | ||
22292 | - the right one. Prevent an endless | ||
22293 | - loop. */ | ||
22294 | - abort (); | ||
22295 | - free (digits); | ||
22296 | - if (ndigits == precision) | ||
22297 | - exponent -= 1; | ||
22298 | - else | ||
22299 | - exponent += 1; | ||
22300 | - adjusted = 1; | ||
22301 | - } | ||
22302 | - | ||
22303 | - /* Here ndigits = precision+1. */ | ||
22304 | - *p++ = digits[--ndigits]; | ||
22305 | - if ((flags & FLAG_ALT) || precision > 0) | ||
22306 | - { | ||
22307 | - *p++ = decimal_point_char (); | ||
22308 | - while (ndigits > 0) | ||
22309 | - { | ||
22310 | - --ndigits; | ||
22311 | - *p++ = digits[ndigits]; | ||
22312 | - } | ||
22313 | - } | ||
22314 | - | ||
22315 | - free (digits); | ||
22316 | - } | ||
22317 | - | ||
22318 | - *p++ = dp->conversion; /* 'e' or 'E' */ | ||
22319 | -# if WIDE_CHAR_VERSION | ||
22320 | - { | ||
22321 | - static const wchar_t decimal_format[] = | ||
22322 | - /* Produce the same number of exponent digits | ||
22323 | - as the native printf implementation. */ | ||
22324 | -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
22325 | - { '%', '+', '.', '3', 'd', '\0' }; | ||
22326 | -# else | ||
22327 | - { '%', '+', '.', '2', 'd', '\0' }; | ||
22328 | -# endif | ||
22329 | - SNPRINTF (p, 6 + 1, decimal_format, exponent); | ||
22330 | - } | ||
22331 | - while (*p != '\0') | ||
22332 | - p++; | ||
22333 | -# else | ||
22334 | - { | ||
22335 | - static const char decimal_format[] = | ||
22336 | - /* Produce the same number of exponent digits | ||
22337 | - as the native printf implementation. */ | ||
22338 | -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
22339 | - "%+.3d"; | ||
22340 | -# else | ||
22341 | - "%+.2d"; | ||
22342 | -# endif | ||
22343 | - if (sizeof (DCHAR_T) == 1) | ||
22344 | - { | ||
22345 | - sprintf ((char *) p, decimal_format, exponent); | ||
22346 | - while (*p != '\0') | ||
22347 | - p++; | ||
22348 | - } | ||
22349 | - else | ||
22350 | - { | ||
22351 | - char expbuf[6 + 1]; | ||
22352 | - const char *ep; | ||
22353 | - sprintf (expbuf, decimal_format, exponent); | ||
22354 | - for (ep = expbuf; (*p = *ep) != '\0'; ep++) | ||
22355 | - p++; | ||
22356 | - } | ||
22357 | - } | ||
22358 | -# endif | ||
22359 | - } | ||
22360 | - else if (dp->conversion == 'g' || dp->conversion == 'G') | ||
22361 | - { | ||
22362 | - if (precision == 0) | ||
22363 | - precision = 1; | ||
22364 | - /* precision >= 1. */ | ||
22365 | - | ||
22366 | - if (arg == 0.0) | ||
22367 | - /* The exponent is 0, >= -4, < precision. | ||
22368 | - Use fixed-point notation. */ | ||
22369 | - { | ||
22370 | - size_t ndigits = precision; | ||
22371 | - /* Number of trailing zeroes that have to be | ||
22372 | - dropped. */ | ||
22373 | - size_t nzeroes = | ||
22374 | - (flags & FLAG_ALT ? 0 : precision - 1); | ||
22375 | - | ||
22376 | - --ndigits; | ||
22377 | - *p++ = '0'; | ||
22378 | - if ((flags & FLAG_ALT) || ndigits > nzeroes) | ||
22379 | - { | ||
22380 | - *p++ = decimal_point_char (); | ||
22381 | - while (ndigits > nzeroes) | ||
22382 | - { | ||
22383 | - --ndigits; | ||
22384 | - *p++ = '0'; | ||
22385 | - } | ||
22386 | - } | ||
22387 | - } | ||
22388 | - else | ||
22389 | - { | ||
22390 | - /* arg > 0.0. */ | ||
22391 | - int exponent; | ||
22392 | - int adjusted; | ||
22393 | - char *digits; | ||
22394 | - size_t ndigits; | ||
22395 | - size_t nzeroes; | ||
22396 | - | ||
22397 | - exponent = floorlog10 (arg); | ||
22398 | - adjusted = 0; | ||
22399 | - for (;;) | ||
22400 | - { | ||
22401 | - digits = | ||
22402 | - scale10_round_decimal_double (arg, | ||
22403 | - (int)(precision - 1) - exponent); | ||
22404 | - if (digits == NULL) | ||
22405 | - goto out_of_memory; | ||
22406 | - ndigits = strlen (digits); | ||
22407 | - | ||
22408 | - if (ndigits == precision) | ||
22409 | - break; | ||
22410 | - if (ndigits < precision - 1 | ||
22411 | - || ndigits > precision + 1) | ||
22412 | - /* The exponent was not guessed | ||
22413 | - precisely enough. */ | ||
22414 | - abort (); | ||
22415 | - if (adjusted) | ||
22416 | - /* None of two values of exponent is | ||
22417 | - the right one. Prevent an endless | ||
22418 | - loop. */ | ||
22419 | - abort (); | ||
22420 | - free (digits); | ||
22421 | - if (ndigits < precision) | ||
22422 | - exponent -= 1; | ||
22423 | - else | ||
22424 | - exponent += 1; | ||
22425 | - adjusted = 1; | ||
22426 | - } | ||
22427 | - /* Here ndigits = precision. */ | ||
22428 | - | ||
22429 | - /* Determine the number of trailing zeroes | ||
22430 | - that have to be dropped. */ | ||
22431 | - nzeroes = 0; | ||
22432 | - if ((flags & FLAG_ALT) == 0) | ||
22433 | - while (nzeroes < ndigits | ||
22434 | - && digits[nzeroes] == '0') | ||
22435 | - nzeroes++; | ||
22436 | - | ||
22437 | - /* The exponent is now determined. */ | ||
22438 | - if (exponent >= -4 | ||
22439 | - && exponent < (long)precision) | ||
22440 | - { | ||
22441 | - /* Fixed-point notation: | ||
22442 | - max(exponent,0)+1 digits, then the | ||
22443 | - decimal point, then the remaining | ||
22444 | - digits without trailing zeroes. */ | ||
22445 | - if (exponent >= 0) | ||
22446 | - { | ||
22447 | - size_t count = exponent + 1; | ||
22448 | - /* Note: count <= precision = ndigits. */ | ||
22449 | - for (; count > 0; count--) | ||
22450 | - *p++ = digits[--ndigits]; | ||
22451 | - if ((flags & FLAG_ALT) || ndigits > nzeroes) | ||
22452 | - { | ||
22453 | - *p++ = decimal_point_char (); | ||
22454 | - while (ndigits > nzeroes) | ||
22455 | - { | ||
22456 | - --ndigits; | ||
22457 | - *p++ = digits[ndigits]; | ||
22458 | - } | ||
22459 | - } | ||
22460 | - } | ||
22461 | - else | ||
22462 | - { | ||
22463 | - size_t count = -exponent - 1; | ||
22464 | - *p++ = '0'; | ||
22465 | - *p++ = decimal_point_char (); | ||
22466 | - for (; count > 0; count--) | ||
22467 | - *p++ = '0'; | ||
22468 | - while (ndigits > nzeroes) | ||
22469 | - { | ||
22470 | - --ndigits; | ||
22471 | - *p++ = digits[ndigits]; | ||
22472 | - } | ||
22473 | - } | ||
22474 | - } | ||
22475 | - else | ||
22476 | - { | ||
22477 | - /* Exponential notation. */ | ||
22478 | - *p++ = digits[--ndigits]; | ||
22479 | - if ((flags & FLAG_ALT) || ndigits > nzeroes) | ||
22480 | - { | ||
22481 | - *p++ = decimal_point_char (); | ||
22482 | - while (ndigits > nzeroes) | ||
22483 | - { | ||
22484 | - --ndigits; | ||
22485 | - *p++ = digits[ndigits]; | ||
22486 | - } | ||
22487 | - } | ||
22488 | - *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ | ||
22489 | -# if WIDE_CHAR_VERSION | ||
22490 | - { | ||
22491 | - static const wchar_t decimal_format[] = | ||
22492 | - /* Produce the same number of exponent digits | ||
22493 | - as the native printf implementation. */ | ||
22494 | -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
22495 | - { '%', '+', '.', '3', 'd', '\0' }; | ||
22496 | -# else | ||
22497 | - { '%', '+', '.', '2', 'd', '\0' }; | ||
22498 | -# endif | ||
22499 | - SNPRINTF (p, 6 + 1, decimal_format, exponent); | ||
22500 | - } | ||
22501 | - while (*p != '\0') | ||
22502 | - p++; | ||
22503 | -# else | ||
22504 | - { | ||
22505 | - static const char decimal_format[] = | ||
22506 | - /* Produce the same number of exponent digits | ||
22507 | - as the native printf implementation. */ | ||
22508 | -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
22509 | - "%+.3d"; | ||
22510 | -# else | ||
22511 | - "%+.2d"; | ||
22512 | -# endif | ||
22513 | - if (sizeof (DCHAR_T) == 1) | ||
22514 | - { | ||
22515 | - sprintf ((char *) p, decimal_format, exponent); | ||
22516 | - while (*p != '\0') | ||
22517 | - p++; | ||
22518 | - } | ||
22519 | - else | ||
22520 | - { | ||
22521 | - char expbuf[6 + 1]; | ||
22522 | - const char *ep; | ||
22523 | - sprintf (expbuf, decimal_format, exponent); | ||
22524 | - for (ep = expbuf; (*p = *ep) != '\0'; ep++) | ||
22525 | - p++; | ||
22526 | - } | ||
22527 | - } | ||
22528 | -# endif | ||
22529 | - } | ||
22530 | - | ||
22531 | - free (digits); | ||
22532 | - } | ||
22533 | - } | ||
22534 | - else | ||
22535 | - abort (); | ||
22536 | -# else | ||
22537 | - /* arg is finite. */ | ||
22538 | - if (!(arg == 0.0)) | ||
22539 | - abort (); | ||
22540 | - | ||
22541 | - pad_ptr = p; | ||
22542 | - | ||
22543 | - if (dp->conversion == 'f' || dp->conversion == 'F') | ||
22544 | - { | ||
22545 | - *p++ = '0'; | ||
22546 | - if ((flags & FLAG_ALT) || precision > 0) | ||
22547 | - { | ||
22548 | - *p++ = decimal_point_char (); | ||
22549 | - for (; precision > 0; precision--) | ||
22550 | - *p++ = '0'; | ||
22551 | - } | ||
22552 | - } | ||
22553 | - else if (dp->conversion == 'e' || dp->conversion == 'E') | ||
22554 | - { | ||
22555 | - *p++ = '0'; | ||
22556 | - if ((flags & FLAG_ALT) || precision > 0) | ||
22557 | - { | ||
22558 | - *p++ = decimal_point_char (); | ||
22559 | - for (; precision > 0; precision--) | ||
22560 | - *p++ = '0'; | ||
22561 | - } | ||
22562 | - *p++ = dp->conversion; /* 'e' or 'E' */ | ||
22563 | - *p++ = '+'; | ||
22564 | - /* Produce the same number of exponent digits as | ||
22565 | - the native printf implementation. */ | ||
22566 | -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
22567 | - *p++ = '0'; | ||
22568 | -# endif | ||
22569 | - *p++ = '0'; | ||
22570 | - *p++ = '0'; | ||
22571 | - } | ||
22572 | - else if (dp->conversion == 'g' || dp->conversion == 'G') | ||
22573 | - { | ||
22574 | - *p++ = '0'; | ||
22575 | - if (flags & FLAG_ALT) | ||
22576 | - { | ||
22577 | - size_t ndigits = | ||
22578 | - (precision > 0 ? precision - 1 : 0); | ||
22579 | - *p++ = decimal_point_char (); | ||
22580 | - for (; ndigits > 0; --ndigits) | ||
22581 | - *p++ = '0'; | ||
22582 | - } | ||
22583 | - } | ||
22584 | - else | ||
22585 | - abort (); | ||
22586 | -# endif | ||
22587 | - } | ||
22588 | - } | ||
22589 | - } | ||
22590 | -# endif | ||
22591 | - | ||
22592 | - /* The generated string now extends from tmp to p, with the | ||
22593 | - zero padding insertion point being at pad_ptr. */ | ||
22594 | - if (has_width && p - tmp < width) | ||
22595 | - { | ||
22596 | - size_t pad = width - (p - tmp); | ||
22597 | - DCHAR_T *end = p + pad; | ||
22598 | - | ||
22599 | - if (flags & FLAG_LEFT) | ||
22600 | - { | ||
22601 | - /* Pad with spaces on the right. */ | ||
22602 | - for (; pad > 0; pad--) | ||
22603 | - *p++ = ' '; | ||
22604 | - } | ||
22605 | - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) | ||
22606 | - { | ||
22607 | - /* Pad with zeroes. */ | ||
22608 | - DCHAR_T *q = end; | ||
22609 | - | ||
22610 | - while (p > pad_ptr) | ||
22611 | - *--q = *--p; | ||
22612 | - for (; pad > 0; pad--) | ||
22613 | - *p++ = '0'; | ||
22614 | - } | ||
22615 | - else | ||
22616 | - { | ||
22617 | - /* Pad with spaces on the left. */ | ||
22618 | - DCHAR_T *q = end; | ||
22619 | - | ||
22620 | - while (p > tmp) | ||
22621 | - *--q = *--p; | ||
22622 | - for (; pad > 0; pad--) | ||
22623 | - *p++ = ' '; | ||
22624 | - } | ||
22625 | - | ||
22626 | - p = end; | ||
22627 | - } | ||
22628 | - | ||
22629 | - { | ||
22630 | - size_t count = p - tmp; | ||
22631 | - | ||
22632 | - if (count >= tmp_length) | ||
22633 | - /* tmp_length was incorrectly calculated - fix the | ||
22634 | - code above! */ | ||
22635 | - abort (); | ||
22636 | - | ||
22637 | - /* Make room for the result. */ | ||
22638 | - if (count >= allocated - length) | ||
22639 | - { | ||
22640 | - size_t n = xsum (length, count); | ||
22641 | - | ||
22642 | - ENSURE_ALLOCATION (n); | ||
22643 | - } | ||
22644 | - | ||
22645 | - /* Append the result. */ | ||
22646 | - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); | ||
22647 | - if (tmp != tmpbuf) | ||
22648 | - free (tmp); | ||
22649 | - length += count; | ||
22650 | - } | ||
22651 | - } | ||
22652 | -#endif | ||
22653 | - else | ||
22654 | - { | ||
22655 | - arg_type type = a.arg[dp->arg_index].type; | ||
22656 | - int flags = dp->flags; | ||
22657 | -#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | ||
22658 | - int has_width; | ||
22659 | - size_t width; | ||
22660 | -#endif | ||
22661 | -#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION | ||
22662 | - int has_precision; | ||
22663 | - size_t precision; | ||
22664 | -#endif | ||
22665 | -#if NEED_PRINTF_UNBOUNDED_PRECISION | ||
22666 | - int prec_ourselves; | ||
22667 | -#else | ||
22668 | -# define prec_ourselves 0 | ||
22669 | -#endif | ||
22670 | -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | ||
22671 | - int pad_ourselves; | ||
22672 | -#else | ||
22673 | -# define pad_ourselves 0 | ||
22674 | -#endif | ||
22675 | - TCHAR_T *fbp; | ||
22676 | - unsigned int prefix_count; | ||
22677 | - int prefixes[2]; | ||
22678 | -#if !USE_SNPRINTF | ||
22679 | - size_t tmp_length; | ||
22680 | - TCHAR_T tmpbuf[700]; | ||
22681 | - TCHAR_T *tmp; | ||
22682 | -#endif | ||
22683 | - | ||
22684 | -#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | ||
22685 | - has_width = 0; | ||
22686 | - width = 0; | ||
22687 | - if (dp->width_start != dp->width_end) | ||
22688 | - { | ||
22689 | - if (dp->width_arg_index != ARG_NONE) | ||
22690 | - { | ||
22691 | - int arg; | ||
22692 | - | ||
22693 | - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) | ||
22694 | - abort (); | ||
22695 | - arg = a.arg[dp->width_arg_index].a.a_int; | ||
22696 | - if (arg < 0) | ||
22697 | - { | ||
22698 | - /* "A negative field width is taken as a '-' flag | ||
22699 | - followed by a positive field width." */ | ||
22700 | - flags |= FLAG_LEFT; | ||
22701 | - width = (unsigned int) (-arg); | ||
22702 | - } | ||
22703 | - else | ||
22704 | - width = arg; | ||
22705 | - } | ||
22706 | - else | ||
22707 | - { | ||
22708 | - const FCHAR_T *digitp = dp->width_start; | ||
22709 | - | ||
22710 | - do | ||
22711 | - width = xsum (xtimes (width, 10), *digitp++ - '0'); | ||
22712 | - while (digitp != dp->width_end); | ||
22713 | - } | ||
22714 | - has_width = 1; | ||
22715 | - } | ||
22716 | -#endif | ||
22717 | - | ||
22718 | -#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION | ||
22719 | - has_precision = 0; | ||
22720 | - precision = 6; | ||
22721 | - if (dp->precision_start != dp->precision_end) | ||
22722 | - { | ||
22723 | - if (dp->precision_arg_index != ARG_NONE) | ||
22724 | - { | ||
22725 | - int arg; | ||
22726 | - | ||
22727 | - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) | ||
22728 | - abort (); | ||
22729 | - arg = a.arg[dp->precision_arg_index].a.a_int; | ||
22730 | - /* "A negative precision is taken as if the precision | ||
22731 | - were omitted." */ | ||
22732 | - if (arg >= 0) | ||
22733 | - { | ||
22734 | - precision = arg; | ||
22735 | - has_precision = 1; | ||
22736 | - } | ||
22737 | - } | ||
22738 | - else | ||
22739 | - { | ||
22740 | - const FCHAR_T *digitp = dp->precision_start + 1; | ||
22741 | - | ||
22742 | - precision = 0; | ||
22743 | - while (digitp != dp->precision_end) | ||
22744 | - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); | ||
22745 | - has_precision = 1; | ||
22746 | - } | ||
22747 | - } | ||
22748 | -#endif | ||
22749 | - | ||
22750 | -#if !USE_SNPRINTF | ||
22751 | - /* Allocate a temporary buffer of sufficient size for calling | ||
22752 | - sprintf. */ | ||
22753 | - { | ||
22754 | - switch (dp->conversion) | ||
22755 | - { | ||
22756 | - | ||
22757 | - case 'd': case 'i': case 'u': | ||
22758 | -# if HAVE_LONG_LONG_INT | ||
22759 | - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
22760 | - tmp_length = | ||
22761 | - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
22762 | - * 0.30103 /* binary -> decimal */ | ||
22763 | - ) | ||
22764 | - + 1; /* turn floor into ceil */ | ||
22765 | - else | ||
22766 | -# endif | ||
22767 | - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
22768 | - tmp_length = | ||
22769 | - (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
22770 | - * 0.30103 /* binary -> decimal */ | ||
22771 | - ) | ||
22772 | - + 1; /* turn floor into ceil */ | ||
22773 | - else | ||
22774 | - tmp_length = | ||
22775 | - (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
22776 | - * 0.30103 /* binary -> decimal */ | ||
22777 | - ) | ||
22778 | - + 1; /* turn floor into ceil */ | ||
22779 | - if (tmp_length < precision) | ||
22780 | - tmp_length = precision; | ||
22781 | - /* Multiply by 2, as an estimate for FLAG_GROUP. */ | ||
22782 | - tmp_length = xsum (tmp_length, tmp_length); | ||
22783 | - /* Add 1, to account for a leading sign. */ | ||
22784 | - tmp_length = xsum (tmp_length, 1); | ||
22785 | - break; | ||
22786 | - | ||
22787 | - case 'o': | ||
22788 | -# if HAVE_LONG_LONG_INT | ||
22789 | - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
22790 | - tmp_length = | ||
22791 | - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
22792 | - * 0.333334 /* binary -> octal */ | ||
22793 | - ) | ||
22794 | - + 1; /* turn floor into ceil */ | ||
22795 | - else | ||
22796 | -# endif | ||
22797 | - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
22798 | - tmp_length = | ||
22799 | - (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
22800 | - * 0.333334 /* binary -> octal */ | ||
22801 | - ) | ||
22802 | - + 1; /* turn floor into ceil */ | ||
22803 | - else | ||
22804 | - tmp_length = | ||
22805 | - (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
22806 | - * 0.333334 /* binary -> octal */ | ||
22807 | - ) | ||
22808 | - + 1; /* turn floor into ceil */ | ||
22809 | - if (tmp_length < precision) | ||
22810 | - tmp_length = precision; | ||
22811 | - /* Add 1, to account for a leading sign. */ | ||
22812 | - tmp_length = xsum (tmp_length, 1); | ||
22813 | - break; | ||
22814 | - | ||
22815 | - case 'x': case 'X': | ||
22816 | -# if HAVE_LONG_LONG_INT | ||
22817 | - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) | ||
22818 | - tmp_length = | ||
22819 | - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT | ||
22820 | - * 0.25 /* binary -> hexadecimal */ | ||
22821 | - ) | ||
22822 | - + 1; /* turn floor into ceil */ | ||
22823 | - else | ||
22824 | -# endif | ||
22825 | - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) | ||
22826 | - tmp_length = | ||
22827 | - (unsigned int) (sizeof (unsigned long) * CHAR_BIT | ||
22828 | - * 0.25 /* binary -> hexadecimal */ | ||
22829 | - ) | ||
22830 | - + 1; /* turn floor into ceil */ | ||
22831 | - else | ||
22832 | - tmp_length = | ||
22833 | - (unsigned int) (sizeof (unsigned int) * CHAR_BIT | ||
22834 | - * 0.25 /* binary -> hexadecimal */ | ||
22835 | - ) | ||
22836 | - + 1; /* turn floor into ceil */ | ||
22837 | - if (tmp_length < precision) | ||
22838 | - tmp_length = precision; | ||
22839 | - /* Add 2, to account for a leading sign or alternate form. */ | ||
22840 | - tmp_length = xsum (tmp_length, 2); | ||
22841 | - break; | ||
22842 | - | ||
22843 | - case 'f': case 'F': | ||
22844 | - if (type == TYPE_LONGDOUBLE) | ||
22845 | - tmp_length = | ||
22846 | - (unsigned int) (LDBL_MAX_EXP | ||
22847 | - * 0.30103 /* binary -> decimal */ | ||
22848 | - * 2 /* estimate for FLAG_GROUP */ | ||
22849 | - ) | ||
22850 | - + 1 /* turn floor into ceil */ | ||
22851 | - + 10; /* sign, decimal point etc. */ | ||
22852 | - else | ||
22853 | - tmp_length = | ||
22854 | - (unsigned int) (DBL_MAX_EXP | ||
22855 | - * 0.30103 /* binary -> decimal */ | ||
22856 | - * 2 /* estimate for FLAG_GROUP */ | ||
22857 | - ) | ||
22858 | - + 1 /* turn floor into ceil */ | ||
22859 | - + 10; /* sign, decimal point etc. */ | ||
22860 | - tmp_length = xsum (tmp_length, precision); | ||
22861 | - break; | ||
22862 | - | ||
22863 | - case 'e': case 'E': case 'g': case 'G': | ||
22864 | - tmp_length = | ||
22865 | - 12; /* sign, decimal point, exponent etc. */ | ||
22866 | - tmp_length = xsum (tmp_length, precision); | ||
22867 | - break; | ||
22868 | - | ||
22869 | - case 'a': case 'A': | ||
22870 | - if (type == TYPE_LONGDOUBLE) | ||
22871 | - tmp_length = | ||
22872 | - (unsigned int) (LDBL_DIG | ||
22873 | - * 0.831 /* decimal -> hexadecimal */ | ||
22874 | - ) | ||
22875 | - + 1; /* turn floor into ceil */ | ||
22876 | - else | ||
22877 | - tmp_length = | ||
22878 | - (unsigned int) (DBL_DIG | ||
22879 | - * 0.831 /* decimal -> hexadecimal */ | ||
22880 | - ) | ||
22881 | - + 1; /* turn floor into ceil */ | ||
22882 | - if (tmp_length < precision) | ||
22883 | - tmp_length = precision; | ||
22884 | - /* Account for sign, decimal point etc. */ | ||
22885 | - tmp_length = xsum (tmp_length, 12); | ||
22886 | - break; | ||
22887 | - | ||
22888 | - case 'c': | ||
22889 | -# if HAVE_WINT_T && !WIDE_CHAR_VERSION | ||
22890 | - if (type == TYPE_WIDE_CHAR) | ||
22891 | - tmp_length = MB_CUR_MAX; | ||
22892 | - else | ||
22893 | -# endif | ||
22894 | - tmp_length = 1; | ||
22895 | - break; | ||
22896 | - | ||
22897 | - case 's': | ||
22898 | -# if HAVE_WCHAR_T | ||
22899 | - if (type == TYPE_WIDE_STRING) | ||
22900 | - { | ||
22901 | - tmp_length = | ||
22902 | - local_wcslen (a.arg[dp->arg_index].a.a_wide_string); | ||
22903 | - | ||
22904 | -# if !WIDE_CHAR_VERSION | ||
22905 | - tmp_length = xtimes (tmp_length, MB_CUR_MAX); | ||
22906 | -# endif | ||
22907 | - } | ||
22908 | - else | ||
22909 | -# endif | ||
22910 | - tmp_length = strlen (a.arg[dp->arg_index].a.a_string); | ||
22911 | - break; | ||
22912 | - | ||
22913 | - case 'p': | ||
22914 | - tmp_length = | ||
22915 | - (unsigned int) (sizeof (void *) * CHAR_BIT | ||
22916 | - * 0.25 /* binary -> hexadecimal */ | ||
22917 | - ) | ||
22918 | - + 1 /* turn floor into ceil */ | ||
22919 | - + 2; /* account for leading 0x */ | ||
22920 | - break; | ||
22921 | - | ||
22922 | - default: | ||
22923 | - abort (); | ||
22924 | - } | ||
22925 | - | ||
22926 | -# if ENABLE_UNISTDIO | ||
22927 | - /* Padding considers the number of characters, therefore the | ||
22928 | - number of elements after padding may be | ||
22929 | - > max (tmp_length, width) | ||
22930 | - but is certainly | ||
22931 | - <= tmp_length + width. */ | ||
22932 | - tmp_length = xsum (tmp_length, width); | ||
22933 | -# else | ||
22934 | - /* Padding considers the number of elements, says POSIX. */ | ||
22935 | - if (tmp_length < width) | ||
22936 | - tmp_length = width; | ||
22937 | -# endif | ||
22938 | - | ||
22939 | - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ | ||
22940 | - } | ||
22941 | - | ||
22942 | - if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) | ||
22943 | - tmp = tmpbuf; | ||
22944 | - else | ||
22945 | - { | ||
22946 | - size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T)); | ||
22947 | - | ||
22948 | - if (size_overflow_p (tmp_memsize)) | ||
22949 | - /* Overflow, would lead to out of memory. */ | ||
22950 | - goto out_of_memory; | ||
22951 | - tmp = (TCHAR_T *) malloc (tmp_memsize); | ||
22952 | - if (tmp == NULL) | ||
22953 | - /* Out of memory. */ | ||
22954 | - goto out_of_memory; | ||
22955 | - } | ||
22956 | -#endif | ||
22957 | - | ||
22958 | - /* Decide whether to handle the precision ourselves. */ | ||
22959 | -#if NEED_PRINTF_UNBOUNDED_PRECISION | ||
22960 | - switch (dp->conversion) | ||
22961 | - { | ||
22962 | - case 'd': case 'i': case 'u': | ||
22963 | - case 'o': | ||
22964 | - case 'x': case 'X': case 'p': | ||
22965 | - prec_ourselves = has_precision && (precision > 0); | ||
22966 | - break; | ||
22967 | - default: | ||
22968 | - prec_ourselves = 0; | ||
22969 | - break; | ||
22970 | - } | ||
22971 | -#endif | ||
22972 | - | ||
22973 | - /* Decide whether to perform the padding ourselves. */ | ||
22974 | -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | ||
22975 | - switch (dp->conversion) | ||
22976 | - { | ||
22977 | -# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO | ||
22978 | - /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need | ||
22979 | - to perform the padding after this conversion. Functions | ||
22980 | - with unistdio extensions perform the padding based on | ||
22981 | - character count rather than element count. */ | ||
22982 | - case 'c': case 's': | ||
22983 | -# endif | ||
22984 | -# if NEED_PRINTF_FLAG_ZERO | ||
22985 | - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': | ||
22986 | - case 'a': case 'A': | ||
22987 | -# endif | ||
22988 | - pad_ourselves = 1; | ||
22989 | - break; | ||
22990 | - default: | ||
22991 | - pad_ourselves = prec_ourselves; | ||
22992 | - break; | ||
22993 | - } | ||
22994 | -#endif | ||
22995 | - | ||
22996 | - /* Construct the format string for calling snprintf or | ||
22997 | - sprintf. */ | ||
22998 | - fbp = buf; | ||
22999 | - *fbp++ = '%'; | ||
23000 | -#if NEED_PRINTF_FLAG_GROUPING | ||
23001 | - /* The underlying implementation doesn't support the ' flag. | ||
23002 | - Produce no grouping characters in this case; this is | ||
23003 | - acceptable because the grouping is locale dependent. */ | ||
23004 | -#else | ||
23005 | - if (flags & FLAG_GROUP) | ||
23006 | - *fbp++ = '\''; | ||
23007 | -#endif | ||
23008 | - if (flags & FLAG_LEFT) | ||
23009 | - *fbp++ = '-'; | ||
23010 | - if (flags & FLAG_SHOWSIGN) | ||
23011 | - *fbp++ = '+'; | ||
23012 | - if (flags & FLAG_SPACE) | ||
23013 | - *fbp++ = ' '; | ||
23014 | - if (flags & FLAG_ALT) | ||
23015 | - *fbp++ = '#'; | ||
23016 | - if (!pad_ourselves) | ||
23017 | - { | ||
23018 | - if (flags & FLAG_ZERO) | ||
23019 | - *fbp++ = '0'; | ||
23020 | - if (dp->width_start != dp->width_end) | ||
23021 | - { | ||
23022 | - size_t n = dp->width_end - dp->width_start; | ||
23023 | - /* The width specification is known to consist only | ||
23024 | - of standard ASCII characters. */ | ||
23025 | - if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) | ||
23026 | - { | ||
23027 | - memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T)); | ||
23028 | - fbp += n; | ||
23029 | - } | ||
23030 | - else | ||
23031 | - { | ||
23032 | - const FCHAR_T *mp = dp->width_start; | ||
23033 | - do | ||
23034 | - *fbp++ = (unsigned char) *mp++; | ||
23035 | - while (--n > 0); | ||
23036 | - } | ||
23037 | - } | ||
23038 | - } | ||
23039 | - if (!prec_ourselves) | ||
23040 | - { | ||
23041 | - if (dp->precision_start != dp->precision_end) | ||
23042 | - { | ||
23043 | - size_t n = dp->precision_end - dp->precision_start; | ||
23044 | - /* The precision specification is known to consist only | ||
23045 | - of standard ASCII characters. */ | ||
23046 | - if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) | ||
23047 | - { | ||
23048 | - memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T)); | ||
23049 | - fbp += n; | ||
23050 | - } | ||
23051 | - else | ||
23052 | - { | ||
23053 | - const FCHAR_T *mp = dp->precision_start; | ||
23054 | - do | ||
23055 | - *fbp++ = (unsigned char) *mp++; | ||
23056 | - while (--n > 0); | ||
23057 | - } | ||
23058 | - } | ||
23059 | - } | ||
23060 | - | ||
23061 | - switch (type) | ||
23062 | - { | ||
23063 | -#if HAVE_LONG_LONG_INT | ||
23064 | - case TYPE_LONGLONGINT: | ||
23065 | - case TYPE_ULONGLONGINT: | ||
23066 | -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
23067 | - *fbp++ = 'I'; | ||
23068 | - *fbp++ = '6'; | ||
23069 | - *fbp++ = '4'; | ||
23070 | - break; | ||
23071 | -# else | ||
23072 | - *fbp++ = 'l'; | ||
23073 | - /*FALLTHROUGH*/ | ||
23074 | -# endif | ||
23075 | -#endif | ||
23076 | - case TYPE_LONGINT: | ||
23077 | - case TYPE_ULONGINT: | ||
23078 | -#if HAVE_WINT_T | ||
23079 | - case TYPE_WIDE_CHAR: | ||
23080 | -#endif | ||
23081 | -#if HAVE_WCHAR_T | ||
23082 | - case TYPE_WIDE_STRING: | ||
23083 | -#endif | ||
23084 | - *fbp++ = 'l'; | ||
23085 | - break; | ||
23086 | - case TYPE_LONGDOUBLE: | ||
23087 | - *fbp++ = 'L'; | ||
23088 | - break; | ||
23089 | - default: | ||
23090 | - break; | ||
23091 | - } | ||
23092 | -#if NEED_PRINTF_DIRECTIVE_F | ||
23093 | - if (dp->conversion == 'F') | ||
23094 | - *fbp = 'f'; | ||
23095 | - else | ||
23096 | -#endif | ||
23097 | - *fbp = dp->conversion; | ||
23098 | -#if USE_SNPRINTF | ||
23099 | -# if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) | ||
23100 | - fbp[1] = '%'; | ||
23101 | - fbp[2] = 'n'; | ||
23102 | - fbp[3] = '\0'; | ||
23103 | -# else | ||
23104 | - /* On glibc2 systems from glibc >= 2.3 - probably also older | ||
23105 | - ones - we know that snprintf's returns value conforms to | ||
23106 | - ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes. | ||
23107 | - Therefore we can avoid using %n in this situation. | ||
23108 | - On glibc2 systems from 2004-10-18 or newer, the use of %n | ||
23109 | - in format strings in writable memory may crash the program | ||
23110 | - (if compiled with _FORTIFY_SOURCE=2), so we should avoid it | ||
23111 | - in this situation. */ | ||
23112 | - fbp[1] = '\0'; | ||
23113 | -# endif | ||
23114 | -#else | ||
23115 | - fbp[1] = '\0'; | ||
23116 | -#endif | ||
23117 | - | ||
23118 | - /* Construct the arguments for calling snprintf or sprintf. */ | ||
23119 | - prefix_count = 0; | ||
23120 | - if (!pad_ourselves && dp->width_arg_index != ARG_NONE) | ||
23121 | - { | ||
23122 | - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) | ||
23123 | - abort (); | ||
23124 | - prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; | ||
23125 | - } | ||
23126 | - if (dp->precision_arg_index != ARG_NONE) | ||
23127 | - { | ||
23128 | - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) | ||
23129 | - abort (); | ||
23130 | - prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; | ||
23131 | - } | ||
23132 | - | ||
23133 | -#if USE_SNPRINTF | ||
23134 | - /* The SNPRINTF result is appended after result[0..length]. | ||
23135 | - The latter is an array of DCHAR_T; SNPRINTF appends an | ||
23136 | - array of TCHAR_T to it. This is possible because | ||
23137 | - sizeof (TCHAR_T) divides sizeof (DCHAR_T) and | ||
23138 | - alignof (TCHAR_T) <= alignof (DCHAR_T). */ | ||
23139 | -# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T)) | ||
23140 | - /* Prepare checking whether snprintf returns the count | ||
23141 | - via %n. */ | ||
23142 | - ENSURE_ALLOCATION (xsum (length, 1)); | ||
23143 | - *(TCHAR_T *) (result + length) = '\0'; | ||
23144 | -#endif | ||
23145 | - | ||
23146 | - for (;;) | ||
23147 | - { | ||
23148 | - int count = -1; | ||
23149 | - | ||
23150 | -#if USE_SNPRINTF | ||
23151 | - int retcount = 0; | ||
23152 | - size_t maxlen = allocated - length; | ||
23153 | - /* SNPRINTF can fail if its second argument is | ||
23154 | - > INT_MAX. */ | ||
23155 | - if (maxlen > INT_MAX / TCHARS_PER_DCHAR) | ||
23156 | - maxlen = INT_MAX / TCHARS_PER_DCHAR; | ||
23157 | - maxlen = maxlen * TCHARS_PER_DCHAR; | ||
23158 | -# define SNPRINTF_BUF(arg) \ | ||
23159 | - switch (prefix_count) \ | ||
23160 | - { \ | ||
23161 | - case 0: \ | ||
23162 | - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ | ||
23163 | - maxlen, buf, \ | ||
23164 | - arg, &count); \ | ||
23165 | - break; \ | ||
23166 | - case 1: \ | ||
23167 | - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ | ||
23168 | - maxlen, buf, \ | ||
23169 | - prefixes[0], arg, &count); \ | ||
23170 | - break; \ | ||
23171 | - case 2: \ | ||
23172 | - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ | ||
23173 | - maxlen, buf, \ | ||
23174 | - prefixes[0], prefixes[1], arg, \ | ||
23175 | - &count); \ | ||
23176 | - break; \ | ||
23177 | - default: \ | ||
23178 | - abort (); \ | ||
23179 | - } | ||
23180 | -#else | ||
23181 | -# define SNPRINTF_BUF(arg) \ | ||
23182 | - switch (prefix_count) \ | ||
23183 | - { \ | ||
23184 | - case 0: \ | ||
23185 | - count = sprintf (tmp, buf, arg); \ | ||
23186 | - break; \ | ||
23187 | - case 1: \ | ||
23188 | - count = sprintf (tmp, buf, prefixes[0], arg); \ | ||
23189 | - break; \ | ||
23190 | - case 2: \ | ||
23191 | - count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ | ||
23192 | - arg); \ | ||
23193 | - break; \ | ||
23194 | - default: \ | ||
23195 | - abort (); \ | ||
23196 | - } | ||
23197 | -#endif | ||
23198 | - | ||
23199 | - switch (type) | ||
23200 | - { | ||
23201 | - case TYPE_SCHAR: | ||
23202 | - { | ||
23203 | - int arg = a.arg[dp->arg_index].a.a_schar; | ||
23204 | - SNPRINTF_BUF (arg); | ||
23205 | - } | ||
23206 | - break; | ||
23207 | - case TYPE_UCHAR: | ||
23208 | - { | ||
23209 | - unsigned int arg = a.arg[dp->arg_index].a.a_uchar; | ||
23210 | - SNPRINTF_BUF (arg); | ||
23211 | - } | ||
23212 | - break; | ||
23213 | - case TYPE_SHORT: | ||
23214 | - { | ||
23215 | - int arg = a.arg[dp->arg_index].a.a_short; | ||
23216 | - SNPRINTF_BUF (arg); | ||
23217 | - } | ||
23218 | - break; | ||
23219 | - case TYPE_USHORT: | ||
23220 | - { | ||
23221 | - unsigned int arg = a.arg[dp->arg_index].a.a_ushort; | ||
23222 | - SNPRINTF_BUF (arg); | ||
23223 | - } | ||
23224 | - break; | ||
23225 | - case TYPE_INT: | ||
23226 | - { | ||
23227 | - int arg = a.arg[dp->arg_index].a.a_int; | ||
23228 | - SNPRINTF_BUF (arg); | ||
23229 | - } | ||
23230 | - break; | ||
23231 | - case TYPE_UINT: | ||
23232 | - { | ||
23233 | - unsigned int arg = a.arg[dp->arg_index].a.a_uint; | ||
23234 | - SNPRINTF_BUF (arg); | ||
23235 | - } | ||
23236 | - break; | ||
23237 | - case TYPE_LONGINT: | ||
23238 | - { | ||
23239 | - long int arg = a.arg[dp->arg_index].a.a_longint; | ||
23240 | - SNPRINTF_BUF (arg); | ||
23241 | - } | ||
23242 | - break; | ||
23243 | - case TYPE_ULONGINT: | ||
23244 | - { | ||
23245 | - unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; | ||
23246 | - SNPRINTF_BUF (arg); | ||
23247 | - } | ||
23248 | - break; | ||
23249 | -#if HAVE_LONG_LONG_INT | ||
23250 | - case TYPE_LONGLONGINT: | ||
23251 | - { | ||
23252 | - long long int arg = a.arg[dp->arg_index].a.a_longlongint; | ||
23253 | - SNPRINTF_BUF (arg); | ||
23254 | - } | ||
23255 | - break; | ||
23256 | - case TYPE_ULONGLONGINT: | ||
23257 | - { | ||
23258 | - unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; | ||
23259 | - SNPRINTF_BUF (arg); | ||
23260 | - } | ||
23261 | - break; | ||
23262 | -#endif | ||
23263 | - case TYPE_DOUBLE: | ||
23264 | - { | ||
23265 | - double arg = a.arg[dp->arg_index].a.a_double; | ||
23266 | - SNPRINTF_BUF (arg); | ||
23267 | - } | ||
23268 | - break; | ||
23269 | - case TYPE_LONGDOUBLE: | ||
23270 | - { | ||
23271 | - long double arg = a.arg[dp->arg_index].a.a_longdouble; | ||
23272 | - SNPRINTF_BUF (arg); | ||
23273 | - } | ||
23274 | - break; | ||
23275 | - case TYPE_CHAR: | ||
23276 | - { | ||
23277 | - int arg = a.arg[dp->arg_index].a.a_char; | ||
23278 | - SNPRINTF_BUF (arg); | ||
23279 | - } | ||
23280 | - break; | ||
23281 | -#if HAVE_WINT_T | ||
23282 | - case TYPE_WIDE_CHAR: | ||
23283 | - { | ||
23284 | - wint_t arg = a.arg[dp->arg_index].a.a_wide_char; | ||
23285 | - SNPRINTF_BUF (arg); | ||
23286 | - } | ||
23287 | - break; | ||
23288 | -#endif | ||
23289 | - case TYPE_STRING: | ||
23290 | - { | ||
23291 | - const char *arg = a.arg[dp->arg_index].a.a_string; | ||
23292 | - SNPRINTF_BUF (arg); | ||
23293 | - } | ||
23294 | - break; | ||
23295 | -#if HAVE_WCHAR_T | ||
23296 | - case TYPE_WIDE_STRING: | ||
23297 | - { | ||
23298 | - const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; | ||
23299 | - SNPRINTF_BUF (arg); | ||
23300 | - } | ||
23301 | - break; | ||
23302 | -#endif | ||
23303 | - case TYPE_POINTER: | ||
23304 | - { | ||
23305 | - void *arg = a.arg[dp->arg_index].a.a_pointer; | ||
23306 | - SNPRINTF_BUF (arg); | ||
23307 | - } | ||
23308 | - break; | ||
23309 | - default: | ||
23310 | - abort (); | ||
23311 | - } | ||
23312 | - | ||
23313 | -#if USE_SNPRINTF | ||
23314 | - /* Portability: Not all implementations of snprintf() | ||
23315 | - are ISO C 99 compliant. Determine the number of | ||
23316 | - bytes that snprintf() has produced or would have | ||
23317 | - produced. */ | ||
23318 | - if (count >= 0) | ||
23319 | - { | ||
23320 | - /* Verify that snprintf() has NUL-terminated its | ||
23321 | - result. */ | ||
23322 | - if (count < maxlen | ||
23323 | - && ((TCHAR_T *) (result + length)) [count] != '\0') | ||
23324 | - abort (); | ||
23325 | - /* Portability hack. */ | ||
23326 | - if (retcount > count) | ||
23327 | - count = retcount; | ||
23328 | - } | ||
23329 | - else | ||
23330 | - { | ||
23331 | - /* snprintf() doesn't understand the '%n' | ||
23332 | - directive. */ | ||
23333 | - if (fbp[1] != '\0') | ||
23334 | - { | ||
23335 | - /* Don't use the '%n' directive; instead, look | ||
23336 | - at the snprintf() return value. */ | ||
23337 | - fbp[1] = '\0'; | ||
23338 | - continue; | ||
23339 | - } | ||
23340 | - else | ||
23341 | - { | ||
23342 | - /* Look at the snprintf() return value. */ | ||
23343 | - if (retcount < 0) | ||
23344 | - { | ||
23345 | - /* HP-UX 10.20 snprintf() is doubly deficient: | ||
23346 | - It doesn't understand the '%n' directive, | ||
23347 | - *and* it returns -1 (rather than the length | ||
23348 | - that would have been required) when the | ||
23349 | - buffer is too small. */ | ||
23350 | - size_t bigger_need = | ||
23351 | - xsum (xtimes (allocated, 2), 12); | ||
23352 | - ENSURE_ALLOCATION (bigger_need); | ||
23353 | - continue; | ||
23354 | - } | ||
23355 | - else | ||
23356 | - count = retcount; | ||
23357 | - } | ||
23358 | - } | ||
23359 | -#endif | ||
23360 | - | ||
23361 | - /* Attempt to handle failure. */ | ||
23362 | - if (count < 0) | ||
23363 | - { | ||
23364 | - if (!(result == resultbuf || result == NULL)) | ||
23365 | - free (result); | ||
23366 | - if (buf_malloced != NULL) | ||
23367 | - free (buf_malloced); | ||
23368 | - CLEANUP (); | ||
23369 | - errno = EINVAL; | ||
23370 | - return NULL; | ||
23371 | - } | ||
23372 | - | ||
23373 | -#if USE_SNPRINTF | ||
23374 | - /* Handle overflow of the allocated buffer. | ||
23375 | - If such an overflow occurs, a C99 compliant snprintf() | ||
23376 | - returns a count >= maxlen. However, a non-compliant | ||
23377 | - snprintf() function returns only count = maxlen - 1. To | ||
23378 | - cover both cases, test whether count >= maxlen - 1. */ | ||
23379 | - if ((unsigned int) count + 1 >= maxlen) | ||
23380 | - { | ||
23381 | - /* If maxlen already has attained its allowed maximum, | ||
23382 | - allocating more memory will not increase maxlen. | ||
23383 | - Instead of looping, bail out. */ | ||
23384 | - if (maxlen == INT_MAX / TCHARS_PER_DCHAR) | ||
23385 | - goto overflow; | ||
23386 | - else | ||
23387 | - { | ||
23388 | - /* Need at least count * sizeof (TCHAR_T) bytes. | ||
23389 | - But allocate proportionally, to avoid looping | ||
23390 | - eternally if snprintf() reports a too small | ||
23391 | - count. */ | ||
23392 | - size_t n = | ||
23393 | - xmax (xsum (length, | ||
23394 | - (count + TCHARS_PER_DCHAR - 1) | ||
23395 | - / TCHARS_PER_DCHAR), | ||
23396 | - xtimes (allocated, 2)); | ||
23397 | - | ||
23398 | - ENSURE_ALLOCATION (n); | ||
23399 | - continue; | ||
23400 | - } | ||
23401 | - } | ||
23402 | -#endif | ||
23403 | - | ||
23404 | -#if NEED_PRINTF_UNBOUNDED_PRECISION | ||
23405 | - if (prec_ourselves) | ||
23406 | - { | ||
23407 | - /* Handle the precision. */ | ||
23408 | - TCHAR_T *prec_ptr = | ||
23409 | -# if USE_SNPRINTF | ||
23410 | - (TCHAR_T *) (result + length); | ||
23411 | -# else | ||
23412 | - tmp; | ||
23413 | -# endif | ||
23414 | - size_t prefix_count; | ||
23415 | - size_t move; | ||
23416 | - | ||
23417 | - prefix_count = 0; | ||
23418 | - /* Put the additional zeroes after the sign. */ | ||
23419 | - if (count >= 1 | ||
23420 | - && (*prec_ptr == '-' || *prec_ptr == '+' | ||
23421 | - || *prec_ptr == ' ')) | ||
23422 | - prefix_count = 1; | ||
23423 | - /* Put the additional zeroes after the 0x prefix if | ||
23424 | - (flags & FLAG_ALT) || (dp->conversion == 'p'). */ | ||
23425 | - else if (count >= 2 | ||
23426 | - && prec_ptr[0] == '0' | ||
23427 | - && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) | ||
23428 | - prefix_count = 2; | ||
23429 | - | ||
23430 | - move = count - prefix_count; | ||
23431 | - if (precision > move) | ||
23432 | - { | ||
23433 | - /* Insert zeroes. */ | ||
23434 | - size_t insert = precision - move; | ||
23435 | - TCHAR_T *prec_end; | ||
23436 | - | ||
23437 | -# if USE_SNPRINTF | ||
23438 | - size_t n = | ||
23439 | - xsum (length, | ||
23440 | - (count + insert + TCHARS_PER_DCHAR - 1) | ||
23441 | - / TCHARS_PER_DCHAR); | ||
23442 | - length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; | ||
23443 | - ENSURE_ALLOCATION (n); | ||
23444 | - length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; | ||
23445 | - prec_ptr = (TCHAR_T *) (result + length); | ||
23446 | -# endif | ||
23447 | - | ||
23448 | - prec_end = prec_ptr + count; | ||
23449 | - prec_ptr += prefix_count; | ||
23450 | - | ||
23451 | - while (prec_end > prec_ptr) | ||
23452 | - { | ||
23453 | - prec_end--; | ||
23454 | - prec_end[insert] = prec_end[0]; | ||
23455 | - } | ||
23456 | - | ||
23457 | - prec_end += insert; | ||
23458 | - do | ||
23459 | - *--prec_end = '0'; | ||
23460 | - while (prec_end > prec_ptr); | ||
23461 | - | ||
23462 | - count += insert; | ||
23463 | - } | ||
23464 | - } | ||
23465 | -#endif | ||
23466 | - | ||
23467 | -#if !DCHAR_IS_TCHAR | ||
23468 | -# if !USE_SNPRINTF | ||
23469 | - if (count >= tmp_length) | ||
23470 | - /* tmp_length was incorrectly calculated - fix the | ||
23471 | - code above! */ | ||
23472 | - abort (); | ||
23473 | -# endif | ||
23474 | - | ||
23475 | - /* Convert from TCHAR_T[] to DCHAR_T[]. */ | ||
23476 | - if (dp->conversion == 'c' || dp->conversion == 's') | ||
23477 | - { | ||
23478 | - /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING | ||
23479 | - TYPE_WIDE_STRING. | ||
23480 | - The result string is not certainly ASCII. */ | ||
23481 | - const TCHAR_T *tmpsrc; | ||
23482 | - DCHAR_T *tmpdst; | ||
23483 | - size_t tmpdst_len; | ||
23484 | - /* This code assumes that TCHAR_T is 'char'. */ | ||
23485 | - typedef int TCHAR_T_verify | ||
23486 | - [2 * (sizeof (TCHAR_T) == 1) - 1]; | ||
23487 | -# if USE_SNPRINTF | ||
23488 | - tmpsrc = (TCHAR_T *) (result + length); | ||
23489 | -# else | ||
23490 | - tmpsrc = tmp; | ||
23491 | -# endif | ||
23492 | - tmpdst = NULL; | ||
23493 | - tmpdst_len = 0; | ||
23494 | - if (DCHAR_CONV_FROM_ENCODING (locale_charset (), | ||
23495 | - iconveh_question_mark, | ||
23496 | - tmpsrc, count, | ||
23497 | - NULL, | ||
23498 | - &tmpdst, &tmpdst_len) | ||
23499 | - < 0) | ||
23500 | - { | ||
23501 | - int saved_errno = errno; | ||
23502 | - if (!(result == resultbuf || result == NULL)) | ||
23503 | - free (result); | ||
23504 | - if (buf_malloced != NULL) | ||
23505 | - free (buf_malloced); | ||
23506 | - CLEANUP (); | ||
23507 | - errno = saved_errno; | ||
23508 | - return NULL; | ||
23509 | - } | ||
23510 | - ENSURE_ALLOCATION (xsum (length, tmpdst_len)); | ||
23511 | - DCHAR_CPY (result + length, tmpdst, tmpdst_len); | ||
23512 | - free (tmpdst); | ||
23513 | - count = tmpdst_len; | ||
23514 | - } | ||
23515 | - else | ||
23516 | - { | ||
23517 | - /* The result string is ASCII. | ||
23518 | - Simple 1:1 conversion. */ | ||
23519 | -# if USE_SNPRINTF | ||
23520 | - /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a | ||
23521 | - no-op conversion, in-place on the array starting | ||
23522 | - at (result + length). */ | ||
23523 | - if (sizeof (DCHAR_T) != sizeof (TCHAR_T)) | ||
23524 | -# endif | ||
23525 | - { | ||
23526 | - const TCHAR_T *tmpsrc; | ||
23527 | - DCHAR_T *tmpdst; | ||
23528 | - size_t n; | ||
23529 | - | ||
23530 | -# if USE_SNPRINTF | ||
23531 | - if (result == resultbuf) | ||
23532 | - { | ||
23533 | - tmpsrc = (TCHAR_T *) (result + length); | ||
23534 | - /* ENSURE_ALLOCATION will not move tmpsrc | ||
23535 | - (because it's part of resultbuf). */ | ||
23536 | - ENSURE_ALLOCATION (xsum (length, count)); | ||
23537 | - } | ||
23538 | - else | ||
23539 | - { | ||
23540 | - /* ENSURE_ALLOCATION will move the array | ||
23541 | - (because it uses realloc(). */ | ||
23542 | - ENSURE_ALLOCATION (xsum (length, count)); | ||
23543 | - tmpsrc = (TCHAR_T *) (result + length); | ||
23544 | - } | ||
23545 | -# else | ||
23546 | - tmpsrc = tmp; | ||
23547 | - ENSURE_ALLOCATION (xsum (length, count)); | ||
23548 | -# endif | ||
23549 | - tmpdst = result + length; | ||
23550 | - /* Copy backwards, because of overlapping. */ | ||
23551 | - tmpsrc += count; | ||
23552 | - tmpdst += count; | ||
23553 | - for (n = count; n > 0; n--) | ||
23554 | - *--tmpdst = (unsigned char) *--tmpsrc; | ||
23555 | - } | ||
23556 | - } | ||
23557 | -#endif | ||
23558 | - | ||
23559 | -#if DCHAR_IS_TCHAR && !USE_SNPRINTF | ||
23560 | - /* Make room for the result. */ | ||
23561 | - if (count > allocated - length) | ||
23562 | - { | ||
23563 | - /* Need at least count elements. But allocate | ||
23564 | - proportionally. */ | ||
23565 | - size_t n = | ||
23566 | - xmax (xsum (length, count), xtimes (allocated, 2)); | ||
23567 | - | ||
23568 | - ENSURE_ALLOCATION (n); | ||
23569 | - } | ||
23570 | -#endif | ||
23571 | - | ||
23572 | - /* Here count <= allocated - length. */ | ||
23573 | - | ||
23574 | - /* Perform padding. */ | ||
23575 | -#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION | ||
23576 | - if (pad_ourselves && has_width) | ||
23577 | - { | ||
23578 | - size_t w; | ||
23579 | -# if ENABLE_UNISTDIO | ||
23580 | - /* Outside POSIX, it's preferrable to compare the width | ||
23581 | - against the number of _characters_ of the converted | ||
23582 | - value. */ | ||
23583 | - w = DCHAR_MBSNLEN (result + length, count); | ||
23584 | -# else | ||
23585 | - /* The width is compared against the number of _bytes_ | ||
23586 | - of the converted value, says POSIX. */ | ||
23587 | - w = count; | ||
23588 | -# endif | ||
23589 | - if (w < width) | ||
23590 | - { | ||
23591 | - size_t pad = width - w; | ||
23592 | -# if USE_SNPRINTF | ||
23593 | - /* Make room for the result. */ | ||
23594 | - if (xsum (count, pad) > allocated - length) | ||
23595 | - { | ||
23596 | - /* Need at least count + pad elements. But | ||
23597 | - allocate proportionally. */ | ||
23598 | - size_t n = | ||
23599 | - xmax (xsum3 (length, count, pad), | ||
23600 | - xtimes (allocated, 2)); | ||
23601 | - | ||
23602 | - length += count; | ||
23603 | - ENSURE_ALLOCATION (n); | ||
23604 | - length -= count; | ||
23605 | - } | ||
23606 | - /* Here count + pad <= allocated - length. */ | ||
23607 | -# endif | ||
23608 | - { | ||
23609 | -# if !DCHAR_IS_TCHAR || USE_SNPRINTF | ||
23610 | - DCHAR_T * const rp = result + length; | ||
23611 | -# else | ||
23612 | - DCHAR_T * const rp = tmp; | ||
23613 | -# endif | ||
23614 | - DCHAR_T *p = rp + count; | ||
23615 | - DCHAR_T *end = p + pad; | ||
23616 | -# if NEED_PRINTF_FLAG_ZERO | ||
23617 | - DCHAR_T *pad_ptr; | ||
23618 | -# if !DCHAR_IS_TCHAR | ||
23619 | - if (dp->conversion == 'c' | ||
23620 | - || dp->conversion == 's') | ||
23621 | - /* No zero-padding for string directives. */ | ||
23622 | - pad_ptr = NULL; | ||
23623 | - else | ||
23624 | -# endif | ||
23625 | - { | ||
23626 | - pad_ptr = (*rp == '-' ? rp + 1 : rp); | ||
23627 | - /* No zero-padding of "inf" and "nan". */ | ||
23628 | - if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') | ||
23629 | - || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) | ||
23630 | - pad_ptr = NULL; | ||
23631 | - } | ||
23632 | -# endif | ||
23633 | - /* The generated string now extends from rp to p, | ||
23634 | - with the zero padding insertion point being at | ||
23635 | - pad_ptr. */ | ||
23636 | - | ||
23637 | - count = count + pad; /* = end - rp */ | ||
23638 | - | ||
23639 | - if (flags & FLAG_LEFT) | ||
23640 | - { | ||
23641 | - /* Pad with spaces on the right. */ | ||
23642 | - for (; pad > 0; pad--) | ||
23643 | - *p++ = ' '; | ||
23644 | - } | ||
23645 | -# if NEED_PRINTF_FLAG_ZERO | ||
23646 | - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) | ||
23647 | - { | ||
23648 | - /* Pad with zeroes. */ | ||
23649 | - DCHAR_T *q = end; | ||
23650 | - | ||
23651 | - while (p > pad_ptr) | ||
23652 | - *--q = *--p; | ||
23653 | - for (; pad > 0; pad--) | ||
23654 | - *p++ = '0'; | ||
23655 | - } | ||
23656 | -# endif | ||
23657 | - else | ||
23658 | - { | ||
23659 | - /* Pad with spaces on the left. */ | ||
23660 | - DCHAR_T *q = end; | ||
23661 | - | ||
23662 | - while (p > rp) | ||
23663 | - *--q = *--p; | ||
23664 | - for (; pad > 0; pad--) | ||
23665 | - *p++ = ' '; | ||
23666 | - } | ||
23667 | - } | ||
23668 | - } | ||
23669 | - } | ||
23670 | -#endif | ||
23671 | - | ||
23672 | -#if DCHAR_IS_TCHAR && !USE_SNPRINTF | ||
23673 | - if (count >= tmp_length) | ||
23674 | - /* tmp_length was incorrectly calculated - fix the | ||
23675 | - code above! */ | ||
23676 | - abort (); | ||
23677 | -#endif | ||
23678 | - | ||
23679 | - /* Here still count <= allocated - length. */ | ||
23680 | - | ||
23681 | -#if !DCHAR_IS_TCHAR || USE_SNPRINTF | ||
23682 | - /* The snprintf() result did fit. */ | ||
23683 | -#else | ||
23684 | - /* Append the sprintf() result. */ | ||
23685 | - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); | ||
23686 | -#endif | ||
23687 | -#if !USE_SNPRINTF | ||
23688 | - if (tmp != tmpbuf) | ||
23689 | - free (tmp); | ||
23690 | -#endif | ||
23691 | - | ||
23692 | -#if NEED_PRINTF_DIRECTIVE_F | ||
23693 | - if (dp->conversion == 'F') | ||
23694 | - { | ||
23695 | - /* Convert the %f result to upper case for %F. */ | ||
23696 | - DCHAR_T *rp = result + length; | ||
23697 | - size_t rc; | ||
23698 | - for (rc = count; rc > 0; rc--, rp++) | ||
23699 | - if (*rp >= 'a' && *rp <= 'z') | ||
23700 | - *rp = *rp - 'a' + 'A'; | ||
23701 | - } | ||
23702 | -#endif | ||
23703 | - | ||
23704 | - length += count; | ||
23705 | - break; | ||
23706 | - } | ||
23707 | - } | ||
23708 | - } | ||
23709 | - } | ||
23710 | - | ||
23711 | - /* Add the final NUL. */ | ||
23712 | - ENSURE_ALLOCATION (xsum (length, 1)); | ||
23713 | - result[length] = '\0'; | ||
23714 | - | ||
23715 | - if (result != resultbuf && length + 1 < allocated) | ||
23716 | - { | ||
23717 | - /* Shrink the allocated memory if possible. */ | ||
23718 | - DCHAR_T *memory; | ||
23719 | - | ||
23720 | - memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T)); | ||
23721 | - if (memory != NULL) | ||
23722 | - result = memory; | ||
23723 | - } | ||
23724 | - | ||
23725 | - if (buf_malloced != NULL) | ||
23726 | - free (buf_malloced); | ||
23727 | - CLEANUP (); | ||
23728 | - *lengthp = length; | ||
23729 | - /* Note that we can produce a big string of a length > INT_MAX. POSIX | ||
23730 | - says that snprintf() fails with errno = EOVERFLOW in this case, but | ||
23731 | - that's only because snprintf() returns an 'int'. This function does | ||
23732 | - not have this limitation. */ | ||
23733 | - return result; | ||
23734 | - | ||
23735 | - overflow: | ||
23736 | - if (!(result == resultbuf || result == NULL)) | ||
23737 | - free (result); | ||
23738 | - if (buf_malloced != NULL) | ||
23739 | - free (buf_malloced); | ||
23740 | - CLEANUP (); | ||
23741 | - errno = EOVERFLOW; | ||
23742 | - return NULL; | ||
23743 | - | ||
23744 | - out_of_memory: | ||
23745 | - if (!(result == resultbuf || result == NULL)) | ||
23746 | - free (result); | ||
23747 | - if (buf_malloced != NULL) | ||
23748 | - free (buf_malloced); | ||
23749 | - out_of_memory_1: | ||
23750 | - CLEANUP (); | ||
23751 | - errno = ENOMEM; | ||
23752 | - return NULL; | ||
23753 | - } | ||
23754 | -} | ||
23755 | - | ||
23756 | -#undef TCHARS_PER_DCHAR | ||
23757 | -#undef SNPRINTF | ||
23758 | -#undef USE_SNPRINTF | ||
23759 | -#undef DCHAR_CPY | ||
23760 | -#undef PRINTF_PARSE | ||
23761 | -#undef DIRECTIVES | ||
23762 | -#undef DIRECTIVE | ||
23763 | -#undef DCHAR_IS_TCHAR | ||
23764 | -#undef TCHAR_T | ||
23765 | -#undef DCHAR_T | ||
23766 | -#undef FCHAR_T | ||
23767 | -#undef VASNPRINTF | ||
23768 | --- a/intl/vasnprintf.h | ||
23769 | +++ /dev/null | ||
23770 | @@ -1,78 +0,0 @@ | ||
23771 | -/* vsprintf with automatic memory allocation. | ||
23772 | - Copyright (C) 2002-2004 Free Software Foundation, Inc. | ||
23773 | - | ||
23774 | - This program is free software; you can redistribute it and/or modify it | ||
23775 | - under the terms of the GNU Library General Public License as published | ||
23776 | - by the Free Software Foundation; either version 2, or (at your option) | ||
23777 | - any later version. | ||
23778 | - | ||
23779 | - This program is distributed in the hope that it will be useful, | ||
23780 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23781 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
23782 | - Library General Public License for more details. | ||
23783 | - | ||
23784 | - You should have received a copy of the GNU Library General Public | ||
23785 | - License along with this program; if not, write to the Free Software | ||
23786 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
23787 | - USA. */ | ||
23788 | - | ||
23789 | -#ifndef _VASNPRINTF_H | ||
23790 | -#define _VASNPRINTF_H | ||
23791 | - | ||
23792 | -/* Get va_list. */ | ||
23793 | -#include <stdarg.h> | ||
23794 | - | ||
23795 | -/* Get size_t. */ | ||
23796 | -#include <stddef.h> | ||
23797 | - | ||
23798 | -#ifndef __attribute__ | ||
23799 | -/* This feature is available in gcc versions 2.5 and later. */ | ||
23800 | -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ | ||
23801 | -# define __attribute__(Spec) /* empty */ | ||
23802 | -# endif | ||
23803 | -/* The __-protected variants of `format' and `printf' attributes | ||
23804 | - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | ||
23805 | -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | ||
23806 | -# define __format__ format | ||
23807 | -# define __printf__ printf | ||
23808 | -# endif | ||
23809 | -#endif | ||
23810 | - | ||
23811 | -#ifdef __cplusplus | ||
23812 | -extern "C" { | ||
23813 | -#endif | ||
23814 | - | ||
23815 | -/* Write formatted output to a string dynamically allocated with malloc(). | ||
23816 | - You can pass a preallocated buffer for the result in RESULTBUF and its | ||
23817 | - size in *LENGTHP; otherwise you pass RESULTBUF = NULL. | ||
23818 | - If successful, return the address of the string (this may be = RESULTBUF | ||
23819 | - if no dynamic memory allocation was necessary) and set *LENGTHP to the | ||
23820 | - number of resulting bytes, excluding the trailing NUL. Upon error, set | ||
23821 | - errno and return NULL. | ||
23822 | - | ||
23823 | - When dynamic memory allocation occurs, the preallocated buffer is left | ||
23824 | - alone (with possibly modified contents). This makes it possible to use | ||
23825 | - a statically allocated or stack-allocated buffer, like this: | ||
23826 | - | ||
23827 | - char buf[100]; | ||
23828 | - size_t len = sizeof (buf); | ||
23829 | - char *output = vasnprintf (buf, &len, format, args); | ||
23830 | - if (output == NULL) | ||
23831 | - ... error handling ...; | ||
23832 | - else | ||
23833 | - { | ||
23834 | - ... use the output string ...; | ||
23835 | - if (output != buf) | ||
23836 | - free (output); | ||
23837 | - } | ||
23838 | - */ | ||
23839 | -extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) | ||
23840 | - __attribute__ ((__format__ (__printf__, 3, 4))); | ||
23841 | -extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) | ||
23842 | - __attribute__ ((__format__ (__printf__, 3, 0))); | ||
23843 | - | ||
23844 | -#ifdef __cplusplus | ||
23845 | -} | ||
23846 | -#endif | ||
23847 | - | ||
23848 | -#endif /* _VASNPRINTF_H */ | ||
23849 | --- a/intl/vasnwprintf.h | ||
23850 | +++ /dev/null | ||
23851 | @@ -1,46 +0,0 @@ | ||
23852 | -/* vswprintf with automatic memory allocation. | ||
23853 | - Copyright (C) 2002-2003 Free Software Foundation, Inc. | ||
23854 | - | ||
23855 | - This program is free software; you can redistribute it and/or modify it | ||
23856 | - under the terms of the GNU Library General Public License as published | ||
23857 | - by the Free Software Foundation; either version 2, or (at your option) | ||
23858 | - any later version. | ||
23859 | - | ||
23860 | - This program is distributed in the hope that it will be useful, | ||
23861 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23862 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
23863 | - Library General Public License for more details. | ||
23864 | - | ||
23865 | - You should have received a copy of the GNU Library General Public | ||
23866 | - License along with this program; if not, write to the Free Software | ||
23867 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
23868 | - USA. */ | ||
23869 | - | ||
23870 | -#ifndef _VASNWPRINTF_H | ||
23871 | -#define _VASNWPRINTF_H | ||
23872 | - | ||
23873 | -/* Get va_list. */ | ||
23874 | -#include <stdarg.h> | ||
23875 | - | ||
23876 | -/* Get wchar_t, size_t. */ | ||
23877 | -#include <stddef.h> | ||
23878 | - | ||
23879 | -#ifdef __cplusplus | ||
23880 | -extern "C" { | ||
23881 | -#endif | ||
23882 | - | ||
23883 | -/* Write formatted output to a string dynamically allocated with malloc(). | ||
23884 | - You can pass a preallocated buffer for the result in RESULTBUF and its | ||
23885 | - size in *LENGTHP; otherwise you pass RESULTBUF = NULL. | ||
23886 | - If successful, return the address of the string (this may be = RESULTBUF | ||
23887 | - if no dynamic memory allocation was necessary) and set *LENGTHP to the | ||
23888 | - number of resulting bytes, excluding the trailing NUL. Upon error, set | ||
23889 | - errno and return NULL. */ | ||
23890 | -extern wchar_t * asnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, ...); | ||
23891 | -extern wchar_t * vasnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, va_list args); | ||
23892 | - | ||
23893 | -#ifdef __cplusplus | ||
23894 | -} | ||
23895 | -#endif | ||
23896 | - | ||
23897 | -#endif /* _VASNWPRINTF_H */ | ||
23898 | --- a/intl/version.c | ||
23899 | +++ /dev/null | ||
23900 | @@ -1,26 +0,0 @@ | ||
23901 | -/* libintl library version. | ||
23902 | - Copyright (C) 2005 Free Software Foundation, Inc. | ||
23903 | - | ||
23904 | - This program is free software; you can redistribute it and/or modify it | ||
23905 | - under the terms of the GNU Library General Public License as published | ||
23906 | - by the Free Software Foundation; either version 2, or (at your option) | ||
23907 | - any later version. | ||
23908 | - | ||
23909 | - This program is distributed in the hope that it will be useful, | ||
23910 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23911 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
23912 | - Library General Public License for more details. | ||
23913 | - | ||
23914 | - You should have received a copy of the GNU Library General Public | ||
23915 | - License along with this program; if not, write to the Free Software | ||
23916 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
23917 | - USA. */ | ||
23918 | - | ||
23919 | -#ifdef HAVE_CONFIG_H | ||
23920 | -# include <config.h> | ||
23921 | -#endif | ||
23922 | - | ||
23923 | -#include "libgnuintl.h" | ||
23924 | - | ||
23925 | -/* Version number: (major<<16) + (minor<<8) + subminor */ | ||
23926 | -int libintl_version = LIBINTL_VERSION; | ||
23927 | --- a/intl/wprintf-parse.h | ||
23928 | +++ /dev/null | ||
23929 | @@ -1,75 +0,0 @@ | ||
23930 | -/* Parse printf format string. | ||
23931 | - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. | ||
23932 | - | ||
23933 | - This program is free software; you can redistribute it and/or modify it | ||
23934 | - under the terms of the GNU Library General Public License as published | ||
23935 | - by the Free Software Foundation; either version 2, or (at your option) | ||
23936 | - any later version. | ||
23937 | - | ||
23938 | - This program is distributed in the hope that it will be useful, | ||
23939 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23940 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
23941 | - Library General Public License for more details. | ||
23942 | - | ||
23943 | - You should have received a copy of the GNU Library General Public | ||
23944 | - License along with this program; if not, write to the Free Software | ||
23945 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
23946 | - USA. */ | ||
23947 | - | ||
23948 | -#ifndef _WPRINTF_PARSE_H | ||
23949 | -#define _WPRINTF_PARSE_H | ||
23950 | - | ||
23951 | -#include "printf-args.h" | ||
23952 | - | ||
23953 | - | ||
23954 | -/* Flags */ | ||
23955 | -#define FLAG_GROUP 1 /* ' flag */ | ||
23956 | -#define FLAG_LEFT 2 /* - flag */ | ||
23957 | -#define FLAG_SHOWSIGN 4 /* + flag */ | ||
23958 | -#define FLAG_SPACE 8 /* space flag */ | ||
23959 | -#define FLAG_ALT 16 /* # flag */ | ||
23960 | -#define FLAG_ZERO 32 | ||
23961 | - | ||
23962 | -/* arg_index value indicating that no argument is consumed. */ | ||
23963 | -#define ARG_NONE (~(size_t)0) | ||
23964 | - | ||
23965 | -/* A parsed directive. */ | ||
23966 | -typedef struct | ||
23967 | -{ | ||
23968 | - const wchar_t* dir_start; | ||
23969 | - const wchar_t* dir_end; | ||
23970 | - int flags; | ||
23971 | - const wchar_t* width_start; | ||
23972 | - const wchar_t* width_end; | ||
23973 | - size_t width_arg_index; | ||
23974 | - const wchar_t* precision_start; | ||
23975 | - const wchar_t* precision_end; | ||
23976 | - size_t precision_arg_index; | ||
23977 | - wchar_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ | ||
23978 | - size_t arg_index; | ||
23979 | -} | ||
23980 | -wchar_t_directive; | ||
23981 | - | ||
23982 | -/* A parsed format string. */ | ||
23983 | -typedef struct | ||
23984 | -{ | ||
23985 | - size_t count; | ||
23986 | - wchar_t_directive *dir; | ||
23987 | - size_t max_width_length; | ||
23988 | - size_t max_precision_length; | ||
23989 | -} | ||
23990 | -wchar_t_directives; | ||
23991 | - | ||
23992 | - | ||
23993 | -/* Parses the format string. Fills in the number N of directives, and fills | ||
23994 | - in directives[0], ..., directives[N-1], and sets directives[N].dir_start | ||
23995 | - to the end of the format string. Also fills in the arg_type fields of the | ||
23996 | - arguments and the needed count of arguments. */ | ||
23997 | -#ifdef STATIC | ||
23998 | -STATIC | ||
23999 | -#else | ||
24000 | -extern | ||
24001 | -#endif | ||
24002 | -int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a); | ||
24003 | - | ||
24004 | -#endif /* _WPRINTF_PARSE_H */ | ||
24005 | --- a/intl/xsize.h | ||
24006 | +++ /dev/null | ||
24007 | @@ -1,109 +0,0 @@ | ||
24008 | -/* xsize.h -- Checked size_t computations. | ||
24009 | - | ||
24010 | - Copyright (C) 2003 Free Software Foundation, Inc. | ||
24011 | - | ||
24012 | - This program is free software; you can redistribute it and/or modify it | ||
24013 | - under the terms of the GNU Library General Public License as published | ||
24014 | - by the Free Software Foundation; either version 2, or (at your option) | ||
24015 | - any later version. | ||
24016 | - | ||
24017 | - This program is distributed in the hope that it will be useful, | ||
24018 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
24019 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
24020 | - Library General Public License for more details. | ||
24021 | - | ||
24022 | - You should have received a copy of the GNU Library General Public | ||
24023 | - License along with this program; if not, write to the Free Software | ||
24024 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
24025 | - USA. */ | ||
24026 | - | ||
24027 | -#ifndef _XSIZE_H | ||
24028 | -#define _XSIZE_H | ||
24029 | - | ||
24030 | -/* Get size_t. */ | ||
24031 | -#include <stddef.h> | ||
24032 | - | ||
24033 | -/* Get SIZE_MAX. */ | ||
24034 | -#include <limits.h> | ||
24035 | -#if HAVE_STDINT_H | ||
24036 | -# include <stdint.h> | ||
24037 | -#endif | ||
24038 | - | ||
24039 | -/* The size of memory objects is often computed through expressions of | ||
24040 | - type size_t. Example: | ||
24041 | - void* p = malloc (header_size + n * element_size). | ||
24042 | - These computations can lead to overflow. When this happens, malloc() | ||
24043 | - returns a piece of memory that is way too small, and the program then | ||
24044 | - crashes while attempting to fill the memory. | ||
24045 | - To avoid this, the functions and macros in this file check for overflow. | ||
24046 | - The convention is that SIZE_MAX represents overflow. | ||
24047 | - malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc | ||
24048 | - implementation that uses mmap --, it's recommended to use size_overflow_p() | ||
24049 | - or size_in_bounds_p() before invoking malloc(). | ||
24050 | - The example thus becomes: | ||
24051 | - size_t size = xsum (header_size, xtimes (n, element_size)); | ||
24052 | - void *p = (size_in_bounds_p (size) ? malloc (size) : NULL); | ||
24053 | -*/ | ||
24054 | - | ||
24055 | -/* Convert an arbitrary value >= 0 to type size_t. */ | ||
24056 | -#define xcast_size_t(N) \ | ||
24057 | - ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) | ||
24058 | - | ||
24059 | -/* Sum of two sizes, with overflow check. */ | ||
24060 | -static inline size_t | ||
24061 | -#if __GNUC__ >= 3 | ||
24062 | -__attribute__ ((__pure__)) | ||
24063 | -#endif | ||
24064 | -xsum (size_t size1, size_t size2) | ||
24065 | -{ | ||
24066 | - size_t sum = size1 + size2; | ||
24067 | - return (sum >= size1 ? sum : SIZE_MAX); | ||
24068 | -} | ||
24069 | - | ||
24070 | -/* Sum of three sizes, with overflow check. */ | ||
24071 | -static inline size_t | ||
24072 | -#if __GNUC__ >= 3 | ||
24073 | -__attribute__ ((__pure__)) | ||
24074 | -#endif | ||
24075 | -xsum3 (size_t size1, size_t size2, size_t size3) | ||
24076 | -{ | ||
24077 | - return xsum (xsum (size1, size2), size3); | ||
24078 | -} | ||
24079 | - | ||
24080 | -/* Sum of four sizes, with overflow check. */ | ||
24081 | -static inline size_t | ||
24082 | -#if __GNUC__ >= 3 | ||
24083 | -__attribute__ ((__pure__)) | ||
24084 | -#endif | ||
24085 | -xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) | ||
24086 | -{ | ||
24087 | - return xsum (xsum (xsum (size1, size2), size3), size4); | ||
24088 | -} | ||
24089 | - | ||
24090 | -/* Maximum of two sizes, with overflow check. */ | ||
24091 | -static inline size_t | ||
24092 | -#if __GNUC__ >= 3 | ||
24093 | -__attribute__ ((__pure__)) | ||
24094 | -#endif | ||
24095 | -xmax (size_t size1, size_t size2) | ||
24096 | -{ | ||
24097 | - /* No explicit check is needed here, because for any n: | ||
24098 | - max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */ | ||
24099 | - return (size1 >= size2 ? size1 : size2); | ||
24100 | -} | ||
24101 | - | ||
24102 | -/* Multiplication of a count with an element size, with overflow check. | ||
24103 | - The count must be >= 0 and the element size must be > 0. | ||
24104 | - This is a macro, not an inline function, so that it works correctly even | ||
24105 | - when N is of a wider tupe and N > SIZE_MAX. */ | ||
24106 | -#define xtimes(N, ELSIZE) \ | ||
24107 | - ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) | ||
24108 | - | ||
24109 | -/* Check for overflow. */ | ||
24110 | -#define size_overflow_p(SIZE) \ | ||
24111 | - ((SIZE) == SIZE_MAX) | ||
24112 | -/* Check against overflow. */ | ||
24113 | -#define size_in_bounds_p(SIZE) \ | ||
24114 | - ((SIZE) != SIZE_MAX) | ||
24115 | - | ||
24116 | -#endif /* _XSIZE_H */ | ||
24117 | --- a/m4/intlmacosx.m4 | ||
24118 | +++ b/m4/intlmacosx.m4 | ||
24119 | @@ -1,50 +1,71 @@ | ||
24120 | -# intlmacosx.m4 serial 1 (gettext-0.17) | ||
24121 | -dnl Copyright (C) 2004-2007 Free Software Foundation, Inc. | ||
24122 | +# intlmacosx.m4 serial 6 (gettext-0.20) | ||
24123 | +dnl Copyright (C) 2004-2014, 2016, 2019 Free Software Foundation, Inc. | ||
24124 | dnl This file is free software; the Free Software Foundation | ||
24125 | dnl gives unlimited permission to copy and/or distribute it, | ||
24126 | dnl with or without modifications, as long as this notice is preserved. | ||
24127 | dnl | ||
24128 | -dnl This file can can be used in projects which are not available under | ||
24129 | +dnl This file can be used in projects which are not available under | ||
24130 | dnl the GNU General Public License or the GNU Library General Public | ||
24131 | dnl License but which still want to provide support for the GNU gettext | ||
24132 | dnl functionality. | ||
24133 | dnl Please note that the actual code of the GNU gettext library is covered | ||
24134 | dnl by the GNU Library General Public License, and the rest of the GNU | ||
24135 | -dnl gettext package package is covered by the GNU General Public License. | ||
24136 | +dnl gettext package is covered by the GNU General Public License. | ||
24137 | dnl They are *not* in the public domain. | ||
24138 | |||
24139 | -dnl Checks for special options needed on MacOS X. | ||
24140 | +dnl Checks for special options needed on Mac OS X. | ||
24141 | dnl Defines INTL_MACOSX_LIBS. | ||
24142 | AC_DEFUN([gt_INTL_MACOSX], | ||
24143 | [ | ||
24144 | - dnl Check for API introduced in MacOS X 10.2. | ||
24145 | + dnl Check for API introduced in Mac OS X 10.4. | ||
24146 | AC_CACHE_CHECK([for CFPreferencesCopyAppValue], | ||
24147 | - gt_cv_func_CFPreferencesCopyAppValue, | ||
24148 | + [gt_cv_func_CFPreferencesCopyAppValue], | ||
24149 | [gt_save_LIBS="$LIBS" | ||
24150 | LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" | ||
24151 | - AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>], | ||
24152 | - [CFPreferencesCopyAppValue(NULL, NULL)], | ||
24153 | + AC_LINK_IFELSE( | ||
24154 | + [AC_LANG_PROGRAM( | ||
24155 | + [[#include <CoreFoundation/CFPreferences.h>]], | ||
24156 | + [[CFPreferencesCopyAppValue(NULL, NULL)]])], | ||
24157 | [gt_cv_func_CFPreferencesCopyAppValue=yes], | ||
24158 | [gt_cv_func_CFPreferencesCopyAppValue=no]) | ||
24159 | LIBS="$gt_save_LIBS"]) | ||
24160 | if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then | ||
24161 | - AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, | ||
24162 | - [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) | ||
24163 | + AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], | ||
24164 | + [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) | ||
24165 | fi | ||
24166 | - dnl Check for API introduced in MacOS X 10.3. | ||
24167 | - AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, | ||
24168 | + dnl Check for API introduced in Mac OS X 10.5. | ||
24169 | + AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], | ||
24170 | [gt_save_LIBS="$LIBS" | ||
24171 | LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" | ||
24172 | - AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();], | ||
24173 | + AC_LINK_IFELSE( | ||
24174 | + [AC_LANG_PROGRAM( | ||
24175 | + [[#include <CoreFoundation/CFLocale.h>]], | ||
24176 | + [[CFLocaleCopyCurrent();]])], | ||
24177 | [gt_cv_func_CFLocaleCopyCurrent=yes], | ||
24178 | [gt_cv_func_CFLocaleCopyCurrent=no]) | ||
24179 | LIBS="$gt_save_LIBS"]) | ||
24180 | if test $gt_cv_func_CFLocaleCopyCurrent = yes; then | ||
24181 | - AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, | ||
24182 | - [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) | ||
24183 | + AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], | ||
24184 | + [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) | ||
24185 | + fi | ||
24186 | + AC_CACHE_CHECK([for CFLocaleCopyPreferredLanguages], [gt_cv_func_CFLocaleCopyPreferredLanguages], | ||
24187 | + [gt_save_LIBS="$LIBS" | ||
24188 | + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" | ||
24189 | + AC_LINK_IFELSE( | ||
24190 | + [AC_LANG_PROGRAM( | ||
24191 | + [[#include <CoreFoundation/CFLocale.h>]], | ||
24192 | + [[CFLocaleCopyPreferredLanguages();]])], | ||
24193 | + [gt_cv_func_CFLocaleCopyPreferredLanguages=yes], | ||
24194 | + [gt_cv_func_CFLocaleCopyPreferredLanguages=no]) | ||
24195 | + LIBS="$gt_save_LIBS"]) | ||
24196 | + if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then | ||
24197 | + AC_DEFINE([HAVE_CFLOCALECOPYPREFERREDLANGUAGES], [1], | ||
24198 | + [Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework.]) | ||
24199 | fi | ||
24200 | INTL_MACOSX_LIBS= | ||
24201 | - if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then | ||
24202 | + if test $gt_cv_func_CFPreferencesCopyAppValue = yes \ | ||
24203 | + || test $gt_cv_func_CFLocaleCopyCurrent = yes \ | ||
24204 | + || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then | ||
24205 | INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" | ||
24206 | fi | ||
24207 | AC_SUBST([INTL_MACOSX_LIBS]) | ||
24208 | --- a/po/ChangeLog | ||
24209 | +++ b/po/ChangeLog | ||
24210 | @@ -1,3 +1,11 @@ | ||
24211 | +2019-12-07 gettextize <bug-gnu-gettext@gnu.org> | ||
24212 | + | ||
24213 | + * en@boldquot.header: Upgrade to gettext-0.20.1. | ||
24214 | + * en@quot.header: Upgrade to gettext-0.20.1. | ||
24215 | + * insert-header.sin: Upgrade to gettext-0.20.1. | ||
24216 | + * remove-potcdate.sin: Upgrade to gettext-0.20.1. | ||
24217 | + * Rules-quot: Upgrade to gettext-0.20.1. | ||
24218 | + | ||
24219 | 2009-08-11 Scott James Remnant <scott@netsplit.com> | ||
24220 | |||
24221 | * libnih.pot: Distribute the pot file | ||
24222 | --- a/po/Rules-quot | ||
24223 | +++ b/po/Rules-quot | ||
24224 | @@ -1,4 +1,9 @@ | ||
24225 | # Special Makefile rules for English message catalogs with quotation marks. | ||
24226 | +# | ||
24227 | +# Copyright (C) 2001-2017 Free Software Foundation, Inc. | ||
24228 | +# This file, Rules-quot, and its auxiliary files (listed under | ||
24229 | +# DISTFILES.common.extra1) are free software; the Free Software Foundation | ||
24230 | +# gives unlimited permission to use, copy, distribute, and modify them. | ||
24231 | |||
24232 | DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot | ||
24233 | |||
24234 | @@ -14,13 +19,23 @@ en@boldquot.po-update: en@boldquot.po-up | ||
24235 | |||
24236 | .insert-header.po-update-en: | ||
24237 | @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ | ||
24238 | - if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ | ||
24239 | + if test "$(PACKAGE)" = "gettext-tools" && test "$(CROSS_COMPILING)" != "yes"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ | ||
24240 | tmpdir=`pwd`; \ | ||
24241 | echo "$$lang:"; \ | ||
24242 | ll=`echo $$lang | sed -e 's/@.*//'`; \ | ||
24243 | LC_ALL=C; export LC_ALL; \ | ||
24244 | cd $(srcdir); \ | ||
24245 | - if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$ll -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ | ||
24246 | + if $(MSGINIT) $(MSGINIT_OPTIONS) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null \ | ||
24247 | + | $(SED) -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | \ | ||
24248 | + { case `$(MSGFILTER) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ | ||
24249 | + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-8] | 0.1[0-8].*) \ | ||
24250 | + $(MSGFILTER) $(SED) -f `echo $$lang | sed -e 's/.*@//'`.sed \ | ||
24251 | + ;; \ | ||
24252 | + *) \ | ||
24253 | + $(MSGFILTER) `echo $$lang | sed -e 's/.*@//'` \ | ||
24254 | + ;; \ | ||
24255 | + esac } 2>/dev/null > $$tmpdir/$$lang.new.po \ | ||
24256 | + ; then \ | ||
24257 | if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ | ||
24258 | rm -f $$tmpdir/$$lang.new.po; \ | ||
24259 | else \ | ||
24260 | --- a/po/en@boldquot.header | ||
24261 | +++ b/po/en@boldquot.header | ||
24262 | @@ -2,7 +2,7 @@ | ||
24263 | # The msgids must be ASCII and therefore cannot contain real quotation | ||
24264 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) | ||
24265 | # and double quote (0x22). These substitutes look strange; see | ||
24266 | -# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html | ||
24267 | +# https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html | ||
24268 | # | ||
24269 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to | ||
24270 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). | ||
24271 | --- a/po/en@quot.header | ||
24272 | +++ b/po/en@quot.header | ||
24273 | @@ -2,7 +2,7 @@ | ||
24274 | # The msgids must be ASCII and therefore cannot contain real quotation | ||
24275 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) | ||
24276 | # and double quote (0x22). These substitutes look strange; see | ||
24277 | -# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html | ||
24278 | +# https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html | ||
24279 | # | ||
24280 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to | ||
24281 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). | ||
24282 | --- a/po/insert-header.sin | ||
24283 | +++ b/po/insert-header.sin | ||
24284 | @@ -1,5 +1,10 @@ | ||
24285 | # Sed script that inserts the file called HEADER before the header entry. | ||
24286 | # | ||
24287 | +# Copyright (C) 2001 Free Software Foundation, Inc. | ||
24288 | +# Written by Bruno Haible <bruno@clisp.org>, 2001. | ||
24289 | +# This file is free software; the Free Software Foundation gives | ||
24290 | +# unlimited permission to use, copy, distribute, and modify it. | ||
24291 | +# | ||
24292 | # At each occurrence of a line starting with "msgid ", we execute the following | ||
24293 | # commands. At the first occurrence, insert the file. At the following | ||
24294 | # occurrences, do nothing. The distinction between the first and the following | ||
24295 | --- a/po/remove-potcdate.sin | ||
24296 | +++ b/po/remove-potcdate.sin | ||
24297 | @@ -1,6 +1,12 @@ | ||
24298 | -# Sed script that remove the POT-Creation-Date line in the header entry | ||
24299 | +# Sed script that removes the POT-Creation-Date line in the header entry | ||
24300 | # from a POT file. | ||
24301 | # | ||
24302 | +# Copyright (C) 2002 Free Software Foundation, Inc. | ||
24303 | +# Copying and distribution of this file, with or without modification, | ||
24304 | +# are permitted in any medium without royalty provided the copyright | ||
24305 | +# notice and this notice are preserved. This file is offered as-is, | ||
24306 | +# without any warranty. | ||
24307 | +# | ||
24308 | # The distinction between the first and the following occurrences of the | ||
24309 | # pattern is achieved by looking at the hold space. | ||
24310 | /^"POT-Creation-Date: .*"$/{ | ||
diff --git a/meta-oe/recipes-support/libnih/libnih_1.0.3.bb b/meta-oe/recipes-support/libnih/libnih_1.0.3.bb index fcb6bebd6..ff7a4ed10 100644 --- a/meta-oe/recipes-support/libnih/libnih_1.0.3.bb +++ b/meta-oe/recipes-support/libnih/libnih_1.0.3.bb | |||
@@ -20,19 +20,19 @@ SECTION = "libs" | |||
20 | LICENSE = "GPL-2.0" | 20 | LICENSE = "GPL-2.0" |
21 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" | 21 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" |
22 | 22 | ||
23 | DEPENDS = "dbus libnih-native" | 23 | DEPENDS = "dbus expat" |
24 | DEPENDS_class-native = "dbus-native" | 24 | DEPENDS_append_class-target = " libnih-native" |
25 | 25 | ||
26 | SRC_URI = "https://launchpad.net/${BPN}/1.0/${PV}/+download/${BP}.tar.gz \ | 26 | SRC_URI = "https://launchpad.net/${BPN}/1.0/${PV}/+download/${BP}.tar.gz \ |
27 | file://libnih_1.0.3-4ubuntu16.patch \ | 27 | file://libnih_1.0.3-4ubuntu16.patch \ |
28 | file://0001-signal.c-SIGCLD-and-SIGCHILD-are-same-on-sytem-V-sys.patch \ | 28 | file://0001-signal.c-SIGCLD-and-SIGCHILD-are-same-on-sytem-V-sys.patch \ |
29 | file://0001-Update-autotool-files-also-make-it-work-with-latest-.patch \ | ||
29 | " | 30 | " |
30 | 31 | ||
31 | SRC_URI[md5sum] = "db7990ce55e01daffe19006524a1ccb0" | 32 | SRC_URI[md5sum] = "db7990ce55e01daffe19006524a1ccb0" |
32 | SRC_URI[sha256sum] = "897572df7565c0a90a81532671e23c63f99b4efde2eecbbf11e7857fbc61f405" | 33 | SRC_URI[sha256sum] = "897572df7565c0a90a81532671e23c63f99b4efde2eecbbf11e7857fbc61f405" |
33 | 34 | ||
34 | inherit autotools | 35 | inherit autotools gettext |
35 | inherit gettext | ||
36 | 36 | ||
37 | do_configure_append () { | 37 | do_configure_append () { |
38 | sed -i -e 's,lib/pkgconfig,${baselib}/pkgconfig,g' ${S}/nih/Makefile.in ${S}/nih-dbus/Makefile.in | 38 | sed -i -e 's,lib/pkgconfig,${baselib}/pkgconfig,g' ${S}/nih/Makefile.in ${S}/nih-dbus/Makefile.in |