Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 713442 | Differences between
and this patch

Collapse All | Expand All

(-)a/ABOUT-NLS (-1101 / +1 lines)
Lines 1-1101 Link Here
1
1 Notes on the Free Translation Project
1
<https://www.gnu.org/software/gettext/manual/html_node/Users.html>
2
***************************************
3
4
Free software is going international!  The Free Translation Project is
5
a way to get maintainers of free software, translators, and users all
6
together, so that free software will gradually become able to speak many
7
languages.  A few packages already provide translations for their
8
messages.
9
10
   If you found this `ABOUT-NLS' file inside a distribution, you may
11
assume that the distributed package does use GNU `gettext' internally,
12
itself available at your nearest GNU archive site.  But you do _not_
13
need to install GNU `gettext' prior to configuring, installing or using
14
this package with messages translated.
15
16
   Installers will find here some useful hints.  These notes also
17
explain how users should proceed for getting the programs to use the
18
available translations.  They tell how people wanting to contribute and
19
work on translations can contact the appropriate team.
20
21
   When reporting bugs in the `intl/' directory or bugs which may be
22
related to internationalization, you should tell about the version of
23
`gettext' which is used.  The information can be found in the
24
`intl/VERSION' file, in internationalized packages.
25
26
1.1 Quick configuration advice
27
==============================
28
29
If you want to exploit the full power of internationalization, you
30
should configure it using
31
32
     ./configure --with-included-gettext
33
34
to force usage of internationalizing routines provided within this
35
package, despite the existence of internationalizing capabilities in the
36
operating system where this package is being installed.  So far, only
37
the `gettext' implementation in the GNU C library version 2 provides as
38
many features (such as locale alias, message inheritance, automatic
39
charset conversion or plural form handling) as the implementation here.
40
It is also not possible to offer this additional functionality on top
41
of a `catgets' implementation.  Future versions of GNU `gettext' will
42
very likely convey even more functionality.  So it might be a good idea
43
to change to GNU `gettext' as soon as possible.
44
45
   So you need _not_ provide this option if you are using GNU libc 2 or
46
you have installed a recent copy of the GNU gettext package with the
47
included `libintl'.
48
49
1.2 INSTALL Matters
50
===================
51
52
Some packages are "localizable" when properly installed; the programs
53
they contain can be made to speak your own native language.  Most such
54
packages use GNU `gettext'.  Other packages have their own ways to
55
internationalization, predating GNU `gettext'.
56
57
   By default, this package will be installed to allow translation of
58
messages.  It will automatically detect whether the system already
59
provides the GNU `gettext' functions.  If not, the included GNU
60
`gettext' library will be used.  This library is wholly contained
61
within this package, usually in the `intl/' subdirectory, so prior
62
installation of the GNU `gettext' package is _not_ required.
63
Installers may use special options at configuration time for changing
64
the default behaviour.  The commands:
65
66
     ./configure --with-included-gettext
67
     ./configure --disable-nls
68
69
will, respectively, bypass any pre-existing `gettext' to use the
70
internationalizing routines provided within this package, or else,
71
_totally_ disable translation of messages.
72
73
   When you already have GNU `gettext' installed on your system and run
74
configure without an option for your new package, `configure' will
75
probably detect the previously built and installed `libintl.a' file and
76
will decide to use this.  This might not be desirable.  You should use
77
the more recent version of the GNU `gettext' library.  I.e. if the file
78
`intl/VERSION' shows that the library which comes with this package is
79
more recent, you should use
80
81
     ./configure --with-included-gettext
82
83
to prevent auto-detection.
84
85
   The configuration process will not test for the `catgets' function
86
and therefore it will not be used.  The reason is that even an
87
emulation of `gettext' on top of `catgets' could not provide all the
88
extensions of the GNU `gettext' library.
89
90
   Internationalized packages usually have many `po/LL.po' files, where
91
LL gives an ISO 639 two-letter code identifying the language.  Unless
92
translations have been forbidden at `configure' time by using the
93
`--disable-nls' switch, all available translations are installed
94
together with the package.  However, the environment variable `LINGUAS'
95
may be set, prior to configuration, to limit the installed set.
96
`LINGUAS' should then contain a space separated list of two-letter
97
codes, stating which languages are allowed.
98
99
1.3 Using This Package
100
======================
101
102
As a user, if your language has been installed for this package, you
103
only have to set the `LANG' environment variable to the appropriate
104
`LL_CC' combination.  Here `LL' is an ISO 639 two-letter language code,
105
and `CC' is an ISO 3166 two-letter country code.  For example, let's
106
suppose that you speak German and live in Germany.  At the shell
107
prompt, merely execute `setenv LANG de_DE' (in `csh'),
108
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
109
This can be done from your `.login' or `.profile' file, once and for
110
all.
111
112
   You might think that the country code specification is redundant.
113
But in fact, some languages have dialects in different countries.  For
114
example, `de_AT' is used for Austria, and `pt_BR' for Brazil.  The
115
country code serves to distinguish the dialects.
116
117
   The locale naming convention of `LL_CC', with `LL' denoting the
118
language and `CC' denoting the country, is the one use on systems based
119
on GNU libc.  On other systems, some variations of this scheme are
120
used, such as `LL' or `LL_CC.ENCODING'.  You can get the list of
121
locales supported by your system for your language by running the
122
command `locale -a | grep '^LL''.
123
124
   Not all programs have translations for all languages.  By default, an
125
English message is shown in place of a nonexistent translation.  If you
126
understand other languages, you can set up a priority list of languages.
127
This is done through a different environment variable, called
128
`LANGUAGE'.  GNU `gettext' gives preference to `LANGUAGE' over `LANG'
129
for the purpose of message handling, but you still need to have `LANG'
130
set to the primary language; this is required by other parts of the
131
system libraries.  For example, some Swedish users who would rather
132
read translations in German than English for when Swedish is not
133
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
134
135
   Special advice for Norwegian users: The language code for Norwegian
136
bokma*l changed from `no' to `nb' recently (in 2003).  During the
137
transition period, while some message catalogs for this language are
138
installed under `nb' and some older ones under `no', it's recommended
139
for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and
140
older translations are used.
141
142
   In the `LANGUAGE' environment variable, but not in the `LANG'
143
environment variable, `LL_CC' combinations can be abbreviated as `LL'
144
to denote the language's main dialect.  For example, `de' is equivalent
145
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
146
(Portuguese as spoken in Portugal) in this context.
147
148
1.4 Translating Teams
149
=====================
150
151
For the Free Translation Project to be a success, we need interested
152
people who like their own language and write it well, and who are also
153
able to synergize with other translators speaking the same language.
154
Each translation team has its own mailing list.  The up-to-date list of
155
teams can be found at the Free Translation Project's homepage,
156
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
157
area.
158
159
   If you'd like to volunteer to _work_ at translating messages, you
160
should become a member of the translating team for your own language.
161
The subscribing address is _not_ the same as the list itself, it has
162
`-request' appended.  For example, speakers of Swedish can send a
163
message to `sv-request@li.org', having this message body:
164
165
     subscribe
166
167
   Keep in mind that team members are expected to participate
168
_actively_ in translations, or at solving translational difficulties,
169
rather than merely lurking around.  If your team does not exist yet and
170
you want to start one, or if you are unsure about what to do or how to
171
get started, please write to `translation@iro.umontreal.ca' to reach the
172
coordinator for all translator teams.
173
174
   The English team is special.  It works at improving and uniformizing
175
the terminology in use.  Proven linguistic skills are praised more than
176
programming skills, here.
177
178
1.5 Available Packages
179
======================
180
181
Languages are not equally supported in all packages.  The following
182
matrix shows the current state of internationalization, as of October
183
2006.  The matrix shows, in regard of each package, for which languages
184
PO files have been submitted to translation coordination, with a
185
translation percentage of at least 50%.
186
187
     Ready PO files       af am ar az be bg bs ca cs cy da de el en en_GB eo
188
                        +----------------------------------------------------+
189
     GNUnet             |                                  []                |
190
     a2ps               |             []                [] [] []     []      |
191
     aegis              |                                  ()                |
192
     ant-phone          |                                  ()                |
193
     anubis             |                                  []                |
194
     ap-utils           |                                                    |
195
     aspell             |                      [] []    [] []        []      |
196
     bash               |                      []          []             [] |
197
     batchelor          |                                  []                |
198
     bfd                |                                                    |
199
     bibshelf           |                                  []                |
200
     binutils           |                               []                   |
201
     bison              |                               [] []                |
202
     bison-runtime      |                                                    |
203
     bluez-pin          | []                      []       [] []          [] |
204
     cflow              |                               []                   |
205
     clisp              |                                  []    []          |
206
     console-tools      |                         []       []                |
207
     coreutils          |                []    []          []                |
208
     cpio               |                                                    |
209
     cpplib             |                      []       [] []                |
210
     cryptonit          |                                  []                |
211
     darkstat           |                []             () []                |
212
     dialog             |                      [] [] [] [] [] []             |
213
     diffutils          |                      [] []    [] [] []          [] |
214
     doodle             |                                  []                |
215
     e2fsprogs          |                         []       []                |
216
     enscript           |                      []       [] []        []      |
217
     error              |                      []       [] []        []      |
218
     fetchmail          |                      []       [] () []             |
219
     fileutils          |                               [] []                |
220
     findutils          |                []    []       []                   |
221
     flex               |                      []       [] []                |
222
     fslint             |                                  []                |
223
     gas                |                                                    |
224
     gawk               |                      []       [] []                |
225
     gbiff              |                                  []                |
226
     gcal               |                      []                            |
227
     gcc                |                                  []                |
228
     gettext-examples   | []                   []          [] []          [] |
229
     gettext-runtime    |             []       []       [] []             [] |
230
     gettext-tools      |                      []          []                |
231
     gimp-print         |                         []    [] []        []      |
232
     gip                |                []                                  |
233
     gliv               |                                  []                |
234
     glunarclock        |                []                                  |
235
     gmult              | []                               []                |
236
     gnubiff            |                                  ()                |
237
     gnucash            |                                  () ()     []      |
238
     gnucash-glossary   |                               [] ()                |
239
     gnuedu             |                                                    |
240
     gnulib             | []          [] []    []       [] []                |
241
     gnunet-gtk         |                                                    |
242
     gnutls             |                                                    |
243
     gpe-aerial         |                         []       []                |
244
     gpe-beam           |                         []       []                |
245
     gpe-calendar       |                                                    |
246
     gpe-clock          |                         []       []                |
247
     gpe-conf           |                         []       []                |
248
     gpe-contacts       |                                                    |
249
     gpe-edit           |                         []                         |
250
     gpe-filemanager    |                                                    |
251
     gpe-go             |                         []                         |
252
     gpe-login          |                         []       []                |
253
     gpe-ownerinfo      |                         []       []                |
254
     gpe-package        |                                                    |
255
     gpe-sketchbook     |                         []       []                |
256
     gpe-su             |                         []       []                |
257
     gpe-taskmanager    |                         []       []                |
258
     gpe-timesheet      |                         []                         |
259
     gpe-today          |                         []       []                |
260
     gpe-todo           |                                                    |
261
     gphoto2            |                         []    [] []        []      |
262
     gprof              |                               [] []                |
263
     gpsdrive           |                                  ()    ()          |
264
     gramadoir          | []                               []                |
265
     grep               | []          [] []    []          [] []             |
266
     gretl              |                                                    |
267
     gsasl              |                                                    |
268
     gss                |                                                    |
269
     gst-plugins        | []                   [] []    []                   |
270
     gst-plugins-base   |                []    []       []                   |
271
     gst-plugins-good   | []       []    []    [] []    []           []      |
272
     gstreamer          | []             []    [] []    [] []        []      |
273
     gtick              |                                  ()                |
274
     gtkam              |                         []    [] []                |
275
     gtkorphan          |                []                []                |
276
     gtkspell           |             []                   [] []          [] |
277
     gutenprint         |                               []                   |
278
     hello              |                []    []       [] []             [] |
279
     id-utils           |                               [] []                |
280
     impost             |                                                    |
281
     indent             |                      []          []             [] |
282
     iso_3166           |                                  []             [] |
283
     iso_3166_2         |                                                    |
284
     iso_4217           |                                  []                |
285
     iso_639            |                                  []             [] |
286
     jpilot             |                         []                         |
287
     jtag               |                                                    |
288
     jwhois             |                                                    |
289
     kbd                |                         []    [] [] []             |
290
     keytouch           |                                                    |
291
     keytouch-editor    |                                                    |
292
     keytouch-keyboa... |                                                    |
293
     latrine            |                                  ()                |
294
     ld                 |                               []                   |
295
     leafpad            |                []    [] []       [] []             |
296
     libc               |                      [] []    [] [] []             |
297
     libexif            |                                  []                |
298
     libextractor       |                                  []                |
299
     libgpewidget       |                         []    [] []                |
300
     libgpg-error       |                                  []                |
301
     libgphoto2         |                               [] []                |
302
     libgphoto2_port    |                               [] []                |
303
     libgsasl           |                                                    |
304
     libiconv           |                                  []             [] |
305
     libidn             |                               []                [] |
306
     lifelines          |                               [] ()                |
307
     lilypond           |                                  []                |
308
     lingoteach         |                                                    |
309
     lynx               |                      [] []    [] []                |
310
     m4                 |                         []    [] [] []             |
311
     mailutils          |                      []                            |
312
     make               |                               [] []                |
313
     man-db             |                      [] ()    [] []                |
314
     minicom            |                         []    [] []                |
315
     mysecretdiary      |                               [] []                |
316
     nano               |                []    []          []                |
317
     nano_1_0           |                      [] ()    [] []                |
318
     opcodes            |                                  []                |
319
     parted             |                                                    |
320
     pilot-qof          |                                            []      |
321
     psmisc             |                []                                  |
322
     pwdutils           |                                                    |
323
     python             |                                                    |
324
     qof                |                                                    |
325
     radius             |                      []                            |
326
     recode             |             []       []       [] [] []          [] |
327
     rpm                |                         []    []                   |
328
     screem             |                                                    |
329
     scrollkeeper       |          [] []       [] [] [] [] []        []      |
330
     sed                |                      []          []             [] |
331
     sh-utils           |                               [] []                |
332
     shared-mime-info   |                []       []                 []   [] |
333
     sharutils          |                []    [] []    [] [] []             |
334
     shishi             |                                                    |
335
     silky              |                                                    |
336
     skencil            |                               [] ()                |
337
     sketch             |                               [] ()                |
338
     solfege            |                                                    |
339
     soundtracker       |                               [] []                |
340
     sp                 |                                  []                |
341
     stardict           |                         []                         |
342
     system-tools-ba... |       []       [] [] [] []    [] [] []     []      |
343
     tar                |                []                                  |
344
     texinfo            |                               [] []             [] |
345
     textutils          |                      []       [] []                |
346
     tin                |                                  ()        ()      |
347
     tp-robot           |                                  []                |
348
     tuxpaint           | []             []             [] []        []      |
349
     unicode-han-tra... |                                                    |
350
     unicode-transla... |                                                    |
351
     util-linux         |                      [] []    [] []                |
352
     vorbis-tools       |             []          []    []           []      |
353
     wastesedge         |                                  ()                |
354
     wdiff              |                      []       [] []        []      |
355
     wget               |                      []          []                |
356
     xchat              |             [] []    []          [] []     []      |
357
     xkeyboard-config   |                                                    |
358
     xpad               |                []             []                   |
359
                        +----------------------------------------------------+
360
                          af am ar az be bg bs ca cs cy da de el en en_GB eo
361
                          10  0  1  2  9 22  1 42 41  2 60 95 16  1  17   16
362
363
                          es et eu fa fi fr  ga gl gu he hi hr hu id is it
364
                        +--------------------------------------------------+
365
     GNUnet             |                                                  |
366
     a2ps               |    []       [] []                             () |
367
     aegis              |                                                  |
368
     ant-phone          |                []                                |
369
     anubis             |                []                                |
370
     ap-utils           |             [] []                                |
371
     aspell             |                []  []                         [] |
372
     bash               | []             []                    []          |
373
     batchelor          |                []  []                            |
374
     bfd                | []                                               |
375
     bibshelf           | []                 []                         [] |
376
     binutils           | []          [] []                                |
377
     bison              | [] []          []  []                   []    [] |
378
     bison-runtime      |    []          []  []                   []    [] |
379
     bluez-pin          |             [] []  []                [] []       |
380
     cflow              |                    []                            |
381
     clisp              | []             []                                |
382
     console-tools      |                                                  |
383
     coreutils          | [] []       [] []  []                []          |
384
     cpio               | []             []  []                            |
385
     cpplib             | []             []                                |
386
     cryptonit          |                []                                |
387
     darkstat           | []             ()  []                [] []       |
388
     dialog             | [] [] []    [] []  []                []       [] |
389
     diffutils          | []          [] []  [] []    []       [] []    [] |
390
     doodle             |                    []                         [] |
391
     e2fsprogs          | []             []                             [] |
392
     enscript           |                []  []             []             |
393
     error              | []          [] []  []                []          |
394
     fetchmail          | []                                               |
395
     fileutils          | [] []          []  []                []       [] |
396
     findutils          |    []          []  []                []          |
397
     flex               | []             []  []                            |
398
     fslint             |                []                                |
399
     gas                | []             []                                |
400
     gawk               | []             []  []       []                   |
401
     gbiff              |                []                                |
402
     gcal               | []             []                                |
403
     gcc                | []                                               |
404
     gettext-examples   | []             []  []                [] []    [] |
405
     gettext-runtime    | []          [] []  []                   []    [] |
406
     gettext-tools      | []             []                             [] |
407
     gimp-print         | []             []                                |
408
     gip                | []    []       []                                |
409
     gliv               |                ()                                |
410
     glunarclock        |             []     []                []          |
411
     gmult              |       []       []                             [] |
412
     gnubiff            |                ()                             () |
413
     gnucash            | ()             ()                    ()          |
414
     gnucash-glossary   | []                                            [] |
415
     gnuedu             | []                                               |
416
     gnulib             | [] [] []    [] []  [] []             []          |
417
     gnunet-gtk         |                                                  |
418
     gnutls             |                                                  |
419
     gpe-aerial         | []             []                                |
420
     gpe-beam           | []             []                                |
421
     gpe-calendar       |                                                  |
422
     gpe-clock          | []          [] []                    []          |
423
     gpe-conf           |                []                                |
424
     gpe-contacts       | []             []                                |
425
     gpe-edit           | []             []                    [] []       |
426
     gpe-filemanager    | []                                               |
427
     gpe-go             | []             []                    []          |
428
     gpe-login          | []             []                    []          |
429
     gpe-ownerinfo      | []          [] []                    [] []       |
430
     gpe-package        | []                                               |
431
     gpe-sketchbook     | []             []                                |
432
     gpe-su             | []          [] []                    []          |
433
     gpe-taskmanager    | []          [] []                                |
434
     gpe-timesheet      | []             []  []                   []       |
435
     gpe-today          | []          [] []  []                            |
436
     gpe-todo           | []                                               |
437
     gphoto2            | []          [] []                    []       [] |
438
     gprof              | []             []  []                   []       |
439
     gpsdrive           | ()             ()                    []       () |
440
     gramadoir          |                []  []                            |
441
     grep               | [] [] []    [] []  [] []    []    [] [] []    [] |
442
     gretl              | []             []                             [] |
443
     gsasl              |                    []                   []       |
444
     gss                |                []                                |
445
     gst-plugins        |                []                    []       [] |
446
     gst-plugins-base   |                                      []       [] |
447
     gst-plugins-good   |       []                             []       [] |
448
     gstreamer          |             []                       []       [] |
449
     gtick              |                    []                            |
450
     gtkam              | []             []                    []       [] |
451
     gtkorphan          |                []                             [] |
452
     gtkspell           | []    []    [] []  []                         [] |
453
     gutenprint         |                                      []          |
454
     hello              | [] [] [] [] [] []  [] []    []    [] [] []    [] |
455
     id-utils           |                []  []                [] []    [] |
456
     impost             |                []  []                            |
457
     indent             | [] [] []    [] []  [] []             [] []    [] |
458
     iso_3166           |             [] []                    []          |
459
     iso_3166_2         |                []                                |
460
     iso_4217           |    []       []        []             []          |
461
     iso_639            |          [] [] []  []                []          |
462
     jpilot             | []             []                                |
463
     jtag               |                []                                |
464
     jwhois             | []             []                    [] []    [] |
465
     kbd                | []             []                                |
466
     keytouch           |                    []                            |
467
     keytouch-editor    |                    []                            |
468
     keytouch-keyboa... |                    []                            |
469
     latrine            |                []  []                         [] |
470
     ld                 | []             []                                |
471
     leafpad            | []             []  []       []       []       [] |
472
     libc               | []          [] []     []             []          |
473
     libexif            | []                                               |
474
     libextractor       |                    []                            |
475
     libgpewidget       | []             []  []                [] []       |
476
     libgpg-error       |                                                  |
477
     libgphoto2         | []             []                             [] |
478
     libgphoto2_port    |                []                             [] |
479
     libgsasl           |                []  []                            |
480
     libiconv           |    []              []                            |
481
     libidn             |                []                             [] |
482
     lifelines          |                ()                                |
483
     lilypond           |                []                                |
484
     lingoteach         |                []                       []    [] |
485
     lynx               |    []                                []       [] |
486
     m4                 |                []  [] []                []       |
487
     mailutils          | []             []                                |
488
     make               | []          [] []  [] []    []    []    []       |
489
     man-db             | ()                                               |
490
     minicom            | []          [] []                    []          |
491
     mysecretdiary      | []             []                       []       |
492
     nano               | []    []       []  []                []       [] |
493
     nano_1_0           | []             []     []                []    [] |
494
     opcodes            | []          [] []  []                            |
495
     parted             | []             []                       []    [] |
496
     pilot-qof          |                                                  |
497
     psmisc             |       []                             []       [] |
498
     pwdutils           |                                                  |
499
     python             |                                                  |
500
     qof                |                                         []       |
501
     radius             | []             []                                |
502
     recode             | []             []  [] []    []       [] []    [] |
503
     rpm                |                []                       []       |
504
     screem             |                                                  |
505
     scrollkeeper       | []          []                       []          |
506
     sed                | [] []          []  []                []          |
507
     sh-utils           | [] []       [] []  []                []       [] |
508
     shared-mime-info   | []    []    [] []                    []       [] |
509
     sharutils          | [] []       [] []  [] []             []       [] |
510
     shishi             |                                                  |
511
     silky              |                []                                |
512
     skencil            | []             []                                |
513
     sketch             | []             []                                |
514
     solfege            |                                               [] |
515
     soundtracker       | []             []                             [] |
516
     sp                 |                []                                |
517
     stardict           |                                      []          |
518
     system-tools-ba... | []    []    [] []                 [] [] []    [] |
519
     tar                | [] []       [] []  []                []       [] |
520
     texinfo            |                []           []                   |
521
     textutils          | []             []  [] []             []          |
522
     tin                |    []          ()                                |
523
     tp-robot           |             [] []  []                []          |
524
     tuxpaint           |                    []                []          |
525
     unicode-han-tra... |                                                  |
526
     unicode-transla... |                []  []                            |
527
     util-linux         | [] []       [] []                    [] []    [] |
528
     vorbis-tools       | []             []                                |
529
     wastesedge         |                ()                                |
530
     wdiff              | [] []          []  [] []             [] []    [] |
531
     wget               |    []       [] []  []             [] [] []    [] |
532
     xchat              | []    []    [] []        []    []    []       [] |
533
     xkeyboard-config   |             [] []                    []       [] |
534
     xpad               | []                 []                []          |
535
                        +--------------------------------------------------+
536
                          es et eu fa fi fr  ga gl gu he hi hr hu id is it
537
                          88 22 14  2 40 115 61 14  1  8  1  6 59 31  0 52
538
539
                          ja ko ku ky lg lt lv mk mn ms mt nb ne nl nn no
540
                        +-------------------------------------------------+
541
     GNUnet             |                                                 |
542
     a2ps               |    ()                      []          []    () |
543
     aegis              |                                        ()       |
544
     ant-phone          |                                        []       |
545
     anubis             |                            []    []    []       |
546
     ap-utils           |                            []                   |
547
     aspell             |                         []             []       |
548
     bash               |                                        []       |
549
     batchelor          |                            []          []       |
550
     bfd                |                                                 |
551
     bibshelf           |                            []                   |
552
     binutils           |                                                 |
553
     bison              |                            []    []    []       |
554
     bison-runtime      |                            []    []    []       |
555
     bluez-pin          |       []                   []          []       |
556
     cflow              |                                                 |
557
     clisp              |                                        []       |
558
     console-tools      |                                                 |
559
     coreutils          |                                        []       |
560
     cpio               |                                                 |
561
     cpplib             |                                        []       |
562
     cryptonit          |                                        []       |
563
     darkstat           |                            []          []       |
564
     dialog             |                            []          []       |
565
     diffutils          | []                         []          []       |
566
     doodle             |                                                 |
567
     e2fsprogs          |                                        []       |
568
     enscript           |                                        []       |
569
     error              |                                        []       |
570
     fetchmail          | []                                     []       |
571
     fileutils          | []          []                                  |
572
     findutils          |                                        []       |
573
     flex               |    []                                  []       |
574
     fslint             |                            []          []       |
575
     gas                |                                                 |
576
     gawk               | []                                     []       |
577
     gbiff              |                                        []       |
578
     gcal               |                                                 |
579
     gcc                |                                                 |
580
     gettext-examples   | []                                     []       |
581
     gettext-runtime    | [] []                                  []       |
582
     gettext-tools      | [] []                                           |
583
     gimp-print         | []                                     []       |
584
     gip                |                            []          []       |
585
     gliv               |                                        []       |
586
     glunarclock        |                            []          []       |
587
     gmult              | []                         []                   |
588
     gnubiff            |                                                 |
589
     gnucash            | ()                               ()             |
590
     gnucash-glossary   |                                        []       |
591
     gnuedu             |                                                 |
592
     gnulib             | [] []                      []          []       |
593
     gnunet-gtk         |                                                 |
594
     gnutls             |                                                 |
595
     gpe-aerial         |                                        []       |
596
     gpe-beam           |                                        []       |
597
     gpe-calendar       | []                                              |
598
     gpe-clock          | [] []                                  []       |
599
     gpe-conf           |    []                                  []       |
600
     gpe-contacts       |    []                                           |
601
     gpe-edit           | [] []                                  []       |
602
     gpe-filemanager    | [] []                                           |
603
     gpe-go             | [] []                                  []       |
604
     gpe-login          | [] []                                  []       |
605
     gpe-ownerinfo      | []                                     []       |
606
     gpe-package        | [] []                                           |
607
     gpe-sketchbook     |    []                                  []       |
608
     gpe-su             | [] []                                  []       |
609
     gpe-taskmanager    | [] [] []                               []       |
610
     gpe-timesheet      |                                        []       |
611
     gpe-today          | []                                     []       |
612
     gpe-todo           | []                                              |
613
     gphoto2            | []                                     []       |
614
     gprof              |                                                 |
615
     gpsdrive           | ()                                     ()    () |
616
     gramadoir          |                                        ()       |
617
     grep               | []       []                      []    []       |
618
     gretl              |                                                 |
619
     gsasl              |                                        []       |
620
     gss                |                                                 |
621
     gst-plugins        |                                        []       |
622
     gst-plugins-base   |                                                 |
623
     gst-plugins-good   |                                        []       |
624
     gstreamer          |                                        []       |
625
     gtick              |                                                 |
626
     gtkam              | []                                              |
627
     gtkorphan          |                                        []       |
628
     gtkspell           |                         []             []       |
629
     gutenprint         |                                                 |
630
     hello              | [] []                      []    []    [] []    |
631
     id-utils           |                                        []       |
632
     impost             |                                                 |
633
     indent             | []                                     []       |
634
     iso_3166           |                                        []       |
635
     iso_3166_2         |                                        []       |
636
     iso_4217           | []                      []             []       |
637
     iso_639            | []                                     []       |
638
     jpilot             | ()                                     ()    () |
639
     jtag               |                                                 |
640
     jwhois             |                                        []       |
641
     kbd                |                                        []       |
642
     keytouch           |                                        []       |
643
     keytouch-editor    |                                                 |
644
     keytouch-keyboa... |                                                 |
645
     latrine            |                                        []       |
646
     ld                 |                                                 |
647
     leafpad            | []             []                               |
648
     libc               | [] []                            []    []    [] |
649
     libexif            |                                                 |
650
     libextractor       |                                                 |
651
     libgpewidget       |                                        []       |
652
     libgpg-error       |                                                 |
653
     libgphoto2         | []                                              |
654
     libgphoto2_port    | []                                              |
655
     libgsasl           |                                        []       |
656
     libiconv           |                                                 |
657
     libidn             | []                                     []       |
658
     lifelines          |                                        []       |
659
     lilypond           |                                                 |
660
     lingoteach         |                                        []       |
661
     lynx               | []                                     []       |
662
     m4                 | []                                     []       |
663
     mailutils          |                                                 |
664
     make               | [] []                                  []       |
665
     man-db             | ()                                              |
666
     minicom            | []                                              |
667
     mysecretdiary      |                                        []       |
668
     nano               |                            []    []    []       |
669
     nano_1_0           |                            []    []       []    |
670
     opcodes            |                                        []       |
671
     parted             | []                                     []       |
672
     pilot-qof          |                                                 |
673
     psmisc             | []                               []    []       |
674
     pwdutils           |                                                 |
675
     python             |                                                 |
676
     qof                |                                                 |
677
     radius             |                                                 |
678
     recode             |                                        []       |
679
     rpm                | [] []                                           |
680
     screem             | []                                              |
681
     scrollkeeper       |                                  [] [] [] []    |
682
     sed                | []                                     []       |
683
     sh-utils           | []                               []             |
684
     shared-mime-info   |    []          []                []    [] []    |
685
     sharutils          | []                                     []       |
686
     shishi             |                                                 |
687
     silky              |                                        []       |
688
     skencil            |                                                 |
689
     sketch             |                                                 |
690
     solfege            |                                                 |
691
     soundtracker       |                                                 |
692
     sp                 | ()                                              |
693
     stardict           |                      []                []       |
694
     system-tools-ba... | [] []          []                      []       |
695
     tar                | []       []                            []       |
696
     texinfo            | []                               []    []       |
697
     textutils          | [] []                            []             |
698
     tin                |                                                 |
699
     tp-robot           |                                        []       |
700
     tuxpaint           |                                           []    |
701
     unicode-han-tra... |                                                 |
702
     unicode-transla... |                                                 |
703
     util-linux         | []                                     []       |
704
     vorbis-tools       |                                        []       |
705
     wastesedge         |                                        []       |
706
     wdiff              |                            []    []             |
707
     wget               | []                                     []       |
708
     xchat              | [] []                []                []       |
709
     xkeyboard-config   |                                        []       |
710
     xpad               |    []                      []          []       |
711
                        +-------------------------------------------------+
712
                          ja ko ku ky lg lt lv mk mn ms mt nb ne nl nn no
713
                          52 24  2  2  1  3  0  2  3 21  0 15  1 97  5  1
714
715
                          nso or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv  ta
716
                        +------------------------------------------------------+
717
     GNUnet             |                                                      |
718
     a2ps               |           ()     []      [] []       []    [] []     |
719
     aegis              |                          () ()                       |
720
     ant-phone          |                          []                   []     |
721
     anubis             |           []             [] []                       |
722
     ap-utils           |           ()                                         |
723
     aspell             |                          [] []                       |
724
     bash               |                  []      [] []                       |
725
     batchelor          |                          []                   []     |
726
     bfd                |                                                      |
727
     bibshelf           |                                               []     |
728
     binutils           |                             []                []     |
729
     bison              |           []     []      [] []                []     |
730
     bison-runtime      |           []             []          []       []     |
731
     bluez-pin          |           []     []   [] [] []    [] []    [] []     |
732
     cflow              |           []                                         |
733
     clisp              |                             []                       |
734
     console-tools      |                             []                       |
735
     coreutils          |           []                []       []       []     |
736
     cpio               |           []                []                []     |
737
     cpplib             |                                               []     |
738
     cryptonit          |                  []                           []     |
739
     darkstat           |           []     []      []       []       [] []     |
740
     dialog             |           [] []  []   [] [] [] []          [] []     |
741
     diffutils          |           []     []      [] []             [] []     |
742
     doodle             |                                         []    []     |
743
     e2fsprogs          |           []                                  []     |
744
     enscript           |                  []      [] []       []       []     |
745
     error              |                  []      []       []          []     |
746
     fetchmail          |           []                []          []           |
747
     fileutils          |           []             [] []       []       []     |
748
     findutils          |           [] []          []       [] []       []     |
749
     flex               |           []     []      [] []                []     |
750
     fslint             |                  []      []                [] []     |
751
     gas                |                                                      |
752
     gawk               |           []     []      []                   []     |
753
     gbiff              |                          []                          |
754
     gcal               |                                               []     |
755
     gcc                |                                               []     |
756
     gettext-examples   |           [] []          [] []    [] []    [] []     |
757
     gettext-runtime    |           [] []          [] []    [] []    [] []     |
758
     gettext-tools      |           []             [] []    [] []    [] []     |
759
     gimp-print         |                                   []          []     |
760
     gip                |                       []          []       [] []     |
761
     gliv               |                  []      []       []          []     |
762
     glunarclock        |                  []      [] []    []       [] []     |
763
     gmult              |                       [] []                [] []     |
764
     gnubiff            |                          ()                          |
765
     gnucash            |           ()                                  []     |
766
     gnucash-glossary   |              []                   []          []     |
767
     gnuedu             |                                                      |
768
     gnulib             |           []             [] []       []       []     |
769
     gnunet-gtk         |                                               []     |
770
     gnutls             |           []                                  []     |
771
     gpe-aerial         |              []  []      [] []       []    [] []     |
772
     gpe-beam           |              []  []      [] []       []    [] []     |
773
     gpe-calendar       |                             []                       |
774
     gpe-clock          |              []  []      [] []    [] []    [] []     |
775
     gpe-conf           |              []  []      [] []    [] []       []     |
776
     gpe-contacts       |                          [] []       []    [] []     |
777
     gpe-edit           |              []  []      [] []    [] []    [] []     |
778
     gpe-filemanager    |                                      []       []     |
779
     gpe-go             |                  []      [] []       []    [] []     |
780
     gpe-login          |              []  []      [] []    [] []    [] []     |
781
     gpe-ownerinfo      |              []  []      [] []    [] []    [] []     |
782
     gpe-package        |                                      []       []     |
783
     gpe-sketchbook     |              []  []      [] []    [] []    [] []     |
784
     gpe-su             |              []  []      [] []    [] []    [] []     |
785
     gpe-taskmanager    |              []  []      [] []    [] []    [] []     |
786
     gpe-timesheet      |              []  []      [] []    [] []    [] []     |
787
     gpe-today          |              []  []      [] []    [] []    [] []     |
788
     gpe-todo           |                             []       []    [] []     |
789
     gphoto2            |           []             []       []       [] []     |
790
     gprof              |                  []      []                   []     |
791
     gpsdrive           |        []                []                   []     |
792
     gramadoir          |                                   []          []     |
793
     grep               |           [] []  []      [] []       []    [] []     |
794
     gretl              |           []                                         |
795
     gsasl              |           []                               [] []     |
796
     gss                |           []             []                   []     |
797
     gst-plugins        |     []                                  [] [] []     |
798
     gst-plugins-base   |                                               []     |
799
     gst-plugins-good   |     []                                  [] [] []     |
800
     gstreamer          |                                         [] [] []     |
801
     gtick              |                             []                       |
802
     gtkam              |           []     []         []                []     |
803
     gtkorphan          |                                               []     |
804
     gtkspell           |                  []   [] [] []    [] []    [] []     |
805
     gutenprint         |                                               []     |
806
     hello              |           []     []      [] []    [] []    [] []     |
807
     id-utils           |                  []      [] []                []     |
808
     impost             |                                               []     |
809
     indent             |                  []      [] []    []       [] []     |
810
     iso_3166           |              []                []    [] [] [] []     |
811
     iso_3166_2         |                                                      |
812
     iso_4217           |                                []    []    [] []     |
813
     iso_639            |                                []    []    [] []     |
814
     jpilot             |                                                      |
815
     jtag               |                                   []                 |
816
     jwhois             |           []     []      []                   []     |
817
     kbd                |           []             []                   []     |
818
     keytouch           |                                               []     |
819
     keytouch-editor    |                                               []     |
820
     keytouch-keyboa... |                                               []     |
821
     latrine            |                          []                   []     |
822
     ld                 |                                               []     |
823
     leafpad            |           [] []             []    []          []  [] |
824
     libc               |           []     []         []    []          []     |
825
     libexif            |           []                                         |
826
     libextractor       |                          []                   []     |
827
     libgpewidget       |              []  []      []       [] []    [] []     |
828
     libgpg-error       |           []             []                          |
829
     libgphoto2         |           []                                         |
830
     libgphoto2_port    |           []                []                []     |
831
     libgsasl           |           []             []                [] []     |
832
     libiconv           |                                      []    []        |
833
     libidn             |           []                               [] ()     |
834
     lifelines          |           []                                  []     |
835
     lilypond           |                                                      |
836
     lingoteach         |                  []                                  |
837
     lynx               |                  []         []                []     |
838
     m4                 |           []     []      [] []                []     |
839
     mailutils          |           []             [] []                []     |
840
     make               |           []     []         []                []     |
841
     man-db             |                          []                   []     |
842
     minicom            |           []     []      [] []                []     |
843
     mysecretdiary      |                  []      [] []                []     |
844
     nano               |                  []      []                   []     |
845
     nano_1_0           |           []             [] []                []     |
846
     opcodes            |                          []                   []     |
847
     parted             |           []                                         |
848
     pilot-qof          |                                               []     |
849
     psmisc             |           []                                  []     |
850
     pwdutils           |           []                                  []     |
851
     python             |                                                      |
852
     qof                |                  []                           []     |
853
     radius             |           []                []                       |
854
     recode             |           [] []  []      [] []       []       []     |
855
     rpm                |           [] []             []                []     |
856
     screem             |                                                      |
857
     scrollkeeper       |           []             [] []    []    [] [] []     |
858
     sed                |           [] []  []      [] []    [] []    [] []     |
859
     sh-utils           |                             []       []    []        |
860
     shared-mime-info   |              []  []                     [] [] []     |
861
     sharutils          |           []                []             [] []     |
862
     shishi             |           []                                         |
863
     silky              |                                   []                 |
864
     skencil            |              []  []                           []     |
865
     sketch             |              []  []                           []     |
866
     solfege            |                                               []     |
867
     soundtracker       |                                   []          []     |
868
     sp                 |                                                      |
869
     stardict           |                             []    []          []     |
870
     system-tools-ba... |        [] [] []  []      []             [] [] []  [] |
871
     tar                |           []             [] []       []       []     |
872
     texinfo            |           []             [] []                []     |
873
     textutils          |                             []       []       []     |
874
     tin                |                             ()                       |
875
     tp-robot           |                             []                       |
876
     tuxpaint           |              []                      [] [] [] []     |
877
     unicode-han-tra... |                                                      |
878
     unicode-transla... |                                                      |
879
     util-linux         |                  []         []       []       []     |
880
     vorbis-tools       |                          [] []                       |
881
     wastesedge         |                                                      |
882
     wdiff              |           []     []      [] []    []          []     |
883
     wget               |              []             []    []          []     |
884
     xchat              |        []                   []    [] [] [] [] []     |
885
     xkeyboard-config   |                                      []       []     |
886
     xpad               |                                   [] []       []     |
887
                        +------------------------------------------------------+
888
                          nso or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv  ta
889
                           0   2  3 58 30  54    5 73 72  4 40 46 11 50 128  2
890
891
                          tg th tk tr uk ven vi  wa xh zh_CN zh_HK zh_TW zu
892
                        +---------------------------------------------------+
893
     GNUnet             |                    []                             |  2
894
     a2ps               |          [] []     []                             | 19
895
     aegis              |                                                   |  0
896
     ant-phone          |          []        []                             |  6
897
     anubis             |          [] []     []                             | 11
898
     ap-utils           |             ()     []                             |  4
899
     aspell             |             []     []  []                         | 15
900
     bash               |                    []                             | 11
901
     batchelor          |          []        []                             |  9
902
     bfd                |                                                   |  1
903
     bibshelf           |                    []                             |  7
904
     binutils           |          []        []                     []      |  9
905
     bison              |          []        []                     []      | 19
906
     bison-runtime      |                    []         []          []      | 15
907
     bluez-pin          |          [] []     []  []     []          []      | 28
908
     cflow              |             []     []                             |  5
909
     clisp              |                                                   |  6
910
     console-tools      |          []        []                             |  5
911
     coreutils          |          []        []                             | 16
912
     cpio               |          [] []     []                             |  9
913
     cpplib             |          []        []         []          []      | 11
914
     cryptonit          |                                                   |  5
915
     darkstat           |                    []         ()          ()      | 15
916
     dialog             |          [] []     []         []          []      | 30
917
     diffutils          |          []        []         []          []      | 28
918
     doodle             |                    []                             |  6
919
     e2fsprogs          |          []        []                             | 10
920
     enscript           |          [] []     []                             | 16
921
     error              |          []        []         []          []      | 18
922
     fetchmail          |          []        []                             | 12
923
     fileutils          |          []                   []          []      | 18
924
     findutils          |          []        []                     []      | 17
925
     flex               |          []        []                             | 15
926
     fslint             |                    []                             |  9
927
     gas                |          []                                       |  3
928
     gawk               |          []        []                             | 15
929
     gbiff              |                    []                             |  5
930
     gcal               |          []                                       |  5
931
     gcc                |          []                   []          []      |  6
932
     gettext-examples   |          [] []     []         []    []    []      | 27
933
     gettext-runtime    |          [] []     []         []    []    []      | 28
934
     gettext-tools      |          [] []     []         []          []      | 19
935
     gimp-print         |             []     []                             | 12
936
     gip                |                    []                     []      | 12
937
     gliv               |          []        []                             |  8
938
     glunarclock        |                    []  []                 []      | 15
939
     gmult              |          []        []         []          []      | 15
940
     gnubiff            |                    []                             |  1
941
     gnucash            |          ()                                       |  2
942
     gnucash-glossary   |                    []                     []      |  9
943
     gnuedu             |                    []                             |  2
944
     gnulib             |          [] []     []         []          []      | 28
945
     gnunet-gtk         |                                                   |  1
946
     gnutls             |                                                   |  2
947
     gpe-aerial         |                    []         []                  | 14
948
     gpe-beam           |                    []         []                  | 14
949
     gpe-calendar       |                    []                             |  3
950
     gpe-clock          |          []        []  []     []                  | 21
951
     gpe-conf           |                    []         []                  | 14
952
     gpe-contacts       |                    []         []                  | 10
953
     gpe-edit           |          []        []  []                 []      | 20
954
     gpe-filemanager    |                    []                             |  6
955
     gpe-go             |          []        []                             | 15
956
     gpe-login          |          []        []  []     []          []      | 21
957
     gpe-ownerinfo      |          []        []         []          []      | 21
958
     gpe-package        |                    []                             |  6
959
     gpe-sketchbook     |          []        []                             | 16
960
     gpe-su             |          []        []         []                  | 20
961
     gpe-taskmanager    |          []        []         []                  | 20
962
     gpe-timesheet      |          []        []         []          []      | 18
963
     gpe-today          |          []        []  []     []          []      | 21
964
     gpe-todo           |                    []                             |  7
965
     gphoto2            |             []     []         []          []      | 20
966
     gprof              |          []        []                             | 11
967
     gpsdrive           |                                                   |  4
968
     gramadoir          |                    []                             |  7
969
     grep               |          [] []     []                     []      | 34
970
     gretl              |                                                   |  4
971
     gsasl              |                    []         []                  |  8
972
     gss                |                    []                             |  5
973
     gst-plugins        |             []     []                     []      | 15
974
     gst-plugins-base   |             []     []         []                  |  9
975
     gst-plugins-good   |             []     []         []    []    []      | 20
976
     gstreamer          |          [] []     []                             | 17
977
     gtick              |                    []                             |  3
978
     gtkam              |                    []                             | 13
979
     gtkorphan          |                    []                             |  7
980
     gtkspell           |             []     []  []     []    []    []      | 26
981
     gutenprint         |                                                   |  3
982
     hello              |          [] []     []         []          []      | 37
983
     id-utils           |          []        []                             | 14
984
     impost             |                    []                             |  4
985
     indent             |          []        []         []          []      | 25
986
     iso_3166           |       [] []        []               []            | 16
987
     iso_3166_2         |                                                   |  2
988
     iso_4217           |          []        []                             | 14
989
     iso_639            |                    []                             | 14
990
     jpilot             |          [] []     []         []                  |  7
991
     jtag               |                    []                             |  3
992
     jwhois             |          []        []                     []      | 13
993
     kbd                |          []        []                             | 12
994
     keytouch           |                    []                             |  4
995
     keytouch-editor    |                                                   |  2
996
     keytouch-keyboa... |                    []                             |  3
997
     latrine            |          []        []                             |  8
998
     ld                 |          []        []         []          []      |  8
999
     leafpad            |          []        []         []          []      | 23
1000
     libc               |          []                   []          []      | 23
1001
     libexif            |                    []                             |  4
1002
     libextractor       |                    []                             |  5
1003
     libgpewidget       |                    []  []     []                  | 19
1004
     libgpg-error       |                    []                             |  4
1005
     libgphoto2         |             []                                    |  8
1006
     libgphoto2_port    |             []     []                     []      | 11
1007
     libgsasl           |                    []                             |  8
1008
     libiconv           |                    []                             |  7
1009
     libidn             |                    []         []                  | 10
1010
     lifelines          |                                                   |  4
1011
     lilypond           |                                                   |  2
1012
     lingoteach         |                    []                             |  6
1013
     lynx               |          [] []     []                             | 15
1014
     m4                 |                    []         []          []      | 18
1015
     mailutils          |             []                                    |  8
1016
     make               |          []        []         []                  | 20
1017
     man-db             |                    []                             |  6
1018
     minicom            |                    []                             | 14
1019
     mysecretdiary      |          []        []                             | 12
1020
     nano               |                    []                     []      | 17
1021
     nano_1_0           |          [] []     []                             | 18
1022
     opcodes            |          []        []                             | 10
1023
     parted             |          [] []                            []      | 10
1024
     pilot-qof          |                    []                             |  3
1025
     psmisc             |                    []                             | 10
1026
     pwdutils           |                    []                             |  3
1027
     python             |                                                   |  0
1028
     qof                |                    []                             |  4
1029
     radius             |             []                                    |  6
1030
     recode             |          []        []         []                  | 25
1031
     rpm                |          [] []     []                     []      | 14
1032
     screem             |                    []                             |  2
1033
     scrollkeeper       |          [] []     []                     []      | 26
1034
     sed                |          []        []                     []      | 22
1035
     sh-utils           |          []                                       | 15
1036
     shared-mime-info   |             []     []         []          []      | 24
1037
     sharutils          |          []        []                     []      | 23
1038
     shishi             |                                                   |  1
1039
     silky              |                    []                             |  4
1040
     skencil            |                    []                             |  7
1041
     sketch             |                                                   |  6
1042
     solfege            |                                                   |  2
1043
     soundtracker       |          []        []                             |  9
1044
     sp                 |          []                                       |  3
1045
     stardict           |             []     []         []          []      | 11
1046
     system-tools-ba... |    []    [] []     []     []  []          []      | 37
1047
     tar                |          [] []     []                     []      | 20
1048
     texinfo            |          []        []         []                  | 15
1049
     textutils          |          []                   []          []      | 17
1050
     tin                |                                                   |  1
1051
     tp-robot           |                    []         []          []      | 10
1052
     tuxpaint           |                    []  []                 []      | 16
1053
     unicode-han-tra... |                                                   |  0
1054
     unicode-transla... |                                                   |  2
1055
     util-linux         |          [] []     []                             | 20
1056
     vorbis-tools       |             []     []                             | 11
1057
     wastesedge         |                                                   |  1
1058
     wdiff              |          []        []                             | 22
1059
     wget               |          []        []                     []      | 19
1060
     xchat              |             []     []         []          []      | 29
1061
     xkeyboard-config   |          [] []     []                     []      | 11
1062
     xpad               |                    []         []          []      | 14
1063
                        +---------------------------------------------------+
1064
       77 teams           tg th tk tr uk ven vi  wa xh zh_CN zh_HK zh_TW zu
1065
      170 domains          0  1  1 77 39  0  136 10  1  48     5    54    0  2028
1066
1067
   Some counters in the preceding matrix are higher than the number of
1068
visible blocks let us expect.  This is because a few extra PO files are
1069
used for implementing regional variants of languages, or language
1070
dialects.
1071
1072
   For a PO file in the matrix above to be effective, the package to
1073
which it applies should also have been internationalized and
1074
distributed as such by its maintainer.  There might be an observable
1075
lag between the mere existence a PO file and its wide availability in a
1076
distribution.
1077
1078
   If October 2006 seems to be old, you may fetch a more recent copy of
1079
this `ABOUT-NLS' file on most GNU archive sites.  The most up-to-date
1080
matrix with full percentage details can be found at
1081
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
1082
1083
1.6 Using `gettext' in new packages
1084
===================================
1085
1086
If you are writing a freely available program and want to
1087
internationalize it you are welcome to use GNU `gettext' in your
1088
package.  Of course you have to respect the GNU Library General Public
1089
License which covers the use of the GNU `gettext' library.  This means
1090
in particular that even non-free programs can use `libintl' as a shared
1091
library, whereas only free software can use `libintl' as a static
1092
library or use modified versions of `libintl'.
1093
1094
   Once the sources are changed appropriately and the setup can handle
1095
the use of `gettext' the only thing missing are the translations.  The
1096
Free Translation Project is also available for packages which are not
1097
developed inside the GNU project.  Therefore the information given above
1098
applies also for every other Free Software Project.  Contact
1099
`translation@iro.umontreal.ca' to make the `.pot' files available to
1100
the translation teams.
1101
(-)a/ChangeLog (+16 lines)
Lines 1-3 Link Here
1
2020-10-12  gettextize  <bug-gnu-gettext@gnu.org>
2
3
	* m4/gettext.m4: Upgrade to gettext-0.21.
4
	* m4/host-cpu-c-abi.m4: New file, from gettext-0.21.
5
	* m4/iconv.m4: Upgrade to gettext-0.21.
6
	* m4/intlmacosx.m4: New file, from gettext-0.21.
7
	* m4/lib-ld.m4: Upgrade to gettext-0.21.
8
	* m4/lib-link.m4: Upgrade to gettext-0.21.
9
	* m4/lib-prefix.m4: Upgrade to gettext-0.21.
10
	* m4/nls.m4: Upgrade to gettext-0.21.
11
	* m4/po.m4: Upgrade to gettext-0.21.
12
	* m4/progtest.m4: Upgrade to gettext-0.21.
13
	* Makefile.am (SUBDIRS): Remove intl.
14
	* configure.ac (AC_OUTPUT): Remove intl/Makefile.
15
	(AM_GNU_GETTEXT_VERSION): Bump to 0.21.
16
1
2011-03-13 12:16  sg2
17
2011-03-13 12:16  sg2
2
18
3
	* libmpfc/id3.c, plugins/input/audiocd/cddb.c,
19
	* libmpfc/id3.c, plugins/input/audiocd/cddb.c,
(-)a/Makefile.am (-1 / +1 lines)
Lines 1-4 Link Here
1
SUBDIRS = doc intl po libmpfc libmpfcwnd src plugins 
1
SUBDIRS = doc po libmpfc libmpfcwnd src plugins 
2
2
3
ACLOCAL_AMFLAGS = -I m4
3
ACLOCAL_AMFLAGS = -I m4
4
4
(-)a/config.rpath (-80 / +150 lines)
Lines 2-8 Link Here
2
# Output a system dependent set of variables, describing how to set the
2
# Output a system dependent set of variables, describing how to set the
3
# run time search path of shared libraries in an executable.
3
# run time search path of shared libraries in an executable.
4
#
4
#
5
#   Copyright 1996-2006 Free Software Foundation, Inc.
5
#   Copyright 1996-2020 Free Software Foundation, Inc.
6
#   Taken from GNU libtool, 2001
6
#   Taken from GNU libtool, 2001
7
#   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7
#   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8
#
8
#
Lines 25-31 Link Here
25
#   known workaround is to choose shorter directory names for the build
25
#   known workaround is to choose shorter directory names for the build
26
#   directory and/or the installation directory.
26
#   directory and/or the installation directory.
27
27
28
# All known linkers require a `.a' archive for static linking (except MSVC,
28
# All known linkers require a '.a' archive for static linking (except MSVC,
29
# which needs '.lib').
29
# which needs '.lib').
30
libext=a
30
libext=a
31
shrext=.so
31
shrext=.so
Lines 47-53 for cc_temp in $CC""; do Link Here
47
done
47
done
48
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
48
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
49
49
50
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
50
# Code taken from libtool.m4's _LT_COMPILER_PIC.
51
51
52
wl=
52
wl=
53
if test "$GCC" = yes; then
53
if test "$GCC" = yes; then
Lines 57-70 else Link Here
57
    aix*)
57
    aix*)
58
      wl='-Wl,'
58
      wl='-Wl,'
59
      ;;
59
      ;;
60
    darwin*)
60
    mingw* | cygwin* | pw32* | os2* | cegcc*)
61
      case $cc_basename in
62
        xlc*)
63
          wl='-Wl,'
64
          ;;
65
      esac
66
      ;;
67
    mingw* | pw32* | os2*)
68
      ;;
61
      ;;
69
    hpux9* | hpux10* | hpux11*)
62
    hpux9* | hpux10* | hpux11*)
70
      wl='-Wl,'
63
      wl='-Wl,'
Lines 72-95 else Link Here
72
    irix5* | irix6* | nonstopux*)
65
    irix5* | irix6* | nonstopux*)
73
      wl='-Wl,'
66
      wl='-Wl,'
74
      ;;
67
      ;;
75
    newsos6)
68
    linux* | k*bsd*-gnu | kopensolaris*-gnu)
76
      ;;
77
    linux*)
78
      case $cc_basename in
69
      case $cc_basename in
79
        icc* | ecc*)
70
        ecc*)
71
          wl='-Wl,'
72
          ;;
73
        icc* | ifort*)
80
          wl='-Wl,'
74
          wl='-Wl,'
81
          ;;
75
          ;;
82
        pgcc | pgf77 | pgf90)
76
        lf95*)
77
          wl='-Wl,'
78
          ;;
79
        nagfor*)
80
          wl='-Wl,-Wl,,'
81
          ;;
82
        pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
83
          wl='-Wl,'
83
          wl='-Wl,'
84
          ;;
84
          ;;
85
        ccc*)
85
        ccc*)
86
          wl='-Wl,'
86
          wl='-Wl,'
87
          ;;
87
          ;;
88
        xl* | bgxl* | bgf* | mpixl*)
89
          wl='-Wl,'
90
          ;;
88
        como)
91
        como)
89
          wl='-lopt='
92
          wl='-lopt='
90
          ;;
93
          ;;
91
        *)
94
        *)
92
          case `$CC -V 2>&1 | sed 5q` in
95
          case `$CC -V 2>&1 | sed 5q` in
96
            *Sun\ F* | *Sun*Fortran*)
97
              wl=
98
              ;;
93
            *Sun\ C*)
99
            *Sun\ C*)
94
              wl='-Wl,'
100
              wl='-Wl,'
95
              ;;
101
              ;;
Lines 97-118 else Link Here
97
          ;;
103
          ;;
98
      esac
104
      esac
99
      ;;
105
      ;;
106
    newsos6)
107
      ;;
108
    *nto* | *qnx*)
109
      ;;
100
    osf3* | osf4* | osf5*)
110
    osf3* | osf4* | osf5*)
101
      wl='-Wl,'
111
      wl='-Wl,'
102
      ;;
112
      ;;
103
    sco3.2v5*)
113
    rdos*)
104
      ;;
114
      ;;
105
    solaris*)
115
    solaris*)
106
      wl='-Wl,'
116
      case $cc_basename in
117
        f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
118
          wl='-Qoption ld '
119
          ;;
120
        *)
121
          wl='-Wl,'
122
          ;;
123
      esac
107
      ;;
124
      ;;
108
    sunos4*)
125
    sunos4*)
109
      wl='-Qoption ld '
126
      wl='-Qoption ld '
110
      ;;
127
      ;;
111
    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
128
    sysv4 | sysv4.2uw2* | sysv4.3*)
112
      wl='-Wl,'
129
      wl='-Wl,'
113
      ;;
130
      ;;
114
    sysv4*MP*)
131
    sysv4*MP*)
115
      ;;
132
      ;;
133
    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
134
      wl='-Wl,'
135
      ;;
116
    unicos*)
136
    unicos*)
117
      wl='-Wl,'
137
      wl='-Wl,'
118
      ;;
138
      ;;
Lines 121-127 else Link Here
121
  esac
141
  esac
122
fi
142
fi
123
143
124
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
144
# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
125
145
126
hardcode_libdir_flag_spec=
146
hardcode_libdir_flag_spec=
127
hardcode_libdir_separator=
147
hardcode_libdir_separator=
Lines 129-135 hardcode_direct=no Link Here
129
hardcode_minus_L=no
149
hardcode_minus_L=no
130
150
131
case "$host_os" in
151
case "$host_os" in
132
  cygwin* | mingw* | pw32*)
152
  cygwin* | mingw* | pw32* | cegcc*)
133
    # FIXME: the MSVC++ port hasn't been tested in a loooong time
153
    # FIXME: the MSVC++ port hasn't been tested in a loooong time
134
    # When not using gcc, we currently assume that we are using
154
    # When not using gcc, we currently assume that we are using
135
    # Microsoft Visual C++.
155
    # Microsoft Visual C++.
Lines 155-176 if test "$with_gnu_ld" = yes; then Link Here
155
  # option of GNU ld is called -rpath, not --rpath.
175
  # option of GNU ld is called -rpath, not --rpath.
156
  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
176
  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
157
  case "$host_os" in
177
  case "$host_os" in
158
    aix3* | aix4* | aix5*)
178
    aix[3-9]*)
159
      # On AIX/PPC, the GNU linker is very broken
179
      # On AIX/PPC, the GNU linker is very broken
160
      if test "$host_cpu" != ia64; then
180
      if test "$host_cpu" != ia64; then
161
        ld_shlibs=no
181
        ld_shlibs=no
162
      fi
182
      fi
163
      ;;
183
      ;;
164
    amigaos*)
184
    amigaos*)
165
      hardcode_libdir_flag_spec='-L$libdir'
185
      case "$host_cpu" in
166
      hardcode_minus_L=yes
186
        powerpc)
167
      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
187
          ;;
168
      # that the semantics of dynamic libraries on AmigaOS, at least up
188
        m68k)
169
      # to version 4, is to share data among multiple programs linked
189
          hardcode_libdir_flag_spec='-L$libdir'
170
      # with the same dynamic library.  Since this doesn't match the
190
          hardcode_minus_L=yes
171
      # behavior of shared libraries on other platforms, we cannot use
191
          ;;
172
      # them.
192
      esac
173
      ld_shlibs=no
174
      ;;
193
      ;;
175
    beos*)
194
    beos*)
176
      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
195
      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
Lines 179-185 if test "$with_gnu_ld" = yes; then Link Here
179
        ld_shlibs=no
198
        ld_shlibs=no
180
      fi
199
      fi
181
      ;;
200
      ;;
182
    cygwin* | mingw* | pw32*)
201
    cygwin* | mingw* | pw32* | cegcc*)
183
      # hardcode_libdir_flag_spec is actually meaningless, as there is
202
      # hardcode_libdir_flag_spec is actually meaningless, as there is
184
      # no search path for DLLs.
203
      # no search path for DLLs.
185
      hardcode_libdir_flag_spec='-L$libdir'
204
      hardcode_libdir_flag_spec='-L$libdir'
Lines 189-199 if test "$with_gnu_ld" = yes; then Link Here
189
        ld_shlibs=no
208
        ld_shlibs=no
190
      fi
209
      fi
191
      ;;
210
      ;;
192
    interix3*)
211
    haiku*)
212
      ;;
213
    interix[3-9]*)
193
      hardcode_direct=no
214
      hardcode_direct=no
194
      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
215
      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
195
      ;;
216
      ;;
196
    linux*)
217
    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
197
      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
218
      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
198
        :
219
        :
199
      else
220
      else
Lines 251-257 else Link Here
251
        hardcode_direct=unsupported
272
        hardcode_direct=unsupported
252
      fi
273
      fi
253
      ;;
274
      ;;
254
    aix4* | aix5*)
275
    aix[4-9]*)
255
      if test "$host_cpu" = ia64; then
276
      if test "$host_cpu" = ia64; then
256
        # On IA64, the linker does run time linking by default, so we don't
277
        # On IA64, the linker does run time linking by default, so we don't
257
        # have to do anything special.
278
        # have to do anything special.
Lines 261-267 else Link Here
261
        # Test if we are trying to use run time linking or normal
282
        # Test if we are trying to use run time linking or normal
262
        # AIX style linking. If -brtl is somewhere in LDFLAGS, we
283
        # AIX style linking. If -brtl is somewhere in LDFLAGS, we
263
        # need to do runtime linking.
284
        # need to do runtime linking.
264
        case $host_os in aix4.[23]|aix4.[23].*|aix5*)
285
        case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
265
          for ld_flag in $LDFLAGS; do
286
          for ld_flag in $LDFLAGS; do
266
            if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
287
            if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
267
              aix_use_runtimelinking=yes
288
              aix_use_runtimelinking=yes
Lines 280-286 else Link Here
280
            strings "$collect2name" | grep resolve_lib_name >/dev/null
301
            strings "$collect2name" | grep resolve_lib_name >/dev/null
281
          then
302
          then
282
            # We have reworked collect2
303
            # We have reworked collect2
283
            hardcode_direct=yes
304
            :
284
          else
305
          else
285
            # We have old collect2
306
            # We have old collect2
286
            hardcode_direct=unsupported
307
            hardcode_direct=unsupported
Lines 316-329 else Link Here
316
      fi
337
      fi
317
      ;;
338
      ;;
318
    amigaos*)
339
    amigaos*)
319
      hardcode_libdir_flag_spec='-L$libdir'
340
      case "$host_cpu" in
320
      hardcode_minus_L=yes
341
        powerpc)
321
      # see comment about different semantics on the GNU ld section
342
          ;;
322
      ld_shlibs=no
343
        m68k)
344
          hardcode_libdir_flag_spec='-L$libdir'
345
          hardcode_minus_L=yes
346
          ;;
347
      esac
323
      ;;
348
      ;;
324
    bsdi[45]*)
349
    bsdi[45]*)
325
      ;;
350
      ;;
326
    cygwin* | mingw* | pw32*)
351
    cygwin* | mingw* | pw32* | cegcc*)
327
      # When not using gcc, we currently assume that we are using
352
      # When not using gcc, we currently assume that we are using
328
      # Microsoft Visual C++.
353
      # Microsoft Visual C++.
329
      # hardcode_libdir_flag_spec is actually meaningless, as there is
354
      # hardcode_libdir_flag_spec is actually meaningless, as there is
Lines 333-365 else Link Here
333
      ;;
358
      ;;
334
    darwin* | rhapsody*)
359
    darwin* | rhapsody*)
335
      hardcode_direct=no
360
      hardcode_direct=no
336
      if test "$GCC" = yes ; then
361
      if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
337
        :
362
        :
338
      else
363
      else
339
        case $cc_basename in
364
        ld_shlibs=no
340
          xlc*)
341
            ;;
342
          *)
343
            ld_shlibs=no
344
            ;;
345
        esac
346
      fi
365
      fi
347
      ;;
366
      ;;
348
    dgux*)
367
    dgux*)
349
      hardcode_libdir_flag_spec='-L$libdir'
368
      hardcode_libdir_flag_spec='-L$libdir'
350
      ;;
369
      ;;
351
    freebsd1*)
370
    freebsd2.[01]*)
352
      ld_shlibs=no
353
      ;;
354
    freebsd2.2*)
355
      hardcode_libdir_flag_spec='-R$libdir'
356
      hardcode_direct=yes
357
      ;;
358
    freebsd2*)
359
      hardcode_direct=yes
371
      hardcode_direct=yes
360
      hardcode_minus_L=yes
372
      hardcode_minus_L=yes
361
      ;;
373
      ;;
362
    freebsd* | kfreebsd*-gnu | dragonfly*)
374
    freebsd* | dragonfly*)
363
      hardcode_libdir_flag_spec='-R$libdir'
375
      hardcode_libdir_flag_spec='-R$libdir'
364
      hardcode_direct=yes
376
      hardcode_direct=yes
365
      ;;
377
      ;;
Lines 411-429 else Link Here
411
      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
423
      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
412
      hardcode_libdir_separator=:
424
      hardcode_libdir_separator=:
413
      ;;
425
      ;;
426
    *nto* | *qnx*)
427
      ;;
414
    openbsd*)
428
    openbsd*)
415
      hardcode_direct=yes
429
      if test -f /usr/libexec/ld.so; then
416
      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
430
        hardcode_direct=yes
417
        hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
431
        if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
432
          hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
433
        else
434
          case "$host_os" in
435
            openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
436
              hardcode_libdir_flag_spec='-R$libdir'
437
              ;;
438
            *)
439
              hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
440
              ;;
441
          esac
442
        fi
418
      else
443
      else
419
        case "$host_os" in
444
        ld_shlibs=no
420
          openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
421
            hardcode_libdir_flag_spec='-R$libdir'
422
            ;;
423
          *)
424
            hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
425
            ;;
426
        esac
427
      fi
445
      fi
428
      ;;
446
      ;;
429
    os2*)
447
    os2*)
Lines 471-477 else Link Here
471
        ld_shlibs=yes
489
        ld_shlibs=yes
472
      fi
490
      fi
473
      ;;
491
      ;;
474
    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
492
    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
475
      ;;
493
      ;;
476
    sysv5* | sco3.2v5* | sco5v6*)
494
    sysv5* | sco3.2v5* | sco5v6*)
477
      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
495
      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
Lines 487-520 else Link Here
487
fi
505
fi
488
506
489
# Check dynamic linker characteristics
507
# Check dynamic linker characteristics
490
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
508
# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
509
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
510
# only about the one the linker finds when passed -lNAME. This is the last
511
# element of library_names_spec in libtool.m4, or possibly two of them if the
512
# linker has special search rules.
513
library_names_spec=      # the last element of library_names_spec in libtool.m4
491
libname_spec='lib$name'
514
libname_spec='lib$name'
492
case "$host_os" in
515
case "$host_os" in
493
  aix3*)
516
  aix3*)
517
    library_names_spec='$libname.a'
494
    ;;
518
    ;;
495
  aix4* | aix5*)
519
  aix[4-9]*)
520
    library_names_spec='$libname$shrext'
496
    ;;
521
    ;;
497
  amigaos*)
522
  amigaos*)
523
    case "$host_cpu" in
524
      powerpc*)
525
        library_names_spec='$libname$shrext' ;;
526
      m68k)
527
        library_names_spec='$libname.a' ;;
528
    esac
498
    ;;
529
    ;;
499
  beos*)
530
  beos*)
531
    library_names_spec='$libname$shrext'
500
    ;;
532
    ;;
501
  bsdi[45]*)
533
  bsdi[45]*)
534
    library_names_spec='$libname$shrext'
502
    ;;
535
    ;;
503
  cygwin* | mingw* | pw32*)
536
  cygwin* | mingw* | pw32* | cegcc*)
504
    shrext=.dll
537
    shrext=.dll
538
    library_names_spec='$libname.dll.a $libname.lib'
505
    ;;
539
    ;;
506
  darwin* | rhapsody*)
540
  darwin* | rhapsody*)
507
    shrext=.dylib
541
    shrext=.dylib
542
    library_names_spec='$libname$shrext'
508
    ;;
543
    ;;
509
  dgux*)
544
  dgux*)
545
    library_names_spec='$libname$shrext'
510
    ;;
546
    ;;
511
  freebsd1*)
547
  freebsd[23].*)
512
    ;;
548
    library_names_spec='$libname$shrext$versuffix'
513
  kfreebsd*-gnu)
514
    ;;
549
    ;;
515
  freebsd* | dragonfly*)
550
  freebsd* | dragonfly*)
551
    library_names_spec='$libname$shrext'
516
    ;;
552
    ;;
517
  gnu*)
553
  gnu*)
554
    library_names_spec='$libname$shrext'
555
    ;;
556
  haiku*)
557
    library_names_spec='$libname$shrext'
518
    ;;
558
    ;;
519
  hpux9* | hpux10* | hpux11*)
559
  hpux9* | hpux10* | hpux11*)
520
    case $host_cpu in
560
    case $host_cpu in
Lines 528-537 case "$host_os" in Link Here
528
        shrext=.sl
568
        shrext=.sl
529
        ;;
569
        ;;
530
    esac
570
    esac
571
    library_names_spec='$libname$shrext'
531
    ;;
572
    ;;
532
  interix3*)
573
  interix[3-9]*)
574
    library_names_spec='$libname$shrext'
533
    ;;
575
    ;;
534
  irix5* | irix6* | nonstopux*)
576
  irix5* | irix6* | nonstopux*)
577
    library_names_spec='$libname$shrext'
535
    case "$host_os" in
578
    case "$host_os" in
536
      irix5* | nonstopux*)
579
      irix5* | nonstopux*)
537
        libsuff= shlibsuff=
580
        libsuff= shlibsuff=
Lines 548-588 case "$host_os" in Link Here
548
    ;;
591
    ;;
549
  linux*oldld* | linux*aout* | linux*coff*)
592
  linux*oldld* | linux*aout* | linux*coff*)
550
    ;;
593
    ;;
551
  linux*)
594
  linux* | k*bsd*-gnu | kopensolaris*-gnu)
595
    library_names_spec='$libname$shrext'
552
    ;;
596
    ;;
553
  knetbsd*-gnu)
597
  knetbsd*-gnu)
598
    library_names_spec='$libname$shrext'
554
    ;;
599
    ;;
555
  netbsd*)
600
  netbsd*)
601
    library_names_spec='$libname$shrext'
556
    ;;
602
    ;;
557
  newsos6)
603
  newsos6)
604
    library_names_spec='$libname$shrext'
558
    ;;
605
    ;;
559
  nto-qnx*)
606
  *nto* | *qnx*)
607
    library_names_spec='$libname$shrext'
560
    ;;
608
    ;;
561
  openbsd*)
609
  openbsd*)
610
    library_names_spec='$libname$shrext$versuffix'
562
    ;;
611
    ;;
563
  os2*)
612
  os2*)
564
    libname_spec='$name'
613
    libname_spec='$name'
565
    shrext=.dll
614
    shrext=.dll
615
    library_names_spec='$libname.a'
566
    ;;
616
    ;;
567
  osf3* | osf4* | osf5*)
617
  osf3* | osf4* | osf5*)
618
    library_names_spec='$libname$shrext'
619
    ;;
620
  rdos*)
568
    ;;
621
    ;;
569
  solaris*)
622
  solaris*)
623
    library_names_spec='$libname$shrext'
570
    ;;
624
    ;;
571
  sunos4*)
625
  sunos4*)
626
    library_names_spec='$libname$shrext$versuffix'
572
    ;;
627
    ;;
573
  sysv4 | sysv4.3*)
628
  sysv4 | sysv4.3*)
629
    library_names_spec='$libname$shrext'
574
    ;;
630
    ;;
575
  sysv4*MP*)
631
  sysv4*MP*)
632
    library_names_spec='$libname$shrext'
576
    ;;
633
    ;;
577
  sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
634
  sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
635
    library_names_spec='$libname$shrext'
636
    ;;
637
  tpf*)
638
    library_names_spec='$libname$shrext'
578
    ;;
639
    ;;
579
  uts4*)
640
  uts4*)
641
    library_names_spec='$libname$shrext'
580
    ;;
642
    ;;
581
esac
643
esac
582
644
583
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
645
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
584
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
646
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
585
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
647
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
648
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
649
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
586
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
650
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
587
651
588
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
652
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
Lines 596-601 libext="$libext" Link Here
596
# Shared library suffix (normally "so").
660
# Shared library suffix (normally "so").
597
shlibext="$shlibext"
661
shlibext="$shlibext"
598
662
663
# Format of library name prefix.
664
libname_spec="$escaped_libname_spec"
665
666
# Library names that the linker finds when passed -lNAME.
667
library_names_spec="$escaped_library_names_spec"
668
599
# Flag to hardcode \$libdir into a binary during linking.
669
# Flag to hardcode \$libdir into a binary during linking.
600
# This must work even if \$libdir does not exist.
670
# This must work even if \$libdir does not exist.
601
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
671
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
(-)a/configure.ac (-3 / +3 lines)
Lines 5-12 AC_C_BIGENDIAN Link Here
5
AC_PROG_LIBTOOL
5
AC_PROG_LIBTOOL
6
6
7
AM_CONFIG_HEADER(mpfc-config.h)
7
AM_CONFIG_HEADER(mpfc-config.h)
8
AM_GNU_GETTEXT
8
AM_GNU_GETTEXT([external])
9
AM_GNU_GETTEXT_VERSION(0.16.1)
9
AM_GNU_GETTEXT_VERSION([0.21])
10
10
11
# Set up common libraries
11
# Set up common libraries
12
#COMMON_LIBS="-ldmalloc"
12
#COMMON_LIBS="-ldmalloc"
Lines 252-258 AC_SUBST(OUTPUT_PLUGINS) Link Here
252
252
253
AC_OUTPUT(Makefile \
253
AC_OUTPUT(Makefile \
254
		  doc/Makefile \
254
		  doc/Makefile \
255
		  intl/Makefile  \
255
		   \
256
		  libmpfc/Makefile \
256
		  libmpfc/Makefile \
257
		  libmpfcwnd/Makefile \
257
		  libmpfcwnd/Makefile \
258
		  po/Makefile.in  \
258
		  po/Makefile.in  \
(-)a/intl/ChangeLog (-4 lines)
Lines 1-4 Link Here
1
2006-11-27  GNU  <bug-gnu-gettext@gnu.org>
2
3
	* Version 0.16.1 released.
4
(-)a/intl/Makefile.in (-562 lines)
Lines 1-562 Link Here
1
# Makefile for directory with message catalog handling library of GNU gettext
2
# Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU Library General Public License as published
6
# by the Free Software Foundation; either version 2, or (at your option)
7
# any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
# Library General Public License for more details.
13
#
14
# You should have received a copy of the GNU Library General Public
15
# License along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
# USA.
18
19
PACKAGE = @PACKAGE@
20
VERSION = @VERSION@
21
22
SHELL = /bin/sh
23
24
srcdir = @srcdir@
25
top_srcdir = @top_srcdir@
26
top_builddir = ..
27
28
# The VPATH variables allows builds with $builddir != $srcdir, assuming a
29
# 'make' program that supports VPATH (such as GNU make). This line is removed
30
# by autoconf automatically when "$(srcdir)" = ".".
31
# In this directory, the VPATH handling is particular:
32
# 1. If INTL_LIBTOOL_SUFFIX_PREFIX is 'l' (indicating a build with libtool),
33
#    the .c -> .lo rules carefully use $(srcdir), so that VPATH can be omitted.
34
# 2. If PACKAGE = gettext-tools, VPATH _must_ be omitted, because otherwise
35
#    'make' does the wrong thing if GNU gettext was configured with
36
#    "./configure --srcdir=`pwd`", namely it gets confused by the .lo and .la
37
#    files it finds in srcdir = ../../gettext-runtime/intl.
38
VPATH = $(srcdir)
39
40
prefix = @prefix@
41
exec_prefix = @exec_prefix@
42
transform = @program_transform_name@
43
libdir = @libdir@
44
includedir = @includedir@
45
datarootdir = @datarootdir@
46
datadir = @datadir@
47
localedir = $(datadir)/locale
48
gettextsrcdir = $(datadir)/gettext/intl
49
aliaspath = $(localedir)
50
subdir = intl
51
52
INSTALL = @INSTALL@
53
INSTALL_DATA = @INSTALL_DATA@
54
55
# We use $(mkdir_p).
56
# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
57
# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
58
# @install_sh@ does not start with $(SHELL), so we add it.
59
# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined
60
# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
61
# versions, $(mkinstalldirs) and $(install_sh) are unused.
62
mkinstalldirs = $(SHELL) @install_sh@ -d
63
install_sh = $(SHELL) @install_sh@
64
MKDIR_P = @MKDIR_P@
65
mkdir_p = @mkdir_p@
66
67
l = @INTL_LIBTOOL_SUFFIX_PREFIX@
68
69
AR = ar
70
CC = @CC@
71
LIBTOOL = @LIBTOOL@
72
RANLIB = @RANLIB@
73
YACC = @INTLBISON@ -y -d
74
YFLAGS = --name-prefix=__gettext
75
76
# -DBUILDING_LIBINTL: Change expansion of LIBINTL_DLL_EXPORTED macro.
77
# -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro.
78
DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
79
-DLIBDIR=\"$(libdir)\" -DBUILDING_LIBINTL -DBUILDING_DLL -DIN_LIBINTL \
80
-DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\" -DNO_XMALLOC \
81
-Dset_relocation_prefix=libintl_set_relocation_prefix \
82
-Drelocate=libintl_relocate \
83
-DDEPENDS_ON_LIBICONV=1 @DEFS@
84
CPPFLAGS = @CPPFLAGS@
85
CFLAGS = @CFLAGS@ @CFLAG_VISIBILITY@
86
LDFLAGS = @LDFLAGS@ $(LDFLAGS_@WOE32DLL@)
87
LDFLAGS_yes = -Wl,--export-all-symbols
88
LDFLAGS_no =
89
LIBS = @LIBS@
90
91
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
92
93
HEADERS = \
94
  gmo.h \
95
  gettextP.h \
96
  hash-string.h \
97
  loadinfo.h \
98
  plural-exp.h \
99
  eval-plural.h \
100
  localcharset.h \
101
  lock.h \
102
  relocatable.h \
103
  xsize.h \
104
  printf-args.h printf-args.c \
105
  printf-parse.h wprintf-parse.h printf-parse.c \
106
  vasnprintf.h vasnwprintf.h vasnprintf.c \
107
  os2compat.h \
108
  libgnuintl.h.in
109
SOURCES = \
110
  bindtextdom.c \
111
  dcgettext.c \
112
  dgettext.c \
113
  gettext.c \
114
  finddomain.c \
115
  hash-string.c \
116
  loadmsgcat.c \
117
  localealias.c \
118
  textdomain.c \
119
  l10nflist.c \
120
  explodename.c \
121
  dcigettext.c \
122
  dcngettext.c \
123
  dngettext.c \
124
  ngettext.c \
125
  plural.y \
126
  plural-exp.c \
127
  localcharset.c \
128
  lock.c \
129
  relocatable.c \
130
  langprefs.c \
131
  localename.c \
132
  log.c \
133
  printf.c \
134
  version.c \
135
  osdep.c \
136
  os2compat.c \
137
  intl-exports.c \
138
  intl-compat.c
139
OBJECTS = \
140
  bindtextdom.$lo \
141
  dcgettext.$lo \
142
  dgettext.$lo \
143
  gettext.$lo \
144
  finddomain.$lo \
145
  hash-string.$lo \
146
  loadmsgcat.$lo \
147
  localealias.$lo \
148
  textdomain.$lo \
149
  l10nflist.$lo \
150
  explodename.$lo \
151
  dcigettext.$lo \
152
  dcngettext.$lo \
153
  dngettext.$lo \
154
  ngettext.$lo \
155
  plural.$lo \
156
  plural-exp.$lo \
157
  localcharset.$lo \
158
  lock.$lo \
159
  relocatable.$lo \
160
  langprefs.$lo \
161
  localename.$lo \
162
  log.$lo \
163
  printf.$lo \
164
  version.$lo \
165
  osdep.$lo \
166
  intl-compat.$lo
167
DISTFILES.common = Makefile.in \
168
config.charset locale.alias ref-add.sin ref-del.sin export.h \
169
$(HEADERS) $(SOURCES)
170
DISTFILES.generated = plural.c
171
DISTFILES.normal = VERSION
172
DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc README.woe32
173
DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \
174
COPYING.LIB-2 gettext.h libgettext.h plural-eval.c libgnuintl.h \
175
libgnuintl.h_vms Makefile.vms libgnuintl.h.msvc-static \
176
libgnuintl.h.msvc-shared Makefile.msvc
177
178
all: all-@USE_INCLUDED_LIBINTL@
179
all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
180
all-no: all-no-@BUILD_INCLUDED_LIBINTL@
181
all-no-yes: libgnuintl.$la
182
all-no-no:
183
184
libintl.a libgnuintl.a: $(OBJECTS)
185
	rm -f $@
186
	$(AR) cru $@ $(OBJECTS)
187
	$(RANLIB) $@
188
189
libintl.la libgnuintl.la: $(OBJECTS)
190
	$(LIBTOOL) --mode=link \
191
	  $(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \
192
	  $(OBJECTS) @LTLIBICONV@ @INTL_MACOSX_LIBS@ $(LIBS) @LTLIBTHREAD@ -lc \
193
	  -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
194
	  -rpath $(libdir) \
195
	  -no-undefined
196
197
# Libtool's library version information for libintl.
198
# Before making a gettext release, the gettext maintainer must change this
199
# according to the libtool documentation, section "Library interface versions".
200
# Maintainers of other packages that include the intl directory must *not*
201
# change these values.
202
LTV_CURRENT=8
203
LTV_REVISION=1
204
LTV_AGE=0
205
206
.SUFFIXES:
207
.SUFFIXES: .c .y .o .lo .sin .sed
208
209
.c.o:
210
	$(COMPILE) $<
211
212
.y.c:
213
	$(YACC) $(YFLAGS) --output $@ $<
214
	rm -f $*.h
215
216
bindtextdom.lo: $(srcdir)/bindtextdom.c
217
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/bindtextdom.c
218
dcgettext.lo: $(srcdir)/dcgettext.c
219
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dcgettext.c
220
dgettext.lo: $(srcdir)/dgettext.c
221
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dgettext.c
222
gettext.lo: $(srcdir)/gettext.c
223
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/gettext.c
224
finddomain.lo: $(srcdir)/finddomain.c
225
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/finddomain.c
226
hash-string.lo: $(srcdir)/hash-string.c
227
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/hash-string.c
228
loadmsgcat.lo: $(srcdir)/loadmsgcat.c
229
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/loadmsgcat.c
230
localealias.lo: $(srcdir)/localealias.c
231
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localealias.c
232
textdomain.lo: $(srcdir)/textdomain.c
233
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/textdomain.c
234
l10nflist.lo: $(srcdir)/l10nflist.c
235
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/l10nflist.c
236
explodename.lo: $(srcdir)/explodename.c
237
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/explodename.c
238
dcigettext.lo: $(srcdir)/dcigettext.c
239
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dcigettext.c
240
dcngettext.lo: $(srcdir)/dcngettext.c
241
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dcngettext.c
242
dngettext.lo: $(srcdir)/dngettext.c
243
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/dngettext.c
244
ngettext.lo: $(srcdir)/ngettext.c
245
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/ngettext.c
246
plural.lo: $(srcdir)/plural.c
247
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural.c
248
plural-exp.lo: $(srcdir)/plural-exp.c
249
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c
250
localcharset.lo: $(srcdir)/localcharset.c
251
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c
252
lock.lo: $(srcdir)/lock.c
253
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/lock.c
254
relocatable.lo: $(srcdir)/relocatable.c
255
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/relocatable.c
256
langprefs.lo: $(srcdir)/langprefs.c
257
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/langprefs.c
258
localename.lo: $(srcdir)/localename.c
259
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localename.c
260
log.lo: $(srcdir)/log.c
261
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/log.c
262
printf.lo: $(srcdir)/printf.c
263
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/printf.c
264
version.lo: $(srcdir)/version.c
265
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/version.c
266
osdep.lo: $(srcdir)/osdep.c
267
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/osdep.c
268
intl-compat.lo: $(srcdir)/intl-compat.c
269
	$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/intl-compat.c
270
271
ref-add.sed: $(srcdir)/ref-add.sin
272
	sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-add.sin > t-ref-add.sed
273
	mv t-ref-add.sed ref-add.sed
274
ref-del.sed: $(srcdir)/ref-del.sin
275
	sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $(srcdir)/ref-del.sin > t-ref-del.sed
276
	mv t-ref-del.sed ref-del.sed
277
278
INCLUDES = -I. -I$(srcdir) -I..
279
280
libgnuintl.h: $(srcdir)/libgnuintl.h.in
281
	sed -e '/IN_LIBGLOCALE/d' \
282
	    -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
283
	    -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \
284
	    -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
285
	    -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
286
	  < $(srcdir)/libgnuintl.h.in \
287
	| if test '@WOE32DLL@' = yes; then \
288
	    sed -e 's/extern \([^()]*\);/extern __declspec (dllimport) \1;/'; \
289
	  else \
290
	    cat; \
291
	  fi \
292
	| sed -e 's/extern \([^"]\)/extern LIBINTL_DLL_EXPORTED \1/' \
293
	      -e "/#define _LIBINTL_H/r $(srcdir)/export.h" \
294
	| sed -e 's,@''HAVE_VISIBILITY''@,@HAVE_VISIBILITY@,g' \
295
	  > libgnuintl.h
296
297
libintl.h: $(srcdir)/libgnuintl.h.in
298
	sed -e '/IN_LIBGLOCALE/d' \
299
	    -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \
300
	    -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \
301
	    -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
302
	    -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
303
	  < $(srcdir)/libgnuintl.h.in > libintl.h
304
305
charset.alias: $(srcdir)/config.charset
306
	$(SHELL) $(srcdir)/config.charset '@host@' > t-$@
307
	mv t-$@ $@
308
309
check: all
310
311
# We must not install the libintl.h/libintl.a files if we are on a
312
# system which has the GNU gettext() function in its C library or in a
313
# separate library.
314
# If you want to use the one which comes with this version of the
315
# package, you have to use `configure --with-included-gettext'.
316
install: install-exec install-data
317
install-exec: all
318
	if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
319
	   && test '@USE_INCLUDED_LIBINTL@' = yes; then \
320
	  $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
321
	  $(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \
322
	  $(LIBTOOL) --mode=install \
323
	    $(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \
324
	  if test "@RELOCATABLE@" = yes; then \
325
	    dependencies=`sed -n -e 's,^dependency_libs=\(.*\),\1,p' < $(DESTDIR)$(libdir)/libintl.la | sed -e "s,^',," -e "s,'\$$,,"`; \
326
	    if test -n "$$dependencies"; then \
327
	      rm -f $(DESTDIR)$(libdir)/libintl.la; \
328
	    fi; \
329
	  fi; \
330
	else \
331
	  : ; \
332
	fi
333
	if test "$(PACKAGE)" = "gettext-tools" \
334
	   && test '@USE_INCLUDED_LIBINTL@' = no \
335
	   && test @GLIBC2@ != no; then \
336
	  $(mkdir_p) $(DESTDIR)$(libdir); \
337
	  $(LIBTOOL) --mode=install \
338
	    $(INSTALL_DATA) libgnuintl.$la $(DESTDIR)$(libdir)/libgnuintl.$la; \
339
	  rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \
340
	  $(INSTALL_DATA) $(DESTDIR)$(libdir)/libgnuintl.so $(DESTDIR)$(libdir)/preloadable_libintl.so; \
341
	  $(LIBTOOL) --mode=uninstall \
342
	    rm -f $(DESTDIR)$(libdir)/libgnuintl.$la; \
343
	else \
344
	  : ; \
345
	fi
346
	if test '@USE_INCLUDED_LIBINTL@' = yes; then \
347
	  test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \
348
	  temp=$(DESTDIR)$(libdir)/t-charset.alias; \
349
	  dest=$(DESTDIR)$(libdir)/charset.alias; \
350
	  if test -f $(DESTDIR)$(libdir)/charset.alias; then \
351
	    orig=$(DESTDIR)$(libdir)/charset.alias; \
352
	    sed -f ref-add.sed $$orig > $$temp; \
353
	    $(INSTALL_DATA) $$temp $$dest; \
354
	    rm -f $$temp; \
355
	  else \
356
	    if test @GLIBC21@ = no; then \
357
	      orig=charset.alias; \
358
	      sed -f ref-add.sed $$orig > $$temp; \
359
	      $(INSTALL_DATA) $$temp $$dest; \
360
	      rm -f $$temp; \
361
	    fi; \
362
	  fi; \
363
	  $(mkdir_p) $(DESTDIR)$(localedir); \
364
	  test -f $(DESTDIR)$(localedir)/locale.alias \
365
	    && orig=$(DESTDIR)$(localedir)/locale.alias \
366
	    || orig=$(srcdir)/locale.alias; \
367
	  temp=$(DESTDIR)$(localedir)/t-locale.alias; \
368
	  dest=$(DESTDIR)$(localedir)/locale.alias; \
369
	  sed -f ref-add.sed $$orig > $$temp; \
370
	  $(INSTALL_DATA) $$temp $$dest; \
371
	  rm -f $$temp; \
372
	else \
373
	  : ; \
374
	fi
375
install-data: all
376
	if test "$(PACKAGE)" = "gettext-tools"; then \
377
	  $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
378
	  $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
379
	  $(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \
380
	  dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \
381
	  for file in $$dists; do \
382
	    $(INSTALL_DATA) $(srcdir)/$$file \
383
			    $(DESTDIR)$(gettextsrcdir)/$$file; \
384
	  done; \
385
	  chmod a+x $(DESTDIR)$(gettextsrcdir)/config.charset; \
386
	  dists="$(DISTFILES.generated)"; \
387
	  for file in $$dists; do \
388
	    if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
389
	    $(INSTALL_DATA) $$dir/$$file \
390
			    $(DESTDIR)$(gettextsrcdir)/$$file; \
391
	  done; \
392
	  dists="$(DISTFILES.obsolete)"; \
393
	  for file in $$dists; do \
394
	    rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
395
	  done; \
396
	else \
397
	  : ; \
398
	fi
399
400
install-strip: install
401
402
installdirs:
403
	if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
404
	   && test '@USE_INCLUDED_LIBINTL@' = yes; then \
405
	  $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
406
	else \
407
	  : ; \
408
	fi
409
	if test "$(PACKAGE)" = "gettext-tools" \
410
	   && test '@USE_INCLUDED_LIBINTL@' = no \
411
	   && test @GLIBC2@ != no; then \
412
	  $(mkdir_p) $(DESTDIR)$(libdir); \
413
	else \
414
	  : ; \
415
	fi
416
	if test '@USE_INCLUDED_LIBINTL@' = yes; then \
417
	  test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \
418
	  $(mkdir_p) $(DESTDIR)$(localedir); \
419
	else \
420
	  : ; \
421
	fi
422
	if test "$(PACKAGE)" = "gettext-tools"; then \
423
	  $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
424
	else \
425
	  : ; \
426
	fi
427
428
# Define this as empty until I found a useful application.
429
installcheck:
430
431
uninstall:
432
	if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \
433
	   && test '@USE_INCLUDED_LIBINTL@' = yes; then \
434
	  rm -f $(DESTDIR)$(includedir)/libintl.h; \
435
	  $(LIBTOOL) --mode=uninstall \
436
	    rm -f $(DESTDIR)$(libdir)/libintl.$la; \
437
	else \
438
	  : ; \
439
	fi
440
	if test "$(PACKAGE)" = "gettext-tools" \
441
	   && test '@USE_INCLUDED_LIBINTL@' = no \
442
	   && test @GLIBC2@ != no; then \
443
	  rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \
444
	else \
445
	  : ; \
446
	fi
447
	if test '@USE_INCLUDED_LIBINTL@' = yes; then \
448
	  if test -f $(DESTDIR)$(libdir)/charset.alias; then \
449
	    temp=$(DESTDIR)$(libdir)/t-charset.alias; \
450
	    dest=$(DESTDIR)$(libdir)/charset.alias; \
451
	    sed -f ref-del.sed $$dest > $$temp; \
452
	    if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
453
	      rm -f $$dest; \
454
	    else \
455
	      $(INSTALL_DATA) $$temp $$dest; \
456
	    fi; \
457
	    rm -f $$temp; \
458
	  fi; \
459
	  if test -f $(DESTDIR)$(localedir)/locale.alias; then \
460
	    temp=$(DESTDIR)$(localedir)/t-locale.alias; \
461
	    dest=$(DESTDIR)$(localedir)/locale.alias; \
462
	    sed -f ref-del.sed $$dest > $$temp; \
463
	    if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
464
	      rm -f $$dest; \
465
	    else \
466
	      $(INSTALL_DATA) $$temp $$dest; \
467
	    fi; \
468
	    rm -f $$temp; \
469
	  fi; \
470
	else \
471
	  : ; \
472
	fi
473
	if test "$(PACKAGE)" = "gettext-tools"; then \
474
	  for file in VERSION ChangeLog COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common) $(DISTFILES.generated); do \
475
	    rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
476
	  done; \
477
	else \
478
	  : ; \
479
	fi
480
481
info dvi ps pdf html:
482
483
$(OBJECTS): ../config.h libgnuintl.h
484
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
485
hash-string.$lo dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h
486
explodename.$lo l10nflist.$lo: $(srcdir)/loadinfo.h
487
dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: $(srcdir)/plural-exp.h
488
dcigettext.$lo: $(srcdir)/eval-plural.h
489
localcharset.$lo: $(srcdir)/localcharset.h
490
bindtextdom.$lo dcigettext.$lo finddomain.$lo loadmsgcat.$lo localealias.$lo lock.$lo log.$lo: $(srcdir)/lock.h
491
localealias.$lo localcharset.$lo relocatable.$lo: $(srcdir)/relocatable.h
492
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
493
494
# A bison-2.1 generated plural.c includes <libintl.h> if ENABLE_NLS.
495
PLURAL_DEPS_yes = libintl.h
496
PLURAL_DEPS_no =
497
plural.$lo: $(PLURAL_DEPS_@USE_INCLUDED_LIBINTL@)
498
499
tags: TAGS
500
501
TAGS: $(HEADERS) $(SOURCES)
502
	here=`pwd`; cd $(srcdir) && etags -o $$here/TAGS $(HEADERS) $(SOURCES)
503
504
ctags: CTAGS
505
506
CTAGS: $(HEADERS) $(SOURCES)
507
	here=`pwd`; cd $(srcdir) && ctags -o $$here/CTAGS $(HEADERS) $(SOURCES)
508
509
id: ID
510
511
ID: $(HEADERS) $(SOURCES)
512
	here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES)
513
514
515
mostlyclean:
516
	rm -f *.a *.la *.o *.obj *.lo core core.*
517
	rm -f libgnuintl.h libintl.h charset.alias ref-add.sed ref-del.sed
518
	rm -f -r .libs _libs
519
520
clean: mostlyclean
521
522
distclean: clean
523
	rm -f Makefile ID TAGS
524
	if test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; then \
525
	  rm -f ChangeLog.inst $(DISTFILES.normal); \
526
	else \
527
	  : ; \
528
	fi
529
530
maintainer-clean: distclean
531
	@echo "This command is intended for maintainers to use;"
532
	@echo "it deletes files that may require special tools to rebuild."
533
534
535
# GNU gettext needs not contain the file `VERSION' but contains some
536
# other files which should not be distributed in other packages.
537
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
538
dist distdir: Makefile
539
	if test "$(PACKAGE)" = "gettext-tools"; then \
540
	  : ; \
541
	else \
542
	  if test "$(PACKAGE)" = "gettext-runtime"; then \
543
	    additional="$(DISTFILES.gettext)"; \
544
	  else \
545
	    additional="$(DISTFILES.normal)"; \
546
	  fi; \
547
	  $(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \
548
	  for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) $$additional; do \
549
	    if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
550
	    cp -p $$dir/$$file $(distdir) || test $$file = Makefile.in || exit 1; \
551
	  done; \
552
	fi
553
554
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
555
	cd $(top_builddir) && $(SHELL) ./config.status
556
# This would be more efficient, but doesn't work any more with autoconf-2.57,
557
# when AC_CONFIG_FILES([intl/Makefile:somedir/Makefile.in]) is used.
558
#	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
559
560
# Tell versions [3.59,3.63) of GNU make not to export all variables.
561
# Otherwise a system limit (for SysV at least) may be exceeded.
562
.NOEXPORT:
(-)a/intl/VERSION (-1 lines)
Line 1 Link Here
1
GNU gettext library from gettext-0.16.1
(-)a/intl/bindtextdom.c (-357 lines)
Lines 1-357 Link Here
1
/* Implementation of the bindtextdomain(3) function
2
   Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include <stddef.h>
24
#include <stdlib.h>
25
#include <string.h>
26
27
#include "gettextP.h"
28
#ifdef _LIBC
29
# include <libintl.h>
30
#else
31
# include "libgnuintl.h"
32
#endif
33
34
/* Handle multi-threaded applications.  */
35
#ifdef _LIBC
36
# include <bits/libc-lock.h>
37
# define gl_rwlock_define __libc_rwlock_define
38
# define gl_rwlock_wrlock __libc_rwlock_wrlock
39
# define gl_rwlock_unlock __libc_rwlock_unlock
40
#else
41
# include "lock.h"
42
#endif
43
44
/* The internal variables in the standalone libintl.a must have different
45
   names than the internal variables in GNU libc, otherwise programs
46
   using libintl.a cannot be linked statically.  */
47
#if !defined _LIBC
48
# define _nl_default_dirname libintl_nl_default_dirname
49
# define _nl_domain_bindings libintl_nl_domain_bindings
50
#endif
51
52
/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>.  */
53
#ifndef offsetof
54
# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
55
#endif
56
57
/* @@ end of prolog @@ */
58
59
/* Contains the default location of the message catalogs.  */
60
extern const char _nl_default_dirname[];
61
#ifdef _LIBC
62
libc_hidden_proto (_nl_default_dirname)
63
#endif
64
65
/* List with bindings of specific domains.  */
66
extern struct binding *_nl_domain_bindings;
67
68
/* Lock variable to protect the global data in the gettext implementation.  */
69
gl_rwlock_define (extern, _nl_state_lock attribute_hidden)
70
71
72
/* Names for the libintl functions are a problem.  They must not clash
73
   with existing names and they should follow ANSI C.  But this source
74
   code is also used in GNU C Library where the names have a __
75
   prefix.  So we have to make a difference here.  */
76
#ifdef _LIBC
77
# define BINDTEXTDOMAIN __bindtextdomain
78
# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset
79
# ifndef strdup
80
#  define strdup(str) __strdup (str)
81
# endif
82
#else
83
# define BINDTEXTDOMAIN libintl_bindtextdomain
84
# define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset
85
#endif
86
87
/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
88
   to be used for the DOMAINNAME message catalog.
89
   If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
90
   modified, only the current value is returned.
91
   If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither
92
   modified nor returned.  */
93
static void
94
set_binding_values (const char *domainname,
95
		    const char **dirnamep, const char **codesetp)
96
{
97
  struct binding *binding;
98
  int modified;
99
100
  /* Some sanity checks.  */
101
  if (domainname == NULL || domainname[0] == '\0')
102
    {
103
      if (dirnamep)
104
	*dirnamep = NULL;
105
      if (codesetp)
106
	*codesetp = NULL;
107
      return;
108
    }
109
110
  gl_rwlock_wrlock (_nl_state_lock);
111
112
  modified = 0;
113
114
  for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
115
    {
116
      int compare = strcmp (domainname, binding->domainname);
117
      if (compare == 0)
118
	/* We found it!  */
119
	break;
120
      if (compare < 0)
121
	{
122
	  /* It is not in the list.  */
123
	  binding = NULL;
124
	  break;
125
	}
126
    }
127
128
  if (binding != NULL)
129
    {
130
      if (dirnamep)
131
	{
132
	  const char *dirname = *dirnamep;
133
134
	  if (dirname == NULL)
135
	    /* The current binding has be to returned.  */
136
	    *dirnamep = binding->dirname;
137
	  else
138
	    {
139
	      /* The domain is already bound.  If the new value and the old
140
		 one are equal we simply do nothing.  Otherwise replace the
141
		 old binding.  */
142
	      char *result = binding->dirname;
143
	      if (strcmp (dirname, result) != 0)
144
		{
145
		  if (strcmp (dirname, _nl_default_dirname) == 0)
146
		    result = (char *) _nl_default_dirname;
147
		  else
148
		    {
149
#if defined _LIBC || defined HAVE_STRDUP
150
		      result = strdup (dirname);
151
#else
152
		      size_t len = strlen (dirname) + 1;
153
		      result = (char *) malloc (len);
154
		      if (__builtin_expect (result != NULL, 1))
155
			memcpy (result, dirname, len);
156
#endif
157
		    }
158
159
		  if (__builtin_expect (result != NULL, 1))
160
		    {
161
		      if (binding->dirname != _nl_default_dirname)
162
			free (binding->dirname);
163
164
		      binding->dirname = result;
165
		      modified = 1;
166
		    }
167
		}
168
	      *dirnamep = result;
169
	    }
170
	}
171
172
      if (codesetp)
173
	{
174
	  const char *codeset = *codesetp;
175
176
	  if (codeset == NULL)
177
	    /* The current binding has be to returned.  */
178
	    *codesetp = binding->codeset;
179
	  else
180
	    {
181
	      /* The domain is already bound.  If the new value and the old
182
		 one are equal we simply do nothing.  Otherwise replace the
183
		 old binding.  */
184
	      char *result = binding->codeset;
185
	      if (result == NULL || strcmp (codeset, result) != 0)
186
		{
187
#if defined _LIBC || defined HAVE_STRDUP
188
		  result = strdup (codeset);
189
#else
190
		  size_t len = strlen (codeset) + 1;
191
		  result = (char *) malloc (len);
192
		  if (__builtin_expect (result != NULL, 1))
193
		    memcpy (result, codeset, len);
194
#endif
195
196
		  if (__builtin_expect (result != NULL, 1))
197
		    {
198
		      if (binding->codeset != NULL)
199
			free (binding->codeset);
200
201
		      binding->codeset = result;
202
		      modified = 1;
203
		    }
204
		}
205
	      *codesetp = result;
206
	    }
207
	}
208
    }
209
  else if ((dirnamep == NULL || *dirnamep == NULL)
210
	   && (codesetp == NULL || *codesetp == NULL))
211
    {
212
      /* Simply return the default values.  */
213
      if (dirnamep)
214
	*dirnamep = _nl_default_dirname;
215
      if (codesetp)
216
	*codesetp = NULL;
217
    }
218
  else
219
    {
220
      /* We have to create a new binding.  */
221
      size_t len = strlen (domainname) + 1;
222
      struct binding *new_binding =
223
	(struct binding *) malloc (offsetof (struct binding, domainname) + len);
224
225
      if (__builtin_expect (new_binding == NULL, 0))
226
	goto failed;
227
228
      memcpy (new_binding->domainname, domainname, len);
229
230
      if (dirnamep)
231
	{
232
	  const char *dirname = *dirnamep;
233
234
	  if (dirname == NULL)
235
	    /* The default value.  */
236
	    dirname = _nl_default_dirname;
237
	  else
238
	    {
239
	      if (strcmp (dirname, _nl_default_dirname) == 0)
240
		dirname = _nl_default_dirname;
241
	      else
242
		{
243
		  char *result;
244
#if defined _LIBC || defined HAVE_STRDUP
245
		  result = strdup (dirname);
246
		  if (__builtin_expect (result == NULL, 0))
247
		    goto failed_dirname;
248
#else
249
		  size_t len = strlen (dirname) + 1;
250
		  result = (char *) malloc (len);
251
		  if (__builtin_expect (result == NULL, 0))
252
		    goto failed_dirname;
253
		  memcpy (result, dirname, len);
254
#endif
255
		  dirname = result;
256
		}
257
	    }
258
	  *dirnamep = dirname;
259
	  new_binding->dirname = (char *) dirname;
260
	}
261
      else
262
	/* The default value.  */
263
	new_binding->dirname = (char *) _nl_default_dirname;
264
265
      if (codesetp)
266
	{
267
	  const char *codeset = *codesetp;
268
269
	  if (codeset != NULL)
270
	    {
271
	      char *result;
272
273
#if defined _LIBC || defined HAVE_STRDUP
274
	      result = strdup (codeset);
275
	      if (__builtin_expect (result == NULL, 0))
276
		goto failed_codeset;
277
#else
278
	      size_t len = strlen (codeset) + 1;
279
	      result = (char *) malloc (len);
280
	      if (__builtin_expect (result == NULL, 0))
281
		goto failed_codeset;
282
	      memcpy (result, codeset, len);
283
#endif
284
	      codeset = result;
285
	    }
286
	  *codesetp = codeset;
287
	  new_binding->codeset = (char *) codeset;
288
	}
289
      else
290
	new_binding->codeset = NULL;
291
292
      /* Now enqueue it.  */
293
      if (_nl_domain_bindings == NULL
294
	  || strcmp (domainname, _nl_domain_bindings->domainname) < 0)
295
	{
296
	  new_binding->next = _nl_domain_bindings;
297
	  _nl_domain_bindings = new_binding;
298
	}
299
      else
300
	{
301
	  binding = _nl_domain_bindings;
302
	  while (binding->next != NULL
303
		 && strcmp (domainname, binding->next->domainname) > 0)
304
	    binding = binding->next;
305
306
	  new_binding->next = binding->next;
307
	  binding->next = new_binding;
308
	}
309
310
      modified = 1;
311
312
      /* Here we deal with memory allocation failures.  */
313
      if (0)
314
	{
315
	failed_codeset:
316
	  if (new_binding->dirname != _nl_default_dirname)
317
	    free (new_binding->dirname);
318
	failed_dirname:
319
	  free (new_binding);
320
	failed:
321
	  if (dirnamep)
322
	    *dirnamep = NULL;
323
	  if (codesetp)
324
	    *codesetp = NULL;
325
	}
326
    }
327
328
  /* If we modified any binding, we flush the caches.  */
329
  if (modified)
330
    ++_nl_msg_cat_cntr;
331
332
  gl_rwlock_unlock (_nl_state_lock);
333
}
334
335
/* Specify that the DOMAINNAME message catalog will be found
336
   in DIRNAME rather than in the system locale data base.  */
337
char *
338
BINDTEXTDOMAIN (const char *domainname, const char *dirname)
339
{
340
  set_binding_values (domainname, &dirname, NULL);
341
  return (char *) dirname;
342
}
343
344
/* Specify the character encoding in which the messages from the
345
   DOMAINNAME message catalog will be returned.  */
346
char *
347
BIND_TEXTDOMAIN_CODESET (const char *domainname, const char *codeset)
348
{
349
  set_binding_values (domainname, NULL, &codeset);
350
  return (char *) codeset;
351
}
352
353
#ifdef _LIBC
354
/* Aliases for function names in GNU C Library.  */
355
weak_alias (__bindtextdomain, bindtextdomain);
356
weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset);
357
#endif
(-)a/intl/config.charset (-640 lines)
Lines 1-640 Link Here
1
#! /bin/sh
2
# Output a system dependent table of character encoding aliases.
3
#
4
#   Copyright (C) 2000-2004, 2006 Free Software Foundation, Inc.
5
#
6
#   This program is free software; you can redistribute it and/or modify it
7
#   under the terms of the GNU Library General Public License as published
8
#   by the Free Software Foundation; either version 2, or (at your option)
9
#   any later version.
10
#
11
#   This program is distributed in the hope that it will be useful,
12
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
#   Library General Public License for more details.
15
#
16
#   You should have received a copy of the GNU Library General Public
17
#   License along with this program; if not, write to the Free Software
18
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
#   USA.
20
#
21
# The table consists of lines of the form
22
#    ALIAS  CANONICAL
23
#
24
# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
25
# ALIAS is compared in a case sensitive way.
26
#
27
# CANONICAL is the GNU canonical name for this character encoding.
28
# It must be an encoding supported by libiconv. Support by GNU libc is
29
# also desirable. CANONICAL is case insensitive. Usually an upper case
30
# MIME charset name is preferred.
31
# The current list of GNU canonical charset names is as follows.
32
#
33
#       name              MIME?             used by which systems
34
#   ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin
35
#   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
36
#   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
37
#   ISO-8859-3              Y   glibc solaris
38
#   ISO-8859-4              Y   osf solaris freebsd netbsd darwin
39
#   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
40
#   ISO-8859-6              Y   glibc aix hpux solaris
41
#   ISO-8859-7              Y   glibc aix hpux irix osf solaris netbsd darwin
42
#   ISO-8859-8              Y   glibc aix hpux osf solaris
43
#   ISO-8859-9              Y   glibc aix hpux irix osf solaris darwin
44
#   ISO-8859-13                 glibc netbsd darwin
45
#   ISO-8859-14                 glibc
46
#   ISO-8859-15                 glibc aix osf solaris freebsd darwin
47
#   KOI8-R                  Y   glibc solaris freebsd netbsd darwin
48
#   KOI8-U                  Y   glibc freebsd netbsd darwin
49
#   KOI8-T                      glibc
50
#   CP437                       dos
51
#   CP775                       dos
52
#   CP850                       aix osf dos
53
#   CP852                       dos
54
#   CP855                       dos
55
#   CP856                       aix
56
#   CP857                       dos
57
#   CP861                       dos
58
#   CP862                       dos
59
#   CP864                       dos
60
#   CP865                       dos
61
#   CP866                       freebsd netbsd darwin dos
62
#   CP869                       dos
63
#   CP874                       woe32 dos
64
#   CP922                       aix
65
#   CP932                       aix woe32 dos
66
#   CP943                       aix
67
#   CP949                       osf woe32 dos
68
#   CP950                       woe32 dos
69
#   CP1046                      aix
70
#   CP1124                      aix
71
#   CP1125                      dos
72
#   CP1129                      aix
73
#   CP1250                      woe32
74
#   CP1251                      glibc solaris netbsd darwin woe32
75
#   CP1252                      aix woe32
76
#   CP1253                      woe32
77
#   CP1254                      woe32
78
#   CP1255                      glibc woe32
79
#   CP1256                      woe32
80
#   CP1257                      woe32
81
#   GB2312                  Y   glibc aix hpux irix solaris freebsd netbsd darwin
82
#   EUC-JP                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
83
#   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
84
#   EUC-TW                      glibc aix hpux irix osf solaris netbsd
85
#   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin
86
#   BIG5-HKSCS                  glibc solaris
87
#   GBK                         glibc aix osf solaris woe32 dos
88
#   GB18030                     glibc solaris netbsd
89
#   SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin
90
#   JOHAB                       glibc solaris woe32
91
#   TIS-620                     glibc aix hpux osf solaris
92
#   VISCII                  Y   glibc
93
#   TCVN5712-1                  glibc
94
#   GEORGIAN-PS                 glibc
95
#   HP-ROMAN8                   hpux
96
#   HP-ARABIC8                  hpux
97
#   HP-GREEK8                   hpux
98
#   HP-HEBREW8                  hpux
99
#   HP-TURKISH8                 hpux
100
#   HP-KANA8                    hpux
101
#   DEC-KANJI                   osf
102
#   DEC-HANYU                   osf
103
#   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin
104
#
105
# Note: Names which are not marked as being a MIME name should not be used in
106
# Internet protocols for information interchange (mail, news, etc.).
107
#
108
# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
109
# must understand both names and treat them as equivalent.
110
#
111
# The first argument passed to this file is the canonical host specification,
112
#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
113
# or
114
#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
115
116
host="$1"
117
os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
118
echo "# This file contains a table of character encoding aliases,"
119
echo "# suitable for operating system '${os}'."
120
echo "# It was automatically generated from config.charset."
121
# List of references, updated during installation:
122
echo "# Packages using this file: "
123
case "$os" in
124
    linux-gnulibc1*)
125
	# Linux libc5 doesn't have nl_langinfo(CODESET); therefore
126
	# localcharset.c falls back to using the full locale name
127
	# from the environment variables.
128
	echo "C ASCII"
129
	echo "POSIX ASCII"
130
	for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
131
	         en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
132
	         en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
133
	         es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
134
	         et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
135
	         fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
136
	         it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
137
	         sv_FI sv_SE; do
138
	  echo "$l ISO-8859-1"
139
	  echo "$l.iso-8859-1 ISO-8859-1"
140
	  echo "$l.iso-8859-15 ISO-8859-15"
141
	  echo "$l.iso-8859-15@euro ISO-8859-15"
142
	  echo "$l@euro ISO-8859-15"
143
	  echo "$l.cp-437 CP437"
144
	  echo "$l.cp-850 CP850"
145
	  echo "$l.cp-1252 CP1252"
146
	  echo "$l.cp-1252@euro CP1252"
147
	  #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
148
	  echo "$l.utf-8 UTF-8"
149
	  echo "$l.utf-8@euro UTF-8"
150
	done
151
	for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
152
	         sl_SI sr sr_CS sr_YU; do
153
	  echo "$l ISO-8859-2"
154
	  echo "$l.iso-8859-2 ISO-8859-2"
155
	  echo "$l.cp-852 CP852"
156
	  echo "$l.cp-1250 CP1250"
157
	  echo "$l.utf-8 UTF-8"
158
	done
159
	for l in mk mk_MK ru ru_RU; do
160
	  echo "$l ISO-8859-5"
161
	  echo "$l.iso-8859-5 ISO-8859-5"
162
	  echo "$l.koi8-r KOI8-R"
163
	  echo "$l.cp-866 CP866"
164
	  echo "$l.cp-1251 CP1251"
165
	  echo "$l.utf-8 UTF-8"
166
	done
167
	for l in ar ar_SA; do
168
	  echo "$l ISO-8859-6"
169
	  echo "$l.iso-8859-6 ISO-8859-6"
170
	  echo "$l.cp-864 CP864"
171
	  #echo "$l.cp-868 CP868" # not a commonly used encoding
172
	  echo "$l.cp-1256 CP1256"
173
	  echo "$l.utf-8 UTF-8"
174
	done
175
	for l in el el_GR gr gr_GR; do
176
	  echo "$l ISO-8859-7"
177
	  echo "$l.iso-8859-7 ISO-8859-7"
178
	  echo "$l.cp-869 CP869"
179
	  echo "$l.cp-1253 CP1253"
180
	  echo "$l.cp-1253@euro CP1253"
181
	  echo "$l.utf-8 UTF-8"
182
	  echo "$l.utf-8@euro UTF-8"
183
	done
184
	for l in he he_IL iw iw_IL; do
185
	  echo "$l ISO-8859-8"
186
	  echo "$l.iso-8859-8 ISO-8859-8"
187
	  echo "$l.cp-862 CP862"
188
	  echo "$l.cp-1255 CP1255"
189
	  echo "$l.utf-8 UTF-8"
190
	done
191
	for l in tr tr_TR; do
192
	  echo "$l ISO-8859-9"
193
	  echo "$l.iso-8859-9 ISO-8859-9"
194
	  echo "$l.cp-857 CP857"
195
	  echo "$l.cp-1254 CP1254"
196
	  echo "$l.utf-8 UTF-8"
197
	done
198
	for l in lt lt_LT lv lv_LV; do
199
	  #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
200
	  echo "$l ISO-8859-13"
201
	done
202
	for l in ru_UA uk uk_UA; do
203
	  echo "$l KOI8-U"
204
	done
205
	for l in zh zh_CN; do
206
	  #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
207
	  echo "$l GB2312"
208
	done
209
	for l in ja ja_JP ja_JP.EUC; do
210
	  echo "$l EUC-JP"
211
	done
212
	for l in ko ko_KR; do
213
	  echo "$l EUC-KR"
214
	done
215
	for l in th th_TH; do
216
	  echo "$l TIS-620"
217
	done
218
	for l in fa fa_IR; do
219
	  #echo "$l ISIRI-3342" # a broken encoding
220
	  echo "$l.utf-8 UTF-8"
221
	done
222
	;;
223
    linux* | *-gnu*)
224
	# With glibc-2.1 or newer, we don't need any canonicalization,
225
	# because glibc has iconv and both glibc and libiconv support all
226
	# GNU canonical names directly. Therefore, the Makefile does not
227
	# need to install the alias file at all.
228
	# The following applies only to glibc-2.0.x and older libcs.
229
	echo "ISO_646.IRV:1983 ASCII"
230
	;;
231
    aix*)
232
	echo "ISO8859-1 ISO-8859-1"
233
	echo "ISO8859-2 ISO-8859-2"
234
	echo "ISO8859-5 ISO-8859-5"
235
	echo "ISO8859-6 ISO-8859-6"
236
	echo "ISO8859-7 ISO-8859-7"
237
	echo "ISO8859-8 ISO-8859-8"
238
	echo "ISO8859-9 ISO-8859-9"
239
	echo "ISO8859-15 ISO-8859-15"
240
	echo "IBM-850 CP850"
241
	echo "IBM-856 CP856"
242
	echo "IBM-921 ISO-8859-13"
243
	echo "IBM-922 CP922"
244
	echo "IBM-932 CP932"
245
	echo "IBM-943 CP943"
246
	echo "IBM-1046 CP1046"
247
	echo "IBM-1124 CP1124"
248
	echo "IBM-1129 CP1129"
249
	echo "IBM-1252 CP1252"
250
	echo "IBM-eucCN GB2312"
251
	echo "IBM-eucJP EUC-JP"
252
	echo "IBM-eucKR EUC-KR"
253
	echo "IBM-eucTW EUC-TW"
254
	echo "big5 BIG5"
255
	echo "GBK GBK"
256
	echo "TIS-620 TIS-620"
257
	echo "UTF-8 UTF-8"
258
	;;
259
    hpux*)
260
	echo "iso88591 ISO-8859-1"
261
	echo "iso88592 ISO-8859-2"
262
	echo "iso88595 ISO-8859-5"
263
	echo "iso88596 ISO-8859-6"
264
	echo "iso88597 ISO-8859-7"
265
	echo "iso88598 ISO-8859-8"
266
	echo "iso88599 ISO-8859-9"
267
	echo "iso885915 ISO-8859-15"
268
	echo "roman8 HP-ROMAN8"
269
	echo "arabic8 HP-ARABIC8"
270
	echo "greek8 HP-GREEK8"
271
	echo "hebrew8 HP-HEBREW8"
272
	echo "turkish8 HP-TURKISH8"
273
	echo "kana8 HP-KANA8"
274
	echo "tis620 TIS-620"
275
	echo "big5 BIG5"
276
	echo "eucJP EUC-JP"
277
	echo "eucKR EUC-KR"
278
	echo "eucTW EUC-TW"
279
	echo "hp15CN GB2312"
280
	#echo "ccdc ?" # what is this?
281
	echo "SJIS SHIFT_JIS"
282
	echo "utf8 UTF-8"
283
	;;
284
    irix*)
285
	echo "ISO8859-1 ISO-8859-1"
286
	echo "ISO8859-2 ISO-8859-2"
287
	echo "ISO8859-5 ISO-8859-5"
288
	echo "ISO8859-7 ISO-8859-7"
289
	echo "ISO8859-9 ISO-8859-9"
290
	echo "eucCN GB2312"
291
	echo "eucJP EUC-JP"
292
	echo "eucKR EUC-KR"
293
	echo "eucTW EUC-TW"
294
	;;
295
    osf*)
296
	echo "ISO8859-1 ISO-8859-1"
297
	echo "ISO8859-2 ISO-8859-2"
298
	echo "ISO8859-4 ISO-8859-4"
299
	echo "ISO8859-5 ISO-8859-5"
300
	echo "ISO8859-7 ISO-8859-7"
301
	echo "ISO8859-8 ISO-8859-8"
302
	echo "ISO8859-9 ISO-8859-9"
303
	echo "ISO8859-15 ISO-8859-15"
304
	echo "cp850 CP850"
305
	echo "big5 BIG5"
306
	echo "dechanyu DEC-HANYU"
307
	echo "dechanzi GB2312"
308
	echo "deckanji DEC-KANJI"
309
	echo "deckorean EUC-KR"
310
	echo "eucJP EUC-JP"
311
	echo "eucKR EUC-KR"
312
	echo "eucTW EUC-TW"
313
	echo "GBK GBK"
314
	echo "KSC5601 CP949"
315
	echo "sdeckanji EUC-JP"
316
	echo "SJIS SHIFT_JIS"
317
	echo "TACTIS TIS-620"
318
	echo "UTF-8 UTF-8"
319
	;;
320
    solaris*)
321
	echo "646 ASCII"
322
	echo "ISO8859-1 ISO-8859-1"
323
	echo "ISO8859-2 ISO-8859-2"
324
	echo "ISO8859-3 ISO-8859-3"
325
	echo "ISO8859-4 ISO-8859-4"
326
	echo "ISO8859-5 ISO-8859-5"
327
	echo "ISO8859-6 ISO-8859-6"
328
	echo "ISO8859-7 ISO-8859-7"
329
	echo "ISO8859-8 ISO-8859-8"
330
	echo "ISO8859-9 ISO-8859-9"
331
	echo "ISO8859-15 ISO-8859-15"
332
	echo "koi8-r KOI8-R"
333
	echo "ansi-1251 CP1251"
334
	echo "BIG5 BIG5"
335
	echo "Big5-HKSCS BIG5-HKSCS"
336
	echo "gb2312 GB2312"
337
	echo "GBK GBK"
338
	echo "GB18030 GB18030"
339
	echo "cns11643 EUC-TW"
340
	echo "5601 EUC-KR"
341
	echo "ko_KR.johap92 JOHAB"
342
	echo "eucJP EUC-JP"
343
	echo "PCK SHIFT_JIS"
344
	echo "TIS620.2533 TIS-620"
345
	#echo "sun_eu_greek ?" # what is this?
346
	echo "UTF-8 UTF-8"
347
	;;
348
    freebsd* | os2*)
349
	# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
350
	# localcharset.c falls back to using the full locale name
351
	# from the environment variables.
352
	# Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
353
	# reuse FreeBSD's locale data for OS/2.
354
	echo "C ASCII"
355
	echo "US-ASCII ASCII"
356
	for l in la_LN lt_LN; do
357
	  echo "$l.ASCII ASCII"
358
	done
359
	for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
360
	         fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
361
	         lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
362
	  echo "$l.ISO_8859-1 ISO-8859-1"
363
	  echo "$l.DIS_8859-15 ISO-8859-15"
364
	done
365
	for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
366
	  echo "$l.ISO_8859-2 ISO-8859-2"
367
	done
368
	for l in la_LN lt_LT; do
369
	  echo "$l.ISO_8859-4 ISO-8859-4"
370
	done
371
	for l in ru_RU ru_SU; do
372
	  echo "$l.KOI8-R KOI8-R"
373
	  echo "$l.ISO_8859-5 ISO-8859-5"
374
	  echo "$l.CP866 CP866"
375
	done
376
	echo "uk_UA.KOI8-U KOI8-U"
377
	echo "zh_TW.BIG5 BIG5"
378
	echo "zh_TW.Big5 BIG5"
379
	echo "zh_CN.EUC GB2312"
380
	echo "ja_JP.EUC EUC-JP"
381
	echo "ja_JP.SJIS SHIFT_JIS"
382
	echo "ja_JP.Shift_JIS SHIFT_JIS"
383
	echo "ko_KR.EUC EUC-KR"
384
	;;
385
    netbsd*)
386
	echo "646 ASCII"
387
	echo "ISO8859-1 ISO-8859-1"
388
	echo "ISO8859-2 ISO-8859-2"
389
	echo "ISO8859-4 ISO-8859-4"
390
	echo "ISO8859-5 ISO-8859-5"
391
	echo "ISO8859-7 ISO-8859-7"
392
	echo "ISO8859-13 ISO-8859-13"
393
	echo "ISO8859-15 ISO-8859-15"
394
	echo "eucCN GB2312"
395
	echo "eucJP EUC-JP"
396
	echo "eucKR EUC-KR"
397
	echo "eucTW EUC-TW"
398
	echo "BIG5 BIG5"
399
	echo "SJIS SHIFT_JIS"
400
	;;
401
    darwin[56]*)
402
	# Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
403
	# localcharset.c falls back to using the full locale name
404
	# from the environment variables.
405
	echo "C ASCII"
406
	for l in en_AU en_CA en_GB en_US la_LN; do
407
	  echo "$l.US-ASCII ASCII"
408
	done
409
	for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
410
	         fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
411
	         nl_NL no_NO pt_PT sv_SE; do
412
	  echo "$l ISO-8859-1"
413
	  echo "$l.ISO8859-1 ISO-8859-1"
414
	  echo "$l.ISO8859-15 ISO-8859-15"
415
	done
416
	for l in la_LN; do
417
	  echo "$l.ISO8859-1 ISO-8859-1"
418
	  echo "$l.ISO8859-15 ISO-8859-15"
419
	done
420
	for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
421
	  echo "$l.ISO8859-2 ISO-8859-2"
422
	done
423
	for l in la_LN lt_LT; do
424
	  echo "$l.ISO8859-4 ISO-8859-4"
425
	done
426
	for l in ru_RU; do
427
	  echo "$l.KOI8-R KOI8-R"
428
	  echo "$l.ISO8859-5 ISO-8859-5"
429
	  echo "$l.CP866 CP866"
430
	done
431
	for l in bg_BG; do
432
	  echo "$l.CP1251 CP1251"
433
	done
434
	echo "uk_UA.KOI8-U KOI8-U"
435
	echo "zh_TW.BIG5 BIG5"
436
	echo "zh_TW.Big5 BIG5"
437
	echo "zh_CN.EUC GB2312"
438
	echo "ja_JP.EUC EUC-JP"
439
	echo "ja_JP.SJIS SHIFT_JIS"
440
	echo "ko_KR.EUC EUC-KR"
441
	;;
442
    darwin*)
443
	# Darwin 7.5 has nl_langinfo(CODESET), but it is useless:
444
	# - It returns the empty string when LANG is set to a locale of the
445
	#   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
446
	#   LC_CTYPE file.
447
	# - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
448
	#   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
449
	# - The documentation says:
450
	#     "... all code that calls BSD system routines should ensure
451
	#      that the const *char parameters of these routines are in UTF-8
452
	#      encoding. All BSD system functions expect their string
453
	#      parameters to be in UTF-8 encoding and nothing else."
454
	#   It also says
455
	#     "An additional caveat is that string parameters for files,
456
	#      paths, and other file-system entities must be in canonical
457
	#      UTF-8. In a canonical UTF-8 Unicode string, all decomposable
458
	#      characters are decomposed ..."
459
	#   but this is not true: You can pass non-decomposed UTF-8 strings
460
	#   to file system functions, and it is the OS which will convert
461
	#   them to decomposed UTF-8 before accessing the file system.
462
	# - The Apple Terminal application displays UTF-8 by default.
463
	# - However, other applications are free to use different encodings:
464
	#   - xterm uses ISO-8859-1 by default.
465
	#   - TextEdit uses MacRoman by default.
466
	# We prefer UTF-8 over decomposed UTF-8-MAC because one should
467
	# minimize the use of decomposed Unicode. Unfortunately, through the
468
	# Darwin file system, decomposed UTF-8 strings are leaked into user
469
	# space nevertheless.
470
	echo "* UTF-8"
471
	;;
472
    beos*)
473
	# BeOS has a single locale, and it has UTF-8 encoding.
474
	echo "* UTF-8"
475
	;;
476
    msdosdjgpp*)
477
	# DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
478
	# localcharset.c falls back to using the full locale name
479
	# from the environment variables.
480
	echo "#"
481
	echo "# The encodings given here may not all be correct."
482
	echo "# If you find that the encoding given for your language and"
483
	echo "# country is not the one your DOS machine actually uses, just"
484
	echo "# correct it in this file, and send a mail to"
485
	echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
486
	echo "# and Bruno Haible <bruno@clisp.org>."
487
	echo "#"
488
	echo "C ASCII"
489
	# ISO-8859-1 languages
490
	echo "ca CP850"
491
	echo "ca_ES CP850"
492
	echo "da CP865"    # not CP850 ??
493
	echo "da_DK CP865" # not CP850 ??
494
	echo "de CP850"
495
	echo "de_AT CP850"
496
	echo "de_CH CP850"
497
	echo "de_DE CP850"
498
	echo "en CP850"
499
	echo "en_AU CP850" # not CP437 ??
500
	echo "en_CA CP850"
501
	echo "en_GB CP850"
502
	echo "en_NZ CP437"
503
	echo "en_US CP437"
504
	echo "en_ZA CP850" # not CP437 ??
505
	echo "es CP850"
506
	echo "es_AR CP850"
507
	echo "es_BO CP850"
508
	echo "es_CL CP850"
509
	echo "es_CO CP850"
510
	echo "es_CR CP850"
511
	echo "es_CU CP850"
512
	echo "es_DO CP850"
513
	echo "es_EC CP850"
514
	echo "es_ES CP850"
515
	echo "es_GT CP850"
516
	echo "es_HN CP850"
517
	echo "es_MX CP850"
518
	echo "es_NI CP850"
519
	echo "es_PA CP850"
520
	echo "es_PY CP850"
521
	echo "es_PE CP850"
522
	echo "es_SV CP850"
523
	echo "es_UY CP850"
524
	echo "es_VE CP850"
525
	echo "et CP850"
526
	echo "et_EE CP850"
527
	echo "eu CP850"
528
	echo "eu_ES CP850"
529
	echo "fi CP850"
530
	echo "fi_FI CP850"
531
	echo "fr CP850"
532
	echo "fr_BE CP850"
533
	echo "fr_CA CP850"
534
	echo "fr_CH CP850"
535
	echo "fr_FR CP850"
536
	echo "ga CP850"
537
	echo "ga_IE CP850"
538
	echo "gd CP850"
539
	echo "gd_GB CP850"
540
	echo "gl CP850"
541
	echo "gl_ES CP850"
542
	echo "id CP850"    # not CP437 ??
543
	echo "id_ID CP850" # not CP437 ??
544
	echo "is CP861"    # not CP850 ??
545
	echo "is_IS CP861" # not CP850 ??
546
	echo "it CP850"
547
	echo "it_CH CP850"
548
	echo "it_IT CP850"
549
	echo "lt CP775"
550
	echo "lt_LT CP775"
551
	echo "lv CP775"
552
	echo "lv_LV CP775"
553
	echo "nb CP865"    # not CP850 ??
554
	echo "nb_NO CP865" # not CP850 ??
555
	echo "nl CP850"
556
	echo "nl_BE CP850"
557
	echo "nl_NL CP850"
558
	echo "nn CP865"    # not CP850 ??
559
	echo "nn_NO CP865" # not CP850 ??
560
	echo "no CP865"    # not CP850 ??
561
	echo "no_NO CP865" # not CP850 ??
562
	echo "pt CP850"
563
	echo "pt_BR CP850"
564
	echo "pt_PT CP850"
565
	echo "sv CP850"
566
	echo "sv_SE CP850"
567
	# ISO-8859-2 languages
568
	echo "cs CP852"
569
	echo "cs_CZ CP852"
570
	echo "hr CP852"
571
	echo "hr_HR CP852"
572
	echo "hu CP852"
573
	echo "hu_HU CP852"
574
	echo "pl CP852"
575
	echo "pl_PL CP852"
576
	echo "ro CP852"
577
	echo "ro_RO CP852"
578
	echo "sk CP852"
579
	echo "sk_SK CP852"
580
	echo "sl CP852"
581
	echo "sl_SI CP852"
582
	echo "sq CP852"
583
	echo "sq_AL CP852"
584
	echo "sr CP852"    # CP852 or CP866 or CP855 ??
585
	echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
586
	echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
587
	# ISO-8859-3 languages
588
	echo "mt CP850"
589
	echo "mt_MT CP850"
590
	# ISO-8859-5 languages
591
	echo "be CP866"
592
	echo "be_BE CP866"
593
	echo "bg CP866"    # not CP855 ??
594
	echo "bg_BG CP866" # not CP855 ??
595
	echo "mk CP866"    # not CP855 ??
596
	echo "mk_MK CP866" # not CP855 ??
597
	echo "ru CP866"
598
	echo "ru_RU CP866"
599
	echo "uk CP1125"
600
	echo "uk_UA CP1125"
601
	# ISO-8859-6 languages
602
	echo "ar CP864"
603
	echo "ar_AE CP864"
604
	echo "ar_DZ CP864"
605
	echo "ar_EG CP864"
606
	echo "ar_IQ CP864"
607
	echo "ar_IR CP864"
608
	echo "ar_JO CP864"
609
	echo "ar_KW CP864"
610
	echo "ar_MA CP864"
611
	echo "ar_OM CP864"
612
	echo "ar_QA CP864"
613
	echo "ar_SA CP864"
614
	echo "ar_SY CP864"
615
	# ISO-8859-7 languages
616
	echo "el CP869"
617
	echo "el_GR CP869"
618
	# ISO-8859-8 languages
619
	echo "he CP862"
620
	echo "he_IL CP862"
621
	# ISO-8859-9 languages
622
	echo "tr CP857"
623
	echo "tr_TR CP857"
624
	# Japanese
625
	echo "ja CP932"
626
	echo "ja_JP CP932"
627
	# Chinese
628
	echo "zh_CN GBK"
629
	echo "zh_TW CP950" # not CP938 ??
630
	# Korean
631
	echo "kr CP949"    # not CP934 ??
632
	echo "kr_KR CP949" # not CP934 ??
633
	# Thai
634
	echo "th CP874"
635
	echo "th_TH CP874"
636
	# Other
637
	echo "eo CP850"
638
	echo "eo_EO CP850"
639
	;;
640
esac
(-)a/intl/dcgettext.c (-56 lines)
Lines 1-56 Link Here
1
/* Implementation of the dcgettext(3) function.
2
   Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include "gettextP.h"
24
#ifdef _LIBC
25
# include <libintl.h>
26
#else
27
# include "libgnuintl.h"
28
#endif
29
30
/* @@ end of prolog @@ */
31
32
/* Names for the libintl functions are a problem.  They must not clash
33
   with existing names and they should follow ANSI C.  But this source
34
   code is also used in GNU C Library where the names have a __
35
   prefix.  So we have to make a difference here.  */
36
#ifdef _LIBC
37
# define DCGETTEXT __dcgettext
38
# define DCIGETTEXT __dcigettext
39
#else
40
# define DCGETTEXT libintl_dcgettext
41
# define DCIGETTEXT libintl_dcigettext
42
#endif
43
44
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
45
   locale.  */
46
char *
47
DCGETTEXT (const char *domainname, const char *msgid, int category)
48
{
49
  return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category);
50
}
51
52
#ifdef _LIBC
53
/* Alias for function name in GNU C Library.  */
54
INTDEF(__dcgettext)
55
weak_alias (__dcgettext, dcgettext);
56
#endif
(-)a/intl/dcigettext.c (-1654 lines)
Lines 1-1654 Link Here
1
/* Implementation of the internal dcigettext function.
2
   Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Tell glibc's <string.h> to provide a prototype for mempcpy().
20
   This must come before <config.h> because <config.h> may include
21
   <features.h>, and once <features.h> has been included, it's too late.  */
22
#ifndef _GNU_SOURCE
23
# define _GNU_SOURCE	1
24
#endif
25
26
#ifdef HAVE_CONFIG_H
27
# include <config.h>
28
#endif
29
30
/* NL_LOCALE_NAME does not work in glibc-2.4.  Ignore it.  */
31
#undef HAVE_NL_LOCALE_NAME
32
33
#include <sys/types.h>
34
35
#ifdef __GNUC__
36
# define alloca __builtin_alloca
37
# define HAVE_ALLOCA 1
38
#else
39
# ifdef _MSC_VER
40
#  include <malloc.h>
41
#  define alloca _alloca
42
# else
43
#  if defined HAVE_ALLOCA_H || defined _LIBC
44
#   include <alloca.h>
45
#  else
46
#   ifdef _AIX
47
 #pragma alloca
48
#   else
49
#    ifndef alloca
50
char *alloca ();
51
#    endif
52
#   endif
53
#  endif
54
# endif
55
#endif
56
57
#include <errno.h>
58
#ifndef errno
59
extern int errno;
60
#endif
61
#ifndef __set_errno
62
# define __set_errno(val) errno = (val)
63
#endif
64
65
#include <stddef.h>
66
#include <stdlib.h>
67
#include <string.h>
68
69
#if defined HAVE_UNISTD_H || defined _LIBC
70
# include <unistd.h>
71
#endif
72
73
#include <locale.h>
74
75
#ifdef _LIBC
76
  /* Guess whether integer division by zero raises signal SIGFPE.
77
     Set to 1 only if you know for sure.  In case of doubt, set to 0.  */
78
# if defined __alpha__ || defined __arm__ || defined __i386__ \
79
     || defined __m68k__ || defined __s390__
80
#  define INTDIV0_RAISES_SIGFPE 1
81
# else
82
#  define INTDIV0_RAISES_SIGFPE 0
83
# endif
84
#endif
85
#if !INTDIV0_RAISES_SIGFPE
86
# include <signal.h>
87
#endif
88
89
#if defined HAVE_SYS_PARAM_H || defined _LIBC
90
# include <sys/param.h>
91
#endif
92
93
#if !defined _LIBC && HAVE_NL_LOCALE_NAME
94
# include <langinfo.h>
95
#endif
96
97
#include "gettextP.h"
98
#include "plural-exp.h"
99
#ifdef _LIBC
100
# include <libintl.h>
101
#else
102
# ifdef IN_LIBGLOCALE
103
#  include <libintl.h>
104
# endif
105
# include "libgnuintl.h"
106
#endif
107
#include "hash-string.h"
108
109
/* Handle multi-threaded applications.  */
110
#ifdef _LIBC
111
# include <bits/libc-lock.h>
112
# define gl_rwlock_define_initialized __libc_rwlock_define_initialized
113
# define gl_rwlock_rdlock __libc_rwlock_rdlock
114
# define gl_rwlock_wrlock __libc_rwlock_wrlock
115
# define gl_rwlock_unlock __libc_rwlock_unlock
116
#else
117
# include "lock.h"
118
#endif
119
120
/* Alignment of types.  */
121
#if defined __GNUC__ && __GNUC__ >= 2
122
# define alignof(TYPE) __alignof__ (TYPE)
123
#else
124
# define alignof(TYPE) \
125
    ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)
126
#endif
127
128
/* The internal variables in the standalone libintl.a must have different
129
   names than the internal variables in GNU libc, otherwise programs
130
   using libintl.a cannot be linked statically.  */
131
#if !defined _LIBC
132
# define _nl_default_default_domain libintl_nl_default_default_domain
133
# define _nl_current_default_domain libintl_nl_current_default_domain
134
# define _nl_default_dirname libintl_nl_default_dirname
135
# define _nl_domain_bindings libintl_nl_domain_bindings
136
#endif
137
138
/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>.  */
139
#ifndef offsetof
140
# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
141
#endif
142
143
/* @@ end of prolog @@ */
144
145
#ifdef _LIBC
146
/* Rename the non ANSI C functions.  This is required by the standard
147
   because some ANSI C functions will require linking with this object
148
   file and the name space must not be polluted.  */
149
# define getcwd __getcwd
150
# ifndef stpcpy
151
#  define stpcpy __stpcpy
152
# endif
153
# define tfind __tfind
154
#else
155
# if !defined HAVE_GETCWD
156
char *getwd ();
157
#  define getcwd(buf, max) getwd (buf)
158
# else
159
#  if VMS
160
#   define getcwd(buf, max) (getcwd) (buf, max, 0)
161
#  else
162
char *getcwd ();
163
#  endif
164
# endif
165
# ifndef HAVE_STPCPY
166
static char *stpcpy (char *dest, const char *src);
167
# endif
168
# ifndef HAVE_MEMPCPY
169
static void *mempcpy (void *dest, const void *src, size_t n);
170
# endif
171
#endif
172
173
/* Amount to increase buffer size by in each try.  */
174
#define PATH_INCR 32
175
176
/* The following is from pathmax.h.  */
177
/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
178
   PATH_MAX but might cause redefinition warnings when sys/param.h is
179
   later included (as on MORE/BSD 4.3).  */
180
#if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__)
181
# include <limits.h>
182
#endif
183
184
#ifndef _POSIX_PATH_MAX
185
# define _POSIX_PATH_MAX 255
186
#endif
187
188
#if !defined PATH_MAX && defined _PC_PATH_MAX
189
# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))
190
#endif
191
192
/* Don't include sys/param.h if it already has been.  */
193
#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
194
# include <sys/param.h>
195
#endif
196
197
#if !defined PATH_MAX && defined MAXPATHLEN
198
# define PATH_MAX MAXPATHLEN
199
#endif
200
201
#ifndef PATH_MAX
202
# define PATH_MAX _POSIX_PATH_MAX
203
#endif
204
205
/* Pathname support.
206
   ISSLASH(C)           tests whether C is a directory separator character.
207
   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
208
                        it may be concatenated to a directory pathname.
209
   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
210
 */
211
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
212
  /* Win32, Cygwin, OS/2, DOS */
213
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
214
# define HAS_DEVICE(P) \
215
    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
216
     && (P)[1] == ':')
217
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
218
# define IS_PATH_WITH_DIR(P) \
219
    (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
220
#else
221
  /* Unix */
222
# define ISSLASH(C) ((C) == '/')
223
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
224
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
225
#endif
226
227
/* Whether to support different locales in different threads.  */
228
#if defined _LIBC || HAVE_NL_LOCALE_NAME || (HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS) || defined IN_LIBGLOCALE
229
# define HAVE_PER_THREAD_LOCALE
230
#endif
231
232
/* This is the type used for the search tree where known translations
233
   are stored.  */
234
struct known_translation_t
235
{
236
  /* Domain in which to search.  */
237
  const char *domainname;
238
239
  /* The category.  */
240
  int category;
241
242
#ifdef HAVE_PER_THREAD_LOCALE
243
  /* Name of the relevant locale category, or "" for the global locale.  */
244
  const char *localename;
245
#endif
246
247
#ifdef IN_LIBGLOCALE
248
  /* The character encoding.  */
249
  const char *encoding;
250
#endif
251
252
  /* State of the catalog counter at the point the string was found.  */
253
  int counter;
254
255
  /* Catalog where the string was found.  */
256
  struct loaded_l10nfile *domain;
257
258
  /* And finally the translation.  */
259
  const char *translation;
260
  size_t translation_length;
261
262
  /* Pointer to the string in question.  */
263
  char msgid[ZERO];
264
};
265
266
/* Root of the search tree with known translations.  We can use this
267
   only if the system provides the `tsearch' function family.  */
268
#if defined HAVE_TSEARCH || defined _LIBC
269
# include <search.h>
270
271
gl_rwlock_define_initialized (static, tree_lock)
272
273
static void *root;
274
275
# ifdef _LIBC
276
#  define tsearch __tsearch
277
# endif
278
279
/* Function to compare two entries in the table of known translations.  */
280
static int
281
transcmp (const void *p1, const void *p2)
282
{
283
  const struct known_translation_t *s1;
284
  const struct known_translation_t *s2;
285
  int result;
286
287
  s1 = (const struct known_translation_t *) p1;
288
  s2 = (const struct known_translation_t *) p2;
289
290
  result = strcmp (s1->msgid, s2->msgid);
291
  if (result == 0)
292
    {
293
      result = strcmp (s1->domainname, s2->domainname);
294
      if (result == 0)
295
	{
296
#ifdef HAVE_PER_THREAD_LOCALE
297
	  result = strcmp (s1->localename, s2->localename);
298
	  if (result == 0)
299
#endif
300
	    {
301
#ifdef IN_LIBGLOCALE
302
	      result = strcmp (s1->encoding, s2->encoding);
303
	      if (result == 0)
304
#endif
305
		/* We compare the category last (though this is the cheapest
306
		   operation) since it is hopefully always the same (namely
307
		   LC_MESSAGES).  */
308
		result = s1->category - s2->category;
309
	    }
310
	}
311
    }
312
313
  return result;
314
}
315
#endif
316
317
/* Name of the default domain used for gettext(3) prior any call to
318
   textdomain(3).  The default value for this is "messages".  */
319
const char _nl_default_default_domain[] attribute_hidden = "messages";
320
321
#ifndef IN_LIBGLOCALE
322
/* Value used as the default domain for gettext(3).  */
323
const char *_nl_current_default_domain attribute_hidden
324
     = _nl_default_default_domain;
325
#endif
326
327
/* Contains the default location of the message catalogs.  */
328
#if defined __EMX__
329
extern const char _nl_default_dirname[];
330
#else
331
# ifdef _LIBC
332
extern const char _nl_default_dirname[];
333
libc_hidden_proto (_nl_default_dirname)
334
# endif
335
const char _nl_default_dirname[] = LOCALEDIR;
336
# ifdef _LIBC
337
libc_hidden_data_def (_nl_default_dirname)
338
# endif
339
#endif
340
341
#ifndef IN_LIBGLOCALE
342
/* List with bindings of specific domains created by bindtextdomain()
343
   calls.  */
344
struct binding *_nl_domain_bindings;
345
#endif
346
347
/* Prototypes for local functions.  */
348
static char *plural_lookup (struct loaded_l10nfile *domain,
349
			    unsigned long int n,
350
			    const char *translation, size_t translation_len)
351
     internal_function;
352
353
#ifdef IN_LIBGLOCALE
354
static const char *guess_category_value (int category,
355
					 const char *categoryname,
356
					 const char *localename)
357
     internal_function;
358
#else
359
static const char *guess_category_value (int category,
360
					 const char *categoryname)
361
     internal_function;
362
#endif
363
364
#ifdef _LIBC
365
# include "../locale/localeinfo.h"
366
# define category_to_name(category) \
367
  _nl_category_names.str + _nl_category_name_idxs[category]
368
#else
369
static const char *category_to_name (int category) internal_function;
370
#endif
371
#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE
372
static const char *get_output_charset (struct binding *domainbinding)
373
     internal_function;
374
#endif
375
376
377
/* For those loosing systems which don't have `alloca' we have to add
378
   some additional code emulating it.  */
379
#ifdef HAVE_ALLOCA
380
/* Nothing has to be done.  */
381
# define freea(p) /* nothing */
382
# define ADD_BLOCK(list, address) /* nothing */
383
# define FREE_BLOCKS(list) /* nothing */
384
#else
385
struct block_list
386
{
387
  void *address;
388
  struct block_list *next;
389
};
390
# define ADD_BLOCK(list, addr)						      \
391
  do {									      \
392
    struct block_list *newp = (struct block_list *) malloc (sizeof (*newp));  \
393
    /* If we cannot get a free block we cannot add the new element to	      \
394
       the list.  */							      \
395
    if (newp != NULL) {							      \
396
      newp->address = (addr);						      \
397
      newp->next = (list);						      \
398
      (list) = newp;							      \
399
    }									      \
400
  } while (0)
401
# define FREE_BLOCKS(list)						      \
402
  do {									      \
403
    while (list != NULL) {						      \
404
      struct block_list *old = list;					      \
405
      list = list->next;						      \
406
      free (old->address);						      \
407
      free (old);							      \
408
    }									      \
409
  } while (0)
410
# undef alloca
411
# define alloca(size) (malloc (size))
412
# define freea(p) free (p)
413
#endif	/* have alloca */
414
415
416
#ifdef _LIBC
417
/* List of blocks allocated for translations.  */
418
typedef struct transmem_list
419
{
420
  struct transmem_list *next;
421
  char data[ZERO];
422
} transmem_block_t;
423
static struct transmem_list *transmem_list;
424
#else
425
typedef unsigned char transmem_block_t;
426
#endif
427
428
429
/* Names for the libintl functions are a problem.  They must not clash
430
   with existing names and they should follow ANSI C.  But this source
431
   code is also used in GNU C Library where the names have a __
432
   prefix.  So we have to make a difference here.  */
433
#ifdef _LIBC
434
# define DCIGETTEXT __dcigettext
435
#else
436
# define DCIGETTEXT libintl_dcigettext
437
#endif
438
439
/* Lock variable to protect the global data in the gettext implementation.  */
440
gl_rwlock_define_initialized (, _nl_state_lock attribute_hidden)
441
442
/* Checking whether the binaries runs SUID must be done and glibc provides
443
   easier methods therefore we make a difference here.  */
444
#ifdef _LIBC
445
# define ENABLE_SECURE __libc_enable_secure
446
# define DETERMINE_SECURE
447
#else
448
# ifndef HAVE_GETUID
449
#  define getuid() 0
450
# endif
451
# ifndef HAVE_GETGID
452
#  define getgid() 0
453
# endif
454
# ifndef HAVE_GETEUID
455
#  define geteuid() getuid()
456
# endif
457
# ifndef HAVE_GETEGID
458
#  define getegid() getgid()
459
# endif
460
static int enable_secure;
461
# define ENABLE_SECURE (enable_secure == 1)
462
# define DETERMINE_SECURE \
463
  if (enable_secure == 0)						      \
464
    {									      \
465
      if (getuid () != geteuid () || getgid () != getegid ())		      \
466
	enable_secure = 1;						      \
467
      else								      \
468
	enable_secure = -1;						      \
469
    }
470
#endif
471
472
/* Get the function to evaluate the plural expression.  */
473
#include "eval-plural.h"
474
475
/* Look up MSGID in the DOMAINNAME message catalog for the current
476
   CATEGORY locale and, if PLURAL is nonzero, search over string
477
   depending on the plural form determined by N.  */
478
#ifdef IN_LIBGLOCALE
479
char *
480
gl_dcigettext (const char *domainname,
481
	       const char *msgid1, const char *msgid2,
482
	       int plural, unsigned long int n,
483
	       int category,
484
	       const char *localename, const char *encoding)
485
#else
486
char *
487
DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
488
	    int plural, unsigned long int n, int category)
489
#endif
490
{
491
#ifndef HAVE_ALLOCA
492
  struct block_list *block_list = NULL;
493
#endif
494
  struct loaded_l10nfile *domain;
495
  struct binding *binding;
496
  const char *categoryname;
497
  const char *categoryvalue;
498
  const char *dirname;
499
  char *xdomainname;
500
  char *single_locale;
501
  char *retval;
502
  size_t retlen;
503
  int saved_errno;
504
#if defined HAVE_TSEARCH || defined _LIBC
505
  struct known_translation_t *search;
506
  struct known_translation_t **foundp = NULL;
507
  size_t msgid_len;
508
# if defined HAVE_PER_THREAD_LOCALE && !defined IN_LIBGLOCALE
509
  const char *localename;
510
# endif
511
#endif
512
  size_t domainname_len;
513
514
  /* If no real MSGID is given return NULL.  */
515
  if (msgid1 == NULL)
516
    return NULL;
517
518
#ifdef _LIBC
519
  if (category < 0 || category >= __LC_LAST || category == LC_ALL)
520
    /* Bogus.  */
521
    return (plural == 0
522
	    ? (char *) msgid1
523
	    /* Use the Germanic plural rule.  */
524
	    : n == 1 ? (char *) msgid1 : (char *) msgid2);
525
#endif
526
527
  gl_rwlock_rdlock (_nl_state_lock);
528
529
  /* If DOMAINNAME is NULL, we are interested in the default domain.  If
530
     CATEGORY is not LC_MESSAGES this might not make much sense but the
531
     definition left this undefined.  */
532
  if (domainname == NULL)
533
    domainname = _nl_current_default_domain;
534
535
  /* OS/2 specific: backward compatibility with older libintl versions  */
536
#ifdef LC_MESSAGES_COMPAT
537
  if (category == LC_MESSAGES_COMPAT)
538
    category = LC_MESSAGES;
539
#endif
540
541
#if defined HAVE_TSEARCH || defined _LIBC
542
  msgid_len = strlen (msgid1) + 1;
543
544
  /* Try to find the translation among those which we found at
545
     some time.  */
546
  search = (struct known_translation_t *)
547
	   alloca (offsetof (struct known_translation_t, msgid) + msgid_len);
548
  memcpy (search->msgid, msgid1, msgid_len);
549
  search->domainname = domainname;
550
  search->category = category;
551
# ifdef HAVE_PER_THREAD_LOCALE
552
#  ifndef IN_LIBGLOCALE
553
#   ifdef _LIBC
554
  localename = __current_locale_name (category);
555
#   else
556
#    if HAVE_NL_LOCALE_NAME
557
  /* NL_LOCALE_NAME is public glibc API introduced in glibc-2.4.  */
558
  localename = nl_langinfo (NL_LOCALE_NAME (category));
559
#    else
560
#     if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS
561
  /* The __names field is not public glibc API and must therefore not be used
562
     in code that is installed in public locations.  */
563
  {
564
    locale_t thread_locale = uselocale (NULL);
565
    if (thread_locale != LC_GLOBAL_LOCALE)
566
      localename = thread_locale->__names[category];
567
    else
568
      localename = "";
569
  }
570
#     endif
571
#    endif
572
#   endif
573
#  endif
574
  search->localename = localename;
575
#  ifdef IN_LIBGLOCALE
576
  search->encoding = encoding;
577
#  endif
578
# endif
579
580
  /* Since tfind/tsearch manage a balanced tree, concurrent tfind and
581
     tsearch calls can be fatal.  */
582
  gl_rwlock_rdlock (tree_lock);
583
584
  foundp = (struct known_translation_t **) tfind (search, &root, transcmp);
585
586
  gl_rwlock_unlock (tree_lock);
587
588
  freea (search);
589
  if (foundp != NULL && (*foundp)->counter == _nl_msg_cat_cntr)
590
    {
591
      /* Now deal with plural.  */
592
      if (plural)
593
	retval = plural_lookup ((*foundp)->domain, n, (*foundp)->translation,
594
				(*foundp)->translation_length);
595
      else
596
	retval = (char *) (*foundp)->translation;
597
598
      gl_rwlock_unlock (_nl_state_lock);
599
      return retval;
600
    }
601
#endif
602
603
  /* Preserve the `errno' value.  */
604
  saved_errno = errno;
605
606
  /* See whether this is a SUID binary or not.  */
607
  DETERMINE_SECURE;
608
609
  /* First find matching binding.  */
610
#ifdef IN_LIBGLOCALE
611
  /* We can use a trivial binding, since _nl_find_msg will ignore it anyway,
612
     and _nl_load_domain and _nl_find_domain just pass it through.  */
613
  binding = NULL;
614
  dirname = bindtextdomain (domainname, NULL);
615
#else
616
  for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
617
    {
618
      int compare = strcmp (domainname, binding->domainname);
619
      if (compare == 0)
620
	/* We found it!  */
621
	break;
622
      if (compare < 0)
623
	{
624
	  /* It is not in the list.  */
625
	  binding = NULL;
626
	  break;
627
	}
628
    }
629
630
  if (binding == NULL)
631
    dirname = _nl_default_dirname;
632
  else
633
    {
634
      dirname = binding->dirname;
635
#endif
636
      if (!IS_ABSOLUTE_PATH (dirname))
637
	{
638
	  /* We have a relative path.  Make it absolute now.  */
639
	  size_t dirname_len = strlen (dirname) + 1;
640
	  size_t path_max;
641
	  char *resolved_dirname;
642
	  char *ret;
643
644
	  path_max = (unsigned int) PATH_MAX;
645
	  path_max += 2;		/* The getcwd docs say to do this.  */
646
647
	  for (;;)
648
	    {
649
	      resolved_dirname = (char *) alloca (path_max + dirname_len);
650
	      ADD_BLOCK (block_list, tmp_dirname);
651
652
	      __set_errno (0);
653
	      ret = getcwd (resolved_dirname, path_max);
654
	      if (ret != NULL || errno != ERANGE)
655
		break;
656
657
	      path_max += path_max / 2;
658
	      path_max += PATH_INCR;
659
	    }
660
661
	  if (ret == NULL)
662
	    /* We cannot get the current working directory.  Don't signal an
663
	       error but simply return the default string.  */
664
	    goto return_untranslated;
665
666
	  stpcpy (stpcpy (strchr (resolved_dirname, '\0'), "/"), dirname);
667
	  dirname = resolved_dirname;
668
	}
669
#ifndef IN_LIBGLOCALE
670
    }
671
#endif
672
673
  /* Now determine the symbolic name of CATEGORY and its value.  */
674
  categoryname = category_to_name (category);
675
#ifdef IN_LIBGLOCALE
676
  categoryvalue = guess_category_value (category, categoryname, localename);
677
#else
678
  categoryvalue = guess_category_value (category, categoryname);
679
#endif
680
681
  domainname_len = strlen (domainname);
682
  xdomainname = (char *) alloca (strlen (categoryname)
683
				 + domainname_len + 5);
684
  ADD_BLOCK (block_list, xdomainname);
685
686
  stpcpy (mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
687
		  domainname, domainname_len),
688
	  ".mo");
689
690
  /* Creating working area.  */
691
  single_locale = (char *) alloca (strlen (categoryvalue) + 1);
692
  ADD_BLOCK (block_list, single_locale);
693
694
695
  /* Search for the given string.  This is a loop because we perhaps
696
     got an ordered list of languages to consider for the translation.  */
697
  while (1)
698
    {
699
      /* Make CATEGORYVALUE point to the next element of the list.  */
700
      while (categoryvalue[0] != '\0' && categoryvalue[0] == ':')
701
	++categoryvalue;
702
      if (categoryvalue[0] == '\0')
703
	{
704
	  /* The whole contents of CATEGORYVALUE has been searched but
705
	     no valid entry has been found.  We solve this situation
706
	     by implicitly appending a "C" entry, i.e. no translation
707
	     will take place.  */
708
	  single_locale[0] = 'C';
709
	  single_locale[1] = '\0';
710
	}
711
      else
712
	{
713
	  char *cp = single_locale;
714
	  while (categoryvalue[0] != '\0' && categoryvalue[0] != ':')
715
	    *cp++ = *categoryvalue++;
716
	  *cp = '\0';
717
718
	  /* When this is a SUID binary we must not allow accessing files
719
	     outside the dedicated directories.  */
720
	  if (ENABLE_SECURE && IS_PATH_WITH_DIR (single_locale))
721
	    /* Ingore this entry.  */
722
	    continue;
723
	}
724
725
      /* If the current locale value is C (or POSIX) we don't load a
726
	 domain.  Return the MSGID.  */
727
      if (strcmp (single_locale, "C") == 0
728
	  || strcmp (single_locale, "POSIX") == 0)
729
	break;
730
731
      /* Find structure describing the message catalog matching the
732
	 DOMAINNAME and CATEGORY.  */
733
      domain = _nl_find_domain (dirname, single_locale, xdomainname, binding);
734
735
      if (domain != NULL)
736
	{
737
#if defined IN_LIBGLOCALE
738
	  retval = _nl_find_msg (domain, binding, encoding, msgid1, &retlen);
739
#else
740
	  retval = _nl_find_msg (domain, binding, msgid1, 1, &retlen);
741
#endif
742
743
	  if (retval == NULL)
744
	    {
745
	      int cnt;
746
747
	      for (cnt = 0; domain->successor[cnt] != NULL; ++cnt)
748
		{
749
#if defined IN_LIBGLOCALE
750
		  retval = _nl_find_msg (domain->successor[cnt], binding,
751
					 encoding, msgid1, &retlen);
752
#else
753
		  retval = _nl_find_msg (domain->successor[cnt], binding,
754
					 msgid1, 1, &retlen);
755
#endif
756
757
		  if (retval != NULL)
758
		    {
759
		      domain = domain->successor[cnt];
760
		      break;
761
		    }
762
		}
763
	    }
764
765
	  /* Returning -1 means that some resource problem exists
766
	     (likely memory) and that the strings could not be
767
	     converted.  Return the original strings.  */
768
	  if (__builtin_expect (retval == (char *) -1, 0))
769
	    break;
770
771
	  if (retval != NULL)
772
	    {
773
	      /* Found the translation of MSGID1 in domain DOMAIN:
774
		 starting at RETVAL, RETLEN bytes.  */
775
	      FREE_BLOCKS (block_list);
776
#if defined HAVE_TSEARCH || defined _LIBC
777
	      if (foundp == NULL)
778
		{
779
		  /* Create a new entry and add it to the search tree.  */
780
		  size_t size;
781
		  struct known_translation_t *newp;
782
783
		  size = offsetof (struct known_translation_t, msgid)
784
			 + msgid_len + domainname_len + 1;
785
# ifdef HAVE_PER_THREAD_LOCALE
786
		  size += strlen (localename) + 1;
787
# endif
788
		  newp = (struct known_translation_t *) malloc (size);
789
		  if (newp != NULL)
790
		    {
791
		      char *new_domainname;
792
# ifdef HAVE_PER_THREAD_LOCALE
793
		      char *new_localename;
794
# endif
795
796
		      new_domainname = mempcpy (newp->msgid, msgid1, msgid_len);
797
		      memcpy (new_domainname, domainname, domainname_len + 1);
798
# ifdef HAVE_PER_THREAD_LOCALE
799
		      new_localename = new_domainname + domainname_len + 1;
800
		      strcpy (new_localename, localename);
801
# endif
802
		      newp->domainname = new_domainname;
803
		      newp->category = category;
804
# ifdef HAVE_PER_THREAD_LOCALE
805
		      newp->localename = new_localename;
806
# endif
807
# ifdef IN_LIBGLOCALE
808
		      newp->encoding = encoding;
809
# endif
810
		      newp->counter = _nl_msg_cat_cntr;
811
		      newp->domain = domain;
812
		      newp->translation = retval;
813
		      newp->translation_length = retlen;
814
815
		      gl_rwlock_wrlock (tree_lock);
816
817
		      /* Insert the entry in the search tree.  */
818
		      foundp = (struct known_translation_t **)
819
			tsearch (newp, &root, transcmp);
820
821
		      gl_rwlock_unlock (tree_lock);
822
823
		      if (foundp == NULL
824
			  || __builtin_expect (*foundp != newp, 0))
825
			/* The insert failed.  */
826
			free (newp);
827
		    }
828
		}
829
	      else
830
		{
831
		  /* We can update the existing entry.  */
832
		  (*foundp)->counter = _nl_msg_cat_cntr;
833
		  (*foundp)->domain = domain;
834
		  (*foundp)->translation = retval;
835
		  (*foundp)->translation_length = retlen;
836
		}
837
#endif
838
	      __set_errno (saved_errno);
839
840
	      /* Now deal with plural.  */
841
	      if (plural)
842
		retval = plural_lookup (domain, n, retval, retlen);
843
844
	      gl_rwlock_unlock (_nl_state_lock);
845
	      return retval;
846
	    }
847
	}
848
    }
849
850
 return_untranslated:
851
  /* Return the untranslated MSGID.  */
852
  FREE_BLOCKS (block_list);
853
  gl_rwlock_unlock (_nl_state_lock);
854
#ifndef _LIBC
855
  if (!ENABLE_SECURE)
856
    {
857
      extern void _nl_log_untranslated (const char *logfilename,
858
					const char *domainname,
859
					const char *msgid1, const char *msgid2,
860
					int plural);
861
      const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED");
862
863
      if (logfilename != NULL && logfilename[0] != '\0')
864
	_nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural);
865
    }
866
#endif
867
  __set_errno (saved_errno);
868
  return (plural == 0
869
	  ? (char *) msgid1
870
	  /* Use the Germanic plural rule.  */
871
	  : n == 1 ? (char *) msgid1 : (char *) msgid2);
872
}
873
874
875
/* Look up the translation of msgid within DOMAIN_FILE and DOMAINBINDING.
876
   Return it if found.  Return NULL if not found or in case of a conversion
877
   failure (problem in the particular message catalog).  Return (char *) -1
878
   in case of a memory allocation failure during conversion (only if
879
   ENCODING != NULL resp. CONVERT == true).  */
880
char *
881
internal_function
882
#ifdef IN_LIBGLOCALE
883
_nl_find_msg (struct loaded_l10nfile *domain_file,
884
	      struct binding *domainbinding, const char *encoding,
885
	      const char *msgid,
886
	      size_t *lengthp)
887
#else
888
_nl_find_msg (struct loaded_l10nfile *domain_file,
889
	      struct binding *domainbinding,
890
	      const char *msgid, int convert,
891
	      size_t *lengthp)
892
#endif
893
{
894
  struct loaded_domain *domain;
895
  nls_uint32 nstrings;
896
  size_t act;
897
  char *result;
898
  size_t resultlen;
899
900
  if (domain_file->decided <= 0)
901
    _nl_load_domain (domain_file, domainbinding);
902
903
  if (domain_file->data == NULL)
904
    return NULL;
905
906
  domain = (struct loaded_domain *) domain_file->data;
907
908
  nstrings = domain->nstrings;
909
910
  /* Locate the MSGID and its translation.  */
911
  if (domain->hash_tab != NULL)
912
    {
913
      /* Use the hashing table.  */
914
      nls_uint32 len = strlen (msgid);
915
      nls_uint32 hash_val = __hash_string (msgid);
916
      nls_uint32 idx = hash_val % domain->hash_size;
917
      nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2));
918
919
      while (1)
920
	{
921
	  nls_uint32 nstr =
922
	    W (domain->must_swap_hash_tab, domain->hash_tab[idx]);
923
924
	  if (nstr == 0)
925
	    /* Hash table entry is empty.  */
926
	    return NULL;
927
928
	  nstr--;
929
930
	  /* Compare msgid with the original string at index nstr.
931
	     We compare the lengths with >=, not ==, because plural entries
932
	     are represented by strings with an embedded NUL.  */
933
	  if (nstr < nstrings
934
	      ? W (domain->must_swap, domain->orig_tab[nstr].length) >= len
935
		&& (strcmp (msgid,
936
			    domain->data + W (domain->must_swap,
937
					      domain->orig_tab[nstr].offset))
938
		    == 0)
939
	      : domain->orig_sysdep_tab[nstr - nstrings].length > len
940
		&& (strcmp (msgid,
941
			    domain->orig_sysdep_tab[nstr - nstrings].pointer)
942
		    == 0))
943
	    {
944
	      act = nstr;
945
	      goto found;
946
	    }
947
948
	  if (idx >= domain->hash_size - incr)
949
	    idx -= domain->hash_size - incr;
950
	  else
951
	    idx += incr;
952
	}
953
      /* NOTREACHED */
954
    }
955
  else
956
    {
957
      /* Try the default method:  binary search in the sorted array of
958
	 messages.  */
959
      size_t top, bottom;
960
961
      bottom = 0;
962
      top = nstrings;
963
      while (bottom < top)
964
	{
965
	  int cmp_val;
966
967
	  act = (bottom + top) / 2;
968
	  cmp_val = strcmp (msgid, (domain->data
969
				    + W (domain->must_swap,
970
					 domain->orig_tab[act].offset)));
971
	  if (cmp_val < 0)
972
	    top = act;
973
	  else if (cmp_val > 0)
974
	    bottom = act + 1;
975
	  else
976
	    goto found;
977
	}
978
      /* No translation was found.  */
979
      return NULL;
980
    }
981
982
 found:
983
  /* The translation was found at index ACT.  If we have to convert the
984
     string to use a different character set, this is the time.  */
985
  if (act < nstrings)
986
    {
987
      result = (char *)
988
	(domain->data + W (domain->must_swap, domain->trans_tab[act].offset));
989
      resultlen = W (domain->must_swap, domain->trans_tab[act].length) + 1;
990
    }
991
  else
992
    {
993
      result = (char *) domain->trans_sysdep_tab[act - nstrings].pointer;
994
      resultlen = domain->trans_sysdep_tab[act - nstrings].length;
995
    }
996
997
#if defined _LIBC || HAVE_ICONV
998
# ifdef IN_LIBGLOCALE
999
  if (encoding != NULL)
1000
# else
1001
  if (convert)
1002
# endif
1003
    {
1004
      /* We are supposed to do a conversion.  */
1005
# ifndef IN_LIBGLOCALE
1006
      const char *encoding = get_output_charset (domainbinding);
1007
# endif
1008
1009
      /* Search whether a table with converted translations for this
1010
	 encoding has already been allocated.  */
1011
      size_t nconversions = domain->nconversions;
1012
      struct converted_domain *convd = NULL;
1013
      size_t i;
1014
1015
      for (i = nconversions; i > 0; )
1016
	{
1017
	  i--;
1018
	  if (strcmp (domain->conversions[i].encoding, encoding) == 0)
1019
	    {
1020
	      convd = &domain->conversions[i];
1021
	      break;
1022
	    }
1023
	}
1024
1025
      if (convd == NULL)
1026
	{
1027
	  /* Allocate a table for the converted translations for this
1028
	     encoding.  */
1029
	  struct converted_domain *new_conversions =
1030
	    (struct converted_domain *)
1031
	    (domain->conversions != NULL
1032
	     ? realloc (domain->conversions,
1033
			(nconversions + 1) * sizeof (struct converted_domain))
1034
	     : malloc ((nconversions + 1) * sizeof (struct converted_domain)));
1035
1036
	  if (__builtin_expect (new_conversions == NULL, 0))
1037
	    /* Nothing we can do, no more memory.  We cannot use the
1038
	       translation because it might be encoded incorrectly.  */
1039
	    return (char *) -1;
1040
1041
	  domain->conversions = new_conversions;
1042
1043
	  /* Copy the 'encoding' string to permanent storage.  */
1044
	  encoding = strdup (encoding);
1045
	  if (__builtin_expect (encoding == NULL, 0))
1046
	    /* Nothing we can do, no more memory.  We cannot use the
1047
	       translation because it might be encoded incorrectly.  */
1048
	    return (char *) -1;
1049
1050
	  convd = &new_conversions[nconversions];
1051
	  convd->encoding = encoding;
1052
1053
	  /* Find out about the character set the file is encoded with.
1054
	     This can be found (in textual form) in the entry "".  If this
1055
	     entry does not exist or if this does not contain the 'charset='
1056
	     information, we will assume the charset matches the one the
1057
	     current locale and we don't have to perform any conversion.  */
1058
# ifdef _LIBC
1059
	  convd->conv = (__gconv_t) -1;
1060
# else
1061
#  if HAVE_ICONV
1062
	  convd->conv = (iconv_t) -1;
1063
#  endif
1064
# endif
1065
	  {
1066
	    char *nullentry;
1067
	    size_t nullentrylen;
1068
1069
	    /* Get the header entry.  This is a recursion, but it doesn't
1070
	       reallocate domain->conversions because we pass
1071
	       encoding = NULL or convert = 0, respectively.  */
1072
	    nullentry =
1073
# ifdef IN_LIBGLOCALE
1074
	      _nl_find_msg (domain_file, domainbinding, NULL, "",
1075
			    &nullentrylen);
1076
# else
1077
	      _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
1078
# endif
1079
1080
	    if (nullentry != NULL)
1081
	      {
1082
		const char *charsetstr;
1083
1084
		charsetstr = strstr (nullentry, "charset=");
1085
		if (charsetstr != NULL)
1086
		  {
1087
		    size_t len;
1088
		    char *charset;
1089
		    const char *outcharset;
1090
1091
		    charsetstr += strlen ("charset=");
1092
		    len = strcspn (charsetstr, " \t\n");
1093
1094
		    charset = (char *) alloca (len + 1);
1095
# if defined _LIBC || HAVE_MEMPCPY
1096
		    *((char *) mempcpy (charset, charsetstr, len)) = '\0';
1097
# else
1098
		    memcpy (charset, charsetstr, len);
1099
		    charset[len] = '\0';
1100
# endif
1101
1102
		    outcharset = encoding;
1103
1104
# ifdef _LIBC
1105
		    /* We always want to use transliteration.  */
1106
		    outcharset = norm_add_slashes (outcharset, "TRANSLIT");
1107
		    charset = norm_add_slashes (charset, "");
1108
		    int r = __gconv_open (outcharset, charset, &convd->conv,
1109
					  GCONV_AVOID_NOCONV);
1110
		    if (__builtin_expect (r != __GCONV_OK, 0))
1111
		      {
1112
			/* If the output encoding is the same there is
1113
			   nothing to do.  Otherwise do not use the
1114
			   translation at all.  */
1115
			if (__builtin_expect (r != __GCONV_NOCONV, 1))
1116
			  return NULL;
1117
1118
			convd->conv = (__gconv_t) -1;
1119
		      }
1120
# else
1121
#  if HAVE_ICONV
1122
		    /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
1123
		       we want to use transliteration.  */
1124
#   if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
1125
       || _LIBICONV_VERSION >= 0x0105
1126
		    if (strchr (outcharset, '/') == NULL)
1127
		      {
1128
			char *tmp;
1129
1130
			len = strlen (outcharset);
1131
			tmp = (char *) alloca (len + 10 + 1);
1132
			memcpy (tmp, outcharset, len);
1133
			memcpy (tmp + len, "//TRANSLIT", 10 + 1);
1134
			outcharset = tmp;
1135
1136
			convd->conv = iconv_open (outcharset, charset);
1137
1138
			freea (outcharset);
1139
		      }
1140
		    else
1141
#   endif
1142
		      convd->conv = iconv_open (outcharset, charset);
1143
#  endif
1144
# endif
1145
1146
		    freea (charset);
1147
		  }
1148
	      }
1149
	  }
1150
	  convd->conv_tab = NULL;
1151
	  /* Here domain->conversions is still == new_conversions.  */
1152
	  domain->nconversions++;
1153
	}
1154
1155
      if (
1156
# ifdef _LIBC
1157
	  convd->conv != (__gconv_t) -1
1158
# else
1159
#  if HAVE_ICONV
1160
	  convd->conv != (iconv_t) -1
1161
#  endif
1162
# endif
1163
	  )
1164
	{
1165
	  /* We are supposed to do a conversion.  First allocate an
1166
	     appropriate table with the same structure as the table
1167
	     of translations in the file, where we can put the pointers
1168
	     to the converted strings in.
1169
	     There is a slight complication with plural entries.  They
1170
	     are represented by consecutive NUL terminated strings.  We
1171
	     handle this case by converting RESULTLEN bytes, including
1172
	     NULs.  */
1173
1174
	  if (convd->conv_tab == NULL
1175
	      && ((convd->conv_tab =
1176
		    (char **) calloc (nstrings + domain->n_sysdep_strings,
1177
				      sizeof (char *)))
1178
		  == NULL))
1179
	    /* Mark that we didn't succeed allocating a table.  */
1180
	    convd->conv_tab = (char **) -1;
1181
1182
	  if (__builtin_expect (convd->conv_tab == (char **) -1, 0))
1183
	    /* Nothing we can do, no more memory.  We cannot use the
1184
	       translation because it might be encoded incorrectly.  */
1185
	    return (char *) -1;
1186
1187
	  if (convd->conv_tab[act] == NULL)
1188
	    {
1189
	      /* We haven't used this string so far, so it is not
1190
		 translated yet.  Do this now.  */
1191
	      /* We use a bit more efficient memory handling.
1192
		 We allocate always larger blocks which get used over
1193
		 time.  This is faster than many small allocations.   */
1194
	      __libc_lock_define_initialized (static, lock)
1195
# define INITIAL_BLOCK_SIZE	4080
1196
	      static unsigned char *freemem;
1197
	      static size_t freemem_size;
1198
1199
	      const unsigned char *inbuf;
1200
	      unsigned char *outbuf;
1201
	      int malloc_count;
1202
# ifndef _LIBC
1203
	      transmem_block_t *transmem_list = NULL;
1204
# endif
1205
1206
	      __libc_lock_lock (lock);
1207
1208
	      inbuf = (const unsigned char *) result;
1209
	      outbuf = freemem + sizeof (size_t);
1210
1211
	      malloc_count = 0;
1212
	      while (1)
1213
		{
1214
		  transmem_block_t *newmem;
1215
# ifdef _LIBC
1216
		  size_t non_reversible;
1217
		  int res;
1218
1219
		  if (freemem_size < sizeof (size_t))
1220
		    goto resize_freemem;
1221
1222
		  res = __gconv (convd->conv,
1223
				 &inbuf, inbuf + resultlen,
1224
				 &outbuf,
1225
				 outbuf + freemem_size - sizeof (size_t),
1226
				 &non_reversible);
1227
1228
		  if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT)
1229
		    break;
1230
1231
		  if (res != __GCONV_FULL_OUTPUT)
1232
		    {
1233
		      /* We should not use the translation at all, it
1234
			 is incorrectly encoded.  */
1235
		      __libc_lock_unlock (lock);
1236
		      return NULL;
1237
		    }
1238
1239
		  inbuf = (const unsigned char *) result;
1240
# else
1241
#  if HAVE_ICONV
1242
		  const char *inptr = (const char *) inbuf;
1243
		  size_t inleft = resultlen;
1244
		  char *outptr = (char *) outbuf;
1245
		  size_t outleft;
1246
1247
		  if (freemem_size < sizeof (size_t))
1248
		    goto resize_freemem;
1249
1250
		  outleft = freemem_size - sizeof (size_t);
1251
		  if (iconv (convd->conv,
1252
			     (ICONV_CONST char **) &inptr, &inleft,
1253
			     &outptr, &outleft)
1254
		      != (size_t) (-1))
1255
		    {
1256
		      outbuf = (unsigned char *) outptr;
1257
		      break;
1258
		    }
1259
		  if (errno != E2BIG)
1260
		    {
1261
		      __libc_lock_unlock (lock);
1262
		      return NULL;
1263
		    }
1264
#  endif
1265
# endif
1266
1267
		resize_freemem:
1268
		  /* We must allocate a new buffer or resize the old one.  */
1269
		  if (malloc_count > 0)
1270
		    {
1271
		      ++malloc_count;
1272
		      freemem_size = malloc_count * INITIAL_BLOCK_SIZE;
1273
		      newmem = (transmem_block_t *) realloc (transmem_list,
1274
							     freemem_size);
1275
# ifdef _LIBC
1276
		      if (newmem != NULL)
1277
			transmem_list = transmem_list->next;
1278
		      else
1279
			{
1280
			  struct transmem_list *old = transmem_list;
1281
1282
			  transmem_list = transmem_list->next;
1283
			  free (old);
1284
			}
1285
# endif
1286
		    }
1287
		  else
1288
		    {
1289
		      malloc_count = 1;
1290
		      freemem_size = INITIAL_BLOCK_SIZE;
1291
		      newmem = (transmem_block_t *) malloc (freemem_size);
1292
		    }
1293
		  if (__builtin_expect (newmem == NULL, 0))
1294
		    {
1295
		      freemem = NULL;
1296
		      freemem_size = 0;
1297
		      __libc_lock_unlock (lock);
1298
		      return (char *) -1;
1299
		    }
1300
1301
# ifdef _LIBC
1302
		  /* Add the block to the list of blocks we have to free
1303
		     at some point.  */
1304
		  newmem->next = transmem_list;
1305
		  transmem_list = newmem;
1306
1307
		  freemem = (unsigned char *) newmem->data;
1308
		  freemem_size -= offsetof (struct transmem_list, data);
1309
# else
1310
		  transmem_list = newmem;
1311
		  freemem = newmem;
1312
# endif
1313
1314
		  outbuf = freemem + sizeof (size_t);
1315
		}
1316
1317
	      /* We have now in our buffer a converted string.  Put this
1318
		 into the table of conversions.  */
1319
	      *(size_t *) freemem = outbuf - freemem - sizeof (size_t);
1320
	      convd->conv_tab[act] = (char *) freemem;
1321
	      /* Shrink freemem, but keep it aligned.  */
1322
	      freemem_size -= outbuf - freemem;
1323
	      freemem = outbuf;
1324
	      freemem += freemem_size & (alignof (size_t) - 1);
1325
	      freemem_size = freemem_size & ~ (alignof (size_t) - 1);
1326
1327
	      __libc_lock_unlock (lock);
1328
	    }
1329
1330
	  /* Now convd->conv_tab[act] contains the translation of all
1331
	     the plural variants.  */
1332
	  result = convd->conv_tab[act] + sizeof (size_t);
1333
	  resultlen = *(size_t *) convd->conv_tab[act];
1334
	}
1335
    }
1336
1337
  /* The result string is converted.  */
1338
1339
#endif /* _LIBC || HAVE_ICONV */
1340
1341
  *lengthp = resultlen;
1342
  return result;
1343
}
1344
1345
1346
/* Look up a plural variant.  */
1347
static char *
1348
internal_function
1349
plural_lookup (struct loaded_l10nfile *domain, unsigned long int n,
1350
	       const char *translation, size_t translation_len)
1351
{
1352
  struct loaded_domain *domaindata = (struct loaded_domain *) domain->data;
1353
  unsigned long int index;
1354
  const char *p;
1355
1356
  index = plural_eval (domaindata->plural, n);
1357
  if (index >= domaindata->nplurals)
1358
    /* This should never happen.  It means the plural expression and the
1359
       given maximum value do not match.  */
1360
    index = 0;
1361
1362
  /* Skip INDEX strings at TRANSLATION.  */
1363
  p = translation;
1364
  while (index-- > 0)
1365
    {
1366
#ifdef _LIBC
1367
      p = __rawmemchr (p, '\0');
1368
#else
1369
      p = strchr (p, '\0');
1370
#endif
1371
      /* And skip over the NUL byte.  */
1372
      p++;
1373
1374
      if (p >= translation + translation_len)
1375
	/* This should never happen.  It means the plural expression
1376
	   evaluated to a value larger than the number of variants
1377
	   available for MSGID1.  */
1378
	return (char *) translation;
1379
    }
1380
  return (char *) p;
1381
}
1382
1383
#ifndef _LIBC
1384
/* Return string representation of locale CATEGORY.  */
1385
static const char *
1386
internal_function
1387
category_to_name (int category)
1388
{
1389
  const char *retval;
1390
1391
  switch (category)
1392
  {
1393
#ifdef LC_COLLATE
1394
  case LC_COLLATE:
1395
    retval = "LC_COLLATE";
1396
    break;
1397
#endif
1398
#ifdef LC_CTYPE
1399
  case LC_CTYPE:
1400
    retval = "LC_CTYPE";
1401
    break;
1402
#endif
1403
#ifdef LC_MONETARY
1404
  case LC_MONETARY:
1405
    retval = "LC_MONETARY";
1406
    break;
1407
#endif
1408
#ifdef LC_NUMERIC
1409
  case LC_NUMERIC:
1410
    retval = "LC_NUMERIC";
1411
    break;
1412
#endif
1413
#ifdef LC_TIME
1414
  case LC_TIME:
1415
    retval = "LC_TIME";
1416
    break;
1417
#endif
1418
#ifdef LC_MESSAGES
1419
  case LC_MESSAGES:
1420
    retval = "LC_MESSAGES";
1421
    break;
1422
#endif
1423
#ifdef LC_RESPONSE
1424
  case LC_RESPONSE:
1425
    retval = "LC_RESPONSE";
1426
    break;
1427
#endif
1428
#ifdef LC_ALL
1429
  case LC_ALL:
1430
    /* This might not make sense but is perhaps better than any other
1431
       value.  */
1432
    retval = "LC_ALL";
1433
    break;
1434
#endif
1435
  default:
1436
    /* If you have a better idea for a default value let me know.  */
1437
    retval = "LC_XXX";
1438
  }
1439
1440
  return retval;
1441
}
1442
#endif
1443
1444
/* Guess value of current locale from value of the environment variables
1445
   or system-dependent defaults.  */
1446
static const char *
1447
internal_function
1448
#ifdef IN_LIBGLOCALE
1449
guess_category_value (int category, const char *categoryname,
1450
		      const char *locale)
1451
1452
#else
1453
guess_category_value (int category, const char *categoryname)
1454
#endif
1455
{
1456
  const char *language;
1457
#ifndef IN_LIBGLOCALE
1458
  const char *locale;
1459
# ifndef _LIBC
1460
  const char *language_default;
1461
  int locale_defaulted;
1462
# endif
1463
#endif
1464
1465
  /* We use the settings in the following order:
1466
     1. The value of the environment variable 'LANGUAGE'.  This is a GNU
1467
        extension.  Its value can be a colon-separated list of locale names.
1468
     2. The value of the environment variable 'LC_ALL', 'LC_xxx', or 'LANG'.
1469
        More precisely, the first among these that is set to a non-empty value.
1470
        This is how POSIX specifies it.  The value is a single locale name.
1471
     3. A system-dependent preference list of languages.  Its value can be a
1472
        colon-separated list of locale names.
1473
     4. A system-dependent default locale name.
1474
     This way:
1475
       - System-dependent settings can be overridden by environment variables.
1476
       - If the system provides both a list of languages and a default locale,
1477
         the former is used.  */
1478
1479
#ifndef IN_LIBGLOCALE
1480
  /* Fetch the locale name, through the POSIX method of looking to `LC_ALL',
1481
     `LC_xxx', and `LANG'.  On some systems this can be done by the
1482
     `setlocale' function itself.  */
1483
# ifdef _LIBC
1484
  locale = __current_locale_name (category);
1485
# else
1486
#  if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS
1487
  /* The __names field is not public glibc API and must therefore not be used
1488
     in code that is installed in public locations.  */
1489
  locale_t thread_locale = uselocale (NULL);
1490
  if (thread_locale != LC_GLOBAL_LOCALE)
1491
    {
1492
      locale = thread_locale->__names[category];
1493
      locale_defaulted = 0;
1494
    }
1495
  else
1496
#  endif
1497
    {
1498
      locale = _nl_locale_name_posix (category, categoryname);
1499
      locale_defaulted = 0;
1500
      if (locale == NULL)
1501
	{
1502
	  locale = _nl_locale_name_default ();
1503
	  locale_defaulted = 1;
1504
	}
1505
    }
1506
# endif
1507
#endif
1508
1509
  /* Ignore LANGUAGE and its system-dependent analogon if the locale is set
1510
     to "C" because
1511
     1. "C" locale usually uses the ASCII encoding, and most international
1512
	messages use non-ASCII characters. These characters get displayed
1513
	as question marks (if using glibc's iconv()) or as invalid 8-bit
1514
	characters (because other iconv()s refuse to convert most non-ASCII
1515
	characters to ASCII). In any case, the output is ugly.
1516
     2. The precise output of some programs in the "C" locale is specified
1517
	by POSIX and should not depend on environment variables like
1518
	"LANGUAGE" or system-dependent information.  We allow such programs
1519
        to use gettext().  */
1520
  if (strcmp (locale, "C") == 0)
1521
    return locale;
1522
1523
  /* The highest priority value is the value of the 'LANGUAGE' environment
1524
     variable.  */
1525
  language = getenv ("LANGUAGE");
1526
  if (language != NULL && language[0] != '\0')
1527
    return language;
1528
#if !defined IN_LIBGLOCALE && !defined _LIBC
1529
  /* The next priority value is the locale name, if not defaulted.  */
1530
  if (locale_defaulted)
1531
    {
1532
      /* The next priority value is the default language preferences list. */
1533
      language_default = _nl_language_preferences_default ();
1534
      if (language_default != NULL)
1535
        return language_default;
1536
    }
1537
  /* The least priority value is the locale name, if defaulted.  */
1538
#endif
1539
  return locale;
1540
}
1541
1542
#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE
1543
/* Returns the output charset.  */
1544
static const char *
1545
internal_function
1546
get_output_charset (struct binding *domainbinding)
1547
{
1548
  /* The output charset should normally be determined by the locale.  But
1549
     sometimes the locale is not used or not correctly set up, so we provide
1550
     a possibility for the user to override this: the OUTPUT_CHARSET
1551
     environment variable.  Moreover, the value specified through
1552
     bind_textdomain_codeset overrides both.  */
1553
  if (domainbinding != NULL && domainbinding->codeset != NULL)
1554
    return domainbinding->codeset;
1555
  else
1556
    {
1557
      /* For speed reasons, we look at the value of OUTPUT_CHARSET only
1558
	 once.  This is a user variable that is not supposed to change
1559
	 during a program run.  */
1560
      static char *output_charset_cache;
1561
      static int output_charset_cached;
1562
1563
      if (!output_charset_cached)
1564
	{
1565
	  const char *value = getenv ("OUTPUT_CHARSET");
1566
1567
	  if (value != NULL && value[0] != '\0')
1568
	    {
1569
	      size_t len = strlen (value) + 1;
1570
	      char *value_copy = (char *) malloc (len);
1571
1572
	      if (value_copy != NULL)
1573
		memcpy (value_copy, value, len);
1574
	      output_charset_cache = value_copy;
1575
	    }
1576
	  output_charset_cached = 1;
1577
	}
1578
1579
      if (output_charset_cache != NULL)
1580
	return output_charset_cache;
1581
      else
1582
	{
1583
# ifdef _LIBC
1584
	  return _NL_CURRENT (LC_CTYPE, CODESET);
1585
# else
1586
#  if HAVE_ICONV
1587
	  extern const char *locale_charset (void);
1588
	  return locale_charset ();
1589
#  endif
1590
# endif
1591
	}
1592
    }
1593
}
1594
#endif
1595
1596
/* @@ begin of epilog @@ */
1597
1598
/* We don't want libintl.a to depend on any other library.  So we
1599
   avoid the non-standard function stpcpy.  In GNU C Library this
1600
   function is available, though.  Also allow the symbol HAVE_STPCPY
1601
   to be defined.  */
1602
#if !_LIBC && !HAVE_STPCPY
1603
static char *
1604
stpcpy (char *dest, const char *src)
1605
{
1606
  while ((*dest++ = *src++) != '\0')
1607
    /* Do nothing. */ ;
1608
  return dest - 1;
1609
}
1610
#endif
1611
1612
#if !_LIBC && !HAVE_MEMPCPY
1613
static void *
1614
mempcpy (void *dest, const void *src, size_t n)
1615
{
1616
  return (void *) ((char *) memcpy (dest, src, n) + n);
1617
}
1618
#endif
1619
1620
1621
#ifdef _LIBC
1622
/* If we want to free all resources we have to do some work at
1623
   program's end.  */
1624
libc_freeres_fn (free_mem)
1625
{
1626
  void *old;
1627
1628
  while (_nl_domain_bindings != NULL)
1629
    {
1630
      struct binding *oldp = _nl_domain_bindings;
1631
      _nl_domain_bindings = _nl_domain_bindings->next;
1632
      if (oldp->dirname != _nl_default_dirname)
1633
	/* Yes, this is a pointer comparison.  */
1634
	free (oldp->dirname);
1635
      free (oldp->codeset);
1636
      free (oldp);
1637
    }
1638
1639
  if (_nl_current_default_domain != _nl_default_default_domain)
1640
    /* Yes, again a pointer comparison.  */
1641
    free ((char *) _nl_current_default_domain);
1642
1643
  /* Remove the search tree with the known translations.  */
1644
  __tdestroy (root, free);
1645
  root = NULL;
1646
1647
  while (transmem_list != NULL)
1648
    {
1649
      old = transmem_list;
1650
      transmem_list = transmem_list->next;
1651
      free (old);
1652
    }
1653
}
1654
#endif
(-)a/intl/dcngettext.c (-57 lines)
Lines 1-57 Link Here
1
/* Implementation of the dcngettext(3) function.
2
   Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include "gettextP.h"
24
#ifdef _LIBC
25
# include <libintl.h>
26
#else
27
# include "libgnuintl.h"
28
#endif
29
30
/* @@ end of prolog @@ */
31
32
/* Names for the libintl functions are a problem.  They must not clash
33
   with existing names and they should follow ANSI C.  But this source
34
   code is also used in GNU C Library where the names have a __
35
   prefix.  So we have to make a difference here.  */
36
#ifdef _LIBC
37
# define DCNGETTEXT __dcngettext
38
# define DCIGETTEXT __dcigettext
39
#else
40
# define DCNGETTEXT libintl_dcngettext
41
# define DCIGETTEXT libintl_dcigettext
42
#endif
43
44
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
45
   locale.  */
46
char *
47
DCNGETTEXT (const char *domainname,
48
	    const char *msgid1, const char *msgid2, unsigned long int n,
49
	    int category)
50
{
51
  return DCIGETTEXT (domainname, msgid1, msgid2, 1, n, category);
52
}
53
54
#ifdef _LIBC
55
/* Alias for function name in GNU C Library.  */
56
weak_alias (__dcngettext, dcngettext);
57
#endif
(-)a/intl/dgettext.c (-58 lines)
Lines 1-58 Link Here
1
/* Implementation of the dgettext(3) function.
2
   Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include "gettextP.h"
24
25
#include <locale.h>
26
27
#ifdef _LIBC
28
# include <libintl.h>
29
#else
30
# include "libgnuintl.h"
31
#endif
32
33
/* @@ end of prolog @@ */
34
35
/* Names for the libintl functions are a problem.  They must not clash
36
   with existing names and they should follow ANSI C.  But this source
37
   code is also used in GNU C Library where the names have a __
38
   prefix.  So we have to make a difference here.  */
39
#ifdef _LIBC
40
# define DGETTEXT __dgettext
41
# define DCGETTEXT INTUSE(__dcgettext)
42
#else
43
# define DGETTEXT libintl_dgettext
44
# define DCGETTEXT libintl_dcgettext
45
#endif
46
47
/* Look up MSGID in the DOMAINNAME message catalog of the current
48
   LC_MESSAGES locale.  */
49
char *
50
DGETTEXT (const char *domainname, const char *msgid)
51
{
52
  return DCGETTEXT (domainname, msgid, LC_MESSAGES);
53
}
54
55
#ifdef _LIBC
56
/* Alias for function name in GNU C Library.  */
57
weak_alias (__dgettext, dgettext);
58
#endif
(-)a/intl/dngettext.c (-59 lines)
Lines 1-59 Link Here
1
/* Implementation of the dngettext(3) function.
2
   Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include "gettextP.h"
24
25
#include <locale.h>
26
27
#ifdef _LIBC
28
# include <libintl.h>
29
#else
30
# include "libgnuintl.h"
31
#endif
32
33
/* @@ end of prolog @@ */
34
35
/* Names for the libintl functions are a problem.  They must not clash
36
   with existing names and they should follow ANSI C.  But this source
37
   code is also used in GNU C Library where the names have a __
38
   prefix.  So we have to make a difference here.  */
39
#ifdef _LIBC
40
# define DNGETTEXT __dngettext
41
# define DCNGETTEXT __dcngettext
42
#else
43
# define DNGETTEXT libintl_dngettext
44
# define DCNGETTEXT libintl_dcngettext
45
#endif
46
47
/* Look up MSGID in the DOMAINNAME message catalog of the current
48
   LC_MESSAGES locale and skip message according to the plural form.  */
49
char *
50
DNGETTEXT (const char *domainname,
51
	   const char *msgid1, const char *msgid2, unsigned long int n)
52
{
53
  return DCNGETTEXT (domainname, msgid1, msgid2, n, LC_MESSAGES);
54
}
55
56
#ifdef _LIBC
57
/* Alias for function name in GNU C Library.  */
58
weak_alias (__dngettext, dngettext);
59
#endif
(-)a/intl/eval-plural.h (-108 lines)
Lines 1-108 Link Here
1
/* Plural expression evaluation.
2
   Copyright (C) 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef STATIC
20
#define STATIC static
21
#endif
22
23
/* Evaluate the plural expression and return an index value.  */
24
STATIC
25
unsigned long int
26
internal_function
27
plural_eval (struct expression *pexp, unsigned long int n)
28
{
29
  switch (pexp->nargs)
30
    {
31
    case 0:
32
      switch (pexp->operation)
33
	{
34
	case var:
35
	  return n;
36
	case num:
37
	  return pexp->val.num;
38
	default:
39
	  break;
40
	}
41
      /* NOTREACHED */
42
      break;
43
    case 1:
44
      {
45
	/* pexp->operation must be lnot.  */
46
	unsigned long int arg = plural_eval (pexp->val.args[0], n);
47
	return ! arg;
48
      }
49
    case 2:
50
      {
51
	unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
52
	if (pexp->operation == lor)
53
	  return leftarg || plural_eval (pexp->val.args[1], n);
54
	else if (pexp->operation == land)
55
	  return leftarg && plural_eval (pexp->val.args[1], n);
56
	else
57
	  {
58
	    unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
59
60
	    switch (pexp->operation)
61
	      {
62
	      case mult:
63
		return leftarg * rightarg;
64
	      case divide:
65
#if !INTDIV0_RAISES_SIGFPE
66
		if (rightarg == 0)
67
		  raise (SIGFPE);
68
#endif
69
		return leftarg / rightarg;
70
	      case module:
71
#if !INTDIV0_RAISES_SIGFPE
72
		if (rightarg == 0)
73
		  raise (SIGFPE);
74
#endif
75
		return leftarg % rightarg;
76
	      case plus:
77
		return leftarg + rightarg;
78
	      case minus:
79
		return leftarg - rightarg;
80
	      case less_than:
81
		return leftarg < rightarg;
82
	      case greater_than:
83
		return leftarg > rightarg;
84
	      case less_or_equal:
85
		return leftarg <= rightarg;
86
	      case greater_or_equal:
87
		return leftarg >= rightarg;
88
	      case equal:
89
		return leftarg == rightarg;
90
	      case not_equal:
91
		return leftarg != rightarg;
92
	      default:
93
		break;
94
	      }
95
	  }
96
	/* NOTREACHED */
97
	break;
98
      }
99
    case 3:
100
      {
101
	/* pexp->operation must be qmop.  */
102
	unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
103
	return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
104
      }
105
    }
106
  /* NOTREACHED */
107
  return 0;
108
}
(-)a/intl/explodename.c (-133 lines)
Lines 1-133 Link Here
1
/* Copyright (C) 1995-1998, 2000-2001, 2003, 2005 Free Software Foundation, Inc.
2
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include <stdlib.h>
24
#include <string.h>
25
#include <sys/types.h>
26
27
#include "loadinfo.h"
28
29
/* On some strange systems still no definition of NULL is found.  Sigh!  */
30
#ifndef NULL
31
# if defined __STDC__ && __STDC__
32
#  define NULL ((void *) 0)
33
# else
34
#  define NULL 0
35
# endif
36
#endif
37
38
/* @@ end of prolog @@ */
39
40
/* Split a locale name NAME into a leading language part and all the
41
   rest.  Return a pointer to the first character after the language,
42
   i.e. to the first byte of the rest.  */
43
static char *_nl_find_language (const char *name);
44
45
static char *
46
_nl_find_language (const char *name)
47
{
48
  while (name[0] != '\0' && name[0] != '_' && name[0] != '@' && name[0] != '.')
49
    ++name;
50
51
  return (char *) name;
52
}
53
54
55
int
56
_nl_explode_name (char *name,
57
		  const char **language, const char **modifier,
58
		  const char **territory, const char **codeset,
59
		  const char **normalized_codeset)
60
{
61
  char *cp;
62
  int mask;
63
64
  *modifier = NULL;
65
  *territory = NULL;
66
  *codeset = NULL;
67
  *normalized_codeset = NULL;
68
69
  /* Now we determine the single parts of the locale name.  First
70
     look for the language.  Termination symbols are `_', '.', and `@'.  */
71
  mask = 0;
72
  *language = cp = name;
73
  cp = _nl_find_language (*language);
74
75
  if (*language == cp)
76
    /* This does not make sense: language has to be specified.  Use
77
       this entry as it is without exploding.  Perhaps it is an alias.  */
78
    cp = strchr (*language, '\0');
79
  else
80
    {
81
      if (cp[0] == '_')
82
	{
83
	  /* Next is the territory.  */
84
	  cp[0] = '\0';
85
	  *territory = ++cp;
86
87
	  while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@')
88
	    ++cp;
89
90
	  mask |= XPG_TERRITORY;
91
	}
92
93
      if (cp[0] == '.')
94
	{
95
	  /* Next is the codeset.  */
96
	  cp[0] = '\0';
97
	  *codeset = ++cp;
98
99
	  while (cp[0] != '\0' && cp[0] != '@')
100
	    ++cp;
101
102
	  mask |= XPG_CODESET;
103
104
	  if (*codeset != cp && (*codeset)[0] != '\0')
105
	    {
106
	      *normalized_codeset = _nl_normalize_codeset (*codeset,
107
							   cp - *codeset);
108
	      if (strcmp (*codeset, *normalized_codeset) == 0)
109
		free ((char *) *normalized_codeset);
110
	      else
111
		mask |= XPG_NORM_CODESET;
112
	    }
113
	}
114
    }
115
116
  if (cp[0] == '@')
117
    {
118
      /* Next is the modifier.  */
119
      cp[0] = '\0';
120
      *modifier = ++cp;
121
122
      if (cp[0] != '\0')
123
	mask |= XPG_MODIFIER;
124
    }
125
126
  if (*territory != NULL && (*territory)[0] == '\0')
127
    mask &= ~XPG_TERRITORY;
128
129
  if (*codeset != NULL && (*codeset)[0] == '\0')
130
    mask &= ~XPG_CODESET;
131
132
  return mask;
133
}
(-)a/intl/export.h (-6 lines)
Lines 1-6 Link Here
1
2
#if @HAVE_VISIBILITY@ && BUILDING_LIBINTL
3
#define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default")))
4
#else
5
#define LIBINTL_DLL_EXPORTED
6
#endif
(-)a/intl/finddomain.c (-208 lines)
Lines 1-208 Link Here
1
/* Handle list of needed message catalogs
2
   Copyright (C) 1995-1999, 2000-2001, 2003-2006 Free Software Foundation, Inc.
3
   Written by Ulrich Drepper <drepper@gnu.org>, 1995.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifdef HAVE_CONFIG_H
21
# include <config.h>
22
#endif
23
24
#include <stdio.h>
25
#include <sys/types.h>
26
#include <stdlib.h>
27
#include <string.h>
28
29
#if defined HAVE_UNISTD_H || defined _LIBC
30
# include <unistd.h>
31
#endif
32
33
#include "gettextP.h"
34
#ifdef _LIBC
35
# include <libintl.h>
36
#else
37
# include "libgnuintl.h"
38
#endif
39
40
/* Handle multi-threaded applications.  */
41
#ifdef _LIBC
42
# include <bits/libc-lock.h>
43
# define gl_rwlock_define_initialized __libc_rwlock_define_initialized
44
# define gl_rwlock_rdlock __libc_rwlock_rdlock
45
# define gl_rwlock_wrlock __libc_rwlock_wrlock
46
# define gl_rwlock_unlock __libc_rwlock_unlock
47
#else
48
# include "lock.h"
49
#endif
50
51
/* @@ end of prolog @@ */
52
/* List of already loaded domains.  */
53
static struct loaded_l10nfile *_nl_loaded_domains;
54
55
56
/* Return a data structure describing the message catalog described by
57
   the DOMAINNAME and CATEGORY parameters with respect to the currently
58
   established bindings.  */
59
struct loaded_l10nfile *
60
internal_function
61
_nl_find_domain (const char *dirname, char *locale,
62
		 const char *domainname, struct binding *domainbinding)
63
{
64
  struct loaded_l10nfile *retval;
65
  const char *language;
66
  const char *modifier;
67
  const char *territory;
68
  const char *codeset;
69
  const char *normalized_codeset;
70
  const char *alias_value;
71
  int mask;
72
73
  /* LOCALE can consist of up to four recognized parts for the XPG syntax:
74
75
		language[_territory][.codeset][@modifier]
76
77
     Beside the first part all of them are allowed to be missing.  If
78
     the full specified locale is not found, the less specific one are
79
     looked for.  The various parts will be stripped off according to
80
     the following order:
81
		(1) codeset
82
		(2) normalized codeset
83
		(3) territory
84
		(4) modifier
85
   */
86
87
  /* We need to protect modifying the _NL_LOADED_DOMAINS data.  */
88
  gl_rwlock_define_initialized (static, lock);
89
  gl_rwlock_rdlock (lock);
90
91
  /* If we have already tested for this locale entry there has to
92
     be one data set in the list of loaded domains.  */
93
  retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
94
			       strlen (dirname) + 1, 0, locale, NULL, NULL,
95
			       NULL, NULL, domainname, 0);
96
97
  gl_rwlock_unlock (lock);
98
99
  if (retval != NULL)
100
    {
101
      /* We know something about this locale.  */
102
      int cnt;
103
104
      if (retval->decided <= 0)
105
	_nl_load_domain (retval, domainbinding);
106
107
      if (retval->data != NULL)
108
	return retval;
109
110
      for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
111
	{
112
	  if (retval->successor[cnt]->decided <= 0)
113
	    _nl_load_domain (retval->successor[cnt], domainbinding);
114
115
	  if (retval->successor[cnt]->data != NULL)
116
	    break;
117
	}
118
119
      return retval;
120
      /* NOTREACHED */
121
    }
122
123
  /* See whether the locale value is an alias.  If yes its value
124
     *overwrites* the alias name.  No test for the original value is
125
     done.  */
126
  alias_value = _nl_expand_alias (locale);
127
  if (alias_value != NULL)
128
    {
129
#if defined _LIBC || defined HAVE_STRDUP
130
      locale = strdup (alias_value);
131
      if (locale == NULL)
132
	return NULL;
133
#else
134
      size_t len = strlen (alias_value) + 1;
135
      locale = (char *) malloc (len);
136
      if (locale == NULL)
137
	return NULL;
138
139
      memcpy (locale, alias_value, len);
140
#endif
141
    }
142
143
  /* Now we determine the single parts of the locale name.  First
144
     look for the language.  Termination symbols are `_', '.', and `@'.  */
145
  mask = _nl_explode_name (locale, &language, &modifier, &territory,
146
			   &codeset, &normalized_codeset);
147
148
  /* We need to protect modifying the _NL_LOADED_DOMAINS data.  */
149
  gl_rwlock_wrlock (lock);
150
151
  /* Create all possible locale entries which might be interested in
152
     generalization.  */
153
  retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
154
			       strlen (dirname) + 1, mask, language, territory,
155
			       codeset, normalized_codeset, modifier,
156
			       domainname, 1);
157
158
  gl_rwlock_unlock (lock);
159
160
  if (retval == NULL)
161
    /* This means we are out of core.  */
162
    return NULL;
163
164
  if (retval->decided <= 0)
165
    _nl_load_domain (retval, domainbinding);
166
  if (retval->data == NULL)
167
    {
168
      int cnt;
169
      for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
170
	{
171
	  if (retval->successor[cnt]->decided <= 0)
172
	    _nl_load_domain (retval->successor[cnt], domainbinding);
173
	  if (retval->successor[cnt]->data != NULL)
174
	    break;
175
	}
176
    }
177
178
  /* The room for an alias was dynamically allocated.  Free it now.  */
179
  if (alias_value != NULL)
180
    free (locale);
181
182
  /* The space for normalized_codeset is dynamically allocated.  Free it.  */
183
  if (mask & XPG_NORM_CODESET)
184
    free ((void *) normalized_codeset);
185
186
  return retval;
187
}
188
189
190
#ifdef _LIBC
191
/* This is called from iconv/gconv_db.c's free_mem, as locales must
192
   be freed before freeing gconv steps arrays.  */
193
void __libc_freeres_fn_section
194
_nl_finddomain_subfreeres ()
195
{
196
  struct loaded_l10nfile *runp = _nl_loaded_domains;
197
198
  while (runp != NULL)
199
    {
200
      struct loaded_l10nfile *here = runp;
201
      if (runp->data != NULL)
202
	_nl_unload_domain ((struct loaded_domain *) runp->data);
203
      runp = runp->next;
204
      free ((char *) here->filename);
205
      free (here);
206
    }
207
}
208
#endif
(-)a/intl/gettext.c (-63 lines)
Lines 1-63 Link Here
1
/* Implementation of gettext(3) function.
2
   Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#ifdef _LIBC
24
# define __need_NULL
25
# include <stddef.h>
26
#else
27
# include <stdlib.h>		/* Just for NULL.  */
28
#endif
29
30
#include "gettextP.h"
31
#ifdef _LIBC
32
# include <libintl.h>
33
#else
34
# include "libgnuintl.h"
35
#endif
36
37
/* @@ end of prolog @@ */
38
39
/* Names for the libintl functions are a problem.  They must not clash
40
   with existing names and they should follow ANSI C.  But this source
41
   code is also used in GNU C Library where the names have a __
42
   prefix.  So we have to make a difference here.  */
43
#ifdef _LIBC
44
# define GETTEXT __gettext
45
# define DCGETTEXT INTUSE(__dcgettext)
46
#else
47
# define GETTEXT libintl_gettext
48
# define DCGETTEXT libintl_dcgettext
49
#endif
50
51
/* Look up MSGID in the current default message catalog for the current
52
   LC_MESSAGES locale.  If not found, returns MSGID itself (the default
53
   text).  */
54
char *
55
GETTEXT (const char *msgid)
56
{
57
  return DCGETTEXT (NULL, msgid, LC_MESSAGES);
58
}
59
60
#ifdef _LIBC
61
/* Alias for function name in GNU C Library.  */
62
weak_alias (__gettext, gettext);
63
#endif
(-)a/intl/gettextP.h (-247 lines)
Lines 1-247 Link Here
1
/* Header describing internals of libintl library.
2
   Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
3
   Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifndef _GETTEXTP_H
21
#define _GETTEXTP_H
22
23
#include <stddef.h>		/* Get size_t.  */
24
25
#ifdef _LIBC
26
# include "../iconv/gconv_int.h"
27
#else
28
# if HAVE_ICONV
29
#  include <iconv.h>
30
# endif
31
#endif
32
33
#ifdef _LIBC
34
extern char *__gettext (const char *__msgid);
35
extern char *__dgettext (const char *__domainname, const char *__msgid);
36
extern char *__dcgettext (const char *__domainname, const char *__msgid,
37
			  int __category);
38
extern char *__ngettext (const char *__msgid1, const char *__msgid2,
39
			 unsigned long int __n);
40
extern char *__dngettext (const char *__domainname,
41
			  const char *__msgid1, const char *__msgid2,
42
			  unsigned long int n);
43
extern char *__dcngettext (const char *__domainname,
44
			   const char *__msgid1, const char *__msgid2,
45
			   unsigned long int __n, int __category);
46
extern char *__dcigettext (const char *__domainname,
47
			   const char *__msgid1, const char *__msgid2,
48
			   int __plural, unsigned long int __n,
49
			   int __category);
50
extern char *__textdomain (const char *__domainname);
51
extern char *__bindtextdomain (const char *__domainname,
52
			       const char *__dirname);
53
extern char *__bind_textdomain_codeset (const char *__domainname,
54
					const char *__codeset);
55
extern void _nl_finddomain_subfreeres (void) attribute_hidden;
56
extern void _nl_unload_domain (struct loaded_domain *__domain)
57
     internal_function attribute_hidden;
58
#else
59
/* Declare the exported libintl_* functions, in a way that allows us to
60
   call them under their real name.  */
61
# undef _INTL_REDIRECT_INLINE
62
# undef _INTL_REDIRECT_MACROS
63
# define _INTL_REDIRECT_MACROS
64
# include "libgnuintl.h"
65
# ifdef IN_LIBGLOCALE
66
extern char *gl_dcigettext (const char *__domainname,
67
			    const char *__msgid1, const char *__msgid2,
68
			    int __plural, unsigned long int __n,
69
			    int __category,
70
			    const char *__localename, const char *__encoding);
71
# else
72
extern char *libintl_dcigettext (const char *__domainname,
73
				 const char *__msgid1, const char *__msgid2,
74
				 int __plural, unsigned long int __n,
75
				 int __category);
76
# endif
77
#endif
78
79
#include "loadinfo.h"
80
81
#include "gmo.h"		/* Get nls_uint32.  */
82
83
/* @@ end of prolog @@ */
84
85
#ifndef internal_function
86
# define internal_function
87
#endif
88
89
#ifndef attribute_hidden
90
# define attribute_hidden
91
#endif
92
93
/* Tell the compiler when a conditional or integer expression is
94
   almost always true or almost always false.  */
95
#ifndef HAVE_BUILTIN_EXPECT
96
# define __builtin_expect(expr, val) (expr)
97
#endif
98
99
#ifndef W
100
# define W(flag, data) ((flag) ? SWAP (data) : (data))
101
#endif
102
103
104
#ifdef _LIBC
105
# include <byteswap.h>
106
# define SWAP(i) bswap_32 (i)
107
#else
108
static inline nls_uint32
109
SWAP (i)
110
     nls_uint32 i;
111
{
112
  return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
113
}
114
#endif
115
116
117
/* In-memory representation of system dependent string.  */
118
struct sysdep_string_desc
119
{
120
  /* Length of addressed string, including the trailing NUL.  */
121
  size_t length;
122
  /* Pointer to addressed string.  */
123
  const char *pointer;
124
};
125
126
/* Cache of translated strings after charset conversion.
127
   Note: The strings are converted to the target encoding only on an as-needed
128
   basis.  */
129
struct converted_domain
130
{
131
  /* The target encoding name.  */
132
  const char *encoding;
133
  /* The descriptor for conversion from the message catalog's encoding to
134
     this target encoding.  */
135
#ifdef _LIBC
136
  __gconv_t conv;
137
#else
138
# if HAVE_ICONV
139
  iconv_t conv;
140
# endif
141
#endif
142
  /* The table of translated strings after charset conversion.  */
143
  char **conv_tab;
144
};
145
146
/* The representation of an opened message catalog.  */
147
struct loaded_domain
148
{
149
  /* Pointer to memory containing the .mo file.  */
150
  const char *data;
151
  /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
152
  int use_mmap;
153
  /* Size of mmap()ed memory.  */
154
  size_t mmap_size;
155
  /* 1 if the .mo file uses a different endianness than this machine.  */
156
  int must_swap;
157
  /* Pointer to additional malloc()ed memory.  */
158
  void *malloced;
159
160
  /* Number of static strings pairs.  */
161
  nls_uint32 nstrings;
162
  /* Pointer to descriptors of original strings in the file.  */
163
  const struct string_desc *orig_tab;
164
  /* Pointer to descriptors of translated strings in the file.  */
165
  const struct string_desc *trans_tab;
166
167
  /* Number of system dependent strings pairs.  */
168
  nls_uint32 n_sysdep_strings;
169
  /* Pointer to descriptors of original sysdep strings.  */
170
  const struct sysdep_string_desc *orig_sysdep_tab;
171
  /* Pointer to descriptors of translated sysdep strings.  */
172
  const struct sysdep_string_desc *trans_sysdep_tab;
173
174
  /* Size of hash table.  */
175
  nls_uint32 hash_size;
176
  /* Pointer to hash table.  */
177
  const nls_uint32 *hash_tab;
178
  /* 1 if the hash table uses a different endianness than this machine.  */
179
  int must_swap_hash_tab;
180
181
  /* Cache of charset conversions of the translated strings.  */
182
  struct converted_domain *conversions;
183
  size_t nconversions;
184
185
  struct expression *plural;
186
  unsigned long int nplurals;
187
};
188
189
/* We want to allocate a string at the end of the struct.  But ISO C
190
   doesn't allow zero sized arrays.  */
191
#ifdef __GNUC__
192
# define ZERO 0
193
#else
194
# define ZERO 1
195
#endif
196
197
/* A set of settings bound to a message domain.  Used to store settings
198
   from bindtextdomain() and bind_textdomain_codeset().  */
199
struct binding
200
{
201
  struct binding *next;
202
  char *dirname;
203
  char *codeset;
204
  char domainname[ZERO];
205
};
206
207
/* A counter which is incremented each time some previous translations
208
   become invalid.
209
   This variable is part of the external ABI of the GNU libintl.  */
210
#ifdef IN_LIBGLOCALE
211
# include <glocale/config.h>
212
extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr;
213
#else
214
extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr;
215
#endif
216
217
#ifndef _LIBC
218
const char *_nl_language_preferences_default (void);
219
const char *_nl_locale_name_posix (int category, const char *categoryname);
220
const char *_nl_locale_name_default (void);
221
const char *_nl_locale_name (int category, const char *categoryname);
222
#endif
223
224
struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
225
					 const char *__domainname,
226
					 struct binding *__domainbinding)
227
     internal_function;
228
void _nl_load_domain (struct loaded_l10nfile *__domain,
229
		      struct binding *__domainbinding)
230
     internal_function;
231
232
#ifdef IN_LIBGLOCALE
233
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
234
		    struct binding *domainbinding, const char *encoding,
235
		    const char *msgid,
236
		    size_t *lengthp)
237
     internal_function;
238
#else
239
char *_nl_find_msg (struct loaded_l10nfile *domain_file,
240
		    struct binding *domainbinding, const char *msgid,
241
		    int convert, size_t *lengthp)
242
     internal_function;
243
#endif
244
245
/* @@ begin of epilog @@ */
246
247
#endif /* gettextP.h  */
(-)a/intl/gmo.h (-149 lines)
Lines 1-149 Link Here
1
/* Description of GNU message catalog format: general file layout.
2
   Copyright (C) 1995, 1997, 2000-2002, 2004 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _GETTEXT_H
20
#define _GETTEXT_H 1
21
22
#include <limits.h>
23
24
/* @@ end of prolog @@ */
25
26
/* The magic number of the GNU message catalog format.  */
27
#define _MAGIC 0x950412de
28
#define _MAGIC_SWAPPED 0xde120495
29
30
/* Revision number of the currently used .mo (binary) file format.  */
31
#define MO_REVISION_NUMBER 0
32
#define MO_REVISION_NUMBER_WITH_SYSDEP_I 1
33
34
/* The following contortions are an attempt to use the C preprocessor
35
   to determine an unsigned integral type that is 32 bits wide.  An
36
   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
37
   as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
38
   when cross-compiling.  */
39
40
#if __STDC__
41
# define UINT_MAX_32_BITS 4294967295U
42
#else
43
# define UINT_MAX_32_BITS 0xFFFFFFFF
44
#endif
45
46
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
47
   This should be valid for all systems GNU cares about because
48
   that doesn't include 16-bit systems, and only modern systems
49
   (that certainly have <limits.h>) have 64+-bit integral types.  */
50
51
#ifndef UINT_MAX
52
# define UINT_MAX UINT_MAX_32_BITS
53
#endif
54
55
#if UINT_MAX == UINT_MAX_32_BITS
56
typedef unsigned nls_uint32;
57
#else
58
# if USHRT_MAX == UINT_MAX_32_BITS
59
typedef unsigned short nls_uint32;
60
# else
61
#  if ULONG_MAX == UINT_MAX_32_BITS
62
typedef unsigned long nls_uint32;
63
#  else
64
  /* The following line is intended to throw an error.  Using #error is
65
     not portable enough.  */
66
  "Cannot determine unsigned 32-bit data type."
67
#  endif
68
# endif
69
#endif
70
71
72
/* Header for binary .mo file format.  */
73
struct mo_file_header
74
{
75
  /* The magic number.  */
76
  nls_uint32 magic;
77
  /* The revision number of the file format.  */
78
  nls_uint32 revision;
79
80
  /* The following are only used in .mo files with major revision 0 or 1.  */
81
82
  /* The number of strings pairs.  */
83
  nls_uint32 nstrings;
84
  /* Offset of table with start offsets of original strings.  */
85
  nls_uint32 orig_tab_offset;
86
  /* Offset of table with start offsets of translated strings.  */
87
  nls_uint32 trans_tab_offset;
88
  /* Size of hash table.  */
89
  nls_uint32 hash_tab_size;
90
  /* Offset of first hash table entry.  */
91
  nls_uint32 hash_tab_offset;
92
93
  /* The following are only used in .mo files with minor revision >= 1.  */
94
95
  /* The number of system dependent segments.  */
96
  nls_uint32 n_sysdep_segments;
97
  /* Offset of table describing system dependent segments.  */
98
  nls_uint32 sysdep_segments_offset;
99
  /* The number of system dependent strings pairs.  */
100
  nls_uint32 n_sysdep_strings;
101
  /* Offset of table with start offsets of original sysdep strings.  */
102
  nls_uint32 orig_sysdep_tab_offset;
103
  /* Offset of table with start offsets of translated sysdep strings.  */
104
  nls_uint32 trans_sysdep_tab_offset;
105
};
106
107
/* Descriptor for static string contained in the binary .mo file.  */
108
struct string_desc
109
{
110
  /* Length of addressed string, not including the trailing NUL.  */
111
  nls_uint32 length;
112
  /* Offset of string in file.  */
113
  nls_uint32 offset;
114
};
115
116
/* The following are only used in .mo files with minor revision >= 1.  */
117
118
/* Descriptor for system dependent string segment.  */
119
struct sysdep_segment
120
{
121
  /* Length of addressed string, including the trailing NUL.  */
122
  nls_uint32 length;
123
  /* Offset of string in file.  */
124
  nls_uint32 offset;
125
};
126
127
/* Descriptor for system dependent string.  */
128
struct sysdep_string
129
{
130
  /* Offset of static string segments in file.  */
131
  nls_uint32 offset;
132
  /* Alternating sequence of static and system dependent segments.
133
     The last segment is a static segment, including the trailing NUL.  */
134
  struct segment_pair
135
  {
136
    /* Size of static segment.  */
137
    nls_uint32 segsize;
138
    /* Reference to system dependent string segment, or ~0 at the end.  */
139
    nls_uint32 sysdepref;
140
  } segments[1];
141
};
142
143
/* Marker for the end of the segments[] array.  This has the value 0xFFFFFFFF,
144
   regardless whether 'int' is 16 bit, 32 bit, or 64 bit.  */
145
#define SEGMENTS_END ((nls_uint32) ~0)
146
147
/* @@ begin of epilog @@ */
148
149
#endif	/* gettext.h  */
(-)a/intl/hash-string.c (-51 lines)
Lines 1-51 Link Here
1
/* Implements a string hashing function.
2
   Copyright (C) 1995, 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Lesser General Public
7
   License as published by the Free Software Foundation; either
8
   version 2.1 of the License, or (at your option) any later version.
9
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Lesser General Public License for more details.
14
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
   Boston, MA 02110-1301, USA.  */
19
20
#ifdef HAVE_CONFIG_H
21
# include <config.h>
22
#endif
23
24
/* Specification.  */
25
#include "hash-string.h"
26
27
28
/* Defines the so called `hashpjw' function by P.J. Weinberger
29
   [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
30
   1986, 1987 Bell Telephone Laboratories, Inc.]  */
31
unsigned long int
32
__hash_string (const char *str_param)
33
{
34
  unsigned long int hval, g;
35
  const char *str = str_param;
36
37
  /* Compute the hash value for the given string.  */
38
  hval = 0;
39
  while (*str != '\0')
40
    {
41
      hval <<= 4;
42
      hval += (unsigned char) *str++;
43
      g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
44
      if (g != 0)
45
	{
46
	  hval ^= g >> (HASHWORDBITS - 8);
47
	  hval ^= g;
48
	}
49
    }
50
  return hval;
51
}
(-)a/intl/hash-string.h (-36 lines)
Lines 1-36 Link Here
1
/* Description of GNU message catalog format: string hashing function.
2
   Copyright (C) 1995, 1997-1998, 2000-2003, 2005 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* @@ end of prolog @@ */
20
21
/* We assume to have `unsigned long int' value with at least 32 bits.  */
22
#define HASHWORDBITS 32
23
24
25
#ifndef _LIBC
26
# ifdef IN_LIBINTL
27
#  define __hash_string libintl_hash_string
28
# else
29
#  define __hash_string hash_string
30
# endif
31
#endif
32
33
/* Defines the so called `hashpjw' function by P.J. Weinberger
34
   [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
35
   1986, 1987 Bell Telephone Laboratories, Inc.]  */
36
extern unsigned long int __hash_string (const char *str_param);
(-)a/intl/intl-compat.c (-133 lines)
Lines 1-133 Link Here
1
/* intl-compat.c - Stub functions to call gettext functions from GNU gettext
2
   Library.
3
   Copyright (C) 1995, 2000-2003, 2005 Software Foundation, Inc.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifdef HAVE_CONFIG_H
21
# include <config.h>
22
#endif
23
24
#include "gettextP.h"
25
26
/* @@ end of prolog @@ */
27
28
/* This file redirects the gettext functions (without prefix) to those
29
   defined in the included GNU libintl library (with "libintl_" prefix).
30
   It is compiled into libintl in order to make the AM_GNU_GETTEXT test
31
   of gettext <= 0.11.2 work with the libintl library >= 0.11.3 which
32
   has the redirections primarily in the <libintl.h> include file.
33
   It is also compiled into libgnuintl so that libgnuintl.so can be used
34
   as LD_PRELOADable library on glibc systems, to provide the extra
35
   features that the functions in the libc don't have (namely, logging).  */
36
37
38
#undef gettext
39
#undef dgettext
40
#undef dcgettext
41
#undef ngettext
42
#undef dngettext
43
#undef dcngettext
44
#undef textdomain
45
#undef bindtextdomain
46
#undef bind_textdomain_codeset
47
48
49
/* When building a DLL, we must export some functions.  Note that because
50
   the functions are only defined for binary backward compatibility, we
51
   don't need to use __declspec(dllimport) in any case.  */
52
#if HAVE_VISIBILITY && BUILDING_DLL
53
# define DLL_EXPORTED __attribute__((__visibility__("default")))
54
#elif defined _MSC_VER && BUILDING_DLL
55
# define DLL_EXPORTED __declspec(dllexport)
56
#else
57
# define DLL_EXPORTED
58
#endif
59
60
61
DLL_EXPORTED
62
char *
63
gettext (const char *msgid)
64
{
65
  return libintl_gettext (msgid);
66
}
67
68
69
DLL_EXPORTED
70
char *
71
dgettext (const char *domainname, const char *msgid)
72
{
73
  return libintl_dgettext (domainname, msgid);
74
}
75
76
77
DLL_EXPORTED
78
char *
79
dcgettext (const char *domainname, const char *msgid, int category)
80
{
81
  return libintl_dcgettext (domainname, msgid, category);
82
}
83
84
85
DLL_EXPORTED
86
char *
87
ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
88
{
89
  return libintl_ngettext (msgid1, msgid2, n);
90
}
91
92
93
DLL_EXPORTED
94
char *
95
dngettext (const char *domainname,
96
	   const char *msgid1, const char *msgid2, unsigned long int n)
97
{
98
  return libintl_dngettext (domainname, msgid1, msgid2, n);
99
}
100
101
102
DLL_EXPORTED
103
char *
104
dcngettext (const char *domainname,
105
	    const char *msgid1, const char *msgid2, unsigned long int n,
106
	    int category)
107
{
108
  return libintl_dcngettext (domainname, msgid1, msgid2, n, category);
109
}
110
111
112
DLL_EXPORTED
113
char *
114
textdomain (const char *domainname)
115
{
116
  return libintl_textdomain (domainname);
117
}
118
119
120
DLL_EXPORTED
121
char *
122
bindtextdomain (const char *domainname, const char *dirname)
123
{
124
  return libintl_bindtextdomain (domainname, dirname);
125
}
126
127
128
DLL_EXPORTED
129
char *
130
bind_textdomain_codeset (const char *domainname, const char *codeset)
131
{
132
  return libintl_bind_textdomain_codeset (domainname, codeset);
133
}
(-)a/intl/intl-exports.c (-36 lines)
Lines 1-36 Link Here
1
/* List of exported symbols of libintl on Cygwin.
2
   Copyright (C) 2006 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2006.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
 /* IMP(x) is a symbol that contains the address of x.  */
21
#define IMP(x) _imp__##x
22
23
 /* Ensure that the variable x is exported from the library, and that a
24
    pseudo-variable IMP(x) is available.  */
25
#define VARIABLE(x) \
26
 /* Export x without redefining x.  This code was found by compiling a	\
27
    snippet:								\
28
      extern __declspec(dllexport) int x; int x = 42;  */		\
29
 asm (".section .drectve\n");						\
30
 asm (".ascii \" -export:" #x ",data\"\n");				\
31
 asm (".data\n");							\
32
 /* Allocate a pseudo-variable IMP(x).  */				\
33
 extern int x;								\
34
 void * IMP(x) = &x;
35
36
VARIABLE(libintl_version)
(-)a/intl/l10nflist.c (-400 lines)
Lines 1-400 Link Here
1
/* Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc.
2
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Tell glibc's <string.h> to provide a prototype for stpcpy().
20
   This must come before <config.h> because <config.h> may include
21
   <features.h>, and once <features.h> has been included, it's too late.  */
22
#ifndef _GNU_SOURCE
23
# define _GNU_SOURCE	1
24
#endif
25
26
#ifdef HAVE_CONFIG_H
27
# include <config.h>
28
#endif
29
30
#include <string.h>
31
32
#if defined _LIBC || defined HAVE_ARGZ_H
33
# include <argz.h>
34
#endif
35
#include <ctype.h>
36
#include <sys/types.h>
37
#include <stdlib.h>
38
39
#include "loadinfo.h"
40
41
/* On some strange systems still no definition of NULL is found.  Sigh!  */
42
#ifndef NULL
43
# if defined __STDC__ && __STDC__
44
#  define NULL ((void *) 0)
45
# else
46
#  define NULL 0
47
# endif
48
#endif
49
50
/* @@ end of prolog @@ */
51
52
#ifdef _LIBC
53
/* Rename the non ANSI C functions.  This is required by the standard
54
   because some ANSI C functions will require linking with this object
55
   file and the name space must not be polluted.  */
56
# ifndef stpcpy
57
#  define stpcpy(dest, src) __stpcpy(dest, src)
58
# endif
59
#else
60
# ifndef HAVE_STPCPY
61
static char *stpcpy (char *dest, const char *src);
62
# endif
63
#endif
64
65
/* Pathname support.
66
   ISSLASH(C)           tests whether C is a directory separator character.
67
   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
68
                        it may be concatenated to a directory pathname.
69
 */
70
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
71
  /* Win32, Cygwin, OS/2, DOS */
72
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
73
# define HAS_DEVICE(P) \
74
    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
75
     && (P)[1] == ':')
76
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
77
#else
78
  /* Unix */
79
# define ISSLASH(C) ((C) == '/')
80
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
81
#endif
82
83
/* Define function which are usually not available.  */
84
85
#ifdef _LIBC
86
# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
87
#elif defined HAVE_ARGZ_COUNT
88
# undef __argz_count
89
# define __argz_count argz_count
90
#else
91
/* Returns the number of strings in ARGZ.  */
92
static size_t
93
argz_count__ (const char *argz, size_t len)
94
{
95
  size_t count = 0;
96
  while (len > 0)
97
    {
98
      size_t part_len = strlen (argz);
99
      argz += part_len + 1;
100
      len -= part_len + 1;
101
      count++;
102
    }
103
  return count;
104
}
105
# undef __argz_count
106
# define __argz_count(argz, len) argz_count__ (argz, len)
107
#endif	/* !_LIBC && !HAVE_ARGZ_COUNT */
108
109
#ifdef _LIBC
110
# define __argz_stringify(argz, len, sep) \
111
  INTUSE(__argz_stringify) (argz, len, sep)
112
#elif defined HAVE_ARGZ_STRINGIFY
113
# undef __argz_stringify
114
# define __argz_stringify argz_stringify
115
#else
116
/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
117
   except the last into the character SEP.  */
118
static void
119
argz_stringify__ (char *argz, size_t len, int sep)
120
{
121
  while (len > 0)
122
    {
123
      size_t part_len = strlen (argz);
124
      argz += part_len;
125
      len -= part_len + 1;
126
      if (len > 0)
127
	*argz++ = sep;
128
    }
129
}
130
# undef __argz_stringify
131
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
132
#endif	/* !_LIBC && !HAVE_ARGZ_STRINGIFY */
133
134
#ifdef _LIBC
135
#elif defined HAVE_ARGZ_NEXT
136
# undef __argz_next
137
# define __argz_next argz_next
138
#else
139
static char *
140
argz_next__ (char *argz, size_t argz_len, const char *entry)
141
{
142
  if (entry)
143
    {
144
      if (entry < argz + argz_len)
145
        entry = strchr (entry, '\0') + 1;
146
147
      return entry >= argz + argz_len ? NULL : (char *) entry;
148
    }
149
  else
150
    if (argz_len > 0)
151
      return argz;
152
    else
153
      return 0;
154
}
155
# undef __argz_next
156
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
157
#endif	/* !_LIBC && !HAVE_ARGZ_NEXT */
158
159
160
/* Return number of bits set in X.  */
161
static inline int
162
pop (int x)
163
{
164
  /* We assume that no more than 16 bits are used.  */
165
  x = ((x & ~0x5555) >> 1) + (x & 0x5555);
166
  x = ((x & ~0x3333) >> 2) + (x & 0x3333);
167
  x = ((x >> 4) + x) & 0x0f0f;
168
  x = ((x >> 8) + x) & 0xff;
169
170
  return x;
171
}
172
173
174
struct loaded_l10nfile *
175
_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
176
		    const char *dirlist, size_t dirlist_len,
177
		    int mask, const char *language, const char *territory,
178
		    const char *codeset, const char *normalized_codeset,
179
		    const char *modifier,
180
		    const char *filename, int do_allocate)
181
{
182
  char *abs_filename;
183
  struct loaded_l10nfile **lastp;
184
  struct loaded_l10nfile *retval;
185
  char *cp;
186
  size_t dirlist_count;
187
  size_t entries;
188
  int cnt;
189
190
  /* If LANGUAGE contains an absolute directory specification, we ignore
191
     DIRLIST.  */
192
  if (IS_ABSOLUTE_PATH (language))
193
    dirlist_len = 0;
194
195
  /* Allocate room for the full file name.  */
196
  abs_filename = (char *) malloc (dirlist_len
197
				  + strlen (language)
198
				  + ((mask & XPG_TERRITORY) != 0
199
				     ? strlen (territory) + 1 : 0)
200
				  + ((mask & XPG_CODESET) != 0
201
				     ? strlen (codeset) + 1 : 0)
202
				  + ((mask & XPG_NORM_CODESET) != 0
203
				     ? strlen (normalized_codeset) + 1 : 0)
204
				  + ((mask & XPG_MODIFIER) != 0
205
				     ? strlen (modifier) + 1 : 0)
206
				  + 1 + strlen (filename) + 1);
207
208
  if (abs_filename == NULL)
209
    return NULL;
210
211
  /* Construct file name.  */
212
  cp = abs_filename;
213
  if (dirlist_len > 0)
214
    {
215
      memcpy (cp, dirlist, dirlist_len);
216
      __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
217
      cp += dirlist_len;
218
      cp[-1] = '/';
219
    }
220
221
  cp = stpcpy (cp, language);
222
223
  if ((mask & XPG_TERRITORY) != 0)
224
    {
225
      *cp++ = '_';
226
      cp = stpcpy (cp, territory);
227
    }
228
  if ((mask & XPG_CODESET) != 0)
229
    {
230
      *cp++ = '.';
231
      cp = stpcpy (cp, codeset);
232
    }
233
  if ((mask & XPG_NORM_CODESET) != 0)
234
    {
235
      *cp++ = '.';
236
      cp = stpcpy (cp, normalized_codeset);
237
    }
238
  if ((mask & XPG_MODIFIER) != 0)
239
    {
240
      *cp++ = '@';
241
      cp = stpcpy (cp, modifier);
242
    }
243
244
  *cp++ = '/';
245
  stpcpy (cp, filename);
246
247
  /* Look in list of already loaded domains whether it is already
248
     available.  */
249
  lastp = l10nfile_list;
250
  for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
251
    if (retval->filename != NULL)
252
      {
253
	int compare = strcmp (retval->filename, abs_filename);
254
	if (compare == 0)
255
	  /* We found it!  */
256
	  break;
257
	if (compare < 0)
258
	  {
259
	    /* It's not in the list.  */
260
	    retval = NULL;
261
	    break;
262
	  }
263
264
	lastp = &retval->next;
265
      }
266
267
  if (retval != NULL || do_allocate == 0)
268
    {
269
      free (abs_filename);
270
      return retval;
271
    }
272
273
  dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
274
275
  /* Allocate a new loaded_l10nfile.  */
276
  retval =
277
    (struct loaded_l10nfile *)
278
    malloc (sizeof (*retval)
279
	    + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
280
	       * sizeof (struct loaded_l10nfile *)));
281
  if (retval == NULL)
282
    {
283
      free (abs_filename);
284
      return NULL;
285
    }
286
287
  retval->filename = abs_filename;
288
289
  /* We set retval->data to NULL here; it is filled in later.
290
     Setting retval->decided to 1 here means that retval does not
291
     correspond to a real file (dirlist_count > 1) or is not worth
292
     looking up (if an unnormalized codeset was specified).  */
293
  retval->decided = (dirlist_count > 1
294
		     || ((mask & XPG_CODESET) != 0
295
			 && (mask & XPG_NORM_CODESET) != 0));
296
  retval->data = NULL;
297
298
  retval->next = *lastp;
299
  *lastp = retval;
300
301
  entries = 0;
302
  /* Recurse to fill the inheritance list of RETVAL.
303
     If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL
304
     entry does not correspond to a real file; retval->filename contains
305
     colons.  In this case we loop across all elements of DIRLIST and
306
     across all bit patterns dominated by MASK.
307
     If the DIRLIST is a single directory or entirely redundant (i.e.
308
     DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
309
     MASK, excluding MASK itself.
310
     In either case, we loop down from MASK to 0.  This has the effect
311
     that the extra bits in the locale name are dropped in this order:
312
     first the modifier, then the territory, then the codeset, then the
313
     normalized_codeset.  */
314
  for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
315
    if ((cnt & ~mask) == 0
316
	&& !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0))
317
      {
318
	if (dirlist_count > 1)
319
	  {
320
	    /* Iterate over all elements of the DIRLIST.  */
321
	    char *dir = NULL;
322
323
	    while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
324
		   != NULL)
325
	      retval->successor[entries++]
326
		= _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
327
				      cnt, language, territory, codeset,
328
				      normalized_codeset, modifier, filename,
329
				      1);
330
	  }
331
	else
332
	  retval->successor[entries++]
333
	    = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
334
				  cnt, language, territory, codeset,
335
				  normalized_codeset, modifier, filename, 1);
336
      }
337
  retval->successor[entries] = NULL;
338
339
  return retval;
340
}
341
342
/* Normalize codeset name.  There is no standard for the codeset
343
   names.  Normalization allows the user to use any of the common
344
   names.  The return value is dynamically allocated and has to be
345
   freed by the caller.  */
346
const char *
347
_nl_normalize_codeset (const char *codeset, size_t name_len)
348
{
349
  int len = 0;
350
  int only_digit = 1;
351
  char *retval;
352
  char *wp;
353
  size_t cnt;
354
355
  for (cnt = 0; cnt < name_len; ++cnt)
356
    if (isalnum ((unsigned char) codeset[cnt]))
357
      {
358
	++len;
359
360
	if (isalpha ((unsigned char) codeset[cnt]))
361
	  only_digit = 0;
362
      }
363
364
  retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
365
366
  if (retval != NULL)
367
    {
368
      if (only_digit)
369
	wp = stpcpy (retval, "iso");
370
      else
371
	wp = retval;
372
373
      for (cnt = 0; cnt < name_len; ++cnt)
374
	if (isalpha ((unsigned char) codeset[cnt]))
375
	  *wp++ = tolower ((unsigned char) codeset[cnt]);
376
	else if (isdigit ((unsigned char) codeset[cnt]))
377
	  *wp++ = codeset[cnt];
378
379
      *wp = '\0';
380
    }
381
382
  return (const char *) retval;
383
}
384
385
386
/* @@ begin of epilog @@ */
387
388
/* We don't want libintl.a to depend on any other library.  So we
389
   avoid the non-standard function stpcpy.  In GNU C Library this
390
   function is available, though.  Also allow the symbol HAVE_STPCPY
391
   to be defined.  */
392
#if !_LIBC && !HAVE_STPCPY
393
static char *
394
stpcpy (char *dest, const char *src)
395
{
396
  while ((*dest++ = *src++) != '\0')
397
    /* Do nothing. */ ;
398
  return dest - 1;
399
}
400
#endif
(-)a/intl/langprefs.c (-130 lines)
Lines 1-130 Link Here
1
/* Determine the user's language preferences.
2
   Copyright (C) 2004-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Written by Bruno Haible <bruno@clisp.org>.  */
20
21
#ifdef HAVE_CONFIG_H
22
# include <config.h>
23
#endif
24
25
#include <stdlib.h>
26
27
#if HAVE_CFPREFERENCESCOPYAPPVALUE
28
# include <string.h>
29
# include <CoreFoundation/CFPreferences.h>
30
# include <CoreFoundation/CFPropertyList.h>
31
# include <CoreFoundation/CFArray.h>
32
# include <CoreFoundation/CFString.h>
33
extern void _nl_locale_name_canonicalize (char *name);
34
#endif
35
36
/* Determine the user's language preferences, as a colon separated list of
37
   locale names in XPG syntax
38
     language[_territory][.codeset][@modifier]
39
   The result must not be freed; it is statically allocated.
40
   The LANGUAGE environment variable does not need to be considered; it is
41
   already taken into account by the caller.  */
42
43
const char *
44
_nl_language_preferences_default (void)
45
{
46
#if HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */
47
  {
48
    /* Cache the preferences list, since CoreFoundation calls are expensive.  */
49
    static const char *cached_languages;
50
    static int cache_initialized;
51
52
    if (!cache_initialized)
53
      {
54
	CFTypeRef preferences =
55
	  CFPreferencesCopyAppValue (CFSTR ("AppleLanguages"),
56
				     kCFPreferencesCurrentApplication);
57
	if (preferences != NULL
58
	    && CFGetTypeID (preferences) == CFArrayGetTypeID ())
59
	  {
60
	    CFArrayRef prefArray = (CFArrayRef)preferences;
61
	    int n = CFArrayGetCount (prefArray);
62
	    char buf[256];
63
	    size_t size = 0;
64
	    int i;
65
66
	    for (i = 0; i < n; i++)
67
	      {
68
		CFTypeRef element = CFArrayGetValueAtIndex (prefArray, i);
69
		if (element != NULL
70
		    && CFGetTypeID (element) == CFStringGetTypeID ()
71
		    && CFStringGetCString ((CFStringRef)element,
72
					   buf, sizeof (buf),
73
					   kCFStringEncodingASCII))
74
		  {
75
		    _nl_locale_name_canonicalize (buf);
76
		    size += strlen (buf) + 1;
77
		    /* Most GNU programs use msgids in English and don't ship
78
		       an en.mo message catalog.  Therefore when we see "en"
79
		       in the preferences list, arrange for gettext() to
80
		       return the msgid, and ignore all further elements of
81
		       the preferences list.  */
82
		    if (strcmp (buf, "en") == 0)
83
		      break;
84
		  }
85
		else
86
		  break;
87
	      }
88
	    if (size > 0)
89
	      {
90
		char *languages = (char *) malloc (size);
91
92
		if (languages != NULL)
93
		  {
94
		    char *p = languages;
95
96
		    for (i = 0; i < n; i++)
97
		      {
98
			CFTypeRef element =
99
			  CFArrayGetValueAtIndex (prefArray, i);
100
			if (element != NULL
101
		            && CFGetTypeID (element) == CFStringGetTypeID ()
102
			    && CFStringGetCString ((CFStringRef)element,
103
						   buf, sizeof (buf),
104
						   kCFStringEncodingASCII))
105
			  {
106
			    _nl_locale_name_canonicalize (buf);
107
			    strcpy (p, buf);
108
			    p += strlen (buf);
109
			    *p++ = ':';
110
			    if (strcmp (buf, "en") == 0)
111
			      break;
112
			  }
113
			else
114
			  break;
115
		      }
116
		    *--p = '\0';
117
118
		    cached_languages = languages;
119
		  }
120
	      }
121
	  }
122
	cache_initialized = 1;
123
      }
124
    if (cached_languages != NULL)
125
      return cached_languages;
126
  }
127
#endif
128
129
  return NULL;
130
}
(-)a/intl/libgnuintl.h.in (-419 lines)
Lines 1-419 Link Here
1
/* Message catalogs for internationalization.
2
   Copyright (C) 1995-1997, 2000-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _LIBINTL_H
20
#define _LIBINTL_H	1
21
22
#include <locale.h>
23
24
/* The LC_MESSAGES locale category is the category used by the functions
25
   gettext() and dgettext().  It is specified in POSIX, but not in ANSI C.
26
   On systems that don't define it, use an arbitrary value instead.
27
   On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
28
   then includes <libintl.h> (i.e. this file!) and then only defines
29
   LC_MESSAGES.  To avoid a redefinition warning, don't define LC_MESSAGES
30
   in this case.  */
31
#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
32
# define LC_MESSAGES 1729
33
#endif
34
35
/* We define an additional symbol to signal that we use the GNU
36
   implementation of gettext.  */
37
#define __USE_GNU_GETTEXT 1
38
39
/* Provide information about the supported file formats.  Returns the
40
   maximum minor revision number supported for a given major revision.  */
41
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
42
  ((major) == 0 || (major) == 1 ? 1 : -1)
43
44
/* Resolve a platform specific conflict on DJGPP.  GNU gettext takes
45
   precedence over _conio_gettext.  */
46
#ifdef __DJGPP__
47
# undef gettext
48
#endif
49
50
#ifdef __cplusplus
51
extern "C" {
52
#endif
53
54
55
/* Version number: (major<<16) + (minor<<8) + subminor */
56
#define LIBINTL_VERSION 0x001000
57
extern int libintl_version;
58
59
60
/* We redirect the functions to those prefixed with "libintl_".  This is
61
   necessary, because some systems define gettext/textdomain/... in the C
62
   library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
63
   If we used the unprefixed names, there would be cases where the
64
   definition in the C library would override the one in the libintl.so
65
   shared library.  Recall that on ELF systems, the symbols are looked
66
   up in the following order:
67
     1. in the executable,
68
     2. in the shared libraries specified on the link command line, in order,
69
     3. in the dependencies of the shared libraries specified on the link
70
        command line,
71
     4. in the dlopen()ed shared libraries, in the order in which they were
72
        dlopen()ed.
73
   The definition in the C library would override the one in libintl.so if
74
   either
75
     * -lc is given on the link command line and -lintl isn't, or
76
     * -lc is given on the link command line before -lintl, or
77
     * libintl.so is a dependency of a dlopen()ed shared library but not
78
       linked to the executable at link time.
79
   Since Solaris gettext() behaves differently than GNU gettext(), this
80
   would be unacceptable.
81
82
   The redirection happens by default through macros in C, so that &gettext
83
   is independent of the compilation unit, but through inline functions in
84
   C++, in order not to interfere with the name mangling of class fields or
85
   class methods called 'gettext'.  */
86
87
/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
88
   If he doesn't, we choose the method.  A third possible method is
89
   _INTL_REDIRECT_ASM, supported only by GCC.  */
90
#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
91
# if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
92
#  define _INTL_REDIRECT_ASM
93
# else
94
#  ifdef __cplusplus
95
#   define _INTL_REDIRECT_INLINE
96
#  else
97
#   define _INTL_REDIRECT_MACROS
98
#  endif
99
# endif
100
#endif
101
/* Auxiliary macros.  */
102
#ifdef _INTL_REDIRECT_ASM
103
# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
104
# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
105
# define _INTL_STRINGIFY(prefix) #prefix
106
#else
107
# define _INTL_ASM(cname)
108
#endif
109
110
/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
111
   its n-th argument literally.  This enables GCC to warn for example about
112
   printf (gettext ("foo %y")).  */
113
#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
114
# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
115
#else
116
# define _INTL_MAY_RETURN_STRING_ARG(n)
117
#endif
118
119
/* Look up MSGID in the current default message catalog for the current
120
   LC_MESSAGES locale.  If not found, returns MSGID itself (the default
121
   text).  */
122
#ifdef _INTL_REDIRECT_INLINE
123
extern char *libintl_gettext (const char *__msgid)
124
       _INTL_MAY_RETURN_STRING_ARG (1);
125
static inline char *gettext (const char *__msgid)
126
{
127
  return libintl_gettext (__msgid);
128
}
129
#else
130
#ifdef _INTL_REDIRECT_MACROS
131
# define gettext libintl_gettext
132
#endif
133
extern char *gettext (const char *__msgid)
134
       _INTL_ASM (libintl_gettext)
135
       _INTL_MAY_RETURN_STRING_ARG (1);
136
#endif
137
138
/* Look up MSGID in the DOMAINNAME message catalog for the current
139
   LC_MESSAGES locale.  */
140
#ifdef _INTL_REDIRECT_INLINE
141
extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
142
       _INTL_MAY_RETURN_STRING_ARG (2);
143
static inline char *dgettext (const char *__domainname, const char *__msgid)
144
{
145
  return libintl_dgettext (__domainname, __msgid);
146
}
147
#else
148
#ifdef _INTL_REDIRECT_MACROS
149
# define dgettext libintl_dgettext
150
#endif
151
extern char *dgettext (const char *__domainname, const char *__msgid)
152
       _INTL_ASM (libintl_dgettext)
153
       _INTL_MAY_RETURN_STRING_ARG (2);
154
#endif
155
156
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
157
   locale.  */
158
#ifdef _INTL_REDIRECT_INLINE
159
extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
160
				int __category)
161
       _INTL_MAY_RETURN_STRING_ARG (2);
162
static inline char *dcgettext (const char *__domainname, const char *__msgid,
163
			       int __category)
164
{
165
  return libintl_dcgettext (__domainname, __msgid, __category);
166
}
167
#else
168
#ifdef _INTL_REDIRECT_MACROS
169
# define dcgettext libintl_dcgettext
170
#endif
171
extern char *dcgettext (const char *__domainname, const char *__msgid,
172
			int __category)
173
       _INTL_ASM (libintl_dcgettext)
174
       _INTL_MAY_RETURN_STRING_ARG (2);
175
#endif
176
177
178
/* Similar to `gettext' but select the plural form corresponding to the
179
   number N.  */
180
#ifdef _INTL_REDIRECT_INLINE
181
extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
182
			       unsigned long int __n)
183
       _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
184
static inline char *ngettext (const char *__msgid1, const char *__msgid2,
185
			      unsigned long int __n)
186
{
187
  return libintl_ngettext (__msgid1, __msgid2, __n);
188
}
189
#else
190
#ifdef _INTL_REDIRECT_MACROS
191
# define ngettext libintl_ngettext
192
#endif
193
extern char *ngettext (const char *__msgid1, const char *__msgid2,
194
		       unsigned long int __n)
195
       _INTL_ASM (libintl_ngettext)
196
       _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
197
#endif
198
199
/* Similar to `dgettext' but select the plural form corresponding to the
200
   number N.  */
201
#ifdef _INTL_REDIRECT_INLINE
202
extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
203
				const char *__msgid2, unsigned long int __n)
204
       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
205
static inline char *dngettext (const char *__domainname, const char *__msgid1,
206
			       const char *__msgid2, unsigned long int __n)
207
{
208
  return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
209
}
210
#else
211
#ifdef _INTL_REDIRECT_MACROS
212
# define dngettext libintl_dngettext
213
#endif
214
extern char *dngettext (const char *__domainname,
215
			const char *__msgid1, const char *__msgid2,
216
			unsigned long int __n)
217
       _INTL_ASM (libintl_dngettext)
218
       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
219
#endif
220
221
/* Similar to `dcgettext' but select the plural form corresponding to the
222
   number N.  */
223
#ifdef _INTL_REDIRECT_INLINE
224
extern char *libintl_dcngettext (const char *__domainname,
225
				 const char *__msgid1, const char *__msgid2,
226
				 unsigned long int __n, int __category)
227
       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
228
static inline char *dcngettext (const char *__domainname,
229
				const char *__msgid1, const char *__msgid2,
230
				unsigned long int __n, int __category)
231
{
232
  return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
233
}
234
#else
235
#ifdef _INTL_REDIRECT_MACROS
236
# define dcngettext libintl_dcngettext
237
#endif
238
extern char *dcngettext (const char *__domainname,
239
			 const char *__msgid1, const char *__msgid2,
240
			 unsigned long int __n, int __category)
241
       _INTL_ASM (libintl_dcngettext)
242
       _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
243
#endif
244
245
246
#ifndef IN_LIBGLOCALE
247
248
/* Set the current default message catalog to DOMAINNAME.
249
   If DOMAINNAME is null, return the current default.
250
   If DOMAINNAME is "", reset to the default of "messages".  */
251
#ifdef _INTL_REDIRECT_INLINE
252
extern char *libintl_textdomain (const char *__domainname);
253
static inline char *textdomain (const char *__domainname)
254
{
255
  return libintl_textdomain (__domainname);
256
}
257
#else
258
#ifdef _INTL_REDIRECT_MACROS
259
# define textdomain libintl_textdomain
260
#endif
261
extern char *textdomain (const char *__domainname)
262
       _INTL_ASM (libintl_textdomain);
263
#endif
264
265
/* Specify that the DOMAINNAME message catalog will be found
266
   in DIRNAME rather than in the system locale data base.  */
267
#ifdef _INTL_REDIRECT_INLINE
268
extern char *libintl_bindtextdomain (const char *__domainname,
269
				     const char *__dirname);
270
static inline char *bindtextdomain (const char *__domainname,
271
				    const char *__dirname)
272
{
273
  return libintl_bindtextdomain (__domainname, __dirname);
274
}
275
#else
276
#ifdef _INTL_REDIRECT_MACROS
277
# define bindtextdomain libintl_bindtextdomain
278
#endif
279
extern char *bindtextdomain (const char *__domainname, const char *__dirname)
280
       _INTL_ASM (libintl_bindtextdomain);
281
#endif
282
283
/* Specify the character encoding in which the messages from the
284
   DOMAINNAME message catalog will be returned.  */
285
#ifdef _INTL_REDIRECT_INLINE
286
extern char *libintl_bind_textdomain_codeset (const char *__domainname,
287
					      const char *__codeset);
288
static inline char *bind_textdomain_codeset (const char *__domainname,
289
					     const char *__codeset)
290
{
291
  return libintl_bind_textdomain_codeset (__domainname, __codeset);
292
}
293
#else
294
#ifdef _INTL_REDIRECT_MACROS
295
# define bind_textdomain_codeset libintl_bind_textdomain_codeset
296
#endif
297
extern char *bind_textdomain_codeset (const char *__domainname,
298
				      const char *__codeset)
299
       _INTL_ASM (libintl_bind_textdomain_codeset);
300
#endif
301
302
#endif /* IN_LIBGLOCALE */
303
304
305
/* Support for format strings with positions in *printf(), following the
306
   POSIX/XSI specification.
307
   Note: These replacements for the *printf() functions are visible only
308
   in source files that #include <libintl.h> or #include "gettext.h".
309
   Packages that use *printf() in source files that don't refer to _()
310
   or gettext() but for which the format string could be the return value
311
   of _() or gettext() need to add this #include.  Oh well.  */
312
313
#if !@HAVE_POSIX_PRINTF@
314
315
#include <stdio.h>
316
#include <stddef.h>
317
318
/* Get va_list.  */
319
#if __STDC__ || defined __cplusplus || defined _MSC_VER
320
# include <stdarg.h>
321
#else
322
# include <varargs.h>
323
#endif
324
325
#undef fprintf
326
#define fprintf libintl_fprintf
327
extern int fprintf (FILE *, const char *, ...);
328
#undef vfprintf
329
#define vfprintf libintl_vfprintf
330
extern int vfprintf (FILE *, const char *, va_list);
331
332
#undef printf
333
#if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__
334
/* Don't break __attribute__((format(printf,M,N))).
335
   This redefinition is only possible because the libc in NetBSD, Cygwin,
336
   mingw does not have a function __printf__.  */
337
# define libintl_printf __printf__
338
#endif
339
#define printf libintl_printf
340
extern int printf (const char *, ...);
341
#undef vprintf
342
#define vprintf libintl_vprintf
343
extern int vprintf (const char *, va_list);
344
345
#undef sprintf
346
#define sprintf libintl_sprintf
347
extern int sprintf (char *, const char *, ...);
348
#undef vsprintf
349
#define vsprintf libintl_vsprintf
350
extern int vsprintf (char *, const char *, va_list);
351
352
#if @HAVE_SNPRINTF@
353
354
#undef snprintf
355
#define snprintf libintl_snprintf
356
extern int snprintf (char *, size_t, const char *, ...);
357
#undef vsnprintf
358
#define vsnprintf libintl_vsnprintf
359
extern int vsnprintf (char *, size_t, const char *, va_list);
360
361
#endif
362
363
#if @HAVE_ASPRINTF@
364
365
#undef asprintf
366
#define asprintf libintl_asprintf
367
extern int asprintf (char **, const char *, ...);
368
#undef vasprintf
369
#define vasprintf libintl_vasprintf
370
extern int vasprintf (char **, const char *, va_list);
371
372
#endif
373
374
#if @HAVE_WPRINTF@
375
376
#undef fwprintf
377
#define fwprintf libintl_fwprintf
378
extern int fwprintf (FILE *, const wchar_t *, ...);
379
#undef vfwprintf
380
#define vfwprintf libintl_vfwprintf
381
extern int vfwprintf (FILE *, const wchar_t *, va_list);
382
383
#undef wprintf
384
#define wprintf libintl_wprintf
385
extern int wprintf (const wchar_t *, ...);
386
#undef vwprintf
387
#define vwprintf libintl_vwprintf
388
extern int vwprintf (const wchar_t *, va_list);
389
390
#undef swprintf
391
#define swprintf libintl_swprintf
392
extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
393
#undef vswprintf
394
#define vswprintf libintl_vswprintf
395
extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
396
397
#endif
398
399
#endif
400
401
402
/* Support for relocatable packages.  */
403
404
/* Sets the original and the current installation prefix of the package.
405
   Relocation simply replaces a pathname starting with the original prefix
406
   by the corresponding pathname with the current prefix instead.  Both
407
   prefixes should be directory names without trailing slash (i.e. use ""
408
   instead of "/").  */
409
#define libintl_set_relocation_prefix libintl_set_relocation_prefix
410
extern void
411
       libintl_set_relocation_prefix (const char *orig_prefix,
412
				      const char *curr_prefix);
413
414
415
#ifdef __cplusplus
416
}
417
#endif
418
419
#endif /* libintl.h */
(-)a/intl/loadinfo.h (-132 lines)
Lines 1-132 Link Here
1
/* Copyright (C) 1996-1999, 2000-2003, 2005-2006 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifndef _LOADINFO_H
21
#define _LOADINFO_H	1
22
23
/* Declarations of locale dependent catalog lookup functions.
24
   Implemented in
25
26
     localealias.c    Possibly replace a locale name by another.
27
     explodename.c    Split a locale name into its various fields.
28
     l10nflist.c      Generate a list of filenames of possible message catalogs.
29
     finddomain.c     Find and open the relevant message catalogs.
30
31
   The main function _nl_find_domain() in finddomain.c is declared
32
   in gettextP.h.
33
 */
34
35
#ifndef internal_function
36
# define internal_function
37
#endif
38
39
#ifndef LIBINTL_DLL_EXPORTED
40
# define LIBINTL_DLL_EXPORTED
41
#endif
42
43
/* Tell the compiler when a conditional or integer expression is
44
   almost always true or almost always false.  */
45
#ifndef HAVE_BUILTIN_EXPECT
46
# define __builtin_expect(expr, val) (expr)
47
#endif
48
49
/* Separator in PATH like lists of pathnames.  */
50
#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
51
  /* Win32, OS/2, DOS */
52
# define PATH_SEPARATOR ';'
53
#else
54
  /* Unix */
55
# define PATH_SEPARATOR ':'
56
#endif
57
58
/* Encoding of locale name parts.  */
59
#define XPG_NORM_CODESET	1
60
#define XPG_CODESET		2
61
#define XPG_TERRITORY		4
62
#define XPG_MODIFIER		8
63
64
65
struct loaded_l10nfile
66
{
67
  const char *filename;
68
  int decided;
69
70
  const void *data;
71
72
  struct loaded_l10nfile *next;
73
  struct loaded_l10nfile *successor[1];
74
};
75
76
77
/* Normalize codeset name.  There is no standard for the codeset
78
   names.  Normalization allows the user to use any of the common
79
   names.  The return value is dynamically allocated and has to be
80
   freed by the caller.  */
81
extern const char *_nl_normalize_codeset (const char *codeset,
82
					  size_t name_len);
83
84
/* Lookup a locale dependent file.
85
   *L10NFILE_LIST denotes a pool of lookup results of locale dependent
86
   files of the same kind, sorted in decreasing order of ->filename.
87
   DIRLIST and DIRLIST_LEN are an argz list of directories in which to
88
   look, containing at least one directory (i.e. DIRLIST_LEN > 0).
89
   MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER
90
   are the pieces of the locale name, as produced by _nl_explode_name().
91
   FILENAME is the filename suffix.
92
   The return value is the lookup result, either found in *L10NFILE_LIST,
93
   or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL.
94
   If the return value is non-NULL, it is added to *L10NFILE_LIST, and
95
   its ->next field denotes the chaining inside *L10NFILE_LIST, and
96
   furthermore its ->successor[] field contains a list of other lookup
97
   results from which this lookup result inherits.  */
98
extern struct loaded_l10nfile *
99
_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
100
		    const char *dirlist, size_t dirlist_len, int mask,
101
		    const char *language, const char *territory,
102
		    const char *codeset, const char *normalized_codeset,
103
		    const char *modifier,
104
		    const char *filename, int do_allocate);
105
106
/* Lookup the real locale name for a locale alias NAME, or NULL if
107
   NAME is not a locale alias (but possibly a real locale name).
108
   The return value is statically allocated and must not be freed.  */
109
/* Part of the libintl ABI only for the sake of the gettext.m4 macro.  */
110
extern LIBINTL_DLL_EXPORTED const char *_nl_expand_alias (const char *name);
111
112
/* Split a locale name NAME into its pieces: language, modifier,
113
   territory, codeset.
114
   NAME gets destructively modified: NUL bytes are inserted here and
115
   there.  *LANGUAGE gets assigned NAME.  Each of *MODIFIER, *TERRITORY,
116
   *CODESET gets assigned either a pointer into the old NAME string, or
117
   NULL.  *NORMALIZED_CODESET gets assigned the expanded *CODESET, if it
118
   is different from *CODESET; this one is dynamically allocated and has
119
   to be freed by the caller.
120
   The return value is a bitmask, where each bit corresponds to one
121
   filled-in value:
122
     XPG_MODIFIER                for *MODIFIER,
123
     XPG_TERRITORY               for *TERRITORY,
124
     XPG_CODESET                 for *CODESET,
125
     XPG_NORM_CODESET            for *NORMALIZED_CODESET.
126
 */
127
extern int _nl_explode_name (char *name, const char **language,
128
			     const char **modifier, const char **territory,
129
			     const char **codeset,
130
			     const char **normalized_codeset);
131
132
#endif	/* loadinfo.h */
(-)a/intl/loadmsgcat.c (-1333 lines)
Lines 1-1333 Link Here
1
/* Load needed message catalogs.
2
   Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Tell glibc's <string.h> to provide a prototype for mempcpy().
20
   This must come before <config.h> because <config.h> may include
21
   <features.h>, and once <features.h> has been included, it's too late.  */
22
#ifndef _GNU_SOURCE
23
# define _GNU_SOURCE    1
24
#endif
25
26
#ifdef HAVE_CONFIG_H
27
# include <config.h>
28
#endif
29
30
#include <ctype.h>
31
#include <errno.h>
32
#include <fcntl.h>
33
#include <sys/types.h>
34
#include <sys/stat.h>
35
36
#ifdef __GNUC__
37
# undef  alloca
38
# define alloca __builtin_alloca
39
# define HAVE_ALLOCA 1
40
#else
41
# ifdef _MSC_VER
42
#  include <malloc.h>
43
#  define alloca _alloca
44
# else
45
#  if defined HAVE_ALLOCA_H || defined _LIBC
46
#   include <alloca.h>
47
#  else
48
#   ifdef _AIX
49
 #pragma alloca
50
#   else
51
#    ifndef alloca
52
char *alloca ();
53
#    endif
54
#   endif
55
#  endif
56
# endif
57
#endif
58
59
#include <stdlib.h>
60
#include <string.h>
61
62
#if defined HAVE_UNISTD_H || defined _LIBC
63
# include <unistd.h>
64
#endif
65
66
#ifdef _LIBC
67
# include <langinfo.h>
68
# include <locale.h>
69
#endif
70
71
#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
72
    || (defined _LIBC && defined _POSIX_MAPPED_FILES)
73
# include <sys/mman.h>
74
# undef HAVE_MMAP
75
# define HAVE_MMAP	1
76
#else
77
# undef HAVE_MMAP
78
#endif
79
80
#if defined HAVE_STDINT_H_WITH_UINTMAX || defined _LIBC
81
# include <stdint.h>
82
#endif
83
#if defined HAVE_INTTYPES_H || defined _LIBC
84
# include <inttypes.h>
85
#endif
86
87
#include "gmo.h"
88
#include "gettextP.h"
89
#include "hash-string.h"
90
#include "plural-exp.h"
91
92
#ifdef _LIBC
93
# include "../locale/localeinfo.h"
94
# include <not-cancel.h>
95
#endif
96
97
/* Handle multi-threaded applications.  */
98
#ifdef _LIBC
99
# include <bits/libc-lock.h>
100
#else
101
# include "lock.h"
102
#endif
103
104
/* Provide fallback values for macros that ought to be defined in <inttypes.h>.
105
   Note that our fallback values need not be literal strings, because we don't
106
   use them with preprocessor string concatenation.  */
107
#if !defined PRId8 || PRI_MACROS_BROKEN
108
# undef PRId8
109
# define PRId8 "d"
110
#endif
111
#if !defined PRIi8 || PRI_MACROS_BROKEN
112
# undef PRIi8
113
# define PRIi8 "i"
114
#endif
115
#if !defined PRIo8 || PRI_MACROS_BROKEN
116
# undef PRIo8
117
# define PRIo8 "o"
118
#endif
119
#if !defined PRIu8 || PRI_MACROS_BROKEN
120
# undef PRIu8
121
# define PRIu8 "u"
122
#endif
123
#if !defined PRIx8 || PRI_MACROS_BROKEN
124
# undef PRIx8
125
# define PRIx8 "x"
126
#endif
127
#if !defined PRIX8 || PRI_MACROS_BROKEN
128
# undef PRIX8
129
# define PRIX8 "X"
130
#endif
131
#if !defined PRId16 || PRI_MACROS_BROKEN
132
# undef PRId16
133
# define PRId16 "d"
134
#endif
135
#if !defined PRIi16 || PRI_MACROS_BROKEN
136
# undef PRIi16
137
# define PRIi16 "i"
138
#endif
139
#if !defined PRIo16 || PRI_MACROS_BROKEN
140
# undef PRIo16
141
# define PRIo16 "o"
142
#endif
143
#if !defined PRIu16 || PRI_MACROS_BROKEN
144
# undef PRIu16
145
# define PRIu16 "u"
146
#endif
147
#if !defined PRIx16 || PRI_MACROS_BROKEN
148
# undef PRIx16
149
# define PRIx16 "x"
150
#endif
151
#if !defined PRIX16 || PRI_MACROS_BROKEN
152
# undef PRIX16
153
# define PRIX16 "X"
154
#endif
155
#if !defined PRId32 || PRI_MACROS_BROKEN
156
# undef PRId32
157
# define PRId32 "d"
158
#endif
159
#if !defined PRIi32 || PRI_MACROS_BROKEN
160
# undef PRIi32
161
# define PRIi32 "i"
162
#endif
163
#if !defined PRIo32 || PRI_MACROS_BROKEN
164
# undef PRIo32
165
# define PRIo32 "o"
166
#endif
167
#if !defined PRIu32 || PRI_MACROS_BROKEN
168
# undef PRIu32
169
# define PRIu32 "u"
170
#endif
171
#if !defined PRIx32 || PRI_MACROS_BROKEN
172
# undef PRIx32
173
# define PRIx32 "x"
174
#endif
175
#if !defined PRIX32 || PRI_MACROS_BROKEN
176
# undef PRIX32
177
# define PRIX32 "X"
178
#endif
179
#if !defined PRId64 || PRI_MACROS_BROKEN
180
# undef PRId64
181
# define PRId64 (sizeof (long) == 8 ? "ld" : "lld")
182
#endif
183
#if !defined PRIi64 || PRI_MACROS_BROKEN
184
# undef PRIi64
185
# define PRIi64 (sizeof (long) == 8 ? "li" : "lli")
186
#endif
187
#if !defined PRIo64 || PRI_MACROS_BROKEN
188
# undef PRIo64
189
# define PRIo64 (sizeof (long) == 8 ? "lo" : "llo")
190
#endif
191
#if !defined PRIu64 || PRI_MACROS_BROKEN
192
# undef PRIu64
193
# define PRIu64 (sizeof (long) == 8 ? "lu" : "llu")
194
#endif
195
#if !defined PRIx64 || PRI_MACROS_BROKEN
196
# undef PRIx64
197
# define PRIx64 (sizeof (long) == 8 ? "lx" : "llx")
198
#endif
199
#if !defined PRIX64 || PRI_MACROS_BROKEN
200
# undef PRIX64
201
# define PRIX64 (sizeof (long) == 8 ? "lX" : "llX")
202
#endif
203
#if !defined PRIdLEAST8 || PRI_MACROS_BROKEN
204
# undef PRIdLEAST8
205
# define PRIdLEAST8 "d"
206
#endif
207
#if !defined PRIiLEAST8 || PRI_MACROS_BROKEN
208
# undef PRIiLEAST8
209
# define PRIiLEAST8 "i"
210
#endif
211
#if !defined PRIoLEAST8 || PRI_MACROS_BROKEN
212
# undef PRIoLEAST8
213
# define PRIoLEAST8 "o"
214
#endif
215
#if !defined PRIuLEAST8 || PRI_MACROS_BROKEN
216
# undef PRIuLEAST8
217
# define PRIuLEAST8 "u"
218
#endif
219
#if !defined PRIxLEAST8 || PRI_MACROS_BROKEN
220
# undef PRIxLEAST8
221
# define PRIxLEAST8 "x"
222
#endif
223
#if !defined PRIXLEAST8 || PRI_MACROS_BROKEN
224
# undef PRIXLEAST8
225
# define PRIXLEAST8 "X"
226
#endif
227
#if !defined PRIdLEAST16 || PRI_MACROS_BROKEN
228
# undef PRIdLEAST16
229
# define PRIdLEAST16 "d"
230
#endif
231
#if !defined PRIiLEAST16 || PRI_MACROS_BROKEN
232
# undef PRIiLEAST16
233
# define PRIiLEAST16 "i"
234
#endif
235
#if !defined PRIoLEAST16 || PRI_MACROS_BROKEN
236
# undef PRIoLEAST16
237
# define PRIoLEAST16 "o"
238
#endif
239
#if !defined PRIuLEAST16 || PRI_MACROS_BROKEN
240
# undef PRIuLEAST16
241
# define PRIuLEAST16 "u"
242
#endif
243
#if !defined PRIxLEAST16 || PRI_MACROS_BROKEN
244
# undef PRIxLEAST16
245
# define PRIxLEAST16 "x"
246
#endif
247
#if !defined PRIXLEAST16 || PRI_MACROS_BROKEN
248
# undef PRIXLEAST16
249
# define PRIXLEAST16 "X"
250
#endif
251
#if !defined PRIdLEAST32 || PRI_MACROS_BROKEN
252
# undef PRIdLEAST32
253
# define PRIdLEAST32 "d"
254
#endif
255
#if !defined PRIiLEAST32 || PRI_MACROS_BROKEN
256
# undef PRIiLEAST32
257
# define PRIiLEAST32 "i"
258
#endif
259
#if !defined PRIoLEAST32 || PRI_MACROS_BROKEN
260
# undef PRIoLEAST32
261
# define PRIoLEAST32 "o"
262
#endif
263
#if !defined PRIuLEAST32 || PRI_MACROS_BROKEN
264
# undef PRIuLEAST32
265
# define PRIuLEAST32 "u"
266
#endif
267
#if !defined PRIxLEAST32 || PRI_MACROS_BROKEN
268
# undef PRIxLEAST32
269
# define PRIxLEAST32 "x"
270
#endif
271
#if !defined PRIXLEAST32 || PRI_MACROS_BROKEN
272
# undef PRIXLEAST32
273
# define PRIXLEAST32 "X"
274
#endif
275
#if !defined PRIdLEAST64 || PRI_MACROS_BROKEN
276
# undef PRIdLEAST64
277
# define PRIdLEAST64 PRId64
278
#endif
279
#if !defined PRIiLEAST64 || PRI_MACROS_BROKEN
280
# undef PRIiLEAST64
281
# define PRIiLEAST64 PRIi64
282
#endif
283
#if !defined PRIoLEAST64 || PRI_MACROS_BROKEN
284
# undef PRIoLEAST64
285
# define PRIoLEAST64 PRIo64
286
#endif
287
#if !defined PRIuLEAST64 || PRI_MACROS_BROKEN
288
# undef PRIuLEAST64
289
# define PRIuLEAST64 PRIu64
290
#endif
291
#if !defined PRIxLEAST64 || PRI_MACROS_BROKEN
292
# undef PRIxLEAST64
293
# define PRIxLEAST64 PRIx64
294
#endif
295
#if !defined PRIXLEAST64 || PRI_MACROS_BROKEN
296
# undef PRIXLEAST64
297
# define PRIXLEAST64 PRIX64
298
#endif
299
#if !defined PRIdFAST8 || PRI_MACROS_BROKEN
300
# undef PRIdFAST8
301
# define PRIdFAST8 "d"
302
#endif
303
#if !defined PRIiFAST8 || PRI_MACROS_BROKEN
304
# undef PRIiFAST8
305
# define PRIiFAST8 "i"
306
#endif
307
#if !defined PRIoFAST8 || PRI_MACROS_BROKEN
308
# undef PRIoFAST8
309
# define PRIoFAST8 "o"
310
#endif
311
#if !defined PRIuFAST8 || PRI_MACROS_BROKEN
312
# undef PRIuFAST8
313
# define PRIuFAST8 "u"
314
#endif
315
#if !defined PRIxFAST8 || PRI_MACROS_BROKEN
316
# undef PRIxFAST8
317
# define PRIxFAST8 "x"
318
#endif
319
#if !defined PRIXFAST8 || PRI_MACROS_BROKEN
320
# undef PRIXFAST8
321
# define PRIXFAST8 "X"
322
#endif
323
#if !defined PRIdFAST16 || PRI_MACROS_BROKEN
324
# undef PRIdFAST16
325
# define PRIdFAST16 "d"
326
#endif
327
#if !defined PRIiFAST16 || PRI_MACROS_BROKEN
328
# undef PRIiFAST16
329
# define PRIiFAST16 "i"
330
#endif
331
#if !defined PRIoFAST16 || PRI_MACROS_BROKEN
332
# undef PRIoFAST16
333
# define PRIoFAST16 "o"
334
#endif
335
#if !defined PRIuFAST16 || PRI_MACROS_BROKEN
336
# undef PRIuFAST16
337
# define PRIuFAST16 "u"
338
#endif
339
#if !defined PRIxFAST16 || PRI_MACROS_BROKEN
340
# undef PRIxFAST16
341
# define PRIxFAST16 "x"
342
#endif
343
#if !defined PRIXFAST16 || PRI_MACROS_BROKEN
344
# undef PRIXFAST16
345
# define PRIXFAST16 "X"
346
#endif
347
#if !defined PRIdFAST32 || PRI_MACROS_BROKEN
348
# undef PRIdFAST32
349
# define PRIdFAST32 "d"
350
#endif
351
#if !defined PRIiFAST32 || PRI_MACROS_BROKEN
352
# undef PRIiFAST32
353
# define PRIiFAST32 "i"
354
#endif
355
#if !defined PRIoFAST32 || PRI_MACROS_BROKEN
356
# undef PRIoFAST32
357
# define PRIoFAST32 "o"
358
#endif
359
#if !defined PRIuFAST32 || PRI_MACROS_BROKEN
360
# undef PRIuFAST32
361
# define PRIuFAST32 "u"
362
#endif
363
#if !defined PRIxFAST32 || PRI_MACROS_BROKEN
364
# undef PRIxFAST32
365
# define PRIxFAST32 "x"
366
#endif
367
#if !defined PRIXFAST32 || PRI_MACROS_BROKEN
368
# undef PRIXFAST32
369
# define PRIXFAST32 "X"
370
#endif
371
#if !defined PRIdFAST64 || PRI_MACROS_BROKEN
372
# undef PRIdFAST64
373
# define PRIdFAST64 PRId64
374
#endif
375
#if !defined PRIiFAST64 || PRI_MACROS_BROKEN
376
# undef PRIiFAST64
377
# define PRIiFAST64 PRIi64
378
#endif
379
#if !defined PRIoFAST64 || PRI_MACROS_BROKEN
380
# undef PRIoFAST64
381
# define PRIoFAST64 PRIo64
382
#endif
383
#if !defined PRIuFAST64 || PRI_MACROS_BROKEN
384
# undef PRIuFAST64
385
# define PRIuFAST64 PRIu64
386
#endif
387
#if !defined PRIxFAST64 || PRI_MACROS_BROKEN
388
# undef PRIxFAST64
389
# define PRIxFAST64 PRIx64
390
#endif
391
#if !defined PRIXFAST64 || PRI_MACROS_BROKEN
392
# undef PRIXFAST64
393
# define PRIXFAST64 PRIX64
394
#endif
395
#if !defined PRIdMAX || PRI_MACROS_BROKEN
396
# undef PRIdMAX
397
# define PRIdMAX (sizeof (uintmax_t) == sizeof (long) ? "ld" : "lld")
398
#endif
399
#if !defined PRIiMAX || PRI_MACROS_BROKEN
400
# undef PRIiMAX
401
# define PRIiMAX (sizeof (uintmax_t) == sizeof (long) ? "li" : "lli")
402
#endif
403
#if !defined PRIoMAX || PRI_MACROS_BROKEN
404
# undef PRIoMAX
405
# define PRIoMAX (sizeof (uintmax_t) == sizeof (long) ? "lo" : "llo")
406
#endif
407
#if !defined PRIuMAX || PRI_MACROS_BROKEN
408
# undef PRIuMAX
409
# define PRIuMAX (sizeof (uintmax_t) == sizeof (long) ? "lu" : "llu")
410
#endif
411
#if !defined PRIxMAX || PRI_MACROS_BROKEN
412
# undef PRIxMAX
413
# define PRIxMAX (sizeof (uintmax_t) == sizeof (long) ? "lx" : "llx")
414
#endif
415
#if !defined PRIXMAX || PRI_MACROS_BROKEN
416
# undef PRIXMAX
417
# define PRIXMAX (sizeof (uintmax_t) == sizeof (long) ? "lX" : "llX")
418
#endif
419
#if !defined PRIdPTR || PRI_MACROS_BROKEN
420
# undef PRIdPTR
421
# define PRIdPTR \
422
  (sizeof (void *) == sizeof (long) ? "ld" : \
423
   sizeof (void *) == sizeof (int) ? "d" : \
424
   "lld")
425
#endif
426
#if !defined PRIiPTR || PRI_MACROS_BROKEN
427
# undef PRIiPTR
428
# define PRIiPTR \
429
  (sizeof (void *) == sizeof (long) ? "li" : \
430
   sizeof (void *) == sizeof (int) ? "i" : \
431
   "lli")
432
#endif
433
#if !defined PRIoPTR || PRI_MACROS_BROKEN
434
# undef PRIoPTR
435
# define PRIoPTR \
436
  (sizeof (void *) == sizeof (long) ? "lo" : \
437
   sizeof (void *) == sizeof (int) ? "o" : \
438
   "llo")
439
#endif
440
#if !defined PRIuPTR || PRI_MACROS_BROKEN
441
# undef PRIuPTR
442
# define PRIuPTR \
443
  (sizeof (void *) == sizeof (long) ? "lu" : \
444
   sizeof (void *) == sizeof (int) ? "u" : \
445
   "llu")
446
#endif
447
#if !defined PRIxPTR || PRI_MACROS_BROKEN
448
# undef PRIxPTR
449
# define PRIxPTR \
450
  (sizeof (void *) == sizeof (long) ? "lx" : \
451
   sizeof (void *) == sizeof (int) ? "x" : \
452
   "llx")
453
#endif
454
#if !defined PRIXPTR || PRI_MACROS_BROKEN
455
# undef PRIXPTR
456
# define PRIXPTR \
457
  (sizeof (void *) == sizeof (long) ? "lX" : \
458
   sizeof (void *) == sizeof (int) ? "X" : \
459
   "llX")
460
#endif
461
462
/* @@ end of prolog @@ */
463
464
#ifdef _LIBC
465
/* Rename the non ISO C functions.  This is required by the standard
466
   because some ISO C functions will require linking with this object
467
   file and the name space must not be polluted.  */
468
# define open(name, flags)	open_not_cancel_2 (name, flags)
469
# define close(fd)		close_not_cancel_no_status (fd)
470
# define read(fd, buf, n)	read_not_cancel (fd, buf, n)
471
# define mmap(addr, len, prot, flags, fd, offset) \
472
  __mmap (addr, len, prot, flags, fd, offset)
473
# define munmap(addr, len)	__munmap (addr, len)
474
#endif
475
476
/* For those losing systems which don't have `alloca' we have to add
477
   some additional code emulating it.  */
478
#ifdef HAVE_ALLOCA
479
# define freea(p) /* nothing */
480
#else
481
# define alloca(n) malloc (n)
482
# define freea(p) free (p)
483
#endif
484
485
/* For systems that distinguish between text and binary I/O.
486
   O_BINARY is usually declared in <fcntl.h>. */
487
#if !defined O_BINARY && defined _O_BINARY
488
  /* For MSC-compatible compilers.  */
489
# define O_BINARY _O_BINARY
490
# define O_TEXT _O_TEXT
491
#endif
492
#ifdef __BEOS__
493
  /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */
494
# undef O_BINARY
495
# undef O_TEXT
496
#endif
497
/* On reasonable systems, binary I/O is the default.  */
498
#ifndef O_BINARY
499
# define O_BINARY 0
500
#endif
501
502
503
/* We need a sign, whether a new catalog was loaded, which can be associated
504
   with all translations.  This is important if the translations are
505
   cached by one of GCC's features.  */
506
int _nl_msg_cat_cntr;
507
508
509
/* Expand a system dependent string segment.  Return NULL if unsupported.  */
510
static const char *
511
get_sysdep_segment_value (const char *name)
512
{
513
  /* Test for an ISO C 99 section 7.8.1 format string directive.
514
     Syntax:
515
     P R I { d | i | o | u | x | X }
516
     { { | LEAST | FAST } { 8 | 16 | 32 | 64 } | MAX | PTR }  */
517
  /* We don't use a table of 14 times 6 'const char *' strings here, because
518
     data relocations cost startup time.  */
519
  if (name[0] == 'P' && name[1] == 'R' && name[2] == 'I')
520
    {
521
      if (name[3] == 'd' || name[3] == 'i' || name[3] == 'o' || name[3] == 'u'
522
	  || name[3] == 'x' || name[3] == 'X')
523
	{
524
	  if (name[4] == '8' && name[5] == '\0')
525
	    {
526
	      if (name[3] == 'd')
527
		return PRId8;
528
	      if (name[3] == 'i')
529
		return PRIi8;
530
	      if (name[3] == 'o')
531
		return PRIo8;
532
	      if (name[3] == 'u')
533
		return PRIu8;
534
	      if (name[3] == 'x')
535
		return PRIx8;
536
	      if (name[3] == 'X')
537
		return PRIX8;
538
	      abort ();
539
	    }
540
	  if (name[4] == '1' && name[5] == '6' && name[6] == '\0')
541
	    {
542
	      if (name[3] == 'd')
543
		return PRId16;
544
	      if (name[3] == 'i')
545
		return PRIi16;
546
	      if (name[3] == 'o')
547
		return PRIo16;
548
	      if (name[3] == 'u')
549
		return PRIu16;
550
	      if (name[3] == 'x')
551
		return PRIx16;
552
	      if (name[3] == 'X')
553
		return PRIX16;
554
	      abort ();
555
	    }
556
	  if (name[4] == '3' && name[5] == '2' && name[6] == '\0')
557
	    {
558
	      if (name[3] == 'd')
559
		return PRId32;
560
	      if (name[3] == 'i')
561
		return PRIi32;
562
	      if (name[3] == 'o')
563
		return PRIo32;
564
	      if (name[3] == 'u')
565
		return PRIu32;
566
	      if (name[3] == 'x')
567
		return PRIx32;
568
	      if (name[3] == 'X')
569
		return PRIX32;
570
	      abort ();
571
	    }
572
	  if (name[4] == '6' && name[5] == '4' && name[6] == '\0')
573
	    {
574
	      if (name[3] == 'd')
575
		return PRId64;
576
	      if (name[3] == 'i')
577
		return PRIi64;
578
	      if (name[3] == 'o')
579
		return PRIo64;
580
	      if (name[3] == 'u')
581
		return PRIu64;
582
	      if (name[3] == 'x')
583
		return PRIx64;
584
	      if (name[3] == 'X')
585
		return PRIX64;
586
	      abort ();
587
	    }
588
	  if (name[4] == 'L' && name[5] == 'E' && name[6] == 'A'
589
	      && name[7] == 'S' && name[8] == 'T')
590
	    {
591
	      if (name[9] == '8' && name[10] == '\0')
592
		{
593
		  if (name[3] == 'd')
594
		    return PRIdLEAST8;
595
		  if (name[3] == 'i')
596
		    return PRIiLEAST8;
597
		  if (name[3] == 'o')
598
		    return PRIoLEAST8;
599
		  if (name[3] == 'u')
600
		    return PRIuLEAST8;
601
		  if (name[3] == 'x')
602
		    return PRIxLEAST8;
603
		  if (name[3] == 'X')
604
		    return PRIXLEAST8;
605
		  abort ();
606
		}
607
	      if (name[9] == '1' && name[10] == '6' && name[11] == '\0')
608
		{
609
		  if (name[3] == 'd')
610
		    return PRIdLEAST16;
611
		  if (name[3] == 'i')
612
		    return PRIiLEAST16;
613
		  if (name[3] == 'o')
614
		    return PRIoLEAST16;
615
		  if (name[3] == 'u')
616
		    return PRIuLEAST16;
617
		  if (name[3] == 'x')
618
		    return PRIxLEAST16;
619
		  if (name[3] == 'X')
620
		    return PRIXLEAST16;
621
		  abort ();
622
		}
623
	      if (name[9] == '3' && name[10] == '2' && name[11] == '\0')
624
		{
625
		  if (name[3] == 'd')
626
		    return PRIdLEAST32;
627
		  if (name[3] == 'i')
628
		    return PRIiLEAST32;
629
		  if (name[3] == 'o')
630
		    return PRIoLEAST32;
631
		  if (name[3] == 'u')
632
		    return PRIuLEAST32;
633
		  if (name[3] == 'x')
634
		    return PRIxLEAST32;
635
		  if (name[3] == 'X')
636
		    return PRIXLEAST32;
637
		  abort ();
638
		}
639
	      if (name[9] == '6' && name[10] == '4' && name[11] == '\0')
640
		{
641
		  if (name[3] == 'd')
642
		    return PRIdLEAST64;
643
		  if (name[3] == 'i')
644
		    return PRIiLEAST64;
645
		  if (name[3] == 'o')
646
		    return PRIoLEAST64;
647
		  if (name[3] == 'u')
648
		    return PRIuLEAST64;
649
		  if (name[3] == 'x')
650
		    return PRIxLEAST64;
651
		  if (name[3] == 'X')
652
		    return PRIXLEAST64;
653
		  abort ();
654
		}
655
	    }
656
	  if (name[4] == 'F' && name[5] == 'A' && name[6] == 'S'
657
	      && name[7] == 'T')
658
	    {
659
	      if (name[8] == '8' && name[9] == '\0')
660
		{
661
		  if (name[3] == 'd')
662
		    return PRIdFAST8;
663
		  if (name[3] == 'i')
664
		    return PRIiFAST8;
665
		  if (name[3] == 'o')
666
		    return PRIoFAST8;
667
		  if (name[3] == 'u')
668
		    return PRIuFAST8;
669
		  if (name[3] == 'x')
670
		    return PRIxFAST8;
671
		  if (name[3] == 'X')
672
		    return PRIXFAST8;
673
		  abort ();
674
		}
675
	      if (name[8] == '1' && name[9] == '6' && name[10] == '\0')
676
		{
677
		  if (name[3] == 'd')
678
		    return PRIdFAST16;
679
		  if (name[3] == 'i')
680
		    return PRIiFAST16;
681
		  if (name[3] == 'o')
682
		    return PRIoFAST16;
683
		  if (name[3] == 'u')
684
		    return PRIuFAST16;
685
		  if (name[3] == 'x')
686
		    return PRIxFAST16;
687
		  if (name[3] == 'X')
688
		    return PRIXFAST16;
689
		  abort ();
690
		}
691
	      if (name[8] == '3' && name[9] == '2' && name[10] == '\0')
692
		{
693
		  if (name[3] == 'd')
694
		    return PRIdFAST32;
695
		  if (name[3] == 'i')
696
		    return PRIiFAST32;
697
		  if (name[3] == 'o')
698
		    return PRIoFAST32;
699
		  if (name[3] == 'u')
700
		    return PRIuFAST32;
701
		  if (name[3] == 'x')
702
		    return PRIxFAST32;
703
		  if (name[3] == 'X')
704
		    return PRIXFAST32;
705
		  abort ();
706
		}
707
	      if (name[8] == '6' && name[9] == '4' && name[10] == '\0')
708
		{
709
		  if (name[3] == 'd')
710
		    return PRIdFAST64;
711
		  if (name[3] == 'i')
712
		    return PRIiFAST64;
713
		  if (name[3] == 'o')
714
		    return PRIoFAST64;
715
		  if (name[3] == 'u')
716
		    return PRIuFAST64;
717
		  if (name[3] == 'x')
718
		    return PRIxFAST64;
719
		  if (name[3] == 'X')
720
		    return PRIXFAST64;
721
		  abort ();
722
		}
723
	    }
724
	  if (name[4] == 'M' && name[5] == 'A' && name[6] == 'X'
725
	      && name[7] == '\0')
726
	    {
727
	      if (name[3] == 'd')
728
		return PRIdMAX;
729
	      if (name[3] == 'i')
730
		return PRIiMAX;
731
	      if (name[3] == 'o')
732
		return PRIoMAX;
733
	      if (name[3] == 'u')
734
		return PRIuMAX;
735
	      if (name[3] == 'x')
736
		return PRIxMAX;
737
	      if (name[3] == 'X')
738
		return PRIXMAX;
739
	      abort ();
740
	    }
741
	  if (name[4] == 'P' && name[5] == 'T' && name[6] == 'R'
742
	      && name[7] == '\0')
743
	    {
744
	      if (name[3] == 'd')
745
		return PRIdPTR;
746
	      if (name[3] == 'i')
747
		return PRIiPTR;
748
	      if (name[3] == 'o')
749
		return PRIoPTR;
750
	      if (name[3] == 'u')
751
		return PRIuPTR;
752
	      if (name[3] == 'x')
753
		return PRIxPTR;
754
	      if (name[3] == 'X')
755
		return PRIXPTR;
756
	      abort ();
757
	    }
758
	}
759
    }
760
  /* Test for a glibc specific printf() format directive flag.  */
761
  if (name[0] == 'I' && name[1] == '\0')
762
    {
763
#if defined _LIBC || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
764
      /* The 'I' flag, in numeric format directives, replaces ASCII digits
765
	 with the 'outdigits' defined in the LC_CTYPE locale facet.  This is
766
	 used for Farsi (Persian) and maybe Arabic.  */
767
      return "I";
768
#else
769
      return "";
770
#endif
771
    }
772
  /* Other system dependent strings are not valid.  */
773
  return NULL;
774
}
775
776
/* Load the message catalogs specified by FILENAME.  If it is no valid
777
   message catalog do nothing.  */
778
void
779
internal_function
780
_nl_load_domain (struct loaded_l10nfile *domain_file,
781
		 struct binding *domainbinding)
782
{
783
  __libc_lock_define_initialized_recursive (static, lock)
784
  int fd = -1;
785
  size_t size;
786
#ifdef _LIBC
787
  struct stat64 st;
788
#else
789
  struct stat st;
790
#endif
791
  struct mo_file_header *data = (struct mo_file_header *) -1;
792
  int use_mmap = 0;
793
  struct loaded_domain *domain;
794
  int revision;
795
  const char *nullentry;
796
  size_t nullentrylen;
797
798
  __libc_lock_lock_recursive (lock);
799
  if (domain_file->decided != 0)
800
    {
801
      /* There are two possibilities:
802
803
	 + this is the same thread calling again during this initialization
804
	   via _nl_find_msg.  We have initialized everything this call needs.
805
806
	 + this is another thread which tried to initialize this object.
807
	   Not necessary anymore since if the lock is available this
808
	   is finished.
809
      */
810
      goto done;
811
    }
812
813
  domain_file->decided = -1;
814
  domain_file->data = NULL;
815
816
  /* Note that it would be useless to store domainbinding in domain_file
817
     because domainbinding might be == NULL now but != NULL later (after
818
     a call to bind_textdomain_codeset).  */
819
820
  /* If the record does not represent a valid locale the FILENAME
821
     might be NULL.  This can happen when according to the given
822
     specification the locale file name is different for XPG and CEN
823
     syntax.  */
824
  if (domain_file->filename == NULL)
825
    goto out;
826
827
  /* Try to open the addressed file.  */
828
  fd = open (domain_file->filename, O_RDONLY | O_BINARY);
829
  if (fd == -1)
830
    goto out;
831
832
  /* We must know about the size of the file.  */
833
  if (
834
#ifdef _LIBC
835
      __builtin_expect (fstat64 (fd, &st) != 0, 0)
836
#else
837
      __builtin_expect (fstat (fd, &st) != 0, 0)
838
#endif
839
      || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
840
      || __builtin_expect (size < sizeof (struct mo_file_header), 0))
841
    /* Something went wrong.  */
842
    goto out;
843
844
#ifdef HAVE_MMAP
845
  /* Now we are ready to load the file.  If mmap() is available we try
846
     this first.  If not available or it failed we try to load it.  */
847
  data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
848
					 MAP_PRIVATE, fd, 0);
849
850
  if (__builtin_expect (data != (struct mo_file_header *) -1, 1))
851
    {
852
      /* mmap() call was successful.  */
853
      close (fd);
854
      fd = -1;
855
      use_mmap = 1;
856
    }
857
#endif
858
859
  /* If the data is not yet available (i.e. mmap'ed) we try to load
860
     it manually.  */
861
  if (data == (struct mo_file_header *) -1)
862
    {
863
      size_t to_read;
864
      char *read_ptr;
865
866
      data = (struct mo_file_header *) malloc (size);
867
      if (data == NULL)
868
	goto out;
869
870
      to_read = size;
871
      read_ptr = (char *) data;
872
      do
873
	{
874
	  long int nb = (long int) read (fd, read_ptr, to_read);
875
	  if (nb <= 0)
876
	    {
877
#ifdef EINTR
878
	      if (nb == -1 && errno == EINTR)
879
		continue;
880
#endif
881
	      goto out;
882
	    }
883
	  read_ptr += nb;
884
	  to_read -= nb;
885
	}
886
      while (to_read > 0);
887
888
      close (fd);
889
      fd = -1;
890
    }
891
892
  /* Using the magic number we can test whether it really is a message
893
     catalog file.  */
894
  if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED,
895
			0))
896
    {
897
      /* The magic number is wrong: not a message catalog file.  */
898
#ifdef HAVE_MMAP
899
      if (use_mmap)
900
	munmap ((caddr_t) data, size);
901
      else
902
#endif
903
	free (data);
904
      goto out;
905
    }
906
907
  domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain));
908
  if (domain == NULL)
909
    goto out;
910
  domain_file->data = domain;
911
912
  domain->data = (char *) data;
913
  domain->use_mmap = use_mmap;
914
  domain->mmap_size = size;
915
  domain->must_swap = data->magic != _MAGIC;
916
  domain->malloced = NULL;
917
918
  /* Fill in the information about the available tables.  */
919
  revision = W (domain->must_swap, data->revision);
920
  /* We support only the major revisions 0 and 1.  */
921
  switch (revision >> 16)
922
    {
923
    case 0:
924
    case 1:
925
      domain->nstrings = W (domain->must_swap, data->nstrings);
926
      domain->orig_tab = (const struct string_desc *)
927
	((char *) data + W (domain->must_swap, data->orig_tab_offset));
928
      domain->trans_tab = (const struct string_desc *)
929
	((char *) data + W (domain->must_swap, data->trans_tab_offset));
930
      domain->hash_size = W (domain->must_swap, data->hash_tab_size);
931
      domain->hash_tab =
932
	(domain->hash_size > 2
933
	 ? (const nls_uint32 *)
934
	   ((char *) data + W (domain->must_swap, data->hash_tab_offset))
935
	 : NULL);
936
      domain->must_swap_hash_tab = domain->must_swap;
937
938
      /* Now dispatch on the minor revision.  */
939
      switch (revision & 0xffff)
940
	{
941
	case 0:
942
	  domain->n_sysdep_strings = 0;
943
	  domain->orig_sysdep_tab = NULL;
944
	  domain->trans_sysdep_tab = NULL;
945
	  break;
946
	case 1:
947
	default:
948
	  {
949
	    nls_uint32 n_sysdep_strings;
950
951
	    if (domain->hash_tab == NULL)
952
	      /* This is invalid.  These minor revisions need a hash table.  */
953
	      goto invalid;
954
955
	    n_sysdep_strings =
956
	      W (domain->must_swap, data->n_sysdep_strings);
957
	    if (n_sysdep_strings > 0)
958
	      {
959
		nls_uint32 n_sysdep_segments;
960
		const struct sysdep_segment *sysdep_segments;
961
		const char **sysdep_segment_values;
962
		const nls_uint32 *orig_sysdep_tab;
963
		const nls_uint32 *trans_sysdep_tab;
964
		nls_uint32 n_inmem_sysdep_strings;
965
		size_t memneed;
966
		char *mem;
967
		struct sysdep_string_desc *inmem_orig_sysdep_tab;
968
		struct sysdep_string_desc *inmem_trans_sysdep_tab;
969
		nls_uint32 *inmem_hash_tab;
970
		unsigned int i, j;
971
972
		/* Get the values of the system dependent segments.  */
973
		n_sysdep_segments =
974
		  W (domain->must_swap, data->n_sysdep_segments);
975
		sysdep_segments = (const struct sysdep_segment *)
976
		  ((char *) data
977
		   + W (domain->must_swap, data->sysdep_segments_offset));
978
		sysdep_segment_values =
979
		  alloca (n_sysdep_segments * sizeof (const char *));
980
		for (i = 0; i < n_sysdep_segments; i++)
981
		  {
982
		    const char *name =
983
		      (char *) data
984
		      + W (domain->must_swap, sysdep_segments[i].offset);
985
		    nls_uint32 namelen =
986
		      W (domain->must_swap, sysdep_segments[i].length);
987
988
		    if (!(namelen > 0 && name[namelen - 1] == '\0'))
989
		      {
990
			freea (sysdep_segment_values);
991
			goto invalid;
992
		      }
993
994
		    sysdep_segment_values[i] = get_sysdep_segment_value (name);
995
		  }
996
997
		orig_sysdep_tab = (const nls_uint32 *)
998
		  ((char *) data
999
		   + W (domain->must_swap, data->orig_sysdep_tab_offset));
1000
		trans_sysdep_tab = (const nls_uint32 *)
1001
		  ((char *) data
1002
		   + W (domain->must_swap, data->trans_sysdep_tab_offset));
1003
1004
		/* Compute the amount of additional memory needed for the
1005
		   system dependent strings and the augmented hash table.
1006
		   At the same time, also drop string pairs which refer to
1007
		   an undefined system dependent segment.  */
1008
		n_inmem_sysdep_strings = 0;
1009
		memneed = domain->hash_size * sizeof (nls_uint32);
1010
		for (i = 0; i < n_sysdep_strings; i++)
1011
		  {
1012
		    int valid = 1;
1013
		    size_t needs[2];
1014
1015
		    for (j = 0; j < 2; j++)
1016
		      {
1017
			const struct sysdep_string *sysdep_string =
1018
			  (const struct sysdep_string *)
1019
			  ((char *) data
1020
			   + W (domain->must_swap,
1021
				j == 0
1022
				? orig_sysdep_tab[i]
1023
				: trans_sysdep_tab[i]));
1024
			size_t need = 0;
1025
			const struct segment_pair *p = sysdep_string->segments;
1026
1027
			if (W (domain->must_swap, p->sysdepref) != SEGMENTS_END)
1028
			  for (p = sysdep_string->segments;; p++)
1029
			    {
1030
			      nls_uint32 sysdepref;
1031
1032
			      need += W (domain->must_swap, p->segsize);
1033
1034
			      sysdepref = W (domain->must_swap, p->sysdepref);
1035
			      if (sysdepref == SEGMENTS_END)
1036
				break;
1037
1038
			      if (sysdepref >= n_sysdep_segments)
1039
				{
1040
				  /* Invalid.  */
1041
				  freea (sysdep_segment_values);
1042
				  goto invalid;
1043
				}
1044
1045
			      if (sysdep_segment_values[sysdepref] == NULL)
1046
				{
1047
				  /* This particular string pair is invalid.  */
1048
				  valid = 0;
1049
				  break;
1050
				}
1051
1052
			      need += strlen (sysdep_segment_values[sysdepref]);
1053
			    }
1054
1055
			needs[j] = need;
1056
			if (!valid)
1057
			  break;
1058
		      }
1059
1060
		    if (valid)
1061
		      {
1062
			n_inmem_sysdep_strings++;
1063
			memneed += needs[0] + needs[1];
1064
		      }
1065
		  }
1066
		memneed += 2 * n_inmem_sysdep_strings
1067
			   * sizeof (struct sysdep_string_desc);
1068
1069
		if (n_inmem_sysdep_strings > 0)
1070
		  {
1071
		    unsigned int k;
1072
1073
		    /* Allocate additional memory.  */
1074
		    mem = (char *) malloc (memneed);
1075
		    if (mem == NULL)
1076
		      goto invalid;
1077
1078
		    domain->malloced = mem;
1079
		    inmem_orig_sysdep_tab = (struct sysdep_string_desc *) mem;
1080
		    mem += n_inmem_sysdep_strings
1081
			   * sizeof (struct sysdep_string_desc);
1082
		    inmem_trans_sysdep_tab = (struct sysdep_string_desc *) mem;
1083
		    mem += n_inmem_sysdep_strings
1084
			   * sizeof (struct sysdep_string_desc);
1085
		    inmem_hash_tab = (nls_uint32 *) mem;
1086
		    mem += domain->hash_size * sizeof (nls_uint32);
1087
1088
		    /* Compute the system dependent strings.  */
1089
		    k = 0;
1090
		    for (i = 0; i < n_sysdep_strings; i++)
1091
		      {
1092
			int valid = 1;
1093
1094
			for (j = 0; j < 2; j++)
1095
			  {
1096
			    const struct sysdep_string *sysdep_string =
1097
			      (const struct sysdep_string *)
1098
			      ((char *) data
1099
			       + W (domain->must_swap,
1100
				    j == 0
1101
				    ? orig_sysdep_tab[i]
1102
				    : trans_sysdep_tab[i]));
1103
			    const struct segment_pair *p =
1104
			      sysdep_string->segments;
1105
1106
			    if (W (domain->must_swap, p->sysdepref)
1107
				!= SEGMENTS_END)
1108
			      for (p = sysdep_string->segments;; p++)
1109
				{
1110
				  nls_uint32 sysdepref;
1111
1112
				  sysdepref =
1113
				    W (domain->must_swap, p->sysdepref);
1114
				  if (sysdepref == SEGMENTS_END)
1115
				    break;
1116
1117
				  if (sysdep_segment_values[sysdepref] == NULL)
1118
				    {
1119
				      /* This particular string pair is
1120
					 invalid.  */
1121
				      valid = 0;
1122
				      break;
1123
				    }
1124
				}
1125
1126
			    if (!valid)
1127
			      break;
1128
			  }
1129
1130
			if (valid)
1131
			  {
1132
			    for (j = 0; j < 2; j++)
1133
			      {
1134
				const struct sysdep_string *sysdep_string =
1135
				  (const struct sysdep_string *)
1136
				  ((char *) data
1137
				   + W (domain->must_swap,
1138
					j == 0
1139
					? orig_sysdep_tab[i]
1140
					: trans_sysdep_tab[i]));
1141
				const char *static_segments =
1142
				  (char *) data
1143
				  + W (domain->must_swap, sysdep_string->offset);
1144
				const struct segment_pair *p =
1145
				  sysdep_string->segments;
1146
1147
				/* Concatenate the segments, and fill
1148
				   inmem_orig_sysdep_tab[k] (for j == 0) and
1149
				   inmem_trans_sysdep_tab[k] (for j == 1).  */
1150
1151
				struct sysdep_string_desc *inmem_tab_entry =
1152
				  (j == 0
1153
				   ? inmem_orig_sysdep_tab
1154
				   : inmem_trans_sysdep_tab)
1155
				  + k;
1156
1157
				if (W (domain->must_swap, p->sysdepref)
1158
				    == SEGMENTS_END)
1159
				  {
1160
				    /* Only one static segment.  */
1161
				    inmem_tab_entry->length =
1162
				      W (domain->must_swap, p->segsize);
1163
				    inmem_tab_entry->pointer = static_segments;
1164
				  }
1165
				else
1166
				  {
1167
				    inmem_tab_entry->pointer = mem;
1168
1169
				    for (p = sysdep_string->segments;; p++)
1170
				      {
1171
					nls_uint32 segsize =
1172
					  W (domain->must_swap, p->segsize);
1173
					nls_uint32 sysdepref =
1174
					  W (domain->must_swap, p->sysdepref);
1175
					size_t n;
1176
1177
					if (segsize > 0)
1178
					  {
1179
					    memcpy (mem, static_segments, segsize);
1180
					    mem += segsize;
1181
					    static_segments += segsize;
1182
					  }
1183
1184
					if (sysdepref == SEGMENTS_END)
1185
					  break;
1186
1187
					n = strlen (sysdep_segment_values[sysdepref]);
1188
					memcpy (mem, sysdep_segment_values[sysdepref], n);
1189
					mem += n;
1190
				      }
1191
1192
				    inmem_tab_entry->length =
1193
				      mem - inmem_tab_entry->pointer;
1194
				  }
1195
			      }
1196
1197
			    k++;
1198
			  }
1199
		      }
1200
		    if (k != n_inmem_sysdep_strings)
1201
		      abort ();
1202
1203
		    /* Compute the augmented hash table.  */
1204
		    for (i = 0; i < domain->hash_size; i++)
1205
		      inmem_hash_tab[i] =
1206
			W (domain->must_swap_hash_tab, domain->hash_tab[i]);
1207
		    for (i = 0; i < n_inmem_sysdep_strings; i++)
1208
		      {
1209
			const char *msgid = inmem_orig_sysdep_tab[i].pointer;
1210
			nls_uint32 hash_val = __hash_string (msgid);
1211
			nls_uint32 idx = hash_val % domain->hash_size;
1212
			nls_uint32 incr =
1213
			  1 + (hash_val % (domain->hash_size - 2));
1214
1215
			for (;;)
1216
			  {
1217
			    if (inmem_hash_tab[idx] == 0)
1218
			      {
1219
				/* Hash table entry is empty.  Use it.  */
1220
				inmem_hash_tab[idx] = 1 + domain->nstrings + i;
1221
				break;
1222
			      }
1223
1224
			    if (idx >= domain->hash_size - incr)
1225
			      idx -= domain->hash_size - incr;
1226
			    else
1227
			      idx += incr;
1228
			  }
1229
		      }
1230
1231
		    domain->n_sysdep_strings = n_inmem_sysdep_strings;
1232
		    domain->orig_sysdep_tab = inmem_orig_sysdep_tab;
1233
		    domain->trans_sysdep_tab = inmem_trans_sysdep_tab;
1234
1235
		    domain->hash_tab = inmem_hash_tab;
1236
		    domain->must_swap_hash_tab = 0;
1237
		  }
1238
		else
1239
		  {
1240
		    domain->n_sysdep_strings = 0;
1241
		    domain->orig_sysdep_tab = NULL;
1242
		    domain->trans_sysdep_tab = NULL;
1243
		  }
1244
1245
		freea (sysdep_segment_values);
1246
	      }
1247
	    else
1248
	      {
1249
		domain->n_sysdep_strings = 0;
1250
		domain->orig_sysdep_tab = NULL;
1251
		domain->trans_sysdep_tab = NULL;
1252
	      }
1253
	  }
1254
	  break;
1255
	}
1256
      break;
1257
    default:
1258
      /* This is an invalid revision.  */
1259
    invalid:
1260
      /* This is an invalid .mo file.  */
1261
      if (domain->malloced)
1262
	free (domain->malloced);
1263
#ifdef HAVE_MMAP
1264
      if (use_mmap)
1265
	munmap ((caddr_t) data, size);
1266
      else
1267
#endif
1268
	free (data);
1269
      free (domain);
1270
      domain_file->data = NULL;
1271
      goto out;
1272
    }
1273
1274
  /* No caches of converted translations so far.  */
1275
  domain->conversions = NULL;
1276
  domain->nconversions = 0;
1277
1278
  /* Get the header entry and look for a plural specification.  */
1279
#ifdef IN_LIBGLOCALE
1280
  nullentry =
1281
    _nl_find_msg (domain_file, domainbinding, NULL, "", &nullentrylen);
1282
#else
1283
  nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen);
1284
#endif
1285
  EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
1286
1287
 out:
1288
  if (fd != -1)
1289
    close (fd);
1290
1291
  domain_file->decided = 1;
1292
1293
 done:
1294
  __libc_lock_unlock_recursive (lock);
1295
}
1296
1297
1298
#ifdef _LIBC
1299
void
1300
internal_function __libc_freeres_fn_section
1301
_nl_unload_domain (struct loaded_domain *domain)
1302
{
1303
  size_t i;
1304
1305
  if (domain->plural != &__gettext_germanic_plural)
1306
    __gettext_free_exp (domain->plural);
1307
1308
  for (i = 0; i < domain->nconversions; i++)
1309
    {
1310
      struct converted_domain *convd = &domain->conversions[i];
1311
1312
      free (convd->encoding);
1313
      if (convd->conv_tab != NULL && convd->conv_tab != (char **) -1)
1314
	free (convd->conv_tab);
1315
      if (convd->conv != (__gconv_t) -1)
1316
	__gconv_close (convd->conv);
1317
    }
1318
  if (domain->conversions != NULL)
1319
    free (domain->conversions);
1320
1321
  if (domain->malloced)
1322
    free (domain->malloced);
1323
1324
# ifdef _POSIX_MAPPED_FILES
1325
  if (domain->use_mmap)
1326
    munmap ((caddr_t) domain->data, domain->mmap_size);
1327
  else
1328
# endif	/* _POSIX_MAPPED_FILES */
1329
    free ((void *) domain->data);
1330
1331
  free (domain);
1332
}
1333
#endif
(-)a/intl/localcharset.c (-461 lines)
Lines 1-461 Link Here
1
/* Determine a canonical name for the current locale's character encoding.
2
3
   Copyright (C) 2000-2006 Free Software Foundation, Inc.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
/* Written by Bruno Haible <bruno@clisp.org>.  */
21
22
#include <config.h>
23
24
/* Specification.  */
25
#include "localcharset.h"
26
27
#include <stddef.h>
28
#include <stdio.h>
29
#include <string.h>
30
#include <stdlib.h>
31
32
#if defined _WIN32 || defined __WIN32__
33
# define WIN32_NATIVE
34
#endif
35
36
#if defined __EMX__
37
/* Assume EMX program runs on OS/2, even if compiled under DOS.  */
38
# define OS2
39
#endif
40
41
#if !defined WIN32_NATIVE
42
# if HAVE_LANGINFO_CODESET
43
#  include <langinfo.h>
44
# else
45
#  if 0 /* see comment below */
46
#   include <locale.h>
47
#  endif
48
# endif
49
# ifdef __CYGWIN__
50
#  define WIN32_LEAN_AND_MEAN
51
#  include <windows.h>
52
# endif
53
#elif defined WIN32_NATIVE
54
# define WIN32_LEAN_AND_MEAN
55
# include <windows.h>
56
#endif
57
#if defined OS2
58
# define INCL_DOS
59
# include <os2.h>
60
#endif
61
62
#if ENABLE_RELOCATABLE
63
# include "relocatable.h"
64
#else
65
# define relocate(pathname) (pathname)
66
#endif
67
68
/* Get LIBDIR.  */
69
#ifndef LIBDIR
70
# include "configmake.h"
71
#endif
72
73
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
74
  /* Win32, Cygwin, OS/2, DOS */
75
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
76
#endif
77
78
#ifndef DIRECTORY_SEPARATOR
79
# define DIRECTORY_SEPARATOR '/'
80
#endif
81
82
#ifndef ISSLASH
83
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
84
#endif
85
86
#if HAVE_DECL_GETC_UNLOCKED
87
# undef getc
88
# define getc getc_unlocked
89
#endif
90
91
/* The following static variable is declared 'volatile' to avoid a
92
   possible multithread problem in the function get_charset_aliases. If we
93
   are running in a threaded environment, and if two threads initialize
94
   'charset_aliases' simultaneously, both will produce the same value,
95
   and everything will be ok if the two assignments to 'charset_aliases'
96
   are atomic. But I don't know what will happen if the two assignments mix.  */
97
#if __STDC__ != 1
98
# define volatile /* empty */
99
#endif
100
/* Pointer to the contents of the charset.alias file, if it has already been
101
   read, else NULL.  Its format is:
102
   ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0'  */
103
static const char * volatile charset_aliases;
104
105
/* Return a pointer to the contents of the charset.alias file.  */
106
static const char *
107
get_charset_aliases (void)
108
{
109
  const char *cp;
110
111
  cp = charset_aliases;
112
  if (cp == NULL)
113
    {
114
#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
115
      FILE *fp;
116
      const char *dir;
117
      const char *base = "charset.alias";
118
      char *file_name;
119
120
      /* Make it possible to override the charset.alias location.  This is
121
	 necessary for running the testsuite before "make install".  */
122
      dir = getenv ("CHARSETALIASDIR");
123
      if (dir == NULL || dir[0] == '\0')
124
	dir = relocate (LIBDIR);
125
126
      /* Concatenate dir and base into freshly allocated file_name.  */
127
      {
128
	size_t dir_len = strlen (dir);
129
	size_t base_len = strlen (base);
130
	int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
131
	file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
132
	if (file_name != NULL)
133
	  {
134
	    memcpy (file_name, dir, dir_len);
135
	    if (add_slash)
136
	      file_name[dir_len] = DIRECTORY_SEPARATOR;
137
	    memcpy (file_name + dir_len + add_slash, base, base_len + 1);
138
	  }
139
      }
140
141
      if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
142
	/* Out of memory or file not found, treat it as empty.  */
143
	cp = "";
144
      else
145
	{
146
	  /* Parse the file's contents.  */
147
	  char *res_ptr = NULL;
148
	  size_t res_size = 0;
149
150
	  for (;;)
151
	    {
152
	      int c;
153
	      char buf1[50+1];
154
	      char buf2[50+1];
155
	      size_t l1, l2;
156
	      char *old_res_ptr;
157
158
	      c = getc (fp);
159
	      if (c == EOF)
160
		break;
161
	      if (c == '\n' || c == ' ' || c == '\t')
162
		continue;
163
	      if (c == '#')
164
		{
165
		  /* Skip comment, to end of line.  */
166
		  do
167
		    c = getc (fp);
168
		  while (!(c == EOF || c == '\n'));
169
		  if (c == EOF)
170
		    break;
171
		  continue;
172
		}
173
	      ungetc (c, fp);
174
	      if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
175
		break;
176
	      l1 = strlen (buf1);
177
	      l2 = strlen (buf2);
178
	      old_res_ptr = res_ptr;
179
	      if (res_size == 0)
180
		{
181
		  res_size = l1 + 1 + l2 + 1;
182
		  res_ptr = (char *) malloc (res_size + 1);
183
		}
184
	      else
185
		{
186
		  res_size += l1 + 1 + l2 + 1;
187
		  res_ptr = (char *) realloc (res_ptr, res_size + 1);
188
		}
189
	      if (res_ptr == NULL)
190
		{
191
		  /* Out of memory. */
192
		  res_size = 0;
193
		  if (old_res_ptr != NULL)
194
		    free (old_res_ptr);
195
		  break;
196
		}
197
	      strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
198
	      strcpy (res_ptr + res_size - (l2 + 1), buf2);
199
	    }
200
	  fclose (fp);
201
	  if (res_size == 0)
202
	    cp = "";
203
	  else
204
	    {
205
	      *(res_ptr + res_size) = '\0';
206
	      cp = res_ptr;
207
	    }
208
	}
209
210
      if (file_name != NULL)
211
	free (file_name);
212
213
#else
214
215
# if defined VMS
216
      /* To avoid the troubles of an extra file charset.alias_vms in the
217
	 sources of many GNU packages, simply inline the aliases here.  */
218
      /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
219
	 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
220
	 section 10.7 "Handling Different Character Sets".  */
221
      cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
222
	   "ISO8859-2" "\0" "ISO-8859-2" "\0"
223
	   "ISO8859-5" "\0" "ISO-8859-5" "\0"
224
	   "ISO8859-7" "\0" "ISO-8859-7" "\0"
225
	   "ISO8859-8" "\0" "ISO-8859-8" "\0"
226
	   "ISO8859-9" "\0" "ISO-8859-9" "\0"
227
	   /* Japanese */
228
	   "eucJP" "\0" "EUC-JP" "\0"
229
	   "SJIS" "\0" "SHIFT_JIS" "\0"
230
	   "DECKANJI" "\0" "DEC-KANJI" "\0"
231
	   "SDECKANJI" "\0" "EUC-JP" "\0"
232
	   /* Chinese */
233
	   "eucTW" "\0" "EUC-TW" "\0"
234
	   "DECHANYU" "\0" "DEC-HANYU" "\0"
235
	   "DECHANZI" "\0" "GB2312" "\0"
236
	   /* Korean */
237
	   "DECKOREAN" "\0" "EUC-KR" "\0";
238
# endif
239
240
# if defined WIN32_NATIVE || defined __CYGWIN__
241
      /* To avoid the troubles of installing a separate file in the same
242
	 directory as the DLL and of retrieving the DLL's directory at
243
	 runtime, simply inline the aliases here.  */
244
245
      cp = "CP936" "\0" "GBK" "\0"
246
	   "CP1361" "\0" "JOHAB" "\0"
247
	   "CP20127" "\0" "ASCII" "\0"
248
	   "CP20866" "\0" "KOI8-R" "\0"
249
	   "CP20936" "\0" "GB2312" "\0"
250
	   "CP21866" "\0" "KOI8-RU" "\0"
251
	   "CP28591" "\0" "ISO-8859-1" "\0"
252
	   "CP28592" "\0" "ISO-8859-2" "\0"
253
	   "CP28593" "\0" "ISO-8859-3" "\0"
254
	   "CP28594" "\0" "ISO-8859-4" "\0"
255
	   "CP28595" "\0" "ISO-8859-5" "\0"
256
	   "CP28596" "\0" "ISO-8859-6" "\0"
257
	   "CP28597" "\0" "ISO-8859-7" "\0"
258
	   "CP28598" "\0" "ISO-8859-8" "\0"
259
	   "CP28599" "\0" "ISO-8859-9" "\0"
260
	   "CP28605" "\0" "ISO-8859-15" "\0"
261
	   "CP38598" "\0" "ISO-8859-8" "\0"
262
	   "CP51932" "\0" "EUC-JP" "\0"
263
	   "CP51936" "\0" "GB2312" "\0"
264
	   "CP51949" "\0" "EUC-KR" "\0"
265
	   "CP51950" "\0" "EUC-TW" "\0"
266
	   "CP54936" "\0" "GB18030" "\0"
267
	   "CP65001" "\0" "UTF-8" "\0";
268
# endif
269
#endif
270
271
      charset_aliases = cp;
272
    }
273
274
  return cp;
275
}
276
277
/* Determine the current locale's character encoding, and canonicalize it
278
   into one of the canonical names listed in config.charset.
279
   The result must not be freed; it is statically allocated.
280
   If the canonical name cannot be determined, the result is a non-canonical
281
   name.  */
282
283
#ifdef STATIC
284
STATIC
285
#endif
286
const char *
287
locale_charset (void)
288
{
289
  const char *codeset;
290
  const char *aliases;
291
292
#if !(defined WIN32_NATIVE || defined OS2)
293
294
# if HAVE_LANGINFO_CODESET
295
296
  /* Most systems support nl_langinfo (CODESET) nowadays.  */
297
  codeset = nl_langinfo (CODESET);
298
299
#  ifdef __CYGWIN__
300
  /* Cygwin 2006 does not have locales.  nl_langinfo (CODESET) always
301
     returns "US-ASCII".  As long as this is not fixed, return the suffix
302
     of the locale name from the environment variables (if present) or
303
     the codepage as a number.  */
304
  if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
305
    {
306
      const char *locale;
307
      static char buf[2 + 10 + 1];
308
309
      locale = getenv ("LC_ALL");
310
      if (locale == NULL || locale[0] == '\0')
311
	{
312
	  locale = getenv ("LC_CTYPE");
313
	  if (locale == NULL || locale[0] == '\0')
314
	    locale = getenv ("LANG");
315
	}
316
      if (locale != NULL && locale[0] != '\0')
317
	{
318
	  /* If the locale name contains an encoding after the dot, return
319
	     it.  */
320
	  const char *dot = strchr (locale, '.');
321
322
	  if (dot != NULL)
323
	    {
324
	      const char *modifier;
325
326
	      dot++;
327
	      /* Look for the possible @... trailer and remove it, if any.  */
328
	      modifier = strchr (dot, '@');
329
	      if (modifier == NULL)
330
		return dot;
331
	      if (modifier - dot < sizeof (buf))
332
		{
333
		  memcpy (buf, dot, modifier - dot);
334
		  buf [modifier - dot] = '\0';
335
		  return buf;
336
		}
337
	    }
338
	}
339
340
      /* Woe32 has a function returning the locale's codepage as a number.  */
341
      sprintf (buf, "CP%u", GetACP ());
342
      codeset = buf;
343
    }
344
#  endif
345
346
# else
347
348
  /* On old systems which lack it, use setlocale or getenv.  */
349
  const char *locale = NULL;
350
351
  /* But most old systems don't have a complete set of locales.  Some
352
     (like SunOS 4 or DJGPP) have only the C locale.  Therefore we don't
353
     use setlocale here; it would return "C" when it doesn't support the
354
     locale name the user has set.  */
355
#  if 0
356
  locale = setlocale (LC_CTYPE, NULL);
357
#  endif
358
  if (locale == NULL || locale[0] == '\0')
359
    {
360
      locale = getenv ("LC_ALL");
361
      if (locale == NULL || locale[0] == '\0')
362
	{
363
	  locale = getenv ("LC_CTYPE");
364
	  if (locale == NULL || locale[0] == '\0')
365
	    locale = getenv ("LANG");
366
	}
367
    }
368
369
  /* On some old systems, one used to set locale = "iso8859_1". On others,
370
     you set it to "language_COUNTRY.charset". In any case, we resolve it
371
     through the charset.alias file.  */
372
  codeset = locale;
373
374
# endif
375
376
#elif defined WIN32_NATIVE
377
378
  static char buf[2 + 10 + 1];
379
380
  /* Woe32 has a function returning the locale's codepage as a number.  */
381
  sprintf (buf, "CP%u", GetACP ());
382
  codeset = buf;
383
384
#elif defined OS2
385
386
  const char *locale;
387
  static char buf[2 + 10 + 1];
388
  ULONG cp[3];
389
  ULONG cplen;
390
391
  /* Allow user to override the codeset, as set in the operating system,
392
     with standard language environment variables.  */
393
  locale = getenv ("LC_ALL");
394
  if (locale == NULL || locale[0] == '\0')
395
    {
396
      locale = getenv ("LC_CTYPE");
397
      if (locale == NULL || locale[0] == '\0')
398
	locale = getenv ("LANG");
399
    }
400
  if (locale != NULL && locale[0] != '\0')
401
    {
402
      /* If the locale name contains an encoding after the dot, return it.  */
403
      const char *dot = strchr (locale, '.');
404
405
      if (dot != NULL)
406
	{
407
	  const char *modifier;
408
409
	  dot++;
410
	  /* Look for the possible @... trailer and remove it, if any.  */
411
	  modifier = strchr (dot, '@');
412
	  if (modifier == NULL)
413
	    return dot;
414
	  if (modifier - dot < sizeof (buf))
415
	    {
416
	      memcpy (buf, dot, modifier - dot);
417
	      buf [modifier - dot] = '\0';
418
	      return buf;
419
	    }
420
	}
421
422
      /* Resolve through the charset.alias file.  */
423
      codeset = locale;
424
    }
425
  else
426
    {
427
      /* OS/2 has a function returning the locale's codepage as a number.  */
428
      if (DosQueryCp (sizeof (cp), cp, &cplen))
429
	codeset = "";
430
      else
431
	{
432
	  sprintf (buf, "CP%u", cp[0]);
433
	  codeset = buf;
434
	}
435
    }
436
437
#endif
438
439
  if (codeset == NULL)
440
    /* The canonical name cannot be determined.  */
441
    codeset = "";
442
443
  /* Resolve alias. */
444
  for (aliases = get_charset_aliases ();
445
       *aliases != '\0';
446
       aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
447
    if (strcmp (codeset, aliases) == 0
448
	|| (aliases[0] == '*' && aliases[1] == '\0'))
449
      {
450
	codeset = aliases + strlen (aliases) + 1;
451
	break;
452
      }
453
454
  /* Don't return an empty string.  GNU libc and GNU libiconv interpret
455
     the empty string as denoting "the locale's character encoding",
456
     thus GNU libiconv would call this function a second time.  */
457
  if (codeset[0] == '\0')
458
    codeset = "ASCII";
459
460
  return codeset;
461
}
(-)a/intl/localcharset.h (-42 lines)
Lines 1-42 Link Here
1
/* Determine a canonical name for the current locale's character encoding.
2
   Copyright (C) 2000-2003 Free Software Foundation, Inc.
3
   This file is part of the GNU CHARSET Library.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifndef _LOCALCHARSET_H
21
#define _LOCALCHARSET_H
22
23
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
28
29
/* Determine the current locale's character encoding, and canonicalize it
30
   into one of the canonical names listed in config.charset.
31
   The result must not be freed; it is statically allocated.
32
   If the canonical name cannot be determined, the result is a non-canonical
33
   name.  */
34
extern const char * locale_charset (void);
35
36
37
#ifdef __cplusplus
38
}
39
#endif
40
41
42
#endif /* _LOCALCHARSET_H */
(-)a/intl/locale.alias (-78 lines)
Lines 1-78 Link Here
1
# Locale name alias data base.
2
# Copyright (C) 1996-2001,2003 Free Software Foundation, Inc.
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU Library General Public License as published
6
# by the Free Software Foundation; either version 2, or (at your option)
7
# any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
# Library General Public License for more details.
13
#
14
# You should have received a copy of the GNU Library General Public
15
# License along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
# USA.
18
19
# The format of this file is the same as for the corresponding file of
20
# the X Window System, which normally can be found in
21
#	/usr/lib/X11/locale/locale.alias
22
# A single line contains two fields: an alias and a substitution value.
23
# All entries are case independent.
24
25
# Note: This file is far from being complete.  If you have a value for
26
# your own site which you think might be useful for others too, share
27
# it with the rest of us.  Send it using the `glibcbug' script to
28
# bugs@gnu.org.
29
30
# Packages using this file: 
31
32
bokmal		nb_NO.ISO-8859-1
33
bokmål		nb_NO.ISO-8859-1
34
catalan		ca_ES.ISO-8859-1
35
croatian	hr_HR.ISO-8859-2
36
czech		cs_CZ.ISO-8859-2
37
danish          da_DK.ISO-8859-1
38
dansk		da_DK.ISO-8859-1
39
deutsch		de_DE.ISO-8859-1
40
dutch		nl_NL.ISO-8859-1
41
eesti		et_EE.ISO-8859-1
42
estonian	et_EE.ISO-8859-1
43
finnish         fi_FI.ISO-8859-1
44
français	fr_FR.ISO-8859-1
45
french		fr_FR.ISO-8859-1
46
galego		gl_ES.ISO-8859-1
47
galician	gl_ES.ISO-8859-1
48
german		de_DE.ISO-8859-1
49
greek           el_GR.ISO-8859-7
50
hebrew          he_IL.ISO-8859-8
51
hrvatski	hr_HR.ISO-8859-2
52
hungarian       hu_HU.ISO-8859-2
53
icelandic       is_IS.ISO-8859-1
54
italian         it_IT.ISO-8859-1
55
japanese	ja_JP.eucJP
56
japanese.euc	ja_JP.eucJP
57
ja_JP		ja_JP.eucJP
58
ja_JP.ujis	ja_JP.eucJP
59
japanese.sjis	ja_JP.SJIS
60
korean		ko_KR.eucKR
61
korean.euc 	ko_KR.eucKR
62
ko_KR		ko_KR.eucKR
63
lithuanian      lt_LT.ISO-8859-13
64
no_NO		nb_NO.ISO-8859-1
65
no_NO.ISO-8859-1 nb_NO.ISO-8859-1
66
norwegian       nb_NO.ISO-8859-1
67
nynorsk		nn_NO.ISO-8859-1
68
polish          pl_PL.ISO-8859-2
69
portuguese      pt_PT.ISO-8859-1
70
romanian        ro_RO.ISO-8859-2
71
russian         ru_RU.ISO-8859-5
72
slovak          sk_SK.ISO-8859-2
73
slovene         sl_SI.ISO-8859-2
74
slovenian       sl_SI.ISO-8859-2
75
spanish         es_ES.ISO-8859-1
76
swedish         sv_SE.ISO-8859-1
77
thai		th_TH.TIS-620
78
turkish         tr_TR.ISO-8859-9
(-)a/intl/localealias.c (-437 lines)
Lines 1-437 Link Here
1
/* Handle aliases for locale names.
2
   Copyright (C) 1995-1999, 2000-2001, 2003, 2005 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Tell glibc's <string.h> to provide a prototype for mempcpy().
20
   This must come before <config.h> because <config.h> may include
21
   <features.h>, and once <features.h> has been included, it's too late.  */
22
#ifndef _GNU_SOURCE
23
# define _GNU_SOURCE    1
24
#endif
25
26
#ifdef HAVE_CONFIG_H
27
# include <config.h>
28
#endif
29
30
#include <ctype.h>
31
#include <stdio.h>
32
#if defined _LIBC || defined HAVE___FSETLOCKING
33
# include <stdio_ext.h>
34
#endif
35
#include <sys/types.h>
36
37
#ifdef __GNUC__
38
# undef alloca
39
# define alloca __builtin_alloca
40
# define HAVE_ALLOCA 1
41
#else
42
# ifdef _MSC_VER
43
#  include <malloc.h>
44
#  define alloca _alloca
45
# else
46
#  if defined HAVE_ALLOCA_H || defined _LIBC
47
#   include <alloca.h>
48
#  else
49
#   ifdef _AIX
50
 #pragma alloca
51
#   else
52
#    ifndef alloca
53
char *alloca ();
54
#    endif
55
#   endif
56
#  endif
57
# endif
58
#endif
59
60
#include <stdlib.h>
61
#include <string.h>
62
63
#include "gettextP.h"
64
65
#if ENABLE_RELOCATABLE
66
# include "relocatable.h"
67
#else
68
# define relocate(pathname) (pathname)
69
#endif
70
71
/* @@ end of prolog @@ */
72
73
#ifdef _LIBC
74
/* Rename the non ANSI C functions.  This is required by the standard
75
   because some ANSI C functions will require linking with this object
76
   file and the name space must not be polluted.  */
77
# define strcasecmp __strcasecmp
78
79
# ifndef mempcpy
80
#  define mempcpy __mempcpy
81
# endif
82
# define HAVE_MEMPCPY	1
83
# define HAVE___FSETLOCKING	1
84
#endif
85
86
/* Handle multi-threaded applications.  */
87
#ifdef _LIBC
88
# include <bits/libc-lock.h>
89
#else
90
# include "lock.h"
91
#endif
92
93
#ifndef internal_function
94
# define internal_function
95
#endif
96
97
/* Some optimizations for glibc.  */
98
#ifdef _LIBC
99
# define FEOF(fp)		feof_unlocked (fp)
100
# define FGETS(buf, n, fp)	fgets_unlocked (buf, n, fp)
101
#else
102
# define FEOF(fp)		feof (fp)
103
# define FGETS(buf, n, fp)	fgets (buf, n, fp)
104
#endif
105
106
/* For those losing systems which don't have `alloca' we have to add
107
   some additional code emulating it.  */
108
#ifdef HAVE_ALLOCA
109
# define freea(p) /* nothing */
110
#else
111
# define alloca(n) malloc (n)
112
# define freea(p) free (p)
113
#endif
114
115
#if defined _LIBC_REENTRANT || HAVE_DECL_FGETS_UNLOCKED
116
# undef fgets
117
# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
118
#endif
119
#if defined _LIBC_REENTRANT || HAVE_DECL_FEOF_UNLOCKED
120
# undef feof
121
# define feof(s) feof_unlocked (s)
122
#endif
123
124
125
__libc_lock_define_initialized (static, lock)
126
127
128
struct alias_map
129
{
130
  const char *alias;
131
  const char *value;
132
};
133
134
135
#ifndef _LIBC
136
# define libc_freeres_ptr(decl) decl
137
#endif
138
139
libc_freeres_ptr (static char *string_space);
140
static size_t string_space_act;
141
static size_t string_space_max;
142
libc_freeres_ptr (static struct alias_map *map);
143
static size_t nmap;
144
static size_t maxmap;
145
146
147
/* Prototypes for local functions.  */
148
static size_t read_alias_file (const char *fname, int fname_len)
149
     internal_function;
150
static int extend_alias_table (void);
151
static int alias_compare (const struct alias_map *map1,
152
			  const struct alias_map *map2);
153
154
155
const char *
156
_nl_expand_alias (const char *name)
157
{
158
  static const char *locale_alias_path;
159
  struct alias_map *retval;
160
  const char *result = NULL;
161
  size_t added;
162
163
  __libc_lock_lock (lock);
164
165
  if (locale_alias_path == NULL)
166
    locale_alias_path = LOCALE_ALIAS_PATH;
167
168
  do
169
    {
170
      struct alias_map item;
171
172
      item.alias = name;
173
174
      if (nmap > 0)
175
	retval = (struct alias_map *) bsearch (&item, map, nmap,
176
					       sizeof (struct alias_map),
177
					       (int (*) (const void *,
178
							 const void *)
179
						) alias_compare);
180
      else
181
	retval = NULL;
182
183
      /* We really found an alias.  Return the value.  */
184
      if (retval != NULL)
185
	{
186
	  result = retval->value;
187
	  break;
188
	}
189
190
      /* Perhaps we can find another alias file.  */
191
      added = 0;
192
      while (added == 0 && locale_alias_path[0] != '\0')
193
	{
194
	  const char *start;
195
196
	  while (locale_alias_path[0] == PATH_SEPARATOR)
197
	    ++locale_alias_path;
198
	  start = locale_alias_path;
199
200
	  while (locale_alias_path[0] != '\0'
201
		 && locale_alias_path[0] != PATH_SEPARATOR)
202
	    ++locale_alias_path;
203
204
	  if (start < locale_alias_path)
205
	    added = read_alias_file (start, locale_alias_path - start);
206
	}
207
    }
208
  while (added != 0);
209
210
  __libc_lock_unlock (lock);
211
212
  return result;
213
}
214
215
216
static size_t
217
internal_function
218
read_alias_file (const char *fname, int fname_len)
219
{
220
  FILE *fp;
221
  char *full_fname;
222
  size_t added;
223
  static const char aliasfile[] = "/locale.alias";
224
225
  full_fname = (char *) alloca (fname_len + sizeof aliasfile);
226
#ifdef HAVE_MEMPCPY
227
  mempcpy (mempcpy (full_fname, fname, fname_len),
228
	   aliasfile, sizeof aliasfile);
229
#else
230
  memcpy (full_fname, fname, fname_len);
231
  memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
232
#endif
233
234
#ifdef _LIBC
235
  /* Note the file is opened with cancellation in the I/O functions
236
     disabled.  */
237
  fp = fopen (relocate (full_fname), "rc");
238
#else
239
  fp = fopen (relocate (full_fname), "r");
240
#endif
241
  freea (full_fname);
242
  if (fp == NULL)
243
    return 0;
244
245
#ifdef HAVE___FSETLOCKING
246
  /* No threads present.  */
247
  __fsetlocking (fp, FSETLOCKING_BYCALLER);
248
#endif
249
250
  added = 0;
251
  while (!FEOF (fp))
252
    {
253
      /* It is a reasonable approach to use a fix buffer here because
254
	 a) we are only interested in the first two fields
255
	 b) these fields must be usable as file names and so must not
256
	    be that long
257
	 We avoid a multi-kilobyte buffer here since this would use up
258
	 stack space which we might not have if the program ran out of
259
	 memory.  */
260
      char buf[400];
261
      char *alias;
262
      char *value;
263
      char *cp;
264
      int complete_line;
265
266
      if (FGETS (buf, sizeof buf, fp) == NULL)
267
	/* EOF reached.  */
268
	break;
269
270
      /* Determine whether the line is complete.  */
271
      complete_line = strchr (buf, '\n') != NULL;
272
273
      cp = buf;
274
      /* Ignore leading white space.  */
275
      while (isspace ((unsigned char) cp[0]))
276
	++cp;
277
278
      /* A leading '#' signals a comment line.  */
279
      if (cp[0] != '\0' && cp[0] != '#')
280
	{
281
	  alias = cp++;
282
	  while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
283
	    ++cp;
284
	  /* Terminate alias name.  */
285
	  if (cp[0] != '\0')
286
	    *cp++ = '\0';
287
288
	  /* Now look for the beginning of the value.  */
289
	  while (isspace ((unsigned char) cp[0]))
290
	    ++cp;
291
292
	  if (cp[0] != '\0')
293
	    {
294
	      value = cp++;
295
	      while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
296
		++cp;
297
	      /* Terminate value.  */
298
	      if (cp[0] == '\n')
299
		{
300
		  /* This has to be done to make the following test
301
		     for the end of line possible.  We are looking for
302
		     the terminating '\n' which do not overwrite here.  */
303
		  *cp++ = '\0';
304
		  *cp = '\n';
305
		}
306
	      else if (cp[0] != '\0')
307
		*cp++ = '\0';
308
309
#ifdef IN_LIBGLOCALE
310
	      /* glibc's locale.alias contains entries for ja_JP and ko_KR
311
		 that make it impossible to use a Japanese or Korean UTF-8
312
		 locale under the name "ja_JP" or "ko_KR".  Ignore these
313
		 entries.  */
314
	      if (strchr (alias, '_') == NULL)
315
#endif
316
		{
317
		  size_t alias_len;
318
		  size_t value_len;
319
320
		  if (nmap >= maxmap)
321
		    if (__builtin_expect (extend_alias_table (), 0))
322
		      goto out;
323
324
		  alias_len = strlen (alias) + 1;
325
		  value_len = strlen (value) + 1;
326
327
		  if (string_space_act + alias_len + value_len > string_space_max)
328
		    {
329
		      /* Increase size of memory pool.  */
330
		      size_t new_size = (string_space_max
331
					 + (alias_len + value_len > 1024
332
					    ? alias_len + value_len : 1024));
333
		      char *new_pool = (char *) realloc (string_space, new_size);
334
		      if (new_pool == NULL)
335
			goto out;
336
337
		      if (__builtin_expect (string_space != new_pool, 0))
338
			{
339
			  size_t i;
340
341
			  for (i = 0; i < nmap; i++)
342
			    {
343
			      map[i].alias += new_pool - string_space;
344
			      map[i].value += new_pool - string_space;
345
			    }
346
			}
347
348
		      string_space = new_pool;
349
		      string_space_max = new_size;
350
		    }
351
352
		  map[nmap].alias = memcpy (&string_space[string_space_act],
353
					    alias, alias_len);
354
		  string_space_act += alias_len;
355
356
		  map[nmap].value = memcpy (&string_space[string_space_act],
357
					    value, value_len);
358
		  string_space_act += value_len;
359
360
		  ++nmap;
361
		  ++added;
362
		}
363
	    }
364
	}
365
366
      /* Possibly not the whole line fits into the buffer.  Ignore
367
	 the rest of the line.  */
368
      if (! complete_line)
369
	do
370
	  if (FGETS (buf, sizeof buf, fp) == NULL)
371
	    /* Make sure the inner loop will be left.  The outer loop
372
	       will exit at the `feof' test.  */
373
	    break;
374
	while (strchr (buf, '\n') == NULL);
375
    }
376
377
 out:
378
  /* Should we test for ferror()?  I think we have to silently ignore
379
     errors.  --drepper  */
380
  fclose (fp);
381
382
  if (added > 0)
383
    qsort (map, nmap, sizeof (struct alias_map),
384
	   (int (*) (const void *, const void *)) alias_compare);
385
386
  return added;
387
}
388
389
390
static int
391
extend_alias_table ()
392
{
393
  size_t new_size;
394
  struct alias_map *new_map;
395
396
  new_size = maxmap == 0 ? 100 : 2 * maxmap;
397
  new_map = (struct alias_map *) realloc (map, (new_size
398
						* sizeof (struct alias_map)));
399
  if (new_map == NULL)
400
    /* Simply don't extend: we don't have any more core.  */
401
    return -1;
402
403
  map = new_map;
404
  maxmap = new_size;
405
  return 0;
406
}
407
408
409
static int
410
alias_compare (const struct alias_map *map1, const struct alias_map *map2)
411
{
412
#if defined _LIBC || defined HAVE_STRCASECMP
413
  return strcasecmp (map1->alias, map2->alias);
414
#else
415
  const unsigned char *p1 = (const unsigned char *) map1->alias;
416
  const unsigned char *p2 = (const unsigned char *) map2->alias;
417
  unsigned char c1, c2;
418
419
  if (p1 == p2)
420
    return 0;
421
422
  do
423
    {
424
      /* I know this seems to be odd but the tolower() function in
425
	 some systems libc cannot handle nonalpha characters.  */
426
      c1 = isupper (*p1) ? tolower (*p1) : *p1;
427
      c2 = isupper (*p2) ? tolower (*p2) : *p2;
428
      if (c1 == '\0')
429
	break;
430
      ++p1;
431
      ++p2;
432
    }
433
  while (c1 == c2);
434
435
  return c1 - c2;
436
#endif
437
}
(-)a/intl/localename.c (-1499 lines)
Lines 1-1499 Link Here
1
/* Determine the current selected locale.
2
   Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Written by Ulrich Drepper <drepper@gnu.org>, 1995.  */
20
/* Win32 code written by Tor Lillqvist <tml@iki.fi>.  */
21
/* MacOS X code written by Bruno Haible <bruno@clisp.org>.  */
22
23
#ifdef HAVE_CONFIG_H
24
# include <config.h>
25
#endif
26
27
#include <stdlib.h>
28
#include <locale.h>
29
30
#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
31
# include <string.h>
32
# include <CoreFoundation/CFString.h>
33
# if HAVE_CFLOCALECOPYCURRENT
34
#  include <CoreFoundation/CFLocale.h>
35
# elif HAVE_CFPREFERENCESCOPYAPPVALUE
36
#  include <CoreFoundation/CFPreferences.h>
37
# endif
38
#endif
39
40
#if defined _WIN32 || defined __WIN32__
41
# define WIN32_NATIVE
42
#endif
43
44
#ifdef WIN32_NATIVE
45
# define WIN32_LEAN_AND_MEAN
46
# include <windows.h>
47
/* List of language codes, sorted by value:
48
   0x01 LANG_ARABIC
49
   0x02 LANG_BULGARIAN
50
   0x03 LANG_CATALAN
51
   0x04 LANG_CHINESE
52
   0x05 LANG_CZECH
53
   0x06 LANG_DANISH
54
   0x07 LANG_GERMAN
55
   0x08 LANG_GREEK
56
   0x09 LANG_ENGLISH
57
   0x0a LANG_SPANISH
58
   0x0b LANG_FINNISH
59
   0x0c LANG_FRENCH
60
   0x0d LANG_HEBREW
61
   0x0e LANG_HUNGARIAN
62
   0x0f LANG_ICELANDIC
63
   0x10 LANG_ITALIAN
64
   0x11 LANG_JAPANESE
65
   0x12 LANG_KOREAN
66
   0x13 LANG_DUTCH
67
   0x14 LANG_NORWEGIAN
68
   0x15 LANG_POLISH
69
   0x16 LANG_PORTUGUESE
70
   0x17 LANG_RHAETO_ROMANCE
71
   0x18 LANG_ROMANIAN
72
   0x19 LANG_RUSSIAN
73
   0x1a LANG_CROATIAN == LANG_SERBIAN
74
   0x1b LANG_SLOVAK
75
   0x1c LANG_ALBANIAN
76
   0x1d LANG_SWEDISH
77
   0x1e LANG_THAI
78
   0x1f LANG_TURKISH
79
   0x20 LANG_URDU
80
   0x21 LANG_INDONESIAN
81
   0x22 LANG_UKRAINIAN
82
   0x23 LANG_BELARUSIAN
83
   0x24 LANG_SLOVENIAN
84
   0x25 LANG_ESTONIAN
85
   0x26 LANG_LATVIAN
86
   0x27 LANG_LITHUANIAN
87
   0x28 LANG_TAJIK
88
   0x29 LANG_FARSI
89
   0x2a LANG_VIETNAMESE
90
   0x2b LANG_ARMENIAN
91
   0x2c LANG_AZERI
92
   0x2d LANG_BASQUE
93
   0x2e LANG_SORBIAN
94
   0x2f LANG_MACEDONIAN
95
   0x30 LANG_SUTU
96
   0x31 LANG_TSONGA
97
   0x32 LANG_TSWANA
98
   0x33 LANG_VENDA
99
   0x34 LANG_XHOSA
100
   0x35 LANG_ZULU
101
   0x36 LANG_AFRIKAANS
102
   0x37 LANG_GEORGIAN
103
   0x38 LANG_FAEROESE
104
   0x39 LANG_HINDI
105
   0x3a LANG_MALTESE
106
   0x3b LANG_SAAMI
107
   0x3c LANG_GAELIC
108
   0x3d LANG_YIDDISH
109
   0x3e LANG_MALAY
110
   0x3f LANG_KAZAK
111
   0x40 LANG_KYRGYZ
112
   0x41 LANG_SWAHILI
113
   0x42 LANG_TURKMEN
114
   0x43 LANG_UZBEK
115
   0x44 LANG_TATAR
116
   0x45 LANG_BENGALI
117
   0x46 LANG_PUNJABI
118
   0x47 LANG_GUJARATI
119
   0x48 LANG_ORIYA
120
   0x49 LANG_TAMIL
121
   0x4a LANG_TELUGU
122
   0x4b LANG_KANNADA
123
   0x4c LANG_MALAYALAM
124
   0x4d LANG_ASSAMESE
125
   0x4e LANG_MARATHI
126
   0x4f LANG_SANSKRIT
127
   0x50 LANG_MONGOLIAN
128
   0x51 LANG_TIBETAN
129
   0x52 LANG_WELSH
130
   0x53 LANG_CAMBODIAN
131
   0x54 LANG_LAO
132
   0x55 LANG_BURMESE
133
   0x56 LANG_GALICIAN
134
   0x57 LANG_KONKANI
135
   0x58 LANG_MANIPURI
136
   0x59 LANG_SINDHI
137
   0x5a LANG_SYRIAC
138
   0x5b LANG_SINHALESE
139
   0x5c LANG_CHEROKEE
140
   0x5d LANG_INUKTITUT
141
   0x5e LANG_AMHARIC
142
   0x5f LANG_TAMAZIGHT
143
   0x60 LANG_KASHMIRI
144
   0x61 LANG_NEPALI
145
   0x62 LANG_FRISIAN
146
   0x63 LANG_PASHTO
147
   0x64 LANG_TAGALOG
148
   0x65 LANG_DIVEHI
149
   0x66 LANG_EDO
150
   0x67 LANG_FULFULDE
151
   0x68 LANG_HAUSA
152
   0x69 LANG_IBIBIO
153
   0x6a LANG_YORUBA
154
   0x70 LANG_IGBO
155
   0x71 LANG_KANURI
156
   0x72 LANG_OROMO
157
   0x73 LANG_TIGRINYA
158
   0x74 LANG_GUARANI
159
   0x75 LANG_HAWAIIAN
160
   0x76 LANG_LATIN
161
   0x77 LANG_SOMALI
162
   0x78 LANG_YI
163
   0x79 LANG_PAPIAMENTU
164
*/
165
/* Mingw headers don't have latest language and sublanguage codes.  */
166
# ifndef LANG_AFRIKAANS
167
# define LANG_AFRIKAANS 0x36
168
# endif
169
# ifndef LANG_ALBANIAN
170
# define LANG_ALBANIAN 0x1c
171
# endif
172
# ifndef LANG_AMHARIC
173
# define LANG_AMHARIC 0x5e
174
# endif
175
# ifndef LANG_ARABIC
176
# define LANG_ARABIC 0x01
177
# endif
178
# ifndef LANG_ARMENIAN
179
# define LANG_ARMENIAN 0x2b
180
# endif
181
# ifndef LANG_ASSAMESE
182
# define LANG_ASSAMESE 0x4d
183
# endif
184
# ifndef LANG_AZERI
185
# define LANG_AZERI 0x2c
186
# endif
187
# ifndef LANG_BASQUE
188
# define LANG_BASQUE 0x2d
189
# endif
190
# ifndef LANG_BELARUSIAN
191
# define LANG_BELARUSIAN 0x23
192
# endif
193
# ifndef LANG_BENGALI
194
# define LANG_BENGALI 0x45
195
# endif
196
# ifndef LANG_BURMESE
197
# define LANG_BURMESE 0x55
198
# endif
199
# ifndef LANG_CAMBODIAN
200
# define LANG_CAMBODIAN 0x53
201
# endif
202
# ifndef LANG_CATALAN
203
# define LANG_CATALAN 0x03
204
# endif
205
# ifndef LANG_CHEROKEE
206
# define LANG_CHEROKEE 0x5c
207
# endif
208
# ifndef LANG_DIVEHI
209
# define LANG_DIVEHI 0x65
210
# endif
211
# ifndef LANG_EDO
212
# define LANG_EDO 0x66
213
# endif
214
# ifndef LANG_ESTONIAN
215
# define LANG_ESTONIAN 0x25
216
# endif
217
# ifndef LANG_FAEROESE
218
# define LANG_FAEROESE 0x38
219
# endif
220
# ifndef LANG_FARSI
221
# define LANG_FARSI 0x29
222
# endif
223
# ifndef LANG_FRISIAN
224
# define LANG_FRISIAN 0x62
225
# endif
226
# ifndef LANG_FULFULDE
227
# define LANG_FULFULDE 0x67
228
# endif
229
# ifndef LANG_GAELIC
230
# define LANG_GAELIC 0x3c
231
# endif
232
# ifndef LANG_GALICIAN
233
# define LANG_GALICIAN 0x56
234
# endif
235
# ifndef LANG_GEORGIAN
236
# define LANG_GEORGIAN 0x37
237
# endif
238
# ifndef LANG_GUARANI
239
# define LANG_GUARANI 0x74
240
# endif
241
# ifndef LANG_GUJARATI
242
# define LANG_GUJARATI 0x47
243
# endif
244
# ifndef LANG_HAUSA
245
# define LANG_HAUSA 0x68
246
# endif
247
# ifndef LANG_HAWAIIAN
248
# define LANG_HAWAIIAN 0x75
249
# endif
250
# ifndef LANG_HEBREW
251
# define LANG_HEBREW 0x0d
252
# endif
253
# ifndef LANG_HINDI
254
# define LANG_HINDI 0x39
255
# endif
256
# ifndef LANG_IBIBIO
257
# define LANG_IBIBIO 0x69
258
# endif
259
# ifndef LANG_IGBO
260
# define LANG_IGBO 0x70
261
# endif
262
# ifndef LANG_INDONESIAN
263
# define LANG_INDONESIAN 0x21
264
# endif
265
# ifndef LANG_INUKTITUT
266
# define LANG_INUKTITUT 0x5d
267
# endif
268
# ifndef LANG_KANNADA
269
# define LANG_KANNADA 0x4b
270
# endif
271
# ifndef LANG_KANURI
272
# define LANG_KANURI 0x71
273
# endif
274
# ifndef LANG_KASHMIRI
275
# define LANG_KASHMIRI 0x60
276
# endif
277
# ifndef LANG_KAZAK
278
# define LANG_KAZAK 0x3f
279
# endif
280
# ifndef LANG_KONKANI
281
# define LANG_KONKANI 0x57
282
# endif
283
# ifndef LANG_KYRGYZ
284
# define LANG_KYRGYZ 0x40
285
# endif
286
# ifndef LANG_LAO
287
# define LANG_LAO 0x54
288
# endif
289
# ifndef LANG_LATIN
290
# define LANG_LATIN 0x76
291
# endif
292
# ifndef LANG_LATVIAN
293
# define LANG_LATVIAN 0x26
294
# endif
295
# ifndef LANG_LITHUANIAN
296
# define LANG_LITHUANIAN 0x27
297
# endif
298
# ifndef LANG_MACEDONIAN
299
# define LANG_MACEDONIAN 0x2f
300
# endif
301
# ifndef LANG_MALAY
302
# define LANG_MALAY 0x3e
303
# endif
304
# ifndef LANG_MALAYALAM
305
# define LANG_MALAYALAM 0x4c
306
# endif
307
# ifndef LANG_MALTESE
308
# define LANG_MALTESE 0x3a
309
# endif
310
# ifndef LANG_MANIPURI
311
# define LANG_MANIPURI 0x58
312
# endif
313
# ifndef LANG_MARATHI
314
# define LANG_MARATHI 0x4e
315
# endif
316
# ifndef LANG_MONGOLIAN
317
# define LANG_MONGOLIAN 0x50
318
# endif
319
# ifndef LANG_NEPALI
320
# define LANG_NEPALI 0x61
321
# endif
322
# ifndef LANG_ORIYA
323
# define LANG_ORIYA 0x48
324
# endif
325
# ifndef LANG_OROMO
326
# define LANG_OROMO 0x72
327
# endif
328
# ifndef LANG_PAPIAMENTU
329
# define LANG_PAPIAMENTU 0x79
330
# endif
331
# ifndef LANG_PASHTO
332
# define LANG_PASHTO 0x63
333
# endif
334
# ifndef LANG_PUNJABI
335
# define LANG_PUNJABI 0x46
336
# endif
337
# ifndef LANG_RHAETO_ROMANCE
338
# define LANG_RHAETO_ROMANCE 0x17
339
# endif
340
# ifndef LANG_SAAMI
341
# define LANG_SAAMI 0x3b
342
# endif
343
# ifndef LANG_SANSKRIT
344
# define LANG_SANSKRIT 0x4f
345
# endif
346
# ifndef LANG_SERBIAN
347
# define LANG_SERBIAN 0x1a
348
# endif
349
# ifndef LANG_SINDHI
350
# define LANG_SINDHI 0x59
351
# endif
352
# ifndef LANG_SINHALESE
353
# define LANG_SINHALESE 0x5b
354
# endif
355
# ifndef LANG_SLOVAK
356
# define LANG_SLOVAK 0x1b
357
# endif
358
# ifndef LANG_SOMALI
359
# define LANG_SOMALI 0x77
360
# endif
361
# ifndef LANG_SORBIAN
362
# define LANG_SORBIAN 0x2e
363
# endif
364
# ifndef LANG_SUTU
365
# define LANG_SUTU 0x30
366
# endif
367
# ifndef LANG_SWAHILI
368
# define LANG_SWAHILI 0x41
369
# endif
370
# ifndef LANG_SYRIAC
371
# define LANG_SYRIAC 0x5a
372
# endif
373
# ifndef LANG_TAGALOG
374
# define LANG_TAGALOG 0x64
375
# endif
376
# ifndef LANG_TAJIK
377
# define LANG_TAJIK 0x28
378
# endif
379
# ifndef LANG_TAMAZIGHT
380
# define LANG_TAMAZIGHT 0x5f
381
# endif
382
# ifndef LANG_TAMIL
383
# define LANG_TAMIL 0x49
384
# endif
385
# ifndef LANG_TATAR
386
# define LANG_TATAR 0x44
387
# endif
388
# ifndef LANG_TELUGU
389
# define LANG_TELUGU 0x4a
390
# endif
391
# ifndef LANG_THAI
392
# define LANG_THAI 0x1e
393
# endif
394
# ifndef LANG_TIBETAN
395
# define LANG_TIBETAN 0x51
396
# endif
397
# ifndef LANG_TIGRINYA
398
# define LANG_TIGRINYA 0x73
399
# endif
400
# ifndef LANG_TSONGA
401
# define LANG_TSONGA 0x31
402
# endif
403
# ifndef LANG_TSWANA
404
# define LANG_TSWANA 0x32
405
# endif
406
# ifndef LANG_TURKMEN
407
# define LANG_TURKMEN 0x42
408
# endif
409
# ifndef LANG_UKRAINIAN
410
# define LANG_UKRAINIAN 0x22
411
# endif
412
# ifndef LANG_URDU
413
# define LANG_URDU 0x20
414
# endif
415
# ifndef LANG_UZBEK
416
# define LANG_UZBEK 0x43
417
# endif
418
# ifndef LANG_VENDA
419
# define LANG_VENDA 0x33
420
# endif
421
# ifndef LANG_VIETNAMESE
422
# define LANG_VIETNAMESE 0x2a
423
# endif
424
# ifndef LANG_WELSH
425
# define LANG_WELSH 0x52
426
# endif
427
# ifndef LANG_XHOSA
428
# define LANG_XHOSA 0x34
429
# endif
430
# ifndef LANG_YI
431
# define LANG_YI 0x78
432
# endif
433
# ifndef LANG_YIDDISH
434
# define LANG_YIDDISH 0x3d
435
# endif
436
# ifndef LANG_YORUBA
437
# define LANG_YORUBA 0x6a
438
# endif
439
# ifndef LANG_ZULU
440
# define LANG_ZULU 0x35
441
# endif
442
# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
443
# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
444
# endif
445
# ifndef SUBLANG_ARABIC_IRAQ
446
# define SUBLANG_ARABIC_IRAQ 0x02
447
# endif
448
# ifndef SUBLANG_ARABIC_EGYPT
449
# define SUBLANG_ARABIC_EGYPT 0x03
450
# endif
451
# ifndef SUBLANG_ARABIC_LIBYA
452
# define SUBLANG_ARABIC_LIBYA 0x04
453
# endif
454
# ifndef SUBLANG_ARABIC_ALGERIA
455
# define SUBLANG_ARABIC_ALGERIA 0x05
456
# endif
457
# ifndef SUBLANG_ARABIC_MOROCCO
458
# define SUBLANG_ARABIC_MOROCCO 0x06
459
# endif
460
# ifndef SUBLANG_ARABIC_TUNISIA
461
# define SUBLANG_ARABIC_TUNISIA 0x07
462
# endif
463
# ifndef SUBLANG_ARABIC_OMAN
464
# define SUBLANG_ARABIC_OMAN 0x08
465
# endif
466
# ifndef SUBLANG_ARABIC_YEMEN
467
# define SUBLANG_ARABIC_YEMEN 0x09
468
# endif
469
# ifndef SUBLANG_ARABIC_SYRIA
470
# define SUBLANG_ARABIC_SYRIA 0x0a
471
# endif
472
# ifndef SUBLANG_ARABIC_JORDAN
473
# define SUBLANG_ARABIC_JORDAN 0x0b
474
# endif
475
# ifndef SUBLANG_ARABIC_LEBANON
476
# define SUBLANG_ARABIC_LEBANON 0x0c
477
# endif
478
# ifndef SUBLANG_ARABIC_KUWAIT
479
# define SUBLANG_ARABIC_KUWAIT 0x0d
480
# endif
481
# ifndef SUBLANG_ARABIC_UAE
482
# define SUBLANG_ARABIC_UAE 0x0e
483
# endif
484
# ifndef SUBLANG_ARABIC_BAHRAIN
485
# define SUBLANG_ARABIC_BAHRAIN 0x0f
486
# endif
487
# ifndef SUBLANG_ARABIC_QATAR
488
# define SUBLANG_ARABIC_QATAR 0x10
489
# endif
490
# ifndef SUBLANG_AZERI_LATIN
491
# define SUBLANG_AZERI_LATIN 0x01
492
# endif
493
# ifndef SUBLANG_AZERI_CYRILLIC
494
# define SUBLANG_AZERI_CYRILLIC 0x02
495
# endif
496
# ifndef SUBLANG_BENGALI_INDIA
497
# define SUBLANG_BENGALI_INDIA 0x00
498
# endif
499
# ifndef SUBLANG_BENGALI_BANGLADESH
500
# define SUBLANG_BENGALI_BANGLADESH 0x01
501
# endif
502
# ifndef SUBLANG_CHINESE_MACAU
503
# define SUBLANG_CHINESE_MACAU 0x05
504
# endif
505
# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
506
# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
507
# endif
508
# ifndef SUBLANG_ENGLISH_JAMAICA
509
# define SUBLANG_ENGLISH_JAMAICA 0x08
510
# endif
511
# ifndef SUBLANG_ENGLISH_CARIBBEAN
512
# define SUBLANG_ENGLISH_CARIBBEAN 0x09
513
# endif
514
# ifndef SUBLANG_ENGLISH_BELIZE
515
# define SUBLANG_ENGLISH_BELIZE 0x0a
516
# endif
517
# ifndef SUBLANG_ENGLISH_TRINIDAD
518
# define SUBLANG_ENGLISH_TRINIDAD 0x0b
519
# endif
520
# ifndef SUBLANG_ENGLISH_ZIMBABWE
521
# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
522
# endif
523
# ifndef SUBLANG_ENGLISH_PHILIPPINES
524
# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
525
# endif
526
# ifndef SUBLANG_ENGLISH_INDONESIA
527
# define SUBLANG_ENGLISH_INDONESIA 0x0e
528
# endif
529
# ifndef SUBLANG_ENGLISH_HONGKONG
530
# define SUBLANG_ENGLISH_HONGKONG 0x0f
531
# endif
532
# ifndef SUBLANG_ENGLISH_INDIA
533
# define SUBLANG_ENGLISH_INDIA 0x10
534
# endif
535
# ifndef SUBLANG_ENGLISH_MALAYSIA
536
# define SUBLANG_ENGLISH_MALAYSIA 0x11
537
# endif
538
# ifndef SUBLANG_ENGLISH_SINGAPORE
539
# define SUBLANG_ENGLISH_SINGAPORE 0x12
540
# endif
541
# ifndef SUBLANG_FRENCH_LUXEMBOURG
542
# define SUBLANG_FRENCH_LUXEMBOURG 0x05
543
# endif
544
# ifndef SUBLANG_FRENCH_MONACO
545
# define SUBLANG_FRENCH_MONACO 0x06
546
# endif
547
# ifndef SUBLANG_FRENCH_WESTINDIES
548
# define SUBLANG_FRENCH_WESTINDIES 0x07
549
# endif
550
# ifndef SUBLANG_FRENCH_REUNION
551
# define SUBLANG_FRENCH_REUNION 0x08
552
# endif
553
# ifndef SUBLANG_FRENCH_CONGO
554
# define SUBLANG_FRENCH_CONGO 0x09
555
# endif
556
# ifndef SUBLANG_FRENCH_SENEGAL
557
# define SUBLANG_FRENCH_SENEGAL 0x0a
558
# endif
559
# ifndef SUBLANG_FRENCH_CAMEROON
560
# define SUBLANG_FRENCH_CAMEROON 0x0b
561
# endif
562
# ifndef SUBLANG_FRENCH_COTEDIVOIRE
563
# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
564
# endif
565
# ifndef SUBLANG_FRENCH_MALI
566
# define SUBLANG_FRENCH_MALI 0x0d
567
# endif
568
# ifndef SUBLANG_FRENCH_MOROCCO
569
# define SUBLANG_FRENCH_MOROCCO 0x0e
570
# endif
571
# ifndef SUBLANG_FRENCH_HAITI
572
# define SUBLANG_FRENCH_HAITI 0x0f
573
# endif
574
# ifndef SUBLANG_GERMAN_LUXEMBOURG
575
# define SUBLANG_GERMAN_LUXEMBOURG 0x04
576
# endif
577
# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
578
# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
579
# endif
580
# ifndef SUBLANG_KASHMIRI_INDIA
581
# define SUBLANG_KASHMIRI_INDIA 0x02
582
# endif
583
# ifndef SUBLANG_MALAY_MALAYSIA
584
# define SUBLANG_MALAY_MALAYSIA 0x01
585
# endif
586
# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
587
# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
588
# endif
589
# ifndef SUBLANG_NEPALI_INDIA
590
# define SUBLANG_NEPALI_INDIA 0x02
591
# endif
592
# ifndef SUBLANG_PUNJABI_INDIA
593
# define SUBLANG_PUNJABI_INDIA 0x00
594
# endif
595
# ifndef SUBLANG_PUNJABI_PAKISTAN
596
# define SUBLANG_PUNJABI_PAKISTAN 0x01
597
# endif
598
# ifndef SUBLANG_ROMANIAN_ROMANIA
599
# define SUBLANG_ROMANIAN_ROMANIA 0x00
600
# endif
601
# ifndef SUBLANG_ROMANIAN_MOLDOVA
602
# define SUBLANG_ROMANIAN_MOLDOVA 0x01
603
# endif
604
# ifndef SUBLANG_SERBIAN_LATIN
605
# define SUBLANG_SERBIAN_LATIN 0x02
606
# endif
607
# ifndef SUBLANG_SERBIAN_CYRILLIC
608
# define SUBLANG_SERBIAN_CYRILLIC 0x03
609
# endif
610
# ifndef SUBLANG_SINDHI_INDIA
611
# define SUBLANG_SINDHI_INDIA 0x00
612
# endif
613
# ifndef SUBLANG_SINDHI_PAKISTAN
614
# define SUBLANG_SINDHI_PAKISTAN 0x01
615
# endif
616
# ifndef SUBLANG_SPANISH_GUATEMALA
617
# define SUBLANG_SPANISH_GUATEMALA 0x04
618
# endif
619
# ifndef SUBLANG_SPANISH_COSTA_RICA
620
# define SUBLANG_SPANISH_COSTA_RICA 0x05
621
# endif
622
# ifndef SUBLANG_SPANISH_PANAMA
623
# define SUBLANG_SPANISH_PANAMA 0x06
624
# endif
625
# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
626
# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
627
# endif
628
# ifndef SUBLANG_SPANISH_VENEZUELA
629
# define SUBLANG_SPANISH_VENEZUELA 0x08
630
# endif
631
# ifndef SUBLANG_SPANISH_COLOMBIA
632
# define SUBLANG_SPANISH_COLOMBIA 0x09
633
# endif
634
# ifndef SUBLANG_SPANISH_PERU
635
# define SUBLANG_SPANISH_PERU 0x0a
636
# endif
637
# ifndef SUBLANG_SPANISH_ARGENTINA
638
# define SUBLANG_SPANISH_ARGENTINA 0x0b
639
# endif
640
# ifndef SUBLANG_SPANISH_ECUADOR
641
# define SUBLANG_SPANISH_ECUADOR 0x0c
642
# endif
643
# ifndef SUBLANG_SPANISH_CHILE
644
# define SUBLANG_SPANISH_CHILE 0x0d
645
# endif
646
# ifndef SUBLANG_SPANISH_URUGUAY
647
# define SUBLANG_SPANISH_URUGUAY 0x0e
648
# endif
649
# ifndef SUBLANG_SPANISH_PARAGUAY
650
# define SUBLANG_SPANISH_PARAGUAY 0x0f
651
# endif
652
# ifndef SUBLANG_SPANISH_BOLIVIA
653
# define SUBLANG_SPANISH_BOLIVIA 0x10
654
# endif
655
# ifndef SUBLANG_SPANISH_EL_SALVADOR
656
# define SUBLANG_SPANISH_EL_SALVADOR 0x11
657
# endif
658
# ifndef SUBLANG_SPANISH_HONDURAS
659
# define SUBLANG_SPANISH_HONDURAS 0x12
660
# endif
661
# ifndef SUBLANG_SPANISH_NICARAGUA
662
# define SUBLANG_SPANISH_NICARAGUA 0x13
663
# endif
664
# ifndef SUBLANG_SPANISH_PUERTO_RICO
665
# define SUBLANG_SPANISH_PUERTO_RICO 0x14
666
# endif
667
# ifndef SUBLANG_SWEDISH_FINLAND
668
# define SUBLANG_SWEDISH_FINLAND 0x02
669
# endif
670
# ifndef SUBLANG_TAMAZIGHT_ARABIC
671
# define SUBLANG_TAMAZIGHT_ARABIC 0x01
672
# endif
673
# ifndef SUBLANG_TAMAZIGHT_LATIN
674
# define SUBLANG_TAMAZIGHT_LATIN 0x02
675
# endif
676
# ifndef SUBLANG_TIGRINYA_ETHIOPIA
677
# define SUBLANG_TIGRINYA_ETHIOPIA 0x00
678
# endif
679
# ifndef SUBLANG_TIGRINYA_ERITREA
680
# define SUBLANG_TIGRINYA_ERITREA 0x01
681
# endif
682
# ifndef SUBLANG_URDU_PAKISTAN
683
# define SUBLANG_URDU_PAKISTAN 0x01
684
# endif
685
# ifndef SUBLANG_URDU_INDIA
686
# define SUBLANG_URDU_INDIA 0x02
687
# endif
688
# ifndef SUBLANG_UZBEK_LATIN
689
# define SUBLANG_UZBEK_LATIN 0x01
690
# endif
691
# ifndef SUBLANG_UZBEK_CYRILLIC
692
# define SUBLANG_UZBEK_CYRILLIC 0x02
693
# endif
694
#endif
695
696
# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
697
/* MacOS X 10.2 or newer */
698
699
/* Canonicalize a MacOS X locale name to a Unix locale name.
700
   NAME is a sufficiently large buffer.
701
   On input, it contains the MacOS X locale name.
702
   On output, it contains the Unix locale name.  */
703
void
704
_nl_locale_name_canonicalize (char *name)
705
{
706
  /* This conversion is based on a posting by
707
     Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08,
708
     http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */
709
710
  /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and
711
     ISO 3166) names.  Prior to MacOS X 10.3, there is no API for doing this.
712
     Therefore we do it ourselves, using a table based on the results of the
713
     MacOS X 10.3.8 function
714
     CFLocaleCreateCanonicalLocaleIdentifierFromString().  */
715
  typedef struct { const char legacy[21+1]; const char unixy[5+1]; }
716
	  legacy_entry;
717
  static const legacy_entry legacy_table[] = {
718
    { "Afrikaans",             "af" },
719
    { "Albanian",              "sq" },
720
    { "Amharic",               "am" },
721
    { "Arabic",                "ar" },
722
    { "Armenian",              "hy" },
723
    { "Assamese",              "as" },
724
    { "Aymara",                "ay" },
725
    { "Azerbaijani",           "az" },
726
    { "Basque",                "eu" },
727
    { "Belarusian",            "be" },
728
    { "Belorussian",           "be" },
729
    { "Bengali",               "bn" },
730
    { "Brazilian Portugese",   "pt_BR" },
731
    { "Brazilian Portuguese",  "pt_BR" },
732
    { "Breton",                "br" },
733
    { "Bulgarian",             "bg" },
734
    { "Burmese",               "my" },
735
    { "Byelorussian",          "be" },
736
    { "Catalan",               "ca" },
737
    { "Chewa",                 "ny" },
738
    { "Chichewa",              "ny" },
739
    { "Chinese",               "zh" },
740
    { "Chinese, Simplified",   "zh_CN" },
741
    { "Chinese, Traditional",  "zh_TW" },
742
    { "Chinese, Tradtional",   "zh_TW" },
743
    { "Croatian",              "hr" },
744
    { "Czech",                 "cs" },
745
    { "Danish",                "da" },
746
    { "Dutch",                 "nl" },
747
    { "Dzongkha",              "dz" },
748
    { "English",               "en" },
749
    { "Esperanto",             "eo" },
750
    { "Estonian",              "et" },
751
    { "Faroese",               "fo" },
752
    { "Farsi",                 "fa" },
753
    { "Finnish",               "fi" },
754
    { "Flemish",               "nl_BE" },
755
    { "French",                "fr" },
756
    { "Galician",              "gl" },
757
    { "Gallegan",              "gl" },
758
    { "Georgian",              "ka" },
759
    { "German",                "de" },
760
    { "Greek",                 "el" },
761
    { "Greenlandic",           "kl" },
762
    { "Guarani",               "gn" },
763
    { "Gujarati",              "gu" },
764
    { "Hawaiian",              "haw" }, /* Yes, "haw", not "cpe".  */
765
    { "Hebrew",                "he" },
766
    { "Hindi",                 "hi" },
767
    { "Hungarian",             "hu" },
768
    { "Icelandic",             "is" },
769
    { "Indonesian",            "id" },
770
    { "Inuktitut",             "iu" },
771
    { "Irish",                 "ga" },
772
    { "Italian",               "it" },
773
    { "Japanese",              "ja" },
774
    { "Javanese",              "jv" },
775
    { "Kalaallisut",           "kl" },
776
    { "Kannada",               "kn" },
777
    { "Kashmiri",              "ks" },
778
    { "Kazakh",                "kk" },
779
    { "Khmer",                 "km" },
780
    { "Kinyarwanda",           "rw" },
781
    { "Kirghiz",               "ky" },
782
    { "Korean",                "ko" },
783
    { "Kurdish",               "ku" },
784
    { "Latin",                 "la" },
785
    { "Latvian",               "lv" },
786
    { "Lithuanian",            "lt" },
787
    { "Macedonian",            "mk" },
788
    { "Malagasy",              "mg" },
789
    { "Malay",                 "ms" },
790
    { "Malayalam",             "ml" },
791
    { "Maltese",               "mt" },
792
    { "Manx",                  "gv" },
793
    { "Marathi",               "mr" },
794
    { "Moldavian",             "mo" },
795
    { "Mongolian",             "mn" },
796
    { "Nepali",                "ne" },
797
    { "Norwegian",             "nb" }, /* Yes, "nb", not the obsolete "no".  */
798
    { "Nyanja",                "ny" },
799
    { "Nynorsk",               "nn" },
800
    { "Oriya",                 "or" },
801
    { "Oromo",                 "om" },
802
    { "Panjabi",               "pa" },
803
    { "Pashto",                "ps" },
804
    { "Persian",               "fa" },
805
    { "Polish",                "pl" },
806
    { "Portuguese",            "pt" },
807
    { "Portuguese, Brazilian", "pt_BR" },
808
    { "Punjabi",               "pa" },
809
    { "Pushto",                "ps" },
810
    { "Quechua",               "qu" },
811
    { "Romanian",              "ro" },
812
    { "Ruanda",                "rw" },
813
    { "Rundi",                 "rn" },
814
    { "Russian",               "ru" },
815
    { "Sami",                  "se_NO" }, /* Not just "se".  */
816
    { "Sanskrit",              "sa" },
817
    { "Scottish",              "gd" },
818
    { "Serbian",               "sr" },
819
    { "Simplified Chinese",    "zh_CN" },
820
    { "Sindhi",                "sd" },
821
    { "Sinhalese",             "si" },
822
    { "Slovak",                "sk" },
823
    { "Slovenian",             "sl" },
824
    { "Somali",                "so" },
825
    { "Spanish",               "es" },
826
    { "Sundanese",             "su" },
827
    { "Swahili",               "sw" },
828
    { "Swedish",               "sv" },
829
    { "Tagalog",               "tl" },
830
    { "Tajik",                 "tg" },
831
    { "Tajiki",                "tg" },
832
    { "Tamil",                 "ta" },
833
    { "Tatar",                 "tt" },
834
    { "Telugu",                "te" },
835
    { "Thai",                  "th" },
836
    { "Tibetan",               "bo" },
837
    { "Tigrinya",              "ti" },
838
    { "Tongan",                "to" },
839
    { "Traditional Chinese",   "zh_TW" },
840
    { "Turkish",               "tr" },
841
    { "Turkmen",               "tk" },
842
    { "Uighur",                "ug" },
843
    { "Ukrainian",             "uk" },
844
    { "Urdu",                  "ur" },
845
    { "Uzbek",                 "uz" },
846
    { "Vietnamese",            "vi" },
847
    { "Welsh",                 "cy" },
848
    { "Yiddish",               "yi" }
849
  };
850
851
  /* Convert new-style locale names with language tags (ISO 639 and ISO 15924)
852
     to Unix (ISO 639 and ISO 3166) names.  */
853
  typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
854
	  langtag_entry;
855
  static const langtag_entry langtag_table[] = {
856
    /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn".
857
       The default script for az on Unix is Latin.  */
858
    { "az-Latn", "az" },
859
    /* MacOS X has "ga-dots".  Does not yet exist on Unix.  */
860
    { "ga-dots", "ga" },
861
    /* MacOS X has "kk-Cyrl".  Does not yet exist on Unix.  */
862
    /* MacOS X has "mn-Cyrl", "mn-Mong".
863
       The default script for mn on Unix is Cyrillic.  */
864
    { "mn-Cyrl", "mn" },
865
    /* MacOS X has "ms-Arab", "ms-Latn".
866
       The default script for ms on Unix is Latin.  */
867
    { "ms-Latn", "ms" },
868
    /* MacOS X has "tg-Cyrl".
869
       The default script for tg on Unix is Cyrillic.  */
870
    { "tg-Cyrl", "tg" },
871
    /* MacOS X has "tk-Cyrl".  Does not yet exist on Unix.  */
872
    /* MacOS X has "tt-Cyrl".
873
       The default script for tt on Unix is Cyrillic.  */
874
    { "tt-Cyrl", "tt" },
875
    /* MacOS X has "zh-Hans", "zh-Hant".
876
       Country codes are used to distinguish these on Unix.  */
877
    { "zh-Hans", "zh_CN" },
878
    { "zh-Hant", "zh_TW" }
879
  };
880
881
  /* Convert script names (ISO 15924) to Unix conventions.
882
     See http://www.unicode.org/iso15924/iso15924-codes.html  */
883
  typedef struct { const char script[4+1]; const char unixy[9+1]; }
884
	  script_entry;
885
  static const script_entry script_table[] = {
886
    { "Arab", "arabic" },
887
    { "Cyrl", "cyrillic" },
888
    { "Mong", "mongolian" }
889
  };
890
891
  /* Step 1: Convert using legacy_table.  */
892
  if (name[0] >= 'A' && name[0] <= 'Z')
893
    {
894
      unsigned int i1, i2;
895
      i1 = 0;
896
      i2 = sizeof (legacy_table) / sizeof (legacy_entry);
897
      while (i2 - i1 > 1)
898
	{
899
	  /* At this point we know that if name occurs in legacy_table,
900
	     its index must be >= i1 and < i2.  */
901
	  unsigned int i = (i1 + i2) >> 1;
902
	  const legacy_entry *p = &legacy_table[i];
903
	  if (strcmp (name, p->legacy) < 0)
904
	    i2 = i;
905
	  else
906
	    i1 = i;
907
	}
908
      if (strcmp (name, legacy_table[i1].legacy) == 0)
909
	{
910
	  strcpy (name, legacy_table[i1].unixy);
911
	  return;
912
	}
913
    }
914
915
  /* Step 2: Convert using langtag_table and script_table.  */
916
  if (strlen (name) == 7 && name[2] == '-')
917
    {
918
      unsigned int i1, i2;
919
      i1 = 0;
920
      i2 = sizeof (langtag_table) / sizeof (langtag_entry);
921
      while (i2 - i1 > 1)
922
	{
923
	  /* At this point we know that if name occurs in langtag_table,
924
	     its index must be >= i1 and < i2.  */
925
	  unsigned int i = (i1 + i2) >> 1;
926
	  const langtag_entry *p = &langtag_table[i];
927
	  if (strcmp (name, p->langtag) < 0)
928
	    i2 = i;
929
	  else
930
	    i1 = i;
931
	}
932
      if (strcmp (name, langtag_table[i1].langtag) == 0)
933
	{
934
	  strcpy (name, langtag_table[i1].unixy);
935
	  return;
936
	}
937
938
      i1 = 0;
939
      i2 = sizeof (script_table) / sizeof (script_entry);
940
      while (i2 - i1 > 1)
941
	{
942
	  /* At this point we know that if (name + 3) occurs in script_table,
943
	     its index must be >= i1 and < i2.  */
944
	  unsigned int i = (i1 + i2) >> 1;
945
	  const script_entry *p = &script_table[i];
946
	  if (strcmp (name + 3, p->script) < 0)
947
	    i2 = i;
948
	  else
949
	    i1 = i;
950
	}
951
      if (strcmp (name + 3, script_table[i1].script) == 0)
952
	{
953
	  name[2] = '@';
954
	  strcpy (name + 3, script_table[i1].unixy);
955
	  return;
956
	}
957
    }
958
959
  /* Step 3: Convert new-style dash to Unix underscore. */
960
  {
961
    char *p;
962
    for (p = name; *p != '\0'; p++)
963
      if (*p == '-')
964
	*p = '_';
965
  }
966
}
967
968
#endif
969
970
/* XPG3 defines the result of 'setlocale (category, NULL)' as:
971
   "Directs 'setlocale()' to query 'category' and return the current
972
    setting of 'local'."
973
   However it does not specify the exact format.  Neither do SUSV2 and
974
   ISO C 99.  So we can use this feature only on selected systems (e.g.
975
   those using GNU C Library).  */
976
#if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2)
977
# define HAVE_LOCALE_NULL
978
#endif
979
980
/* Determine the current locale's name, and canonicalize it into XPG syntax
981
     language[_territory][.codeset][@modifier]
982
   The codeset part in the result is not reliable; the locale_charset()
983
   should be used for codeset information instead.
984
   The result must not be freed; it is statically allocated.  */
985
986
const char *
987
_nl_locale_name_posix (int category, const char *categoryname)
988
{
989
  /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
990
     On some systems this can be done by the 'setlocale' function itself.  */
991
#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
992
  return setlocale (category, NULL);
993
#else
994
  const char *retval;
995
996
  /* Setting of LC_ALL overrides all other.  */
997
  retval = getenv ("LC_ALL");
998
  if (retval != NULL && retval[0] != '\0')
999
    return retval;
1000
  /* Next comes the name of the desired category.  */
1001
  retval = getenv (categoryname);
1002
  if (retval != NULL && retval[0] != '\0')
1003
    return retval;
1004
  /* Last possibility is the LANG environment variable.  */
1005
  retval = getenv ("LANG");
1006
  if (retval != NULL && retval[0] != '\0')
1007
    return retval;
1008
1009
  return NULL;
1010
#endif
1011
}
1012
1013
const char *
1014
_nl_locale_name_default (void)
1015
{
1016
  /* POSIX:2001 says:
1017
     "All implementations shall define a locale as the default locale, to be
1018
      invoked when no environment variables are set, or set to the empty
1019
      string.  This default locale can be the POSIX locale or any other
1020
      implementation-defined locale.  Some implementations may provide
1021
      facilities for local installation administrators to set the default
1022
      locale, customizing it for each location.  POSIX:2001 does not require
1023
      such a facility.  */
1024
1025
#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined(WIN32_NATIVE))
1026
1027
  /* The system does not have a way of setting the locale, other than the
1028
     POSIX specified environment variables.  We use C as default locale.  */
1029
  return "C";
1030
1031
#else
1032
1033
  /* Return an XPG style locale name language[_territory][@modifier].
1034
     Don't even bother determining the codeset; it's not useful in this
1035
     context, because message catalogs are not specific to a single
1036
     codeset.  */
1037
1038
# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
1039
  /* MacOS X 10.2 or newer */
1040
  {
1041
    /* Cache the locale name, since CoreFoundation calls are expensive.  */
1042
    static const char *cached_localename;
1043
1044
    if (cached_localename == NULL)
1045
      {
1046
	char namebuf[256];
1047
#  if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */
1048
	CFLocaleRef locale = CFLocaleCopyCurrent ();
1049
	CFStringRef name = CFLocaleGetIdentifier (locale);
1050
1051
	if (CFStringGetCString (name, namebuf, sizeof(namebuf),
1052
				kCFStringEncodingASCII))
1053
	  {
1054
	    _nl_locale_name_canonicalize (namebuf);
1055
	    cached_localename = strdup (namebuf);
1056
	  }
1057
	CFRelease (locale);
1058
#  elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */
1059
	CFTypeRef value =
1060
	  CFPreferencesCopyAppValue (CFSTR ("AppleLocale"),
1061
				     kCFPreferencesCurrentApplication);
1062
	if (value != NULL
1063
	    && CFGetTypeID (value) == CFStringGetTypeID ()
1064
	    && CFStringGetCString ((CFStringRef)value, namebuf, sizeof(namebuf),
1065
				   kCFStringEncodingASCII))
1066
	  {
1067
	    _nl_locale_name_canonicalize (namebuf);
1068
	    cached_localename = strdup (namebuf);
1069
	  }
1070
#  endif
1071
	if (cached_localename == NULL)
1072
	  cached_localename = "C";
1073
      }
1074
    return cached_localename;
1075
  }
1076
1077
# endif
1078
1079
# if defined(WIN32_NATIVE) /* WIN32, not Cygwin */
1080
  {
1081
    LCID lcid;
1082
    LANGID langid;
1083
    int primary, sub;
1084
1085
    /* Use native Win32 API locale ID.  */
1086
    lcid = GetThreadLocale ();
1087
1088
    /* Strip off the sorting rules, keep only the language part.  */
1089
    langid = LANGIDFROMLCID (lcid);
1090
1091
    /* Split into language and territory part.  */
1092
    primary = PRIMARYLANGID (langid);
1093
    sub = SUBLANGID (langid);
1094
1095
    /* Dispatch on language.
1096
       See also http://www.unicode.org/unicode/onlinedat/languages.html .
1097
       For details about languages, see http://www.ethnologue.com/ .  */
1098
    switch (primary)
1099
      {
1100
      case LANG_AFRIKAANS: return "af_ZA";
1101
      case LANG_ALBANIAN: return "sq_AL";
1102
      case LANG_AMHARIC: return "am_ET";
1103
      case LANG_ARABIC:
1104
	switch (sub)
1105
	  {
1106
	  case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
1107
	  case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
1108
	  case SUBLANG_ARABIC_EGYPT: return "ar_EG";
1109
	  case SUBLANG_ARABIC_LIBYA: return "ar_LY";
1110
	  case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
1111
	  case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
1112
	  case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
1113
	  case SUBLANG_ARABIC_OMAN: return "ar_OM";
1114
	  case SUBLANG_ARABIC_YEMEN: return "ar_YE";
1115
	  case SUBLANG_ARABIC_SYRIA: return "ar_SY";
1116
	  case SUBLANG_ARABIC_JORDAN: return "ar_JO";
1117
	  case SUBLANG_ARABIC_LEBANON: return "ar_LB";
1118
	  case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
1119
	  case SUBLANG_ARABIC_UAE: return "ar_AE";
1120
	  case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
1121
	  case SUBLANG_ARABIC_QATAR: return "ar_QA";
1122
	  }
1123
	return "ar";
1124
      case LANG_ARMENIAN: return "hy_AM";
1125
      case LANG_ASSAMESE: return "as_IN";
1126
      case LANG_AZERI:
1127
	switch (sub)
1128
	  {
1129
	  /* FIXME: Adjust this when Azerbaijani locales appear on Unix.  */
1130
	  case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
1131
	  case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
1132
	  }
1133
	return "az";
1134
      case LANG_BASQUE:
1135
	switch (sub)
1136
	  {
1137
	  case SUBLANG_DEFAULT: return "eu_ES";
1138
	  }
1139
	return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR".  */
1140
      case LANG_BELARUSIAN: return "be_BY";
1141
      case LANG_BENGALI:
1142
	switch (sub)
1143
	  {
1144
	  case SUBLANG_BENGALI_INDIA: return "bn_IN";
1145
	  case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
1146
	  }
1147
	return "bn";
1148
      case LANG_BULGARIAN: return "bg_BG";
1149
      case LANG_BURMESE: return "my_MM";
1150
      case LANG_CAMBODIAN: return "km_KH";
1151
      case LANG_CATALAN: return "ca_ES";
1152
      case LANG_CHEROKEE: return "chr_US";
1153
      case LANG_CHINESE:
1154
	switch (sub)
1155
	  {
1156
	  case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
1157
	  case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
1158
	  case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
1159
	  case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
1160
	  case SUBLANG_CHINESE_MACAU: return "zh_MO";
1161
	  }
1162
	return "zh";
1163
      case LANG_CROATIAN:       /* LANG_CROATIAN == LANG_SERBIAN
1164
				 * What used to be called Serbo-Croatian
1165
				 * should really now be two separate
1166
				 * languages because of political reasons.
1167
				 * (Says tml, who knows nothing about Serbian
1168
				 * or Croatian.)
1169
				 * (I can feel those flames coming already.)
1170
				 */
1171
	switch (sub)
1172
	  {
1173
	  case SUBLANG_DEFAULT: return "hr_HR";
1174
	  case SUBLANG_SERBIAN_LATIN: return "sr_CS";
1175
	  case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
1176
	  }
1177
	return "hr";
1178
      case LANG_CZECH: return "cs_CZ";
1179
      case LANG_DANISH: return "da_DK";
1180
      case LANG_DIVEHI: return "dv_MV";
1181
      case LANG_DUTCH:
1182
	switch (sub)
1183
	  {
1184
	  case SUBLANG_DUTCH: return "nl_NL";
1185
	  case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
1186
	  }
1187
	return "nl";
1188
      case LANG_EDO: return "bin_NG";
1189
      case LANG_ENGLISH:
1190
	switch (sub)
1191
	  {
1192
	  /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
1193
	   * English was the language spoken in England.
1194
	   * Oh well.
1195
	   */
1196
	  case SUBLANG_ENGLISH_US: return "en_US";
1197
	  case SUBLANG_ENGLISH_UK: return "en_GB";
1198
	  case SUBLANG_ENGLISH_AUS: return "en_AU";
1199
	  case SUBLANG_ENGLISH_CAN: return "en_CA";
1200
	  case SUBLANG_ENGLISH_NZ: return "en_NZ";
1201
	  case SUBLANG_ENGLISH_EIRE: return "en_IE";
1202
	  case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
1203
	  case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
1204
	  case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
1205
	  case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
1206
	  case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
1207
	  case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
1208
	  case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
1209
	  case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
1210
	  case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
1211
	  case SUBLANG_ENGLISH_INDIA: return "en_IN";
1212
	  case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
1213
	  case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
1214
	  }
1215
	return "en";
1216
      case LANG_ESTONIAN: return "et_EE";
1217
      case LANG_FAEROESE: return "fo_FO";
1218
      case LANG_FARSI: return "fa_IR";
1219
      case LANG_FINNISH: return "fi_FI";
1220
      case LANG_FRENCH:
1221
	switch (sub)
1222
	  {
1223
	  case SUBLANG_FRENCH: return "fr_FR";
1224
	  case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
1225
	  case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
1226
	  case SUBLANG_FRENCH_SWISS: return "fr_CH";
1227
	  case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
1228
	  case SUBLANG_FRENCH_MONACO: return "fr_MC";
1229
	  case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
1230
	  case SUBLANG_FRENCH_REUNION: return "fr_RE";
1231
	  case SUBLANG_FRENCH_CONGO: return "fr_CG";
1232
	  case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
1233
	  case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
1234
	  case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
1235
	  case SUBLANG_FRENCH_MALI: return "fr_ML";
1236
	  case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
1237
	  case SUBLANG_FRENCH_HAITI: return "fr_HT";
1238
	  }
1239
	return "fr";
1240
      case LANG_FRISIAN: return "fy_NL";
1241
      case LANG_FULFULDE:
1242
	/* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin.  */
1243
	return "ff_NG";
1244
      case LANG_GAELIC:
1245
	switch (sub)
1246
	  {
1247
	  case 0x01: /* SCOTTISH */ return "gd_GB";
1248
	  case 0x02: /* IRISH */ return "ga_IE";
1249
	  }
1250
	return "C";
1251
      case LANG_GALICIAN: return "gl_ES";
1252
      case LANG_GEORGIAN: return "ka_GE";
1253
      case LANG_GERMAN:
1254
	switch (sub)
1255
	  {
1256
	  case SUBLANG_GERMAN: return "de_DE";
1257
	  case SUBLANG_GERMAN_SWISS: return "de_CH";
1258
	  case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
1259
	  case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
1260
	  case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
1261
	  }
1262
	return "de";
1263
      case LANG_GREEK: return "el_GR";
1264
      case LANG_GUARANI: return "gn_PY";
1265
      case LANG_GUJARATI: return "gu_IN";
1266
      case LANG_HAUSA: return "ha_NG";
1267
      case LANG_HAWAIIAN:
1268
	/* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
1269
	   or Hawaii Creole English ("cpe_US", 600000 speakers)?  */
1270
	return "cpe_US";
1271
      case LANG_HEBREW: return "he_IL";
1272
      case LANG_HINDI: return "hi_IN";
1273
      case LANG_HUNGARIAN: return "hu_HU";
1274
      case LANG_IBIBIO: return "nic_NG";
1275
      case LANG_ICELANDIC: return "is_IS";
1276
      case LANG_IGBO: return "ig_NG";
1277
      case LANG_INDONESIAN: return "id_ID";
1278
      case LANG_INUKTITUT: return "iu_CA";
1279
      case LANG_ITALIAN:
1280
	switch (sub)
1281
	  {
1282
	  case SUBLANG_ITALIAN: return "it_IT";
1283
	  case SUBLANG_ITALIAN_SWISS: return "it_CH";
1284
	  }
1285
	return "it";
1286
      case LANG_JAPANESE: return "ja_JP";
1287
      case LANG_KANNADA: return "kn_IN";
1288
      case LANG_KANURI: return "kr_NG";
1289
      case LANG_KASHMIRI:
1290
	switch (sub)
1291
	  {
1292
	  case SUBLANG_DEFAULT: return "ks_PK";
1293
	  case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
1294
	  }
1295
	return "ks";
1296
      case LANG_KAZAK: return "kk_KZ";
1297
      case LANG_KONKANI:
1298
	/* FIXME: Adjust this when such locales appear on Unix.  */
1299
	return "kok_IN";
1300
      case LANG_KOREAN: return "ko_KR";
1301
      case LANG_KYRGYZ: return "ky_KG";
1302
      case LANG_LAO: return "lo_LA";
1303
      case LANG_LATIN: return "la_VA";
1304
      case LANG_LATVIAN: return "lv_LV";
1305
      case LANG_LITHUANIAN: return "lt_LT";
1306
      case LANG_MACEDONIAN: return "mk_MK";
1307
      case LANG_MALAY:
1308
	switch (sub)
1309
	  {
1310
	  case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
1311
	  case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
1312
	  }
1313
	return "ms";
1314
      case LANG_MALAYALAM: return "ml_IN";
1315
      case LANG_MALTESE: return "mt_MT";
1316
      case LANG_MANIPURI:
1317
	/* FIXME: Adjust this when such locales appear on Unix.  */
1318
	return "mni_IN";
1319
      case LANG_MARATHI: return "mr_IN";
1320
      case LANG_MONGOLIAN:
1321
	switch (sub)
1322
	  {
1323
	  case SUBLANG_DEFAULT: return "mn_MN";
1324
	  }
1325
	return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN".  */
1326
      case LANG_NEPALI:
1327
	switch (sub)
1328
	  {
1329
	  case SUBLANG_DEFAULT: return "ne_NP";
1330
	  case SUBLANG_NEPALI_INDIA: return "ne_IN";
1331
	  }
1332
	return "ne";
1333
      case LANG_NORWEGIAN:
1334
	switch (sub)
1335
	  {
1336
	  case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO";
1337
	  case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
1338
	  }
1339
	return "no";
1340
      case LANG_ORIYA: return "or_IN";
1341
      case LANG_OROMO: return "om_ET";
1342
      case LANG_PAPIAMENTU: return "pap_AN";
1343
      case LANG_PASHTO:
1344
	return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF".  */
1345
      case LANG_POLISH: return "pl_PL";
1346
      case LANG_PORTUGUESE:
1347
	switch (sub)
1348
	  {
1349
	  case SUBLANG_PORTUGUESE: return "pt_PT";
1350
	  /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
1351
	     Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
1352
	  case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
1353
	  }
1354
	return "pt";
1355
      case LANG_PUNJABI:
1356
	switch (sub)
1357
	  {
1358
	  case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
1359
	  case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
1360
	  }
1361
	return "pa";
1362
      case LANG_RHAETO_ROMANCE: return "rm_CH";
1363
      case LANG_ROMANIAN:
1364
	switch (sub)
1365
	  {
1366
	  case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
1367
	  case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
1368
	  }
1369
	return "ro";
1370
      case LANG_RUSSIAN:
1371
	switch (sub)
1372
	  {
1373
	  case SUBLANG_DEFAULT: return "ru_RU";
1374
	  }
1375
	return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD".  */
1376
      case LANG_SAAMI: /* actually Northern Sami */ return "se_NO";
1377
      case LANG_SANSKRIT: return "sa_IN";
1378
      case LANG_SINDHI:
1379
	switch (sub)
1380
	  {
1381
	  case SUBLANG_SINDHI_INDIA: return "sd_IN";
1382
	  case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
1383
	  }
1384
	return "sd";
1385
      case LANG_SINHALESE: return "si_LK";
1386
      case LANG_SLOVAK: return "sk_SK";
1387
      case LANG_SLOVENIAN: return "sl_SI";
1388
      case LANG_SOMALI: return "so_SO";
1389
      case LANG_SORBIAN:
1390
	/* FIXME: Adjust this when such locales appear on Unix.  */
1391
	return "wen_DE";
1392
      case LANG_SPANISH:
1393
	switch (sub)
1394
	  {
1395
	  case SUBLANG_SPANISH: return "es_ES";
1396
	  case SUBLANG_SPANISH_MEXICAN: return "es_MX";
1397
	  case SUBLANG_SPANISH_MODERN:
1398
	    return "es_ES@modern";	/* not seen on Unix */
1399
	  case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
1400
	  case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
1401
	  case SUBLANG_SPANISH_PANAMA: return "es_PA";
1402
	  case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
1403
	  case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
1404
	  case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
1405
	  case SUBLANG_SPANISH_PERU: return "es_PE";
1406
	  case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
1407
	  case SUBLANG_SPANISH_ECUADOR: return "es_EC";
1408
	  case SUBLANG_SPANISH_CHILE: return "es_CL";
1409
	  case SUBLANG_SPANISH_URUGUAY: return "es_UY";
1410
	  case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
1411
	  case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
1412
	  case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
1413
	  case SUBLANG_SPANISH_HONDURAS: return "es_HN";
1414
	  case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
1415
	  case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
1416
	  }
1417
	return "es";
1418
      case LANG_SUTU: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
1419
      case LANG_SWAHILI: return "sw_KE";
1420
      case LANG_SWEDISH:
1421
	switch (sub)
1422
	  {
1423
	  case SUBLANG_DEFAULT: return "sv_SE";
1424
	  case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
1425
	  }
1426
	return "sv";
1427
      case LANG_SYRIAC: return "syr_TR"; /* An extinct language.  */
1428
      case LANG_TAGALOG: return "tl_PH";
1429
      case LANG_TAJIK: return "tg_TJ";
1430
      case LANG_TAMAZIGHT:
1431
	switch (sub)
1432
	  {
1433
	  /* FIXME: Adjust this when Tamazight locales appear on Unix.  */
1434
	  case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
1435
	  case SUBLANG_TAMAZIGHT_LATIN: return "ber_MA@latin";
1436
	  }
1437
	return "ber_MA";
1438
      case LANG_TAMIL:
1439
	switch (sub)
1440
	  {
1441
	  case SUBLANG_DEFAULT: return "ta_IN";
1442
	  }
1443
	return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG".  */
1444
      case LANG_TATAR: return "tt_RU";
1445
      case LANG_TELUGU: return "te_IN";
1446
      case LANG_THAI: return "th_TH";
1447
      case LANG_TIBETAN: return "bo_CN";
1448
      case LANG_TIGRINYA:
1449
	switch (sub)
1450
	  {
1451
	  case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
1452
	  case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
1453
	  }
1454
	return "ti";
1455
      case LANG_TSONGA: return "ts_ZA";
1456
      case LANG_TSWANA: return "tn_BW";
1457
      case LANG_TURKISH: return "tr_TR";
1458
      case LANG_TURKMEN: return "tk_TM";
1459
      case LANG_UKRAINIAN: return "uk_UA";
1460
      case LANG_URDU:
1461
	switch (sub)
1462
	  {
1463
	  case SUBLANG_URDU_PAKISTAN: return "ur_PK";
1464
	  case SUBLANG_URDU_INDIA: return "ur_IN";
1465
	  }
1466
	return "ur";
1467
      case LANG_UZBEK:
1468
	switch (sub)
1469
	  {
1470
	  case SUBLANG_UZBEK_LATIN: return "uz_UZ";
1471
	  case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
1472
	  }
1473
	return "uz";
1474
      case LANG_VENDA: return "ve_ZA";
1475
      case LANG_VIETNAMESE: return "vi_VN";
1476
      case LANG_WELSH: return "cy_GB";
1477
      case LANG_XHOSA: return "xh_ZA";
1478
      case LANG_YI: return "sit_CN";
1479
      case LANG_YIDDISH: return "yi_IL";
1480
      case LANG_YORUBA: return "yo_NG";
1481
      case LANG_ZULU: return "zu_ZA";
1482
      default: return "C";
1483
      }
1484
  }
1485
# endif
1486
#endif
1487
}
1488
1489
const char *
1490
_nl_locale_name (int category, const char *categoryname)
1491
{
1492
  const char *retval;
1493
1494
  retval = _nl_locale_name_posix (category, categoryname);
1495
  if (retval != NULL)
1496
    return retval;
1497
1498
  return _nl_locale_name_default ();
1499
}
(-)a/intl/lock.c (-922 lines)
Lines 1-922 Link Here
1
/* Locking in multithreaded situations.
2
   Copyright (C) 2005-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
20
   Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
21
   gthr-win32.h.  */
22
23
#include <config.h>
24
25
#include "lock.h"
26
27
/* ========================================================================= */
28
29
#if USE_POSIX_THREADS
30
31
/* Use the POSIX threads library.  */
32
33
# if PTHREAD_IN_USE_DETECTION_HARD
34
35
/* The function to be executed by a dummy thread.  */
36
static void *
37
dummy_thread_func (void *arg)
38
{
39
  return arg;
40
}
41
42
int
43
glthread_in_use (void)
44
{
45
  static int tested;
46
  static int result; /* 1: linked with -lpthread, 0: only with libc */
47
48
  if (!tested)
49
    {
50
      pthread_t thread;
51
52
      if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
53
	/* Thread creation failed.  */
54
	result = 0;
55
      else
56
	{
57
	  /* Thread creation works.  */
58
	  void *retval;
59
	  if (pthread_join (thread, &retval) != 0)
60
	    abort ();
61
	  result = 1;
62
	}
63
      tested = 1;
64
    }
65
  return result;
66
}
67
68
# endif
69
70
/* -------------------------- gl_lock_t datatype -------------------------- */
71
72
/* ------------------------- gl_rwlock_t datatype ------------------------- */
73
74
# if HAVE_PTHREAD_RWLOCK
75
76
#  if !defined PTHREAD_RWLOCK_INITIALIZER
77
78
void
79
glthread_rwlock_init (gl_rwlock_t *lock)
80
{
81
  if (pthread_rwlock_init (&lock->rwlock, NULL) != 0)
82
    abort ();
83
  lock->initialized = 1;
84
}
85
86
void
87
glthread_rwlock_rdlock (gl_rwlock_t *lock)
88
{
89
  if (!lock->initialized)
90
    {
91
      if (pthread_mutex_lock (&lock->guard) != 0)
92
	abort ();
93
      if (!lock->initialized)
94
	glthread_rwlock_init (lock);
95
      if (pthread_mutex_unlock (&lock->guard) != 0)
96
	abort ();
97
    }
98
  if (pthread_rwlock_rdlock (&lock->rwlock) != 0)
99
    abort ();
100
}
101
102
void
103
glthread_rwlock_wrlock (gl_rwlock_t *lock)
104
{
105
  if (!lock->initialized)
106
    {
107
      if (pthread_mutex_lock (&lock->guard) != 0)
108
	abort ();
109
      if (!lock->initialized)
110
	glthread_rwlock_init (lock);
111
      if (pthread_mutex_unlock (&lock->guard) != 0)
112
	abort ();
113
    }
114
  if (pthread_rwlock_wrlock (&lock->rwlock) != 0)
115
    abort ();
116
}
117
118
void
119
glthread_rwlock_unlock (gl_rwlock_t *lock)
120
{
121
  if (!lock->initialized)
122
    abort ();
123
  if (pthread_rwlock_unlock (&lock->rwlock) != 0)
124
    abort ();
125
}
126
127
void
128
glthread_rwlock_destroy (gl_rwlock_t *lock)
129
{
130
  if (!lock->initialized)
131
    abort ();
132
  if (pthread_rwlock_destroy (&lock->rwlock) != 0)
133
    abort ();
134
  lock->initialized = 0;
135
}
136
137
#  endif
138
139
# else
140
141
void
142
glthread_rwlock_init (gl_rwlock_t *lock)
143
{
144
  if (pthread_mutex_init (&lock->lock, NULL) != 0)
145
    abort ();
146
  if (pthread_cond_init (&lock->waiting_readers, NULL) != 0)
147
    abort ();
148
  if (pthread_cond_init (&lock->waiting_writers, NULL) != 0)
149
    abort ();
150
  lock->waiting_writers_count = 0;
151
  lock->runcount = 0;
152
}
153
154
void
155
glthread_rwlock_rdlock (gl_rwlock_t *lock)
156
{
157
  if (pthread_mutex_lock (&lock->lock) != 0)
158
    abort ();
159
  /* Test whether only readers are currently running, and whether the runcount
160
     field will not overflow.  */
161
  /* POSIX says: "It is implementation-defined whether the calling thread
162
     acquires the lock when a writer does not hold the lock and there are
163
     writers blocked on the lock."  Let's say, no: give the writers a higher
164
     priority.  */
165
  while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
166
    {
167
      /* This thread has to wait for a while.  Enqueue it among the
168
	 waiting_readers.  */
169
      if (pthread_cond_wait (&lock->waiting_readers, &lock->lock) != 0)
170
	abort ();
171
    }
172
  lock->runcount++;
173
  if (pthread_mutex_unlock (&lock->lock) != 0)
174
    abort ();
175
}
176
177
void
178
glthread_rwlock_wrlock (gl_rwlock_t *lock)
179
{
180
  if (pthread_mutex_lock (&lock->lock) != 0)
181
    abort ();
182
  /* Test whether no readers or writers are currently running.  */
183
  while (!(lock->runcount == 0))
184
    {
185
      /* This thread has to wait for a while.  Enqueue it among the
186
	 waiting_writers.  */
187
      lock->waiting_writers_count++;
188
      if (pthread_cond_wait (&lock->waiting_writers, &lock->lock) != 0)
189
	abort ();
190
      lock->waiting_writers_count--;
191
    }
192
  lock->runcount--; /* runcount becomes -1 */
193
  if (pthread_mutex_unlock (&lock->lock) != 0)
194
    abort ();
195
}
196
197
void
198
glthread_rwlock_unlock (gl_rwlock_t *lock)
199
{
200
  if (pthread_mutex_lock (&lock->lock) != 0)
201
    abort ();
202
  if (lock->runcount < 0)
203
    {
204
      /* Drop a writer lock.  */
205
      if (!(lock->runcount == -1))
206
	abort ();
207
      lock->runcount = 0;
208
    }
209
  else
210
    {
211
      /* Drop a reader lock.  */
212
      if (!(lock->runcount > 0))
213
	abort ();
214
      lock->runcount--;
215
    }
216
  if (lock->runcount == 0)
217
    {
218
      /* POSIX recommends that "write locks shall take precedence over read
219
	 locks", to avoid "writer starvation".  */
220
      if (lock->waiting_writers_count > 0)
221
	{
222
	  /* Wake up one of the waiting writers.  */
223
	  if (pthread_cond_signal (&lock->waiting_writers) != 0)
224
	    abort ();
225
	}
226
      else
227
	{
228
	  /* Wake up all waiting readers.  */
229
	  if (pthread_cond_broadcast (&lock->waiting_readers) != 0)
230
	    abort ();
231
	}
232
    }
233
  if (pthread_mutex_unlock (&lock->lock) != 0)
234
    abort ();
235
}
236
237
void
238
glthread_rwlock_destroy (gl_rwlock_t *lock)
239
{
240
  if (pthread_mutex_destroy (&lock->lock) != 0)
241
    abort ();
242
  if (pthread_cond_destroy (&lock->waiting_readers) != 0)
243
    abort ();
244
  if (pthread_cond_destroy (&lock->waiting_writers) != 0)
245
    abort ();
246
}
247
248
# endif
249
250
/* --------------------- gl_recursive_lock_t datatype --------------------- */
251
252
# if HAVE_PTHREAD_MUTEX_RECURSIVE
253
254
#  if !(defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
255
256
void
257
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
258
{
259
  pthread_mutexattr_t attributes;
260
261
  if (pthread_mutexattr_init (&attributes) != 0)
262
    abort ();
263
  if (pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE) != 0)
264
    abort ();
265
  if (pthread_mutex_init (&lock->recmutex, &attributes) != 0)
266
    abort ();
267
  if (pthread_mutexattr_destroy (&attributes) != 0)
268
    abort ();
269
  lock->initialized = 1;
270
}
271
272
void
273
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
274
{
275
  if (!lock->initialized)
276
    {
277
      if (pthread_mutex_lock (&lock->guard) != 0)
278
	abort ();
279
      if (!lock->initialized)
280
	glthread_recursive_lock_init (lock);
281
      if (pthread_mutex_unlock (&lock->guard) != 0)
282
	abort ();
283
    }
284
  if (pthread_mutex_lock (&lock->recmutex) != 0)
285
    abort ();
286
}
287
288
void
289
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
290
{
291
  if (!lock->initialized)
292
    abort ();
293
  if (pthread_mutex_unlock (&lock->recmutex) != 0)
294
    abort ();
295
}
296
297
void
298
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
299
{
300
  if (!lock->initialized)
301
    abort ();
302
  if (pthread_mutex_destroy (&lock->recmutex) != 0)
303
    abort ();
304
  lock->initialized = 0;
305
}
306
307
#  endif
308
309
# else
310
311
void
312
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
313
{
314
  if (pthread_mutex_init (&lock->mutex, NULL) != 0)
315
    abort ();
316
  lock->owner = (pthread_t) 0;
317
  lock->depth = 0;
318
}
319
320
void
321
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
322
{
323
  pthread_t self = pthread_self ();
324
  if (lock->owner != self)
325
    {
326
      if (pthread_mutex_lock (&lock->mutex) != 0)
327
	abort ();
328
      lock->owner = self;
329
    }
330
  if (++(lock->depth) == 0) /* wraparound? */
331
    abort ();
332
}
333
334
void
335
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
336
{
337
  if (lock->owner != pthread_self ())
338
    abort ();
339
  if (lock->depth == 0)
340
    abort ();
341
  if (--(lock->depth) == 0)
342
    {
343
      lock->owner = (pthread_t) 0;
344
      if (pthread_mutex_unlock (&lock->mutex) != 0)
345
	abort ();
346
    }
347
}
348
349
void
350
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
351
{
352
  if (lock->owner != (pthread_t) 0)
353
    abort ();
354
  if (pthread_mutex_destroy (&lock->mutex) != 0)
355
    abort ();
356
}
357
358
# endif
359
360
/* -------------------------- gl_once_t datatype -------------------------- */
361
362
static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
363
364
int
365
glthread_once_singlethreaded (pthread_once_t *once_control)
366
{
367
  /* We don't know whether pthread_once_t is an integer type, a floating-point
368
     type, a pointer type, or a structure type.  */
369
  char *firstbyte = (char *)once_control;
370
  if (*firstbyte == *(const char *)&fresh_once)
371
    {
372
      /* First time use of once_control.  Invert the first byte.  */
373
      *firstbyte = ~ *(const char *)&fresh_once;
374
      return 1;
375
    }
376
  else
377
    return 0;
378
}
379
380
#endif
381
382
/* ========================================================================= */
383
384
#if USE_PTH_THREADS
385
386
/* Use the GNU Pth threads library.  */
387
388
/* -------------------------- gl_lock_t datatype -------------------------- */
389
390
/* ------------------------- gl_rwlock_t datatype ------------------------- */
391
392
/* --------------------- gl_recursive_lock_t datatype --------------------- */
393
394
/* -------------------------- gl_once_t datatype -------------------------- */
395
396
void
397
glthread_once_call (void *arg)
398
{
399
  void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
400
  void (*initfunction) (void) = *gl_once_temp_addr;
401
  initfunction ();
402
}
403
404
int
405
glthread_once_singlethreaded (pth_once_t *once_control)
406
{
407
  /* We know that pth_once_t is an integer type.  */
408
  if (*once_control == PTH_ONCE_INIT)
409
    {
410
      /* First time use of once_control.  Invert the marker.  */
411
      *once_control = ~ PTH_ONCE_INIT;
412
      return 1;
413
    }
414
  else
415
    return 0;
416
}
417
418
#endif
419
420
/* ========================================================================= */
421
422
#if USE_SOLARIS_THREADS
423
424
/* Use the old Solaris threads library.  */
425
426
/* -------------------------- gl_lock_t datatype -------------------------- */
427
428
/* ------------------------- gl_rwlock_t datatype ------------------------- */
429
430
/* --------------------- gl_recursive_lock_t datatype --------------------- */
431
432
void
433
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
434
{
435
  if (mutex_init (&lock->mutex, USYNC_THREAD, NULL) != 0)
436
    abort ();
437
  lock->owner = (thread_t) 0;
438
  lock->depth = 0;
439
}
440
441
void
442
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
443
{
444
  thread_t self = thr_self ();
445
  if (lock->owner != self)
446
    {
447
      if (mutex_lock (&lock->mutex) != 0)
448
	abort ();
449
      lock->owner = self;
450
    }
451
  if (++(lock->depth) == 0) /* wraparound? */
452
    abort ();
453
}
454
455
void
456
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
457
{
458
  if (lock->owner != thr_self ())
459
    abort ();
460
  if (lock->depth == 0)
461
    abort ();
462
  if (--(lock->depth) == 0)
463
    {
464
      lock->owner = (thread_t) 0;
465
      if (mutex_unlock (&lock->mutex) != 0)
466
	abort ();
467
    }
468
}
469
470
void
471
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
472
{
473
  if (lock->owner != (thread_t) 0)
474
    abort ();
475
  if (mutex_destroy (&lock->mutex) != 0)
476
    abort ();
477
}
478
479
/* -------------------------- gl_once_t datatype -------------------------- */
480
481
void
482
glthread_once (gl_once_t *once_control, void (*initfunction) (void))
483
{
484
  if (!once_control->inited)
485
    {
486
      /* Use the mutex to guarantee that if another thread is already calling
487
	 the initfunction, this thread waits until it's finished.  */
488
      if (mutex_lock (&once_control->mutex) != 0)
489
	abort ();
490
      if (!once_control->inited)
491
	{
492
	  once_control->inited = 1;
493
	  initfunction ();
494
	}
495
      if (mutex_unlock (&once_control->mutex) != 0)
496
	abort ();
497
    }
498
}
499
500
int
501
glthread_once_singlethreaded (gl_once_t *once_control)
502
{
503
  /* We know that gl_once_t contains an integer type.  */
504
  if (!once_control->inited)
505
    {
506
      /* First time use of once_control.  Invert the marker.  */
507
      once_control->inited = ~ 0;
508
      return 1;
509
    }
510
  else
511
    return 0;
512
}
513
514
#endif
515
516
/* ========================================================================= */
517
518
#if USE_WIN32_THREADS
519
520
/* -------------------------- gl_lock_t datatype -------------------------- */
521
522
void
523
glthread_lock_init (gl_lock_t *lock)
524
{
525
  InitializeCriticalSection (&lock->lock);
526
  lock->guard.done = 1;
527
}
528
529
void
530
glthread_lock_lock (gl_lock_t *lock)
531
{
532
  if (!lock->guard.done)
533
    {
534
      if (InterlockedIncrement (&lock->guard.started) == 0)
535
	/* This thread is the first one to need this lock.  Initialize it.  */
536
	glthread_lock_init (lock);
537
      else
538
	/* Yield the CPU while waiting for another thread to finish
539
	   initializing this lock.  */
540
	while (!lock->guard.done)
541
	  Sleep (0);
542
    }
543
  EnterCriticalSection (&lock->lock);
544
}
545
546
void
547
glthread_lock_unlock (gl_lock_t *lock)
548
{
549
  if (!lock->guard.done)
550
    abort ();
551
  LeaveCriticalSection (&lock->lock);
552
}
553
554
void
555
glthread_lock_destroy (gl_lock_t *lock)
556
{
557
  if (!lock->guard.done)
558
    abort ();
559
  DeleteCriticalSection (&lock->lock);
560
  lock->guard.done = 0;
561
}
562
563
/* ------------------------- gl_rwlock_t datatype ------------------------- */
564
565
static inline void
566
gl_waitqueue_init (gl_waitqueue_t *wq)
567
{
568
  wq->array = NULL;
569
  wq->count = 0;
570
  wq->alloc = 0;
571
  wq->offset = 0;
572
}
573
574
/* Enqueues the current thread, represented by an event, in a wait queue.
575
   Returns INVALID_HANDLE_VALUE if an allocation failure occurs.  */
576
static HANDLE
577
gl_waitqueue_add (gl_waitqueue_t *wq)
578
{
579
  HANDLE event;
580
  unsigned int index;
581
582
  if (wq->count == wq->alloc)
583
    {
584
      unsigned int new_alloc = 2 * wq->alloc + 1;
585
      HANDLE *new_array =
586
	(HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
587
      if (new_array == NULL)
588
	/* No more memory.  */
589
	return INVALID_HANDLE_VALUE;
590
      /* Now is a good opportunity to rotate the array so that its contents
591
	 starts at offset 0.  */
592
      if (wq->offset > 0)
593
	{
594
	  unsigned int old_count = wq->count;
595
	  unsigned int old_alloc = wq->alloc;
596
	  unsigned int old_offset = wq->offset;
597
	  unsigned int i;
598
	  if (old_offset + old_count > old_alloc)
599
	    {
600
	      unsigned int limit = old_offset + old_count - old_alloc;
601
	      for (i = 0; i < limit; i++)
602
		new_array[old_alloc + i] = new_array[i];
603
	    }
604
	  for (i = 0; i < old_count; i++)
605
	    new_array[i] = new_array[old_offset + i];
606
	  wq->offset = 0;
607
	}
608
      wq->array = new_array;
609
      wq->alloc = new_alloc;
610
    }
611
  event = CreateEvent (NULL, TRUE, FALSE, NULL);
612
  if (event == INVALID_HANDLE_VALUE)
613
    /* No way to allocate an event.  */
614
    return INVALID_HANDLE_VALUE;
615
  index = wq->offset + wq->count;
616
  if (index >= wq->alloc)
617
    index -= wq->alloc;
618
  wq->array[index] = event;
619
  wq->count++;
620
  return event;
621
}
622
623
/* Notifies the first thread from a wait queue and dequeues it.  */
624
static inline void
625
gl_waitqueue_notify_first (gl_waitqueue_t *wq)
626
{
627
  SetEvent (wq->array[wq->offset + 0]);
628
  wq->offset++;
629
  wq->count--;
630
  if (wq->count == 0 || wq->offset == wq->alloc)
631
    wq->offset = 0;
632
}
633
634
/* Notifies all threads from a wait queue and dequeues them all.  */
635
static inline void
636
gl_waitqueue_notify_all (gl_waitqueue_t *wq)
637
{
638
  unsigned int i;
639
640
  for (i = 0; i < wq->count; i++)
641
    {
642
      unsigned int index = wq->offset + i;
643
      if (index >= wq->alloc)
644
	index -= wq->alloc;
645
      SetEvent (wq->array[index]);
646
    }
647
  wq->count = 0;
648
  wq->offset = 0;
649
}
650
651
void
652
glthread_rwlock_init (gl_rwlock_t *lock)
653
{
654
  InitializeCriticalSection (&lock->lock);
655
  gl_waitqueue_init (&lock->waiting_readers);
656
  gl_waitqueue_init (&lock->waiting_writers);
657
  lock->runcount = 0;
658
  lock->guard.done = 1;
659
}
660
661
void
662
glthread_rwlock_rdlock (gl_rwlock_t *lock)
663
{
664
  if (!lock->guard.done)
665
    {
666
      if (InterlockedIncrement (&lock->guard.started) == 0)
667
	/* This thread is the first one to need this lock.  Initialize it.  */
668
	glthread_rwlock_init (lock);
669
      else
670
	/* Yield the CPU while waiting for another thread to finish
671
	   initializing this lock.  */
672
	while (!lock->guard.done)
673
	  Sleep (0);
674
    }
675
  EnterCriticalSection (&lock->lock);
676
  /* Test whether only readers are currently running, and whether the runcount
677
     field will not overflow.  */
678
  if (!(lock->runcount + 1 > 0))
679
    {
680
      /* This thread has to wait for a while.  Enqueue it among the
681
	 waiting_readers.  */
682
      HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
683
      if (event != INVALID_HANDLE_VALUE)
684
	{
685
	  DWORD result;
686
	  LeaveCriticalSection (&lock->lock);
687
	  /* Wait until another thread signals this event.  */
688
	  result = WaitForSingleObject (event, INFINITE);
689
	  if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
690
	    abort ();
691
	  CloseHandle (event);
692
	  /* The thread which signalled the event already did the bookkeeping:
693
	     removed us from the waiting_readers, incremented lock->runcount.  */
694
	  if (!(lock->runcount > 0))
695
	    abort ();
696
	  return;
697
	}
698
      else
699
	{
700
	  /* Allocation failure.  Weird.  */
701
	  do
702
	    {
703
	      LeaveCriticalSection (&lock->lock);
704
	      Sleep (1);
705
	      EnterCriticalSection (&lock->lock);
706
	    }
707
	  while (!(lock->runcount + 1 > 0));
708
	}
709
    }
710
  lock->runcount++;
711
  LeaveCriticalSection (&lock->lock);
712
}
713
714
void
715
glthread_rwlock_wrlock (gl_rwlock_t *lock)
716
{
717
  if (!lock->guard.done)
718
    {
719
      if (InterlockedIncrement (&lock->guard.started) == 0)
720
	/* This thread is the first one to need this lock.  Initialize it.  */
721
	glthread_rwlock_init (lock);
722
      else
723
	/* Yield the CPU while waiting for another thread to finish
724
	   initializing this lock.  */
725
	while (!lock->guard.done)
726
	  Sleep (0);
727
    }
728
  EnterCriticalSection (&lock->lock);
729
  /* Test whether no readers or writers are currently running.  */
730
  if (!(lock->runcount == 0))
731
    {
732
      /* This thread has to wait for a while.  Enqueue it among the
733
	 waiting_writers.  */
734
      HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
735
      if (event != INVALID_HANDLE_VALUE)
736
	{
737
	  DWORD result;
738
	  LeaveCriticalSection (&lock->lock);
739
	  /* Wait until another thread signals this event.  */
740
	  result = WaitForSingleObject (event, INFINITE);
741
	  if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
742
	    abort ();
743
	  CloseHandle (event);
744
	  /* The thread which signalled the event already did the bookkeeping:
745
	     removed us from the waiting_writers, set lock->runcount = -1.  */
746
	  if (!(lock->runcount == -1))
747
	    abort ();
748
	  return;
749
	}
750
      else
751
	{
752
	  /* Allocation failure.  Weird.  */
753
	  do
754
	    {
755
	      LeaveCriticalSection (&lock->lock);
756
	      Sleep (1);
757
	      EnterCriticalSection (&lock->lock);
758
	    }
759
	  while (!(lock->runcount == 0));
760
	}
761
    }
762
  lock->runcount--; /* runcount becomes -1 */
763
  LeaveCriticalSection (&lock->lock);
764
}
765
766
void
767
glthread_rwlock_unlock (gl_rwlock_t *lock)
768
{
769
  if (!lock->guard.done)
770
    abort ();
771
  EnterCriticalSection (&lock->lock);
772
  if (lock->runcount < 0)
773
    {
774
      /* Drop a writer lock.  */
775
      if (!(lock->runcount == -1))
776
	abort ();
777
      lock->runcount = 0;
778
    }
779
  else
780
    {
781
      /* Drop a reader lock.  */
782
      if (!(lock->runcount > 0))
783
	abort ();
784
      lock->runcount--;
785
    }
786
  if (lock->runcount == 0)
787
    {
788
      /* POSIX recommends that "write locks shall take precedence over read
789
	 locks", to avoid "writer starvation".  */
790
      if (lock->waiting_writers.count > 0)
791
	{
792
	  /* Wake up one of the waiting writers.  */
793
	  lock->runcount--;
794
	  gl_waitqueue_notify_first (&lock->waiting_writers);
795
	}
796
      else
797
	{
798
	  /* Wake up all waiting readers.  */
799
	  lock->runcount += lock->waiting_readers.count;
800
	  gl_waitqueue_notify_all (&lock->waiting_readers);
801
	}
802
    }
803
  LeaveCriticalSection (&lock->lock);
804
}
805
806
void
807
glthread_rwlock_destroy (gl_rwlock_t *lock)
808
{
809
  if (!lock->guard.done)
810
    abort ();
811
  if (lock->runcount != 0)
812
    abort ();
813
  DeleteCriticalSection (&lock->lock);
814
  if (lock->waiting_readers.array != NULL)
815
    free (lock->waiting_readers.array);
816
  if (lock->waiting_writers.array != NULL)
817
    free (lock->waiting_writers.array);
818
  lock->guard.done = 0;
819
}
820
821
/* --------------------- gl_recursive_lock_t datatype --------------------- */
822
823
void
824
glthread_recursive_lock_init (gl_recursive_lock_t *lock)
825
{
826
  lock->owner = 0;
827
  lock->depth = 0;
828
  InitializeCriticalSection (&lock->lock);
829
  lock->guard.done = 1;
830
}
831
832
void
833
glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
834
{
835
  if (!lock->guard.done)
836
    {
837
      if (InterlockedIncrement (&lock->guard.started) == 0)
838
	/* This thread is the first one to need this lock.  Initialize it.  */
839
	glthread_recursive_lock_init (lock);
840
      else
841
	/* Yield the CPU while waiting for another thread to finish
842
	   initializing this lock.  */
843
	while (!lock->guard.done)
844
	  Sleep (0);
845
    }
846
  {
847
    DWORD self = GetCurrentThreadId ();
848
    if (lock->owner != self)
849
      {
850
	EnterCriticalSection (&lock->lock);
851
	lock->owner = self;
852
      }
853
    if (++(lock->depth) == 0) /* wraparound? */
854
      abort ();
855
  }
856
}
857
858
void
859
glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
860
{
861
  if (lock->owner != GetCurrentThreadId ())
862
    abort ();
863
  if (lock->depth == 0)
864
    abort ();
865
  if (--(lock->depth) == 0)
866
    {
867
      lock->owner = 0;
868
      LeaveCriticalSection (&lock->lock);
869
    }
870
}
871
872
void
873
glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
874
{
875
  if (lock->owner != 0)
876
    abort ();
877
  DeleteCriticalSection (&lock->lock);
878
  lock->guard.done = 0;
879
}
880
881
/* -------------------------- gl_once_t datatype -------------------------- */
882
883
void
884
glthread_once (gl_once_t *once_control, void (*initfunction) (void))
885
{
886
  if (once_control->inited <= 0)
887
    {
888
      if (InterlockedIncrement (&once_control->started) == 0)
889
	{
890
	  /* This thread is the first one to come to this once_control.  */
891
	  InitializeCriticalSection (&once_control->lock);
892
	  EnterCriticalSection (&once_control->lock);
893
	  once_control->inited = 0;
894
	  initfunction ();
895
	  once_control->inited = 1;
896
	  LeaveCriticalSection (&once_control->lock);
897
	}
898
      else
899
	{
900
	  /* Undo last operation.  */
901
	  InterlockedDecrement (&once_control->started);
902
	  /* Some other thread has already started the initialization.
903
	     Yield the CPU while waiting for the other thread to finish
904
	     initializing and taking the lock.  */
905
	  while (once_control->inited < 0)
906
	    Sleep (0);
907
	  if (once_control->inited <= 0)
908
	    {
909
	      /* Take the lock.  This blocks until the other thread has
910
		 finished calling the initfunction.  */
911
	      EnterCriticalSection (&once_control->lock);
912
	      LeaveCriticalSection (&once_control->lock);
913
	      if (!(once_control->inited > 0))
914
		abort ();
915
	    }
916
	}
917
    }
918
}
919
920
#endif
921
922
/* ========================================================================= */
(-)a/intl/lock.h (-833 lines)
Lines 1-833 Link Here
1
/* Locking in multithreaded situations.
2
   Copyright (C) 2005-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
20
   Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
21
   gthr-win32.h.  */
22
23
/* This file contains locking primitives for use with a given thread library.
24
   It does not contain primitives for creating threads or for other
25
   synchronization primitives.
26
27
   Normal (non-recursive) locks:
28
     Type:                gl_lock_t
29
     Declaration:         gl_lock_define(extern, name)
30
     Initializer:         gl_lock_define_initialized(, name)
31
     Initialization:      gl_lock_init (name);
32
     Taking the lock:     gl_lock_lock (name);
33
     Releasing the lock:  gl_lock_unlock (name);
34
     De-initialization:   gl_lock_destroy (name);
35
36
   Read-Write (non-recursive) locks:
37
     Type:                gl_rwlock_t
38
     Declaration:         gl_rwlock_define(extern, name)
39
     Initializer:         gl_rwlock_define_initialized(, name)
40
     Initialization:      gl_rwlock_init (name);
41
     Taking the lock:     gl_rwlock_rdlock (name);
42
                          gl_rwlock_wrlock (name);
43
     Releasing the lock:  gl_rwlock_unlock (name);
44
     De-initialization:   gl_rwlock_destroy (name);
45
46
   Recursive locks:
47
     Type:                gl_recursive_lock_t
48
     Declaration:         gl_recursive_lock_define(extern, name)
49
     Initializer:         gl_recursive_lock_define_initialized(, name)
50
     Initialization:      gl_recursive_lock_init (name);
51
     Taking the lock:     gl_recursive_lock_lock (name);
52
     Releasing the lock:  gl_recursive_lock_unlock (name);
53
     De-initialization:   gl_recursive_lock_destroy (name);
54
55
  Once-only execution:
56
     Type:                gl_once_t
57
     Initializer:         gl_once_define(extern, name)
58
     Execution:           gl_once (name, initfunction);
59
*/
60
61
62
#ifndef _LOCK_H
63
#define _LOCK_H
64
65
/* ========================================================================= */
66
67
#if USE_POSIX_THREADS
68
69
/* Use the POSIX threads library.  */
70
71
# include <pthread.h>
72
# include <stdlib.h>
73
74
# ifdef __cplusplus
75
extern "C" {
76
# endif
77
78
# if PTHREAD_IN_USE_DETECTION_HARD
79
80
/* The pthread_in_use() detection needs to be done at runtime.  */
81
#  define pthread_in_use() \
82
     glthread_in_use ()
83
extern int glthread_in_use (void);
84
85
# endif
86
87
# if USE_POSIX_THREADS_WEAK
88
89
/* Use weak references to the POSIX threads library.  */
90
91
/* Weak references avoid dragging in external libraries if the other parts
92
   of the program don't use them.  Here we use them, because we don't want
93
   every program that uses libintl to depend on libpthread.  This assumes
94
   that libpthread would not be loaded after libintl; i.e. if libintl is
95
   loaded first, by an executable that does not depend on libpthread, and
96
   then a module is dynamically loaded that depends on libpthread, libintl
97
   will not be multithread-safe.  */
98
99
/* The way to test at runtime whether libpthread is present is to test
100
   whether a function pointer's value, such as &pthread_mutex_init, is
101
   non-NULL.  However, some versions of GCC have a bug through which, in
102
   PIC mode, &foo != NULL always evaluates to true if there is a direct
103
   call to foo(...) in the same function.  To avoid this, we test the
104
   address of a function in libpthread that we don't use.  */
105
106
#  pragma weak pthread_mutex_init
107
#  pragma weak pthread_mutex_lock
108
#  pragma weak pthread_mutex_unlock
109
#  pragma weak pthread_mutex_destroy
110
#  pragma weak pthread_rwlock_init
111
#  pragma weak pthread_rwlock_rdlock
112
#  pragma weak pthread_rwlock_wrlock
113
#  pragma weak pthread_rwlock_unlock
114
#  pragma weak pthread_rwlock_destroy
115
#  pragma weak pthread_once
116
#  pragma weak pthread_cond_init
117
#  pragma weak pthread_cond_wait
118
#  pragma weak pthread_cond_signal
119
#  pragma weak pthread_cond_broadcast
120
#  pragma weak pthread_cond_destroy
121
#  pragma weak pthread_mutexattr_init
122
#  pragma weak pthread_mutexattr_settype
123
#  pragma weak pthread_mutexattr_destroy
124
#  ifndef pthread_self
125
#   pragma weak pthread_self
126
#  endif
127
128
#  if !PTHREAD_IN_USE_DETECTION_HARD
129
#   pragma weak pthread_cancel
130
#   define pthread_in_use() (pthread_cancel != NULL)
131
#  endif
132
133
# else
134
135
#  if !PTHREAD_IN_USE_DETECTION_HARD
136
#   define pthread_in_use() 1
137
#  endif
138
139
# endif
140
141
/* -------------------------- gl_lock_t datatype -------------------------- */
142
143
typedef pthread_mutex_t gl_lock_t;
144
# define gl_lock_define(STORAGECLASS, NAME) \
145
    STORAGECLASS pthread_mutex_t NAME;
146
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
147
    STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
148
# define gl_lock_initializer \
149
    PTHREAD_MUTEX_INITIALIZER
150
# define gl_lock_init(NAME) \
151
    if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
152
# define gl_lock_lock(NAME) \
153
    if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
154
# define gl_lock_unlock(NAME) \
155
    if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
156
# define gl_lock_destroy(NAME) \
157
    if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
158
159
/* ------------------------- gl_rwlock_t datatype ------------------------- */
160
161
# if HAVE_PTHREAD_RWLOCK
162
163
#  ifdef PTHREAD_RWLOCK_INITIALIZER
164
165
typedef pthread_rwlock_t gl_rwlock_t;
166
#   define gl_rwlock_define(STORAGECLASS, NAME) \
167
      STORAGECLASS pthread_rwlock_t NAME;
168
#   define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
169
      STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
170
#   define gl_rwlock_initializer \
171
      PTHREAD_RWLOCK_INITIALIZER
172
#   define gl_rwlock_init(NAME) \
173
      if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) abort ()
174
#   define gl_rwlock_rdlock(NAME) \
175
      if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) abort ()
176
#   define gl_rwlock_wrlock(NAME) \
177
      if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) abort ()
178
#   define gl_rwlock_unlock(NAME) \
179
      if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) abort ()
180
#   define gl_rwlock_destroy(NAME) \
181
      if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) abort ()
182
183
#  else
184
185
typedef struct
186
        {
187
          int initialized;
188
          pthread_mutex_t guard;   /* protects the initialization */
189
          pthread_rwlock_t rwlock; /* read-write lock */
190
        }
191
        gl_rwlock_t;
192
#   define gl_rwlock_define(STORAGECLASS, NAME) \
193
      STORAGECLASS gl_rwlock_t NAME;
194
#   define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
195
      STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
196
#   define gl_rwlock_initializer \
197
      { 0, PTHREAD_MUTEX_INITIALIZER }
198
#   define gl_rwlock_init(NAME) \
199
      if (pthread_in_use ()) glthread_rwlock_init (&NAME)
200
#   define gl_rwlock_rdlock(NAME) \
201
      if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
202
#   define gl_rwlock_wrlock(NAME) \
203
      if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
204
#   define gl_rwlock_unlock(NAME) \
205
      if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
206
#   define gl_rwlock_destroy(NAME) \
207
      if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
208
extern void glthread_rwlock_init (gl_rwlock_t *lock);
209
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
210
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
211
extern void glthread_rwlock_unlock (gl_rwlock_t *lock);
212
extern void glthread_rwlock_destroy (gl_rwlock_t *lock);
213
214
#  endif
215
216
# else
217
218
typedef struct
219
        {
220
          pthread_mutex_t lock; /* protects the remaining fields */
221
          pthread_cond_t waiting_readers; /* waiting readers */
222
          pthread_cond_t waiting_writers; /* waiting writers */
223
          unsigned int waiting_writers_count; /* number of waiting writers */
224
          int runcount; /* number of readers running, or -1 when a writer runs */
225
        }
226
        gl_rwlock_t;
227
# define gl_rwlock_define(STORAGECLASS, NAME) \
228
    STORAGECLASS gl_rwlock_t NAME;
229
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
230
    STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
231
# define gl_rwlock_initializer \
232
    { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
233
# define gl_rwlock_init(NAME) \
234
    if (pthread_in_use ()) glthread_rwlock_init (&NAME)
235
# define gl_rwlock_rdlock(NAME) \
236
    if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
237
# define gl_rwlock_wrlock(NAME) \
238
    if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
239
# define gl_rwlock_unlock(NAME) \
240
    if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
241
# define gl_rwlock_destroy(NAME) \
242
    if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
243
extern void glthread_rwlock_init (gl_rwlock_t *lock);
244
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
245
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
246
extern void glthread_rwlock_unlock (gl_rwlock_t *lock);
247
extern void glthread_rwlock_destroy (gl_rwlock_t *lock);
248
249
# endif
250
251
/* --------------------- gl_recursive_lock_t datatype --------------------- */
252
253
# if HAVE_PTHREAD_MUTEX_RECURSIVE
254
255
#  if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
256
257
typedef pthread_mutex_t gl_recursive_lock_t;
258
#   define gl_recursive_lock_define(STORAGECLASS, NAME) \
259
      STORAGECLASS pthread_mutex_t NAME;
260
#   define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
261
      STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
262
#   ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
263
#    define gl_recursive_lock_initializer \
264
       PTHREAD_RECURSIVE_MUTEX_INITIALIZER
265
#   else
266
#    define gl_recursive_lock_initializer \
267
       PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
268
#   endif
269
#   define gl_recursive_lock_init(NAME) \
270
      if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
271
#   define gl_recursive_lock_lock(NAME) \
272
      if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
273
#   define gl_recursive_lock_unlock(NAME) \
274
      if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
275
#   define gl_recursive_lock_destroy(NAME) \
276
      if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
277
278
#  else
279
280
typedef struct
281
        {
282
          pthread_mutex_t recmutex; /* recursive mutex */
283
          pthread_mutex_t guard;    /* protects the initialization */
284
          int initialized;
285
        }
286
        gl_recursive_lock_t;
287
#   define gl_recursive_lock_define(STORAGECLASS, NAME) \
288
      STORAGECLASS gl_recursive_lock_t NAME;
289
#   define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
290
      STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
291
#   define gl_recursive_lock_initializer \
292
      { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
293
#   define gl_recursive_lock_init(NAME) \
294
      if (pthread_in_use ()) glthread_recursive_lock_init (&NAME)
295
#   define gl_recursive_lock_lock(NAME) \
296
      if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
297
#   define gl_recursive_lock_unlock(NAME) \
298
      if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
299
#   define gl_recursive_lock_destroy(NAME) \
300
      if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
301
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
302
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
303
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
304
extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
305
306
#  endif
307
308
# else
309
310
/* Old versions of POSIX threads on Solaris did not have recursive locks.
311
   We have to implement them ourselves.  */
312
313
typedef struct
314
        {
315
          pthread_mutex_t mutex;
316
          pthread_t owner;
317
          unsigned long depth;
318
        }
319
        gl_recursive_lock_t;
320
#  define gl_recursive_lock_define(STORAGECLASS, NAME) \
321
     STORAGECLASS gl_recursive_lock_t NAME;
322
#  define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
323
     STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
324
#  define gl_recursive_lock_initializer \
325
     { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
326
#  define gl_recursive_lock_init(NAME) \
327
     if (pthread_in_use ()) glthread_recursive_lock_init (&NAME)
328
#  define gl_recursive_lock_lock(NAME) \
329
     if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
330
#  define gl_recursive_lock_unlock(NAME) \
331
     if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
332
#  define gl_recursive_lock_destroy(NAME) \
333
     if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
334
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
335
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
336
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
337
extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
338
339
# endif
340
341
/* -------------------------- gl_once_t datatype -------------------------- */
342
343
typedef pthread_once_t gl_once_t;
344
# define gl_once_define(STORAGECLASS, NAME) \
345
    STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
346
# define gl_once(NAME, INITFUNCTION) \
347
    do                                                   \
348
      {                                                  \
349
        if (pthread_in_use ())                           \
350
          {                                              \
351
            if (pthread_once (&NAME, INITFUNCTION) != 0) \
352
              abort ();                                  \
353
          }                                              \
354
        else                                             \
355
          {                                              \
356
            if (glthread_once_singlethreaded (&NAME))    \
357
              INITFUNCTION ();                           \
358
          }                                              \
359
      }                                                  \
360
    while (0)
361
extern int glthread_once_singlethreaded (pthread_once_t *once_control);
362
363
# ifdef __cplusplus
364
}
365
# endif
366
367
#endif
368
369
/* ========================================================================= */
370
371
#if USE_PTH_THREADS
372
373
/* Use the GNU Pth threads library.  */
374
375
# include <pth.h>
376
# include <stdlib.h>
377
378
# ifdef __cplusplus
379
extern "C" {
380
# endif
381
382
# if USE_PTH_THREADS_WEAK
383
384
/* Use weak references to the GNU Pth threads library.  */
385
386
#  pragma weak pth_mutex_init
387
#  pragma weak pth_mutex_acquire
388
#  pragma weak pth_mutex_release
389
#  pragma weak pth_rwlock_init
390
#  pragma weak pth_rwlock_acquire
391
#  pragma weak pth_rwlock_release
392
#  pragma weak pth_once
393
394
#  pragma weak pth_cancel
395
#  define pth_in_use() (pth_cancel != NULL)
396
397
# else
398
399
#  define pth_in_use() 1
400
401
# endif
402
403
/* -------------------------- gl_lock_t datatype -------------------------- */
404
405
typedef pth_mutex_t gl_lock_t;
406
# define gl_lock_define(STORAGECLASS, NAME) \
407
    STORAGECLASS pth_mutex_t NAME;
408
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
409
    STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
410
# define gl_lock_initializer \
411
    PTH_MUTEX_INIT
412
# define gl_lock_init(NAME) \
413
    if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
414
# define gl_lock_lock(NAME) \
415
    if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
416
# define gl_lock_unlock(NAME) \
417
    if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
418
# define gl_lock_destroy(NAME) \
419
    (void)(&NAME)
420
421
/* ------------------------- gl_rwlock_t datatype ------------------------- */
422
423
typedef pth_rwlock_t gl_rwlock_t;
424
#  define gl_rwlock_define(STORAGECLASS, NAME) \
425
     STORAGECLASS pth_rwlock_t NAME;
426
#  define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
427
     STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
428
#  define gl_rwlock_initializer \
429
     PTH_RWLOCK_INIT
430
#  define gl_rwlock_init(NAME) \
431
     if (pth_in_use() && !pth_rwlock_init (&NAME)) abort ()
432
#  define gl_rwlock_rdlock(NAME) \
433
     if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) abort ()
434
#  define gl_rwlock_wrlock(NAME) \
435
     if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) abort ()
436
#  define gl_rwlock_unlock(NAME) \
437
     if (pth_in_use() && !pth_rwlock_release (&NAME)) abort ()
438
#  define gl_rwlock_destroy(NAME) \
439
     (void)(&NAME)
440
441
/* --------------------- gl_recursive_lock_t datatype --------------------- */
442
443
/* In Pth, mutexes are recursive by default.  */
444
typedef pth_mutex_t gl_recursive_lock_t;
445
#  define gl_recursive_lock_define(STORAGECLASS, NAME) \
446
     STORAGECLASS pth_mutex_t NAME;
447
#  define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
448
     STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
449
#  define gl_recursive_lock_initializer \
450
     PTH_MUTEX_INIT
451
#  define gl_recursive_lock_init(NAME) \
452
     if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
453
#  define gl_recursive_lock_lock(NAME) \
454
     if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
455
#  define gl_recursive_lock_unlock(NAME) \
456
     if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
457
#  define gl_recursive_lock_destroy(NAME) \
458
     (void)(&NAME)
459
460
/* -------------------------- gl_once_t datatype -------------------------- */
461
462
typedef pth_once_t gl_once_t;
463
# define gl_once_define(STORAGECLASS, NAME) \
464
    STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
465
# define gl_once(NAME, INITFUNCTION) \
466
    do                                                                \
467
      {                                                               \
468
        if (pth_in_use ())                                            \
469
          {                                                           \
470
            void (*gl_once_temp) (void) = INITFUNCTION;               \
471
            if (!pth_once (&NAME, glthread_once_call, &gl_once_temp)) \
472
              abort ();                                               \
473
          }                                                           \
474
        else                                                          \
475
          {                                                           \
476
            if (glthread_once_singlethreaded (&NAME))                 \
477
              INITFUNCTION ();                                        \
478
          }                                                           \
479
      }                                                               \
480
    while (0)
481
extern void glthread_once_call (void *arg);
482
extern int glthread_once_singlethreaded (pth_once_t *once_control);
483
484
# ifdef __cplusplus
485
}
486
# endif
487
488
#endif
489
490
/* ========================================================================= */
491
492
#if USE_SOLARIS_THREADS
493
494
/* Use the old Solaris threads library.  */
495
496
# include <thread.h>
497
# include <synch.h>
498
# include <stdlib.h>
499
500
# ifdef __cplusplus
501
extern "C" {
502
# endif
503
504
# if USE_SOLARIS_THREADS_WEAK
505
506
/* Use weak references to the old Solaris threads library.  */
507
508
#  pragma weak mutex_init
509
#  pragma weak mutex_lock
510
#  pragma weak mutex_unlock
511
#  pragma weak mutex_destroy
512
#  pragma weak rwlock_init
513
#  pragma weak rw_rdlock
514
#  pragma weak rw_wrlock
515
#  pragma weak rw_unlock
516
#  pragma weak rwlock_destroy
517
#  pragma weak thr_self
518
519
#  pragma weak thr_suspend
520
#  define thread_in_use() (thr_suspend != NULL)
521
522
# else
523
524
#  define thread_in_use() 1
525
526
# endif
527
528
/* -------------------------- gl_lock_t datatype -------------------------- */
529
530
typedef mutex_t gl_lock_t;
531
# define gl_lock_define(STORAGECLASS, NAME) \
532
    STORAGECLASS mutex_t NAME;
533
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
534
    STORAGECLASS mutex_t NAME = gl_lock_initializer;
535
# define gl_lock_initializer \
536
    DEFAULTMUTEX
537
# define gl_lock_init(NAME) \
538
    if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) abort ()
539
# define gl_lock_lock(NAME) \
540
    if (thread_in_use () && mutex_lock (&NAME) != 0) abort ()
541
# define gl_lock_unlock(NAME) \
542
    if (thread_in_use () && mutex_unlock (&NAME) != 0) abort ()
543
# define gl_lock_destroy(NAME) \
544
    if (thread_in_use () && mutex_destroy (&NAME) != 0) abort ()
545
546
/* ------------------------- gl_rwlock_t datatype ------------------------- */
547
548
typedef rwlock_t gl_rwlock_t;
549
# define gl_rwlock_define(STORAGECLASS, NAME) \
550
    STORAGECLASS rwlock_t NAME;
551
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
552
    STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
553
# define gl_rwlock_initializer \
554
    DEFAULTRWLOCK
555
# define gl_rwlock_init(NAME) \
556
    if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0) abort ()
557
# define gl_rwlock_rdlock(NAME) \
558
    if (thread_in_use () && rw_rdlock (&NAME) != 0) abort ()
559
# define gl_rwlock_wrlock(NAME) \
560
    if (thread_in_use () && rw_wrlock (&NAME) != 0) abort ()
561
# define gl_rwlock_unlock(NAME) \
562
    if (thread_in_use () && rw_unlock (&NAME) != 0) abort ()
563
# define gl_rwlock_destroy(NAME) \
564
    if (thread_in_use () && rwlock_destroy (&NAME) != 0) abort ()
565
566
/* --------------------- gl_recursive_lock_t datatype --------------------- */
567
568
/* Old Solaris threads did not have recursive locks.
569
   We have to implement them ourselves.  */
570
571
typedef struct
572
        {
573
          mutex_t mutex;
574
          thread_t owner;
575
          unsigned long depth;
576
        }
577
        gl_recursive_lock_t;
578
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
579
    STORAGECLASS gl_recursive_lock_t NAME;
580
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
581
    STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
582
# define gl_recursive_lock_initializer \
583
    { DEFAULTMUTEX, (thread_t) 0, 0 }
584
# define gl_recursive_lock_init(NAME) \
585
    if (thread_in_use ()) glthread_recursive_lock_init (&NAME)
586
# define gl_recursive_lock_lock(NAME) \
587
    if (thread_in_use ()) glthread_recursive_lock_lock (&NAME)
588
# define gl_recursive_lock_unlock(NAME) \
589
    if (thread_in_use ()) glthread_recursive_lock_unlock (&NAME)
590
# define gl_recursive_lock_destroy(NAME) \
591
    if (thread_in_use ()) glthread_recursive_lock_destroy (&NAME)
592
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
593
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
594
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
595
extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
596
597
/* -------------------------- gl_once_t datatype -------------------------- */
598
599
typedef struct
600
        {
601
          volatile int inited;
602
          mutex_t mutex;
603
        }
604
        gl_once_t;
605
# define gl_once_define(STORAGECLASS, NAME) \
606
    STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
607
# define gl_once(NAME, INITFUNCTION) \
608
    do                                                \
609
      {                                               \
610
        if (thread_in_use ())                         \
611
          {                                           \
612
            glthread_once (&NAME, INITFUNCTION);      \
613
          }                                           \
614
        else                                          \
615
          {                                           \
616
            if (glthread_once_singlethreaded (&NAME)) \
617
              INITFUNCTION ();                        \
618
          }                                           \
619
      }                                               \
620
    while (0)
621
extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void));
622
extern int glthread_once_singlethreaded (gl_once_t *once_control);
623
624
# ifdef __cplusplus
625
}
626
# endif
627
628
#endif
629
630
/* ========================================================================= */
631
632
#if USE_WIN32_THREADS
633
634
# include <windows.h>
635
636
# ifdef __cplusplus
637
extern "C" {
638
# endif
639
640
/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex,
641
   Semaphore types, because
642
     - we need only to synchronize inside a single process (address space),
643
       not inter-process locking,
644
     - we don't need to support trylock operations.  (TryEnterCriticalSection
645
       does not work on Windows 95/98/ME.  Packages that need trylock usually
646
       define their own mutex type.)  */
647
648
/* There is no way to statically initialize a CRITICAL_SECTION.  It needs
649
   to be done lazily, once only.  For this we need spinlocks.  */
650
651
typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
652
653
/* -------------------------- gl_lock_t datatype -------------------------- */
654
655
typedef struct
656
        {
657
          gl_spinlock_t guard; /* protects the initialization */
658
          CRITICAL_SECTION lock;
659
        }
660
        gl_lock_t;
661
# define gl_lock_define(STORAGECLASS, NAME) \
662
    STORAGECLASS gl_lock_t NAME;
663
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
664
    STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
665
# define gl_lock_initializer \
666
    { { 0, -1 } }
667
# define gl_lock_init(NAME) \
668
    glthread_lock_init (&NAME)
669
# define gl_lock_lock(NAME) \
670
    glthread_lock_lock (&NAME)
671
# define gl_lock_unlock(NAME) \
672
    glthread_lock_unlock (&NAME)
673
# define gl_lock_destroy(NAME) \
674
    glthread_lock_destroy (&NAME)
675
extern void glthread_lock_init (gl_lock_t *lock);
676
extern void glthread_lock_lock (gl_lock_t *lock);
677
extern void glthread_lock_unlock (gl_lock_t *lock);
678
extern void glthread_lock_destroy (gl_lock_t *lock);
679
680
/* ------------------------- gl_rwlock_t datatype ------------------------- */
681
682
/* It is impossible to implement read-write locks using plain locks, without
683
   introducing an extra thread dedicated to managing read-write locks.
684
   Therefore here we need to use the low-level Event type.  */
685
686
typedef struct
687
        {
688
          HANDLE *array; /* array of waiting threads, each represented by an event */
689
          unsigned int count; /* number of waiting threads */
690
          unsigned int alloc; /* length of allocated array */
691
          unsigned int offset; /* index of first waiting thread in array */
692
        }
693
        gl_waitqueue_t;
694
typedef struct
695
        {
696
          gl_spinlock_t guard; /* protects the initialization */
697
          CRITICAL_SECTION lock; /* protects the remaining fields */
698
          gl_waitqueue_t waiting_readers; /* waiting readers */
699
          gl_waitqueue_t waiting_writers; /* waiting writers */
700
          int runcount; /* number of readers running, or -1 when a writer runs */
701
        }
702
        gl_rwlock_t;
703
# define gl_rwlock_define(STORAGECLASS, NAME) \
704
    STORAGECLASS gl_rwlock_t NAME;
705
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
706
    STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
707
# define gl_rwlock_initializer \
708
    { { 0, -1 } }
709
# define gl_rwlock_init(NAME) \
710
    glthread_rwlock_init (&NAME)
711
# define gl_rwlock_rdlock(NAME) \
712
    glthread_rwlock_rdlock (&NAME)
713
# define gl_rwlock_wrlock(NAME) \
714
    glthread_rwlock_wrlock (&NAME)
715
# define gl_rwlock_unlock(NAME) \
716
    glthread_rwlock_unlock (&NAME)
717
# define gl_rwlock_destroy(NAME) \
718
    glthread_rwlock_destroy (&NAME)
719
extern void glthread_rwlock_init (gl_rwlock_t *lock);
720
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
721
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
722
extern void glthread_rwlock_unlock (gl_rwlock_t *lock);
723
extern void glthread_rwlock_destroy (gl_rwlock_t *lock);
724
725
/* --------------------- gl_recursive_lock_t datatype --------------------- */
726
727
/* The Win32 documentation says that CRITICAL_SECTION already implements a
728
   recursive lock.  But we need not rely on it: It's easy to implement a
729
   recursive lock without this assumption.  */
730
731
typedef struct
732
        {
733
          gl_spinlock_t guard; /* protects the initialization */
734
          DWORD owner;
735
          unsigned long depth;
736
          CRITICAL_SECTION lock;
737
        }
738
        gl_recursive_lock_t;
739
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
740
    STORAGECLASS gl_recursive_lock_t NAME;
741
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
742
    STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
743
# define gl_recursive_lock_initializer \
744
    { { 0, -1 }, 0, 0 }
745
# define gl_recursive_lock_init(NAME) \
746
    glthread_recursive_lock_init (&NAME)
747
# define gl_recursive_lock_lock(NAME) \
748
    glthread_recursive_lock_lock (&NAME)
749
# define gl_recursive_lock_unlock(NAME) \
750
    glthread_recursive_lock_unlock (&NAME)
751
# define gl_recursive_lock_destroy(NAME) \
752
    glthread_recursive_lock_destroy (&NAME)
753
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
754
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
755
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
756
extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
757
758
/* -------------------------- gl_once_t datatype -------------------------- */
759
760
typedef struct
761
        {
762
          volatile int inited;
763
          volatile long started;
764
          CRITICAL_SECTION lock;
765
        }
766
        gl_once_t;
767
# define gl_once_define(STORAGECLASS, NAME) \
768
    STORAGECLASS gl_once_t NAME = { -1, -1 };
769
# define gl_once(NAME, INITFUNCTION) \
770
    glthread_once (&NAME, INITFUNCTION)
771
extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void));
772
773
# ifdef __cplusplus
774
}
775
# endif
776
777
#endif
778
779
/* ========================================================================= */
780
781
#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS)
782
783
/* Provide dummy implementation if threads are not supported.  */
784
785
/* -------------------------- gl_lock_t datatype -------------------------- */
786
787
typedef int gl_lock_t;
788
# define gl_lock_define(STORAGECLASS, NAME)
789
# define gl_lock_define_initialized(STORAGECLASS, NAME)
790
# define gl_lock_init(NAME)
791
# define gl_lock_lock(NAME)
792
# define gl_lock_unlock(NAME)
793
794
/* ------------------------- gl_rwlock_t datatype ------------------------- */
795
796
typedef int gl_rwlock_t;
797
# define gl_rwlock_define(STORAGECLASS, NAME)
798
# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
799
# define gl_rwlock_init(NAME)
800
# define gl_rwlock_rdlock(NAME)
801
# define gl_rwlock_wrlock(NAME)
802
# define gl_rwlock_unlock(NAME)
803
804
/* --------------------- gl_recursive_lock_t datatype --------------------- */
805
806
typedef int gl_recursive_lock_t;
807
# define gl_recursive_lock_define(STORAGECLASS, NAME)
808
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
809
# define gl_recursive_lock_init(NAME)
810
# define gl_recursive_lock_lock(NAME)
811
# define gl_recursive_lock_unlock(NAME)
812
813
/* -------------------------- gl_once_t datatype -------------------------- */
814
815
typedef int gl_once_t;
816
# define gl_once_define(STORAGECLASS, NAME) \
817
    STORAGECLASS gl_once_t NAME = 0;
818
# define gl_once(NAME, INITFUNCTION) \
819
    do                       \
820
      {                      \
821
        if (NAME == 0)       \
822
          {                  \
823
            NAME = ~ 0;      \
824
            INITFUNCTION (); \
825
          }                  \
826
      }                      \
827
    while (0)
828
829
#endif
830
831
/* ========================================================================= */
832
833
#endif /* _LOCK_H */
(-)a/intl/log.c (-116 lines)
Lines 1-116 Link Here
1
/* Log file output.
2
   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Written by Bruno Haible <bruno@clisp.org>.  */
20
21
#ifdef HAVE_CONFIG_H
22
# include <config.h>
23
#endif
24
25
#include <stdio.h>
26
#include <stdlib.h>
27
#include <string.h>
28
29
/* Handle multi-threaded applications.  */
30
#ifdef _LIBC
31
# include <bits/libc-lock.h>
32
#else
33
# include "lock.h"
34
#endif
35
36
/* Print an ASCII string with quotes and escape sequences where needed.  */
37
static void
38
print_escaped (FILE *stream, const char *str)
39
{
40
  putc ('"', stream);
41
  for (; *str != '\0'; str++)
42
    if (*str == '\n')
43
      {
44
	fputs ("\\n\"", stream);
45
	if (str[1] == '\0')
46
	  return;
47
	fputs ("\n\"", stream);
48
      }
49
    else
50
      {
51
	if (*str == '"' || *str == '\\')
52
	  putc ('\\', stream);
53
	putc (*str, stream);
54
      }
55
  putc ('"', stream);
56
}
57
58
static char *last_logfilename = NULL;
59
static FILE *last_logfile = NULL;
60
__libc_lock_define_initialized (static, lock)
61
62
static inline void
63
_nl_log_untranslated_locked (const char *logfilename, const char *domainname,
64
			     const char *msgid1, const char *msgid2, int plural)
65
{
66
  FILE *logfile;
67
68
  /* Can we reuse the last opened logfile?  */
69
  if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0)
70
    {
71
      /* Close the last used logfile.  */
72
      if (last_logfilename != NULL)
73
	{
74
	  if (last_logfile != NULL)
75
	    {
76
	      fclose (last_logfile);
77
	      last_logfile = NULL;
78
	    }
79
	  free (last_logfilename);
80
	  last_logfilename = NULL;
81
	}
82
      /* Open the logfile.  */
83
      last_logfilename = (char *) malloc (strlen (logfilename) + 1);
84
      if (last_logfilename == NULL)
85
	return;
86
      strcpy (last_logfilename, logfilename);
87
      last_logfile = fopen (logfilename, "a");
88
      if (last_logfile == NULL)
89
	return;
90
    }
91
  logfile = last_logfile;
92
93
  fprintf (logfile, "domain ");
94
  print_escaped (logfile, domainname);
95
  fprintf (logfile, "\nmsgid ");
96
  print_escaped (logfile, msgid1);
97
  if (plural)
98
    {
99
      fprintf (logfile, "\nmsgid_plural ");
100
      print_escaped (logfile, msgid2);
101
      fprintf (logfile, "\nmsgstr[0] \"\"\n");
102
    }
103
  else
104
    fprintf (logfile, "\nmsgstr \"\"\n");
105
  putc ('\n', logfile);
106
}
107
108
/* Add to the log file an entry denoting a failed translation.  */
109
void
110
_nl_log_untranslated (const char *logfilename, const char *domainname,
111
		      const char *msgid1, const char *msgid2, int plural)
112
{
113
  __libc_lock_lock (lock);
114
  _nl_log_untranslated_locked (logfilename, domainname, msgid1, msgid2, plural);
115
  __libc_lock_unlock (lock);
116
}
(-)a/intl/ngettext.c (-65 lines)
Lines 1-65 Link Here
1
/* Implementation of ngettext(3) function.
2
   Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#ifdef _LIBC
24
# define __need_NULL
25
# include <stddef.h>
26
#else
27
# include <stdlib.h>		/* Just for NULL.  */
28
#endif
29
30
#include "gettextP.h"
31
#ifdef _LIBC
32
# include <libintl.h>
33
#else
34
# include "libgnuintl.h"
35
#endif
36
37
#include <locale.h>
38
39
/* @@ end of prolog @@ */
40
41
/* Names for the libintl functions are a problem.  They must not clash
42
   with existing names and they should follow ANSI C.  But this source
43
   code is also used in GNU C Library where the names have a __
44
   prefix.  So we have to make a difference here.  */
45
#ifdef _LIBC
46
# define NGETTEXT __ngettext
47
# define DCNGETTEXT __dcngettext
48
#else
49
# define NGETTEXT libintl_ngettext
50
# define DCNGETTEXT libintl_dcngettext
51
#endif
52
53
/* Look up MSGID in the current default message catalog for the current
54
   LC_MESSAGES locale.  If not found, returns MSGID itself (the default
55
   text).  */
56
char *
57
NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n)
58
{
59
  return DCNGETTEXT (NULL, msgid1, msgid2, n, LC_MESSAGES);
60
}
61
62
#ifdef _LIBC
63
/* Alias for function name in GNU C Library.  */
64
weak_alias (__ngettext, ngettext);
65
#endif
(-)a/intl/os2compat.c (-98 lines)
Lines 1-98 Link Here
1
/* OS/2 compatibility functions.
2
   Copyright (C) 2001-2002 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#define OS2_AWARE
20
#ifdef HAVE_CONFIG_H
21
#include <config.h>
22
#endif
23
24
#include <stdlib.h>
25
#include <string.h>
26
#include <sys/param.h>
27
28
/* A version of getenv() that works from DLLs */
29
extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
30
31
char *
32
_nl_getenv (const char *name)
33
{
34
  unsigned char *value;
35
  if (DosScanEnv (name, &value))
36
    return NULL;
37
  else
38
    return value;
39
}
40
41
/* A fixed size buffer.  */
42
char libintl_nl_default_dirname[MAXPATHLEN+1];
43
44
char *_nlos2_libdir = NULL;
45
char *_nlos2_localealiaspath = NULL;
46
char *_nlos2_localedir = NULL;
47
48
static __attribute__((constructor)) void
49
nlos2_initialize ()
50
{
51
  char *root = getenv ("UNIXROOT");
52
  char *gnulocaledir = getenv ("GNULOCALEDIR");
53
54
  _nlos2_libdir = gnulocaledir;
55
  if (!_nlos2_libdir)
56
    {
57
      if (root)
58
        {
59
          size_t sl = strlen (root);
60
          _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
61
          memcpy (_nlos2_libdir, root, sl);
62
          memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
63
        }
64
      else
65
        _nlos2_libdir = LIBDIR;
66
    }
67
68
  _nlos2_localealiaspath = gnulocaledir;
69
  if (!_nlos2_localealiaspath)
70
    {
71
      if (root)
72
        {
73
          size_t sl = strlen (root);
74
          _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
75
          memcpy (_nlos2_localealiaspath, root, sl);
76
          memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
77
        }
78
     else
79
        _nlos2_localealiaspath = LOCALE_ALIAS_PATH;
80
    }
81
82
  _nlos2_localedir = gnulocaledir;
83
  if (!_nlos2_localedir)
84
    {
85
      if (root)
86
        {
87
          size_t sl = strlen (root);
88
          _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
89
          memcpy (_nlos2_localedir, root, sl);
90
          memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
91
        }
92
      else
93
        _nlos2_localedir = LOCALEDIR;
94
    }
95
96
  if (strlen (_nlos2_localedir) <= MAXPATHLEN)
97
    strcpy (libintl_nl_default_dirname, _nlos2_localedir);
98
}
(-)a/intl/os2compat.h (-46 lines)
Lines 1-46 Link Here
1
/* OS/2 compatibility defines.
2
   This file is intended to be included from config.h
3
   Copyright (C) 2001-2002 Free Software Foundation, Inc.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
/* When included from os2compat.h we need all the original definitions */
21
#ifndef OS2_AWARE
22
23
#undef LIBDIR
24
#define LIBDIR			_nlos2_libdir
25
extern char *_nlos2_libdir;
26
27
#undef LOCALEDIR
28
#define LOCALEDIR		_nlos2_localedir
29
extern char *_nlos2_localedir;
30
31
#undef LOCALE_ALIAS_PATH
32
#define LOCALE_ALIAS_PATH	_nlos2_localealiaspath
33
extern char *_nlos2_localealiaspath;
34
35
#endif
36
37
#undef HAVE_STRCASECMP
38
#define HAVE_STRCASECMP 1
39
#define strcasecmp stricmp
40
#define strncasecmp strnicmp
41
42
/* We have our own getenv() which works even if library is compiled as DLL */
43
#define getenv _nl_getenv
44
45
/* Older versions of gettext used -1 as the value of LC_MESSAGES */
46
#define LC_MESSAGES_COMPAT (-1)
(-)a/intl/osdep.c (-26 lines)
Lines 1-26 Link Here
1
/* OS dependent parts of libintl.
2
   Copyright (C) 2001-2002, 2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#if defined __CYGWIN__
20
# include "intl-exports.c"
21
#elif defined __EMX__
22
# include "os2compat.c"
23
#else
24
/* Avoid AIX compiler warning.  */
25
typedef int dummy;
26
#endif
(-)a/intl/plural-exp.c (-154 lines)
Lines 1-154 Link Here
1
/* Expression parsing for plural form selection.
2
   Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
3
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifdef HAVE_CONFIG_H
21
# include <config.h>
22
#endif
23
24
#include <ctype.h>
25
#include <stdlib.h>
26
#include <string.h>
27
28
#include "plural-exp.h"
29
30
#if (defined __GNUC__ && !(__APPLE_CC__ > 1)) \
31
    || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
32
33
/* These structs are the constant expression for the germanic plural
34
   form determination.  It represents the expression  "n != 1".  */
35
static const struct expression plvar =
36
{
37
  .nargs = 0,
38
  .operation = var,
39
};
40
static const struct expression plone =
41
{
42
  .nargs = 0,
43
  .operation = num,
44
  .val =
45
  {
46
    .num = 1
47
  }
48
};
49
struct expression GERMANIC_PLURAL =
50
{
51
  .nargs = 2,
52
  .operation = not_equal,
53
  .val =
54
  {
55
    .args =
56
    {
57
      [0] = (struct expression *) &plvar,
58
      [1] = (struct expression *) &plone
59
    }
60
  }
61
};
62
63
# define INIT_GERMANIC_PLURAL()
64
65
#else
66
67
/* For compilers without support for ISO C 99 struct/union initializers:
68
   Initialization at run-time.  */
69
70
static struct expression plvar;
71
static struct expression plone;
72
struct expression GERMANIC_PLURAL;
73
74
static void
75
init_germanic_plural ()
76
{
77
  if (plone.val.num == 0)
78
    {
79
      plvar.nargs = 0;
80
      plvar.operation = var;
81
82
      plone.nargs = 0;
83
      plone.operation = num;
84
      plone.val.num = 1;
85
86
      GERMANIC_PLURAL.nargs = 2;
87
      GERMANIC_PLURAL.operation = not_equal;
88
      GERMANIC_PLURAL.val.args[0] = &plvar;
89
      GERMANIC_PLURAL.val.args[1] = &plone;
90
    }
91
}
92
93
# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
94
95
#endif
96
97
void
98
internal_function
99
EXTRACT_PLURAL_EXPRESSION (const char *nullentry, struct expression **pluralp,
100
			   unsigned long int *npluralsp)
101
{
102
  if (nullentry != NULL)
103
    {
104
      const char *plural;
105
      const char *nplurals;
106
107
      plural = strstr (nullentry, "plural=");
108
      nplurals = strstr (nullentry, "nplurals=");
109
      if (plural == NULL || nplurals == NULL)
110
	goto no_plural;
111
      else
112
	{
113
	  char *endp;
114
	  unsigned long int n;
115
	  struct parse_args args;
116
117
	  /* First get the number.  */
118
	  nplurals += 9;
119
	  while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
120
	    ++nplurals;
121
	  if (!(*nplurals >= '0' && *nplurals <= '9'))
122
	    goto no_plural;
123
#if defined HAVE_STRTOUL || defined _LIBC
124
	  n = strtoul (nplurals, &endp, 10);
125
#else
126
	  for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
127
	    n = n * 10 + (*endp - '0');
128
#endif
129
	  if (nplurals == endp)
130
	    goto no_plural;
131
	  *npluralsp = n;
132
133
	  /* Due to the restrictions bison imposes onto the interface of the
134
	     scanner function we have to put the input string and the result
135
	     passed up from the parser into the same structure which address
136
	     is passed down to the parser.  */
137
	  plural += 7;
138
	  args.cp = plural;
139
	  if (PLURAL_PARSE (&args) != 0)
140
	    goto no_plural;
141
	  *pluralp = args.res;
142
	}
143
    }
144
  else
145
    {
146
      /* By default we are using the Germanic form: singular form only
147
         for `one', the plural form otherwise.  Yes, this is also what
148
         English is using since English is a Germanic language.  */
149
    no_plural:
150
      INIT_GERMANIC_PLURAL ();
151
      *pluralp = &GERMANIC_PLURAL;
152
      *npluralsp = 2;
153
    }
154
}
(-)a/intl/plural-exp.h (-118 lines)
Lines 1-118 Link Here
1
/* Expression parsing and evaluation for plural form selection.
2
   Copyright (C) 2000-2003, 2005 Free Software Foundation, Inc.
3
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifndef _PLURAL_EXP_H
21
#define _PLURAL_EXP_H
22
23
#ifndef internal_function
24
# define internal_function
25
#endif
26
27
#ifndef attribute_hidden
28
# define attribute_hidden
29
#endif
30
31
32
/* This is the representation of the expressions to determine the
33
   plural form.  */
34
struct expression
35
{
36
  int nargs;			/* Number of arguments.  */
37
  enum operator
38
  {
39
    /* Without arguments:  */
40
    var,			/* The variable "n".  */
41
    num,			/* Decimal number.  */
42
    /* Unary operators:  */
43
    lnot,			/* Logical NOT.  */
44
    /* Binary operators:  */
45
    mult,			/* Multiplication.  */
46
    divide,			/* Division.  */
47
    module,			/* Modulo operation.  */
48
    plus,			/* Addition.  */
49
    minus,			/* Subtraction.  */
50
    less_than,			/* Comparison.  */
51
    greater_than,		/* Comparison.  */
52
    less_or_equal,		/* Comparison.  */
53
    greater_or_equal,		/* Comparison.  */
54
    equal,			/* Comparison for equality.  */
55
    not_equal,			/* Comparison for inequality.  */
56
    land,			/* Logical AND.  */
57
    lor,			/* Logical OR.  */
58
    /* Ternary operators:  */
59
    qmop			/* Question mark operator.  */
60
  } operation;
61
  union
62
  {
63
    unsigned long int num;	/* Number value for `num'.  */
64
    struct expression *args[3];	/* Up to three arguments.  */
65
  } val;
66
};
67
68
/* This is the data structure to pass information to the parser and get
69
   the result in a thread-safe way.  */
70
struct parse_args
71
{
72
  const char *cp;
73
  struct expression *res;
74
};
75
76
77
/* Names for the libintl functions are a problem.  This source code is used
78
   1. in the GNU C Library library,
79
   2. in the GNU libintl library,
80
   3. in the GNU gettext tools.
81
   The function names in each situation must be different, to allow for
82
   binary incompatible changes in 'struct expression'.  Furthermore,
83
   1. in the GNU C Library library, the names have a __ prefix,
84
   2.+3. in the GNU libintl library and in the GNU gettext tools, the names
85
         must follow ANSI C and not start with __.
86
   So we have to distinguish the three cases.  */
87
#ifdef _LIBC
88
# define FREE_EXPRESSION __gettext_free_exp
89
# define PLURAL_PARSE __gettextparse
90
# define GERMANIC_PLURAL __gettext_germanic_plural
91
# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
92
#elif defined (IN_LIBINTL)
93
# define FREE_EXPRESSION libintl_gettext_free_exp
94
# define PLURAL_PARSE libintl_gettextparse
95
# define GERMANIC_PLURAL libintl_gettext_germanic_plural
96
# define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
97
#else
98
# define FREE_EXPRESSION free_plural_expression
99
# define PLURAL_PARSE parse_plural_expression
100
# define GERMANIC_PLURAL germanic_plural
101
# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
102
#endif
103
104
extern void FREE_EXPRESSION (struct expression *exp)
105
     internal_function;
106
extern int PLURAL_PARSE (void *arg);
107
extern struct expression GERMANIC_PLURAL attribute_hidden;
108
extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
109
				       struct expression **pluralp,
110
				       unsigned long int *npluralsp)
111
     internal_function;
112
113
#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
114
extern unsigned long int plural_eval (struct expression *pexp,
115
				      unsigned long int n);
116
#endif
117
118
#endif /* _PLURAL_EXP_H */
(-)a/intl/plural.c (-1987 lines)
Lines 1-1987 Link Here
1
/* A Bison parser, made by GNU Bison 2.4.3.  */
2
3
/* Skeleton implementation for Bison's Yacc-like parsers in C
4
   
5
      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6
   2009, 2010 Free Software Foundation, Inc.
7
   
8
   This program is free software: you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation, either version 3 of the License, or
11
   (at your option) any later version.
12
   
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
   
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21
/* As a special exception, you may create a larger work that contains
22
   part or all of the Bison parser skeleton and distribute that work
23
   under terms of your choice, so long as that work isn't itself a
24
   parser generator using the skeleton or a modified version thereof
25
   as a parser skeleton.  Alternatively, if you modify or redistribute
26
   the parser skeleton itself, you may (at your option) remove this
27
   special exception, which will cause the skeleton and the resulting
28
   Bison output files to be licensed under the GNU General Public
29
   License without this special exception.
30
   
31
   This special exception was added by the Free Software Foundation in
32
   version 2.2 of Bison.  */
33
34
/* C LALR(1) parser skeleton written by Richard Stallman, by
35
   simplifying the original so-called "semantic" parser.  */
36
37
/* All symbols defined below should begin with yy or YY, to avoid
38
   infringing on user name space.  This should be done even for local
39
   variables, as they might otherwise be expanded by user macros.
40
   There are some unavoidable exceptions within include files to
41
   define necessary library symbols; they are noted "INFRINGES ON
42
   USER NAME SPACE" below.  */
43
44
/* Identify Bison output.  */
45
#define YYBISON 1
46
47
/* Bison version.  */
48
#define YYBISON_VERSION "2.4.3"
49
50
/* Skeleton name.  */
51
#define YYSKELETON_NAME "yacc.c"
52
53
/* Pure parsers.  */
54
#define YYPURE 1
55
56
/* Push parsers.  */
57
#define YYPUSH 0
58
59
/* Pull parsers.  */
60
#define YYPULL 1
61
62
/* Using locations.  */
63
#define YYLSP_NEEDED 0
64
65
/* Substitute the variable and function names.  */
66
#define yyparse         __gettextparse
67
#define yylex           __gettextlex
68
#define yyerror         __gettexterror
69
#define yylval          __gettextlval
70
#define yychar          __gettextchar
71
#define yydebug         __gettextdebug
72
#define yynerrs         __gettextnerrs
73
74
75
/* Copy the first part of user declarations.  */
76
77
/* Line 189 of yacc.c  */
78
#line 1 "plural.y"
79
80
/* Expression parsing for plural form selection.
81
   Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
82
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
83
84
   This program is free software; you can redistribute it and/or modify it
85
   under the terms of the GNU Library General Public License as published
86
   by the Free Software Foundation; either version 2, or (at your option)
87
   any later version.
88
89
   This program is distributed in the hope that it will be useful,
90
   but WITHOUT ANY WARRANTY; without even the implied warranty of
91
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
92
   Library General Public License for more details.
93
94
   You should have received a copy of the GNU Library General Public
95
   License along with this program; if not, write to the Free Software
96
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
97
   USA.  */
98
99
/* For bison < 2.0, the bison generated parser uses alloca.  AIX 3 forces us
100
   to put this declaration at the beginning of the file.  The declaration in
101
   bison's skeleton file comes too late.  This must come before <config.h>
102
   because <config.h> may include arbitrary system headers.
103
   This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0.  */
104
#if defined _AIX && !defined __GNUC__
105
 #pragma alloca
106
#endif
107
108
#ifdef HAVE_CONFIG_H
109
# include <config.h>
110
#endif
111
112
#include <stddef.h>
113
#include <stdlib.h>
114
#include <string.h>
115
#include "plural-exp.h"
116
117
/* The main function generated by the parser is called __gettextparse,
118
   but we want it to be called PLURAL_PARSE.  */
119
#ifndef _LIBC
120
# define __gettextparse PLURAL_PARSE
121
#endif
122
123
#define YYLEX_PARAM	&((struct parse_args *) arg)->cp
124
#define YYPARSE_PARAM	arg
125
126
127
/* Line 189 of yacc.c  */
128
#line 129 "plural.c"
129
130
/* Enabling traces.  */
131
#ifndef YYDEBUG
132
# define YYDEBUG 0
133
#endif
134
135
/* Enabling verbose error messages.  */
136
#ifdef YYERROR_VERBOSE
137
# undef YYERROR_VERBOSE
138
# define YYERROR_VERBOSE 1
139
#else
140
# define YYERROR_VERBOSE 0
141
#endif
142
143
/* Enabling the token table.  */
144
#ifndef YYTOKEN_TABLE
145
# define YYTOKEN_TABLE 0
146
#endif
147
148
149
/* Tokens.  */
150
#ifndef YYTOKENTYPE
151
# define YYTOKENTYPE
152
   /* Put the tokens into the symbol table, so that GDB and other debuggers
153
      know about them.  */
154
   enum yytokentype {
155
     EQUOP2 = 258,
156
     CMPOP2 = 259,
157
     ADDOP2 = 260,
158
     MULOP2 = 261,
159
     NUMBER = 262
160
   };
161
#endif
162
/* Tokens.  */
163
#define EQUOP2 258
164
#define CMPOP2 259
165
#define ADDOP2 260
166
#define MULOP2 261
167
#define NUMBER 262
168
169
170
171
172
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
173
typedef union YYSTYPE
174
{
175
176
/* Line 214 of yacc.c  */
177
#line 51 "plural.y"
178
179
  unsigned long int num;
180
  enum operator op;
181
  struct expression *exp;
182
183
184
185
/* Line 214 of yacc.c  */
186
#line 187 "plural.c"
187
} YYSTYPE;
188
# define YYSTYPE_IS_TRIVIAL 1
189
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
190
# define YYSTYPE_IS_DECLARED 1
191
#endif
192
193
194
/* Copy the second part of user declarations.  */
195
196
/* Line 264 of yacc.c  */
197
#line 57 "plural.y"
198
199
/* Prototypes for local functions.  */
200
static int yylex (YYSTYPE *lval, const char **pexp);
201
static void yyerror (const char *str);
202
203
/* Allocation of expressions.  */
204
205
static struct expression *
206
new_exp (int nargs, enum operator op, struct expression * const *args)
207
{
208
  int i;
209
  struct expression *newp;
210
211
  /* If any of the argument could not be malloc'ed, just return NULL.  */
212
  for (i = nargs - 1; i >= 0; i--)
213
    if (args[i] == NULL)
214
      goto fail;
215
216
  /* Allocate a new expression.  */
217
  newp = (struct expression *) malloc (sizeof (*newp));
218
  if (newp != NULL)
219
    {
220
      newp->nargs = nargs;
221
      newp->operation = op;
222
      for (i = nargs - 1; i >= 0; i--)
223
	newp->val.args[i] = args[i];
224
      return newp;
225
    }
226
227
 fail:
228
  for (i = nargs - 1; i >= 0; i--)
229
    FREE_EXPRESSION (args[i]);
230
231
  return NULL;
232
}
233
234
static inline struct expression *
235
new_exp_0 (enum operator op)
236
{
237
  return new_exp (0, op, NULL);
238
}
239
240
static inline struct expression *
241
new_exp_1 (enum operator op, struct expression *right)
242
{
243
  struct expression *args[1];
244
245
  args[0] = right;
246
  return new_exp (1, op, args);
247
}
248
249
static struct expression *
250
new_exp_2 (enum operator op, struct expression *left, struct expression *right)
251
{
252
  struct expression *args[2];
253
254
  args[0] = left;
255
  args[1] = right;
256
  return new_exp (2, op, args);
257
}
258
259
static inline struct expression *
260
new_exp_3 (enum operator op, struct expression *bexp,
261
	   struct expression *tbranch, struct expression *fbranch)
262
{
263
  struct expression *args[3];
264
265
  args[0] = bexp;
266
  args[1] = tbranch;
267
  args[2] = fbranch;
268
  return new_exp (3, op, args);
269
}
270
271
272
273
/* Line 264 of yacc.c  */
274
#line 275 "plural.c"
275
276
#ifdef short
277
# undef short
278
#endif
279
280
#ifdef YYTYPE_UINT8
281
typedef YYTYPE_UINT8 yytype_uint8;
282
#else
283
typedef unsigned char yytype_uint8;
284
#endif
285
286
#ifdef YYTYPE_INT8
287
typedef YYTYPE_INT8 yytype_int8;
288
#elif (defined __STDC__ || defined __C99__FUNC__ \
289
     || defined __cplusplus || defined _MSC_VER)
290
typedef signed char yytype_int8;
291
#else
292
typedef short int yytype_int8;
293
#endif
294
295
#ifdef YYTYPE_UINT16
296
typedef YYTYPE_UINT16 yytype_uint16;
297
#else
298
typedef unsigned short int yytype_uint16;
299
#endif
300
301
#ifdef YYTYPE_INT16
302
typedef YYTYPE_INT16 yytype_int16;
303
#else
304
typedef short int yytype_int16;
305
#endif
306
307
#ifndef YYSIZE_T
308
# ifdef __SIZE_TYPE__
309
#  define YYSIZE_T __SIZE_TYPE__
310
# elif defined size_t
311
#  define YYSIZE_T size_t
312
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
313
     || defined __cplusplus || defined _MSC_VER)
314
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
315
#  define YYSIZE_T size_t
316
# else
317
#  define YYSIZE_T unsigned int
318
# endif
319
#endif
320
321
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
322
323
#ifndef YY_
324
# if defined YYENABLE_NLS && YYENABLE_NLS
325
#  if ENABLE_NLS
326
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
327
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
328
#  endif
329
# endif
330
# ifndef YY_
331
#  define YY_(msgid) msgid
332
# endif
333
#endif
334
335
/* Suppress unused-variable warnings by "using" E.  */
336
#if ! defined lint || defined __GNUC__
337
# define YYUSE(e) ((void) (e))
338
#else
339
# define YYUSE(e) /* empty */
340
#endif
341
342
/* Identity function, used to suppress warnings about constant conditions.  */
343
#ifndef lint
344
# define YYID(n) (n)
345
#else
346
#if (defined __STDC__ || defined __C99__FUNC__ \
347
     || defined __cplusplus || defined _MSC_VER)
348
static int
349
YYID (int yyi)
350
#else
351
static int
352
YYID (yyi)
353
    int yyi;
354
#endif
355
{
356
  return yyi;
357
}
358
#endif
359
360
#if ! defined yyoverflow || YYERROR_VERBOSE
361
362
/* The parser invokes alloca or malloc; define the necessary symbols.  */
363
364
# ifdef YYSTACK_USE_ALLOCA
365
#  if YYSTACK_USE_ALLOCA
366
#   ifdef __GNUC__
367
#    define YYSTACK_ALLOC __builtin_alloca
368
#   elif defined __BUILTIN_VA_ARG_INCR
369
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
370
#   elif defined _AIX
371
#    define YYSTACK_ALLOC __alloca
372
#   elif defined _MSC_VER
373
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
374
#    define alloca _alloca
375
#   else
376
#    define YYSTACK_ALLOC alloca
377
#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
378
     || defined __cplusplus || defined _MSC_VER)
379
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
380
#     ifndef _STDLIB_H
381
#      define _STDLIB_H 1
382
#     endif
383
#    endif
384
#   endif
385
#  endif
386
# endif
387
388
# ifdef YYSTACK_ALLOC
389
   /* Pacify GCC's `empty if-body' warning.  */
390
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
391
#  ifndef YYSTACK_ALLOC_MAXIMUM
392
    /* The OS might guarantee only one guard page at the bottom of the stack,
393
       and a page size can be as small as 4096 bytes.  So we cannot safely
394
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
395
       to allow for a few compiler-allocated temporary stack slots.  */
396
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
397
#  endif
398
# else
399
#  define YYSTACK_ALLOC YYMALLOC
400
#  define YYSTACK_FREE YYFREE
401
#  ifndef YYSTACK_ALLOC_MAXIMUM
402
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
403
#  endif
404
#  if (defined __cplusplus && ! defined _STDLIB_H \
405
       && ! ((defined YYMALLOC || defined malloc) \
406
	     && (defined YYFREE || defined free)))
407
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
408
#   ifndef _STDLIB_H
409
#    define _STDLIB_H 1
410
#   endif
411
#  endif
412
#  ifndef YYMALLOC
413
#   define YYMALLOC malloc
414
#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
415
     || defined __cplusplus || defined _MSC_VER)
416
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
417
#   endif
418
#  endif
419
#  ifndef YYFREE
420
#   define YYFREE free
421
#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
422
     || defined __cplusplus || defined _MSC_VER)
423
void free (void *); /* INFRINGES ON USER NAME SPACE */
424
#   endif
425
#  endif
426
# endif
427
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
428
429
430
#if (! defined yyoverflow \
431
     && (! defined __cplusplus \
432
	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
433
434
/* A type that is properly aligned for any stack member.  */
435
union yyalloc
436
{
437
  yytype_int16 yyss_alloc;
438
  YYSTYPE yyvs_alloc;
439
};
440
441
/* The size of the maximum gap between one aligned stack and the next.  */
442
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
443
444
/* The size of an array large to enough to hold all stacks, each with
445
   N elements.  */
446
# define YYSTACK_BYTES(N) \
447
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
448
      + YYSTACK_GAP_MAXIMUM)
449
450
/* Copy COUNT objects from FROM to TO.  The source and destination do
451
   not overlap.  */
452
# ifndef YYCOPY
453
#  if defined __GNUC__ && 1 < __GNUC__
454
#   define YYCOPY(To, From, Count) \
455
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
456
#  else
457
#   define YYCOPY(To, From, Count)		\
458
      do					\
459
	{					\
460
	  YYSIZE_T yyi;				\
461
	  for (yyi = 0; yyi < (Count); yyi++)	\
462
	    (To)[yyi] = (From)[yyi];		\
463
	}					\
464
      while (YYID (0))
465
#  endif
466
# endif
467
468
/* Relocate STACK from its old location to the new one.  The
469
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
470
   elements in the stack, and YYPTR gives the new location of the
471
   stack.  Advance YYPTR to a properly aligned location for the next
472
   stack.  */
473
# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
474
    do									\
475
      {									\
476
	YYSIZE_T yynewbytes;						\
477
	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
478
	Stack = &yyptr->Stack_alloc;					\
479
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
480
	yyptr += yynewbytes / sizeof (*yyptr);				\
481
      }									\
482
    while (YYID (0))
483
484
#endif
485
486
/* YYFINAL -- State number of the termination state.  */
487
#define YYFINAL  9
488
/* YYLAST -- Last index in YYTABLE.  */
489
#define YYLAST   54
490
491
/* YYNTOKENS -- Number of terminals.  */
492
#define YYNTOKENS  16
493
/* YYNNTS -- Number of nonterminals.  */
494
#define YYNNTS  3
495
/* YYNRULES -- Number of rules.  */
496
#define YYNRULES  13
497
/* YYNRULES -- Number of states.  */
498
#define YYNSTATES  27
499
500
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
501
#define YYUNDEFTOK  2
502
#define YYMAXUTOK   262
503
504
#define YYTRANSLATE(YYX)						\
505
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
506
507
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
508
static const yytype_uint8 yytranslate[] =
509
{
510
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
511
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
512
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
513
       2,     2,     2,    10,     2,     2,     2,     2,     5,     2,
514
      14,    15,     2,     2,     2,     2,     2,     2,     2,     2,
515
       2,     2,     2,     2,     2,     2,     2,     2,    12,     2,
516
       2,     2,     2,     3,     2,     2,     2,     2,     2,     2,
517
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
518
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
519
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
520
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
521
      13,     2,     2,     2,     2,     2,     2,     2,     2,     2,
522
       2,     2,     2,     2,     4,     2,     2,     2,     2,     2,
523
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
524
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
525
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
526
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
527
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535
       2,     2,     2,     2,     2,     2,     1,     2,     6,     7,
536
       8,     9,    11
537
};
538
539
#if YYDEBUG
540
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
541
   YYRHS.  */
542
static const yytype_uint8 yyprhs[] =
543
{
544
       0,     0,     3,     5,    11,    15,    19,    23,    27,    31,
545
      35,    38,    40,    42
546
};
547
548
/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
549
static const yytype_int8 yyrhs[] =
550
{
551
      17,     0,    -1,    18,    -1,    18,     3,    18,    12,    18,
552
      -1,    18,     4,    18,    -1,    18,     5,    18,    -1,    18,
553
       6,    18,    -1,    18,     7,    18,    -1,    18,     8,    18,
554
      -1,    18,     9,    18,    -1,    10,    18,    -1,    13,    -1,
555
      11,    -1,    14,    18,    15,    -1
556
};
557
558
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
559
static const yytype_uint8 yyrline[] =
560
{
561
       0,   152,   152,   160,   164,   168,   172,   176,   180,   184,
562
     188,   192,   196,   201
563
};
564
#endif
565
566
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
567
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
568
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
569
static const char *const yytname[] =
570
{
571
  "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
572
  "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
573
  "$accept", "start", "exp", 0
574
};
575
#endif
576
577
# ifdef YYPRINT
578
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
579
   token YYLEX-NUM.  */
580
static const yytype_uint16 yytoknum[] =
581
{
582
       0,   256,   257,    63,   124,    38,   258,   259,   260,   261,
583
      33,   262,    58,   110,    40,    41
584
};
585
# endif
586
587
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
588
static const yytype_uint8 yyr1[] =
589
{
590
       0,    16,    17,    18,    18,    18,    18,    18,    18,    18,
591
      18,    18,    18,    18
592
};
593
594
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
595
static const yytype_uint8 yyr2[] =
596
{
597
       0,     2,     1,     5,     3,     3,     3,     3,     3,     3,
598
       2,     1,     1,     3
599
};
600
601
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
602
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
603
   means the default is an error.  */
604
static const yytype_uint8 yydefact[] =
605
{
606
       0,     0,    12,    11,     0,     0,     2,    10,     0,     1,
607
       0,     0,     0,     0,     0,     0,     0,    13,     0,     4,
608
       5,     6,     7,     8,     9,     0,     3
609
};
610
611
/* YYDEFGOTO[NTERM-NUM].  */
612
static const yytype_int8 yydefgoto[] =
613
{
614
      -1,     5,     6
615
};
616
617
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
618
   STATE-NUM.  */
619
#define YYPACT_NINF -10
620
static const yytype_int8 yypact[] =
621
{
622
      -9,    -9,   -10,   -10,    -9,     8,    36,   -10,    13,   -10,
623
      -9,    -9,    -9,    -9,    -9,    -9,    -9,   -10,    26,    41,
624
      45,    18,    -2,    14,   -10,    -9,    36
625
};
626
627
/* YYPGOTO[NTERM-NUM].  */
628
static const yytype_int8 yypgoto[] =
629
{
630
     -10,   -10,    -1
631
};
632
633
/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
634
   positive, shift that token.  If negative, reduce the rule which
635
   number is the opposite.  If zero, do what YYDEFACT says.
636
   If YYTABLE_NINF, syntax error.  */
637
#define YYTABLE_NINF -1
638
static const yytype_uint8 yytable[] =
639
{
640
       7,     1,     2,     8,     3,     4,    15,    16,     9,    18,
641
      19,    20,    21,    22,    23,    24,    10,    11,    12,    13,
642
      14,    15,    16,    16,    26,    14,    15,    16,    17,    10,
643
      11,    12,    13,    14,    15,    16,     0,     0,    25,    10,
644
      11,    12,    13,    14,    15,    16,    12,    13,    14,    15,
645
      16,    13,    14,    15,    16
646
};
647
648
static const yytype_int8 yycheck[] =
649
{
650
       1,    10,    11,     4,    13,    14,     8,     9,     0,    10,
651
      11,    12,    13,    14,    15,    16,     3,     4,     5,     6,
652
       7,     8,     9,     9,    25,     7,     8,     9,    15,     3,
653
       4,     5,     6,     7,     8,     9,    -1,    -1,    12,     3,
654
       4,     5,     6,     7,     8,     9,     5,     6,     7,     8,
655
       9,     6,     7,     8,     9
656
};
657
658
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
659
   symbol of state STATE-NUM.  */
660
static const yytype_uint8 yystos[] =
661
{
662
       0,    10,    11,    13,    14,    17,    18,    18,    18,     0,
663
       3,     4,     5,     6,     7,     8,     9,    15,    18,    18,
664
      18,    18,    18,    18,    18,    12,    18
665
};
666
667
#define yyerrok		(yyerrstatus = 0)
668
#define yyclearin	(yychar = YYEMPTY)
669
#define YYEMPTY		(-2)
670
#define YYEOF		0
671
672
#define YYACCEPT	goto yyacceptlab
673
#define YYABORT		goto yyabortlab
674
#define YYERROR		goto yyerrorlab
675
676
677
/* Like YYERROR except do call yyerror.  This remains here temporarily
678
   to ease the transition to the new meaning of YYERROR, for GCC.
679
   Once GCC version 2 has supplanted version 1, this can go.  However,
680
   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
681
   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
682
   discussed.  */
683
684
#define YYFAIL		goto yyerrlab
685
#if defined YYFAIL
686
  /* This is here to suppress warnings from the GCC cpp's
687
     -Wunused-macros.  Normally we don't worry about that warning, but
688
     some users do, and we want to make it easy for users to remove
689
     YYFAIL uses, which will produce warnings from Bison 2.5.  */
690
#endif
691
692
#define YYRECOVERING()  (!!yyerrstatus)
693
694
#define YYBACKUP(Token, Value)					\
695
do								\
696
  if (yychar == YYEMPTY && yylen == 1)				\
697
    {								\
698
      yychar = (Token);						\
699
      yylval = (Value);						\
700
      yytoken = YYTRANSLATE (yychar);				\
701
      YYPOPSTACK (1);						\
702
      goto yybackup;						\
703
    }								\
704
  else								\
705
    {								\
706
      yyerror (YY_("syntax error: cannot back up")); \
707
      YYERROR;							\
708
    }								\
709
while (YYID (0))
710
711
712
#define YYTERROR	1
713
#define YYERRCODE	256
714
715
716
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
717
   If N is 0, then set CURRENT to the empty location which ends
718
   the previous symbol: RHS[0] (always defined).  */
719
720
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
721
#ifndef YYLLOC_DEFAULT
722
# define YYLLOC_DEFAULT(Current, Rhs, N)				\
723
    do									\
724
      if (YYID (N))                                                    \
725
	{								\
726
	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
727
	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
728
	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
729
	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
730
	}								\
731
      else								\
732
	{								\
733
	  (Current).first_line   = (Current).last_line   =		\
734
	    YYRHSLOC (Rhs, 0).last_line;				\
735
	  (Current).first_column = (Current).last_column =		\
736
	    YYRHSLOC (Rhs, 0).last_column;				\
737
	}								\
738
    while (YYID (0))
739
#endif
740
741
742
/* YY_LOCATION_PRINT -- Print the location on the stream.
743
   This macro was not mandated originally: define only if we know
744
   we won't break user code: when these are the locations we know.  */
745
746
#ifndef YY_LOCATION_PRINT
747
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
748
#  define YY_LOCATION_PRINT(File, Loc)			\
749
     fprintf (File, "%d.%d-%d.%d",			\
750
	      (Loc).first_line, (Loc).first_column,	\
751
	      (Loc).last_line,  (Loc).last_column)
752
# else
753
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
754
# endif
755
#endif
756
757
758
/* YYLEX -- calling `yylex' with the right arguments.  */
759
760
#ifdef YYLEX_PARAM
761
# define YYLEX yylex (&yylval, YYLEX_PARAM)
762
#else
763
# define YYLEX yylex (&yylval)
764
#endif
765
766
/* Enable debugging if requested.  */
767
#if YYDEBUG
768
769
# ifndef YYFPRINTF
770
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
771
#  define YYFPRINTF fprintf
772
# endif
773
774
# define YYDPRINTF(Args)			\
775
do {						\
776
  if (yydebug)					\
777
    YYFPRINTF Args;				\
778
} while (YYID (0))
779
780
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
781
do {									  \
782
  if (yydebug)								  \
783
    {									  \
784
      YYFPRINTF (stderr, "%s ", Title);					  \
785
      yy_symbol_print (stderr,						  \
786
		  Type, Value); \
787
      YYFPRINTF (stderr, "\n");						  \
788
    }									  \
789
} while (YYID (0))
790
791
792
/*--------------------------------.
793
| Print this symbol on YYOUTPUT.  |
794
`--------------------------------*/
795
796
/*ARGSUSED*/
797
#if (defined __STDC__ || defined __C99__FUNC__ \
798
     || defined __cplusplus || defined _MSC_VER)
799
static void
800
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
801
#else
802
static void
803
yy_symbol_value_print (yyoutput, yytype, yyvaluep)
804
    FILE *yyoutput;
805
    int yytype;
806
    YYSTYPE const * const yyvaluep;
807
#endif
808
{
809
  if (!yyvaluep)
810
    return;
811
# ifdef YYPRINT
812
  if (yytype < YYNTOKENS)
813
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
814
# else
815
  YYUSE (yyoutput);
816
# endif
817
  switch (yytype)
818
    {
819
      default:
820
	break;
821
    }
822
}
823
824
825
/*--------------------------------.
826
| Print this symbol on YYOUTPUT.  |
827
`--------------------------------*/
828
829
#if (defined __STDC__ || defined __C99__FUNC__ \
830
     || defined __cplusplus || defined _MSC_VER)
831
static void
832
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
833
#else
834
static void
835
yy_symbol_print (yyoutput, yytype, yyvaluep)
836
    FILE *yyoutput;
837
    int yytype;
838
    YYSTYPE const * const yyvaluep;
839
#endif
840
{
841
  if (yytype < YYNTOKENS)
842
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
843
  else
844
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
845
846
  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
847
  YYFPRINTF (yyoutput, ")");
848
}
849
850
/*------------------------------------------------------------------.
851
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
852
| TOP (included).                                                   |
853
`------------------------------------------------------------------*/
854
855
#if (defined __STDC__ || defined __C99__FUNC__ \
856
     || defined __cplusplus || defined _MSC_VER)
857
static void
858
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
859
#else
860
static void
861
yy_stack_print (yybottom, yytop)
862
    yytype_int16 *yybottom;
863
    yytype_int16 *yytop;
864
#endif
865
{
866
  YYFPRINTF (stderr, "Stack now");
867
  for (; yybottom <= yytop; yybottom++)
868
    {
869
      int yybot = *yybottom;
870
      YYFPRINTF (stderr, " %d", yybot);
871
    }
872
  YYFPRINTF (stderr, "\n");
873
}
874
875
# define YY_STACK_PRINT(Bottom, Top)				\
876
do {								\
877
  if (yydebug)							\
878
    yy_stack_print ((Bottom), (Top));				\
879
} while (YYID (0))
880
881
882
/*------------------------------------------------.
883
| Report that the YYRULE is going to be reduced.  |
884
`------------------------------------------------*/
885
886
#if (defined __STDC__ || defined __C99__FUNC__ \
887
     || defined __cplusplus || defined _MSC_VER)
888
static void
889
yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
890
#else
891
static void
892
yy_reduce_print (yyvsp, yyrule)
893
    YYSTYPE *yyvsp;
894
    int yyrule;
895
#endif
896
{
897
  int yynrhs = yyr2[yyrule];
898
  int yyi;
899
  unsigned long int yylno = yyrline[yyrule];
900
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
901
	     yyrule - 1, yylno);
902
  /* The symbols being reduced.  */
903
  for (yyi = 0; yyi < yynrhs; yyi++)
904
    {
905
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
906
      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
907
		       &(yyvsp[(yyi + 1) - (yynrhs)])
908
		       		       );
909
      YYFPRINTF (stderr, "\n");
910
    }
911
}
912
913
# define YY_REDUCE_PRINT(Rule)		\
914
do {					\
915
  if (yydebug)				\
916
    yy_reduce_print (yyvsp, Rule); \
917
} while (YYID (0))
918
919
/* Nonzero means print parse trace.  It is left uninitialized so that
920
   multiple parsers can coexist.  */
921
int yydebug;
922
#else /* !YYDEBUG */
923
# define YYDPRINTF(Args)
924
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
925
# define YY_STACK_PRINT(Bottom, Top)
926
# define YY_REDUCE_PRINT(Rule)
927
#endif /* !YYDEBUG */
928
929
930
/* YYINITDEPTH -- initial size of the parser's stacks.  */
931
#ifndef	YYINITDEPTH
932
# define YYINITDEPTH 200
933
#endif
934
935
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
936
   if the built-in stack extension method is used).
937
938
   Do not make this value too large; the results are undefined if
939
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
940
   evaluated with infinite-precision integer arithmetic.  */
941
942
#ifndef YYMAXDEPTH
943
# define YYMAXDEPTH 10000
944
#endif
945
946
947
948
#if YYERROR_VERBOSE
949
950
# ifndef yystrlen
951
#  if defined __GLIBC__ && defined _STRING_H
952
#   define yystrlen strlen
953
#  else
954
/* Return the length of YYSTR.  */
955
#if (defined __STDC__ || defined __C99__FUNC__ \
956
     || defined __cplusplus || defined _MSC_VER)
957
static YYSIZE_T
958
yystrlen (const char *yystr)
959
#else
960
static YYSIZE_T
961
yystrlen (yystr)
962
    const char *yystr;
963
#endif
964
{
965
  YYSIZE_T yylen;
966
  for (yylen = 0; yystr[yylen]; yylen++)
967
    continue;
968
  return yylen;
969
}
970
#  endif
971
# endif
972
973
# ifndef yystpcpy
974
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
975
#   define yystpcpy stpcpy
976
#  else
977
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
978
   YYDEST.  */
979
#if (defined __STDC__ || defined __C99__FUNC__ \
980
     || defined __cplusplus || defined _MSC_VER)
981
static char *
982
yystpcpy (char *yydest, const char *yysrc)
983
#else
984
static char *
985
yystpcpy (yydest, yysrc)
986
    char *yydest;
987
    const char *yysrc;
988
#endif
989
{
990
  char *yyd = yydest;
991
  const char *yys = yysrc;
992
993
  while ((*yyd++ = *yys++) != '\0')
994
    continue;
995
996
  return yyd - 1;
997
}
998
#  endif
999
# endif
1000
1001
# ifndef yytnamerr
1002
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1003
   quotes and backslashes, so that it's suitable for yyerror.  The
1004
   heuristic is that double-quoting is unnecessary unless the string
1005
   contains an apostrophe, a comma, or backslash (other than
1006
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1007
   null, do not copy; instead, return the length of what the result
1008
   would have been.  */
1009
static YYSIZE_T
1010
yytnamerr (char *yyres, const char *yystr)
1011
{
1012
  if (*yystr == '"')
1013
    {
1014
      YYSIZE_T yyn = 0;
1015
      char const *yyp = yystr;
1016
1017
      for (;;)
1018
	switch (*++yyp)
1019
	  {
1020
	  case '\'':
1021
	  case ',':
1022
	    goto do_not_strip_quotes;
1023
1024
	  case '\\':
1025
	    if (*++yyp != '\\')
1026
	      goto do_not_strip_quotes;
1027
	    /* Fall through.  */
1028
	  default:
1029
	    if (yyres)
1030
	      yyres[yyn] = *yyp;
1031
	    yyn++;
1032
	    break;
1033
1034
	  case '"':
1035
	    if (yyres)
1036
	      yyres[yyn] = '\0';
1037
	    return yyn;
1038
	  }
1039
    do_not_strip_quotes: ;
1040
    }
1041
1042
  if (! yyres)
1043
    return yystrlen (yystr);
1044
1045
  return yystpcpy (yyres, yystr) - yyres;
1046
}
1047
# endif
1048
1049
/* Copy into YYRESULT an error message about the unexpected token
1050
   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1051
   including the terminating null byte.  If YYRESULT is null, do not
1052
   copy anything; just return the number of bytes that would be
1053
   copied.  As a special case, return 0 if an ordinary "syntax error"
1054
   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1055
   size calculation.  */
1056
static YYSIZE_T
1057
yysyntax_error (char *yyresult, int yystate, int yychar)
1058
{
1059
  int yyn = yypact[yystate];
1060
1061
  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1062
    return 0;
1063
  else
1064
    {
1065
      int yytype = YYTRANSLATE (yychar);
1066
      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1067
      YYSIZE_T yysize = yysize0;
1068
      YYSIZE_T yysize1;
1069
      int yysize_overflow = 0;
1070
      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1071
      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1072
      int yyx;
1073
1074
# if 0
1075
      /* This is so xgettext sees the translatable formats that are
1076
	 constructed on the fly.  */
1077
      YY_("syntax error, unexpected %s");
1078
      YY_("syntax error, unexpected %s, expecting %s");
1079
      YY_("syntax error, unexpected %s, expecting %s or %s");
1080
      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1081
      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1082
# endif
1083
      char *yyfmt;
1084
      char const *yyf;
1085
      static char const yyunexpected[] = "syntax error, unexpected %s";
1086
      static char const yyexpecting[] = ", expecting %s";
1087
      static char const yyor[] = " or %s";
1088
      char yyformat[sizeof yyunexpected
1089
		    + sizeof yyexpecting - 1
1090
		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1091
		       * (sizeof yyor - 1))];
1092
      char const *yyprefix = yyexpecting;
1093
1094
      /* Start YYX at -YYN if negative to avoid negative indexes in
1095
	 YYCHECK.  */
1096
      int yyxbegin = yyn < 0 ? -yyn : 0;
1097
1098
      /* Stay within bounds of both yycheck and yytname.  */
1099
      int yychecklim = YYLAST - yyn + 1;
1100
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1101
      int yycount = 1;
1102
1103
      yyarg[0] = yytname[yytype];
1104
      yyfmt = yystpcpy (yyformat, yyunexpected);
1105
1106
      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1107
	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1108
	  {
1109
	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1110
	      {
1111
		yycount = 1;
1112
		yysize = yysize0;
1113
		yyformat[sizeof yyunexpected - 1] = '\0';
1114
		break;
1115
	      }
1116
	    yyarg[yycount++] = yytname[yyx];
1117
	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1118
	    yysize_overflow |= (yysize1 < yysize);
1119
	    yysize = yysize1;
1120
	    yyfmt = yystpcpy (yyfmt, yyprefix);
1121
	    yyprefix = yyor;
1122
	  }
1123
1124
      yyf = YY_(yyformat);
1125
      yysize1 = yysize + yystrlen (yyf);
1126
      yysize_overflow |= (yysize1 < yysize);
1127
      yysize = yysize1;
1128
1129
      if (yysize_overflow)
1130
	return YYSIZE_MAXIMUM;
1131
1132
      if (yyresult)
1133
	{
1134
	  /* Avoid sprintf, as that infringes on the user's name space.
1135
	     Don't have undefined behavior even if the translation
1136
	     produced a string with the wrong number of "%s"s.  */
1137
	  char *yyp = yyresult;
1138
	  int yyi = 0;
1139
	  while ((*yyp = *yyf) != '\0')
1140
	    {
1141
	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1142
		{
1143
		  yyp += yytnamerr (yyp, yyarg[yyi++]);
1144
		  yyf += 2;
1145
		}
1146
	      else
1147
		{
1148
		  yyp++;
1149
		  yyf++;
1150
		}
1151
	    }
1152
	}
1153
      return yysize;
1154
    }
1155
}
1156
#endif /* YYERROR_VERBOSE */
1157
1158
1159
/*-----------------------------------------------.
1160
| Release the memory associated to this symbol.  |
1161
`-----------------------------------------------*/
1162
1163
/*ARGSUSED*/
1164
#if (defined __STDC__ || defined __C99__FUNC__ \
1165
     || defined __cplusplus || defined _MSC_VER)
1166
static void
1167
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1168
#else
1169
static void
1170
yydestruct (yymsg, yytype, yyvaluep)
1171
    const char *yymsg;
1172
    int yytype;
1173
    YYSTYPE *yyvaluep;
1174
#endif
1175
{
1176
  YYUSE (yyvaluep);
1177
1178
  if (!yymsg)
1179
    yymsg = "Deleting";
1180
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1181
1182
  switch (yytype)
1183
    {
1184
1185
      default:
1186
	break;
1187
    }
1188
}
1189
1190
/* Prevent warnings from -Wmissing-prototypes.  */
1191
#ifdef YYPARSE_PARAM
1192
#if defined __STDC__ || defined __cplusplus
1193
int yyparse (void *YYPARSE_PARAM);
1194
#else
1195
int yyparse ();
1196
#endif
1197
#else /* ! YYPARSE_PARAM */
1198
#if defined __STDC__ || defined __cplusplus
1199
int yyparse (void);
1200
#else
1201
int yyparse ();
1202
#endif
1203
#endif /* ! YYPARSE_PARAM */
1204
1205
1206
1207
1208
1209
/*-------------------------.
1210
| yyparse or yypush_parse.  |
1211
`-------------------------*/
1212
1213
#ifdef YYPARSE_PARAM
1214
#if (defined __STDC__ || defined __C99__FUNC__ \
1215
     || defined __cplusplus || defined _MSC_VER)
1216
int
1217
yyparse (void *YYPARSE_PARAM)
1218
#else
1219
int
1220
yyparse (YYPARSE_PARAM)
1221
    void *YYPARSE_PARAM;
1222
#endif
1223
#else /* ! YYPARSE_PARAM */
1224
#if (defined __STDC__ || defined __C99__FUNC__ \
1225
     || defined __cplusplus || defined _MSC_VER)
1226
int
1227
yyparse (void)
1228
#else
1229
int
1230
yyparse ()
1231
1232
#endif
1233
#endif
1234
{
1235
/* The lookahead symbol.  */
1236
int yychar;
1237
1238
/* The semantic value of the lookahead symbol.  */
1239
YYSTYPE yylval;
1240
1241
    /* Number of syntax errors so far.  */
1242
    int yynerrs;
1243
1244
    int yystate;
1245
    /* Number of tokens to shift before error messages enabled.  */
1246
    int yyerrstatus;
1247
1248
    /* The stacks and their tools:
1249
       `yyss': related to states.
1250
       `yyvs': related to semantic values.
1251
1252
       Refer to the stacks thru separate pointers, to allow yyoverflow
1253
       to reallocate them elsewhere.  */
1254
1255
    /* The state stack.  */
1256
    yytype_int16 yyssa[YYINITDEPTH];
1257
    yytype_int16 *yyss;
1258
    yytype_int16 *yyssp;
1259
1260
    /* The semantic value stack.  */
1261
    YYSTYPE yyvsa[YYINITDEPTH];
1262
    YYSTYPE *yyvs;
1263
    YYSTYPE *yyvsp;
1264
1265
    YYSIZE_T yystacksize;
1266
1267
  int yyn;
1268
  int yyresult;
1269
  /* Lookahead token as an internal (translated) token number.  */
1270
  int yytoken;
1271
  /* The variables used to return semantic value and location from the
1272
     action routines.  */
1273
  YYSTYPE yyval;
1274
1275
#if YYERROR_VERBOSE
1276
  /* Buffer for error messages, and its allocated size.  */
1277
  char yymsgbuf[128];
1278
  char *yymsg = yymsgbuf;
1279
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1280
#endif
1281
1282
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1283
1284
  /* The number of symbols on the RHS of the reduced rule.
1285
     Keep to zero when no symbol should be popped.  */
1286
  int yylen = 0;
1287
1288
  yytoken = 0;
1289
  yyss = yyssa;
1290
  yyvs = yyvsa;
1291
  yystacksize = YYINITDEPTH;
1292
1293
  YYDPRINTF ((stderr, "Starting parse\n"));
1294
1295
  yystate = 0;
1296
  yyerrstatus = 0;
1297
  yynerrs = 0;
1298
  yychar = YYEMPTY; /* Cause a token to be read.  */
1299
1300
  /* Initialize stack pointers.
1301
     Waste one element of value and location stack
1302
     so that they stay on the same level as the state stack.
1303
     The wasted elements are never initialized.  */
1304
  yyssp = yyss;
1305
  yyvsp = yyvs;
1306
1307
  goto yysetstate;
1308
1309
/*------------------------------------------------------------.
1310
| yynewstate -- Push a new state, which is found in yystate.  |
1311
`------------------------------------------------------------*/
1312
 yynewstate:
1313
  /* In all cases, when you get here, the value and location stacks
1314
     have just been pushed.  So pushing a state here evens the stacks.  */
1315
  yyssp++;
1316
1317
 yysetstate:
1318
  *yyssp = yystate;
1319
1320
  if (yyss + yystacksize - 1 <= yyssp)
1321
    {
1322
      /* Get the current used size of the three stacks, in elements.  */
1323
      YYSIZE_T yysize = yyssp - yyss + 1;
1324
1325
#ifdef yyoverflow
1326
      {
1327
	/* Give user a chance to reallocate the stack.  Use copies of
1328
	   these so that the &'s don't force the real ones into
1329
	   memory.  */
1330
	YYSTYPE *yyvs1 = yyvs;
1331
	yytype_int16 *yyss1 = yyss;
1332
1333
	/* Each stack pointer address is followed by the size of the
1334
	   data in use in that stack, in bytes.  This used to be a
1335
	   conditional around just the two extra args, but that might
1336
	   be undefined if yyoverflow is a macro.  */
1337
	yyoverflow (YY_("memory exhausted"),
1338
		    &yyss1, yysize * sizeof (*yyssp),
1339
		    &yyvs1, yysize * sizeof (*yyvsp),
1340
		    &yystacksize);
1341
1342
	yyss = yyss1;
1343
	yyvs = yyvs1;
1344
      }
1345
#else /* no yyoverflow */
1346
# ifndef YYSTACK_RELOCATE
1347
      goto yyexhaustedlab;
1348
# else
1349
      /* Extend the stack our own way.  */
1350
      if (YYMAXDEPTH <= yystacksize)
1351
	goto yyexhaustedlab;
1352
      yystacksize *= 2;
1353
      if (YYMAXDEPTH < yystacksize)
1354
	yystacksize = YYMAXDEPTH;
1355
1356
      {
1357
	yytype_int16 *yyss1 = yyss;
1358
	union yyalloc *yyptr =
1359
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1360
	if (! yyptr)
1361
	  goto yyexhaustedlab;
1362
	YYSTACK_RELOCATE (yyss_alloc, yyss);
1363
	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1364
#  undef YYSTACK_RELOCATE
1365
	if (yyss1 != yyssa)
1366
	  YYSTACK_FREE (yyss1);
1367
      }
1368
# endif
1369
#endif /* no yyoverflow */
1370
1371
      yyssp = yyss + yysize - 1;
1372
      yyvsp = yyvs + yysize - 1;
1373
1374
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1375
		  (unsigned long int) yystacksize));
1376
1377
      if (yyss + yystacksize - 1 <= yyssp)
1378
	YYABORT;
1379
    }
1380
1381
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1382
1383
  if (yystate == YYFINAL)
1384
    YYACCEPT;
1385
1386
  goto yybackup;
1387
1388
/*-----------.
1389
| yybackup.  |
1390
`-----------*/
1391
yybackup:
1392
1393
  /* Do appropriate processing given the current state.  Read a
1394
     lookahead token if we need one and don't already have one.  */
1395
1396
  /* First try to decide what to do without reference to lookahead token.  */
1397
  yyn = yypact[yystate];
1398
  if (yyn == YYPACT_NINF)
1399
    goto yydefault;
1400
1401
  /* Not known => get a lookahead token if don't already have one.  */
1402
1403
  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1404
  if (yychar == YYEMPTY)
1405
    {
1406
      YYDPRINTF ((stderr, "Reading a token: "));
1407
      yychar = YYLEX;
1408
    }
1409
1410
  if (yychar <= YYEOF)
1411
    {
1412
      yychar = yytoken = YYEOF;
1413
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1414
    }
1415
  else
1416
    {
1417
      yytoken = YYTRANSLATE (yychar);
1418
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1419
    }
1420
1421
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1422
     detect an error, take that action.  */
1423
  yyn += yytoken;
1424
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1425
    goto yydefault;
1426
  yyn = yytable[yyn];
1427
  if (yyn <= 0)
1428
    {
1429
      if (yyn == 0 || yyn == YYTABLE_NINF)
1430
	goto yyerrlab;
1431
      yyn = -yyn;
1432
      goto yyreduce;
1433
    }
1434
1435
  /* Count tokens shifted since error; after three, turn off error
1436
     status.  */
1437
  if (yyerrstatus)
1438
    yyerrstatus--;
1439
1440
  /* Shift the lookahead token.  */
1441
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1442
1443
  /* Discard the shifted token.  */
1444
  yychar = YYEMPTY;
1445
1446
  yystate = yyn;
1447
  *++yyvsp = yylval;
1448
1449
  goto yynewstate;
1450
1451
1452
/*-----------------------------------------------------------.
1453
| yydefault -- do the default action for the current state.  |
1454
`-----------------------------------------------------------*/
1455
yydefault:
1456
  yyn = yydefact[yystate];
1457
  if (yyn == 0)
1458
    goto yyerrlab;
1459
  goto yyreduce;
1460
1461
1462
/*-----------------------------.
1463
| yyreduce -- Do a reduction.  |
1464
`-----------------------------*/
1465
yyreduce:
1466
  /* yyn is the number of a rule to reduce with.  */
1467
  yylen = yyr2[yyn];
1468
1469
  /* If YYLEN is nonzero, implement the default value of the action:
1470
     `$$ = $1'.
1471
1472
     Otherwise, the following line sets YYVAL to garbage.
1473
     This behavior is undocumented and Bison
1474
     users should not rely upon it.  Assigning to YYVAL
1475
     unconditionally makes the parser a bit smaller, and it avoids a
1476
     GCC warning that YYVAL may be used uninitialized.  */
1477
  yyval = yyvsp[1-yylen];
1478
1479
1480
  YY_REDUCE_PRINT (yyn);
1481
  switch (yyn)
1482
    {
1483
        case 2:
1484
1485
/* Line 1464 of yacc.c  */
1486
#line 153 "plural.y"
1487
    {
1488
	    if ((yyvsp[(1) - (1)].exp) == NULL)
1489
	      YYABORT;
1490
	    ((struct parse_args *) arg)->res = (yyvsp[(1) - (1)].exp);
1491
	  }
1492
    break;
1493
1494
  case 3:
1495
1496
/* Line 1464 of yacc.c  */
1497
#line 161 "plural.y"
1498
    {
1499
	    (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
1500
	  }
1501
    break;
1502
1503
  case 4:
1504
1505
/* Line 1464 of yacc.c  */
1506
#line 165 "plural.y"
1507
    {
1508
	    (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1509
	  }
1510
    break;
1511
1512
  case 5:
1513
1514
/* Line 1464 of yacc.c  */
1515
#line 169 "plural.y"
1516
    {
1517
	    (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1518
	  }
1519
    break;
1520
1521
  case 6:
1522
1523
/* Line 1464 of yacc.c  */
1524
#line 173 "plural.y"
1525
    {
1526
	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1527
	  }
1528
    break;
1529
1530
  case 7:
1531
1532
/* Line 1464 of yacc.c  */
1533
#line 177 "plural.y"
1534
    {
1535
	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1536
	  }
1537
    break;
1538
1539
  case 8:
1540
1541
/* Line 1464 of yacc.c  */
1542
#line 181 "plural.y"
1543
    {
1544
	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1545
	  }
1546
    break;
1547
1548
  case 9:
1549
1550
/* Line 1464 of yacc.c  */
1551
#line 185 "plural.y"
1552
    {
1553
	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1554
	  }
1555
    break;
1556
1557
  case 10:
1558
1559
/* Line 1464 of yacc.c  */
1560
#line 189 "plural.y"
1561
    {
1562
	    (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
1563
	  }
1564
    break;
1565
1566
  case 11:
1567
1568
/* Line 1464 of yacc.c  */
1569
#line 193 "plural.y"
1570
    {
1571
	    (yyval.exp) = new_exp_0 (var);
1572
	  }
1573
    break;
1574
1575
  case 12:
1576
1577
/* Line 1464 of yacc.c  */
1578
#line 197 "plural.y"
1579
    {
1580
	    if (((yyval.exp) = new_exp_0 (num)) != NULL)
1581
	      (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
1582
	  }
1583
    break;
1584
1585
  case 13:
1586
1587
/* Line 1464 of yacc.c  */
1588
#line 202 "plural.y"
1589
    {
1590
	    (yyval.exp) = (yyvsp[(2) - (3)].exp);
1591
	  }
1592
    break;
1593
1594
1595
1596
/* Line 1464 of yacc.c  */
1597
#line 1598 "plural.c"
1598
      default: break;
1599
    }
1600
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1601
1602
  YYPOPSTACK (yylen);
1603
  yylen = 0;
1604
  YY_STACK_PRINT (yyss, yyssp);
1605
1606
  *++yyvsp = yyval;
1607
1608
  /* Now `shift' the result of the reduction.  Determine what state
1609
     that goes to, based on the state we popped back to and the rule
1610
     number reduced by.  */
1611
1612
  yyn = yyr1[yyn];
1613
1614
  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1615
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1616
    yystate = yytable[yystate];
1617
  else
1618
    yystate = yydefgoto[yyn - YYNTOKENS];
1619
1620
  goto yynewstate;
1621
1622
1623
/*------------------------------------.
1624
| yyerrlab -- here on detecting error |
1625
`------------------------------------*/
1626
yyerrlab:
1627
  /* If not already recovering from an error, report this error.  */
1628
  if (!yyerrstatus)
1629
    {
1630
      ++yynerrs;
1631
#if ! YYERROR_VERBOSE
1632
      yyerror (YY_("syntax error"));
1633
#else
1634
      {
1635
	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1636
	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1637
	  {
1638
	    YYSIZE_T yyalloc = 2 * yysize;
1639
	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1640
	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
1641
	    if (yymsg != yymsgbuf)
1642
	      YYSTACK_FREE (yymsg);
1643
	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1644
	    if (yymsg)
1645
	      yymsg_alloc = yyalloc;
1646
	    else
1647
	      {
1648
		yymsg = yymsgbuf;
1649
		yymsg_alloc = sizeof yymsgbuf;
1650
	      }
1651
	  }
1652
1653
	if (0 < yysize && yysize <= yymsg_alloc)
1654
	  {
1655
	    (void) yysyntax_error (yymsg, yystate, yychar);
1656
	    yyerror (yymsg);
1657
	  }
1658
	else
1659
	  {
1660
	    yyerror (YY_("syntax error"));
1661
	    if (yysize != 0)
1662
	      goto yyexhaustedlab;
1663
	  }
1664
      }
1665
#endif
1666
    }
1667
1668
1669
1670
  if (yyerrstatus == 3)
1671
    {
1672
      /* If just tried and failed to reuse lookahead token after an
1673
	 error, discard it.  */
1674
1675
      if (yychar <= YYEOF)
1676
	{
1677
	  /* Return failure if at end of input.  */
1678
	  if (yychar == YYEOF)
1679
	    YYABORT;
1680
	}
1681
      else
1682
	{
1683
	  yydestruct ("Error: discarding",
1684
		      yytoken, &yylval);
1685
	  yychar = YYEMPTY;
1686
	}
1687
    }
1688
1689
  /* Else will try to reuse lookahead token after shifting the error
1690
     token.  */
1691
  goto yyerrlab1;
1692
1693
1694
/*---------------------------------------------------.
1695
| yyerrorlab -- error raised explicitly by YYERROR.  |
1696
`---------------------------------------------------*/
1697
yyerrorlab:
1698
1699
  /* Pacify compilers like GCC when the user code never invokes
1700
     YYERROR and the label yyerrorlab therefore never appears in user
1701
     code.  */
1702
  if (/*CONSTCOND*/ 0)
1703
     goto yyerrorlab;
1704
1705
  /* Do not reclaim the symbols of the rule which action triggered
1706
     this YYERROR.  */
1707
  YYPOPSTACK (yylen);
1708
  yylen = 0;
1709
  YY_STACK_PRINT (yyss, yyssp);
1710
  yystate = *yyssp;
1711
  goto yyerrlab1;
1712
1713
1714
/*-------------------------------------------------------------.
1715
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
1716
`-------------------------------------------------------------*/
1717
yyerrlab1:
1718
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1719
1720
  for (;;)
1721
    {
1722
      yyn = yypact[yystate];
1723
      if (yyn != YYPACT_NINF)
1724
	{
1725
	  yyn += YYTERROR;
1726
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1727
	    {
1728
	      yyn = yytable[yyn];
1729
	      if (0 < yyn)
1730
		break;
1731
	    }
1732
	}
1733
1734
      /* Pop the current state because it cannot handle the error token.  */
1735
      if (yyssp == yyss)
1736
	YYABORT;
1737
1738
1739
      yydestruct ("Error: popping",
1740
		  yystos[yystate], yyvsp);
1741
      YYPOPSTACK (1);
1742
      yystate = *yyssp;
1743
      YY_STACK_PRINT (yyss, yyssp);
1744
    }
1745
1746
  *++yyvsp = yylval;
1747
1748
1749
  /* Shift the error token.  */
1750
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1751
1752
  yystate = yyn;
1753
  goto yynewstate;
1754
1755
1756
/*-------------------------------------.
1757
| yyacceptlab -- YYACCEPT comes here.  |
1758
`-------------------------------------*/
1759
yyacceptlab:
1760
  yyresult = 0;
1761
  goto yyreturn;
1762
1763
/*-----------------------------------.
1764
| yyabortlab -- YYABORT comes here.  |
1765
`-----------------------------------*/
1766
yyabortlab:
1767
  yyresult = 1;
1768
  goto yyreturn;
1769
1770
#if !defined(yyoverflow) || YYERROR_VERBOSE
1771
/*-------------------------------------------------.
1772
| yyexhaustedlab -- memory exhaustion comes here.  |
1773
`-------------------------------------------------*/
1774
yyexhaustedlab:
1775
  yyerror (YY_("memory exhausted"));
1776
  yyresult = 2;
1777
  /* Fall through.  */
1778
#endif
1779
1780
yyreturn:
1781
  if (yychar != YYEMPTY)
1782
     yydestruct ("Cleanup: discarding lookahead",
1783
		 yytoken, &yylval);
1784
  /* Do not reclaim the symbols of the rule which action triggered
1785
     this YYABORT or YYACCEPT.  */
1786
  YYPOPSTACK (yylen);
1787
  YY_STACK_PRINT (yyss, yyssp);
1788
  while (yyssp != yyss)
1789
    {
1790
      yydestruct ("Cleanup: popping",
1791
		  yystos[*yyssp], yyvsp);
1792
      YYPOPSTACK (1);
1793
    }
1794
#ifndef yyoverflow
1795
  if (yyss != yyssa)
1796
    YYSTACK_FREE (yyss);
1797
#endif
1798
#if YYERROR_VERBOSE
1799
  if (yymsg != yymsgbuf)
1800
    YYSTACK_FREE (yymsg);
1801
#endif
1802
  /* Make sure YYID is used.  */
1803
  return YYID (yyresult);
1804
}
1805
1806
1807
1808
/* Line 1684 of yacc.c  */
1809
#line 207 "plural.y"
1810
1811
1812
void
1813
internal_function
1814
FREE_EXPRESSION (struct expression *exp)
1815
{
1816
  if (exp == NULL)
1817
    return;
1818
1819
  /* Handle the recursive case.  */
1820
  switch (exp->nargs)
1821
    {
1822
    case 3:
1823
      FREE_EXPRESSION (exp->val.args[2]);
1824
      /* FALLTHROUGH */
1825
    case 2:
1826
      FREE_EXPRESSION (exp->val.args[1]);
1827
      /* FALLTHROUGH */
1828
    case 1:
1829
      FREE_EXPRESSION (exp->val.args[0]);
1830
      /* FALLTHROUGH */
1831
    default:
1832
      break;
1833
    }
1834
1835
  free (exp);
1836
}
1837
1838
1839
static int
1840
yylex (YYSTYPE *lval, const char **pexp)
1841
{
1842
  const char *exp = *pexp;
1843
  int result;
1844
1845
  while (1)
1846
    {
1847
      if (exp[0] == '\0')
1848
	{
1849
	  *pexp = exp;
1850
	  return YYEOF;
1851
	}
1852
1853
      if (exp[0] != ' ' && exp[0] != '\t')
1854
	break;
1855
1856
      ++exp;
1857
    }
1858
1859
  result = *exp++;
1860
  switch (result)
1861
    {
1862
    case '0': case '1': case '2': case '3': case '4':
1863
    case '5': case '6': case '7': case '8': case '9':
1864
      {
1865
	unsigned long int n = result - '0';
1866
	while (exp[0] >= '0' && exp[0] <= '9')
1867
	  {
1868
	    n *= 10;
1869
	    n += exp[0] - '0';
1870
	    ++exp;
1871
	  }
1872
	lval->num = n;
1873
	result = NUMBER;
1874
      }
1875
      break;
1876
1877
    case '=':
1878
      if (exp[0] == '=')
1879
	{
1880
	  ++exp;
1881
	  lval->op = equal;
1882
	  result = EQUOP2;
1883
	}
1884
      else
1885
	result = YYERRCODE;
1886
      break;
1887
1888
    case '!':
1889
      if (exp[0] == '=')
1890
	{
1891
	  ++exp;
1892
	  lval->op = not_equal;
1893
	  result = EQUOP2;
1894
	}
1895
      break;
1896
1897
    case '&':
1898
    case '|':
1899
      if (exp[0] == result)
1900
	++exp;
1901
      else
1902
	result = YYERRCODE;
1903
      break;
1904
1905
    case '<':
1906
      if (exp[0] == '=')
1907
	{
1908
	  ++exp;
1909
	  lval->op = less_or_equal;
1910
	}
1911
      else
1912
	lval->op = less_than;
1913
      result = CMPOP2;
1914
      break;
1915
1916
    case '>':
1917
      if (exp[0] == '=')
1918
	{
1919
	  ++exp;
1920
	  lval->op = greater_or_equal;
1921
	}
1922
      else
1923
	lval->op = greater_than;
1924
      result = CMPOP2;
1925
      break;
1926
1927
    case '*':
1928
      lval->op = mult;
1929
      result = MULOP2;
1930
      break;
1931
1932
    case '/':
1933
      lval->op = divide;
1934
      result = MULOP2;
1935
      break;
1936
1937
    case '%':
1938
      lval->op = module;
1939
      result = MULOP2;
1940
      break;
1941
1942
    case '+':
1943
      lval->op = plus;
1944
      result = ADDOP2;
1945
      break;
1946
1947
    case '-':
1948
      lval->op = minus;
1949
      result = ADDOP2;
1950
      break;
1951
1952
    case 'n':
1953
    case '?':
1954
    case ':':
1955
    case '(':
1956
    case ')':
1957
      /* Nothing, just return the character.  */
1958
      break;
1959
1960
    case ';':
1961
    case '\n':
1962
    case '\0':
1963
      /* Be safe and let the user call this function again.  */
1964
      --exp;
1965
      result = YYEOF;
1966
      break;
1967
1968
    default:
1969
      result = YYERRCODE;
1970
#if YYDEBUG != 0
1971
      --exp;
1972
#endif
1973
      break;
1974
    }
1975
1976
  *pexp = exp;
1977
1978
  return result;
1979
}
1980
1981
1982
static void
1983
yyerror (const char *str)
1984
{
1985
  /* Do nothing.  We don't print error messages here.  */
1986
}
1987
(-)a/intl/plural.y (-383 lines)
Lines 1-383 Link Here
1
%{
2
/* Expression parsing for plural form selection.
3
   Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
4
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
5
6
   This program is free software; you can redistribute it and/or modify it
7
   under the terms of the GNU Library General Public License as published
8
   by the Free Software Foundation; either version 2, or (at your option)
9
   any later version.
10
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
   Library General Public License for more details.
15
16
   You should have received a copy of the GNU Library General Public
17
   License along with this program; if not, write to the Free Software
18
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
   USA.  */
20
21
/* For bison < 2.0, the bison generated parser uses alloca.  AIX 3 forces us
22
   to put this declaration at the beginning of the file.  The declaration in
23
   bison's skeleton file comes too late.  This must come before <config.h>
24
   because <config.h> may include arbitrary system headers.
25
   This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0.  */
26
#if defined _AIX && !defined __GNUC__
27
 #pragma alloca
28
#endif
29
30
#ifdef HAVE_CONFIG_H
31
# include <config.h>
32
#endif
33
34
#include <stddef.h>
35
#include <stdlib.h>
36
#include <string.h>
37
#include "plural-exp.h"
38
39
/* The main function generated by the parser is called __gettextparse,
40
   but we want it to be called PLURAL_PARSE.  */
41
#ifndef _LIBC
42
# define __gettextparse PLURAL_PARSE
43
#endif
44
45
#define YYLEX_PARAM	&((struct parse_args *) arg)->cp
46
#define YYPARSE_PARAM	arg
47
%}
48
%pure_parser
49
%expect 7
50
51
%union {
52
  unsigned long int num;
53
  enum operator op;
54
  struct expression *exp;
55
}
56
57
%{
58
/* Prototypes for local functions.  */
59
static int yylex (YYSTYPE *lval, const char **pexp);
60
static void yyerror (const char *str);
61
62
/* Allocation of expressions.  */
63
64
static struct expression *
65
new_exp (int nargs, enum operator op, struct expression * const *args)
66
{
67
  int i;
68
  struct expression *newp;
69
70
  /* If any of the argument could not be malloc'ed, just return NULL.  */
71
  for (i = nargs - 1; i >= 0; i--)
72
    if (args[i] == NULL)
73
      goto fail;
74
75
  /* Allocate a new expression.  */
76
  newp = (struct expression *) malloc (sizeof (*newp));
77
  if (newp != NULL)
78
    {
79
      newp->nargs = nargs;
80
      newp->operation = op;
81
      for (i = nargs - 1; i >= 0; i--)
82
	newp->val.args[i] = args[i];
83
      return newp;
84
    }
85
86
 fail:
87
  for (i = nargs - 1; i >= 0; i--)
88
    FREE_EXPRESSION (args[i]);
89
90
  return NULL;
91
}
92
93
static inline struct expression *
94
new_exp_0 (enum operator op)
95
{
96
  return new_exp (0, op, NULL);
97
}
98
99
static inline struct expression *
100
new_exp_1 (enum operator op, struct expression *right)
101
{
102
  struct expression *args[1];
103
104
  args[0] = right;
105
  return new_exp (1, op, args);
106
}
107
108
static struct expression *
109
new_exp_2 (enum operator op, struct expression *left, struct expression *right)
110
{
111
  struct expression *args[2];
112
113
  args[0] = left;
114
  args[1] = right;
115
  return new_exp (2, op, args);
116
}
117
118
static inline struct expression *
119
new_exp_3 (enum operator op, struct expression *bexp,
120
	   struct expression *tbranch, struct expression *fbranch)
121
{
122
  struct expression *args[3];
123
124
  args[0] = bexp;
125
  args[1] = tbranch;
126
  args[2] = fbranch;
127
  return new_exp (3, op, args);
128
}
129
130
%}
131
132
/* This declares that all operators have the same associativity and the
133
   precedence order as in C.  See [Harbison, Steele: C, A Reference Manual].
134
   There is no unary minus and no bitwise operators.
135
   Operators with the same syntactic behaviour have been merged into a single
136
   token, to save space in the array generated by bison.  */
137
%right '?'		/*   ?		*/
138
%left '|'		/*   ||		*/
139
%left '&'		/*   &&		*/
140
%left EQUOP2		/*   == !=	*/
141
%left CMPOP2		/*   < > <= >=	*/
142
%left ADDOP2		/*   + -	*/
143
%left MULOP2		/*   * / %	*/
144
%right '!'		/*   !		*/
145
146
%token <op> EQUOP2 CMPOP2 ADDOP2 MULOP2
147
%token <num> NUMBER
148
%type <exp> exp
149
150
%%
151
152
start:	  exp
153
	  {
154
	    if ($1 == NULL)
155
	      YYABORT;
156
	    ((struct parse_args *) arg)->res = $1;
157
	  }
158
	;
159
160
exp:	  exp '?' exp ':' exp
161
	  {
162
	    $$ = new_exp_3 (qmop, $1, $3, $5);
163
	  }
164
	| exp '|' exp
165
	  {
166
	    $$ = new_exp_2 (lor, $1, $3);
167
	  }
168
	| exp '&' exp
169
	  {
170
	    $$ = new_exp_2 (land, $1, $3);
171
	  }
172
	| exp EQUOP2 exp
173
	  {
174
	    $$ = new_exp_2 ($2, $1, $3);
175
	  }
176
	| exp CMPOP2 exp
177
	  {
178
	    $$ = new_exp_2 ($2, $1, $3);
179
	  }
180
	| exp ADDOP2 exp
181
	  {
182
	    $$ = new_exp_2 ($2, $1, $3);
183
	  }
184
	| exp MULOP2 exp
185
	  {
186
	    $$ = new_exp_2 ($2, $1, $3);
187
	  }
188
	| '!' exp
189
	  {
190
	    $$ = new_exp_1 (lnot, $2);
191
	  }
192
	| 'n'
193
	  {
194
	    $$ = new_exp_0 (var);
195
	  }
196
	| NUMBER
197
	  {
198
	    if (($$ = new_exp_0 (num)) != NULL)
199
	      $$->val.num = $1;
200
	  }
201
	| '(' exp ')'
202
	  {
203
	    $$ = $2;
204
	  }
205
	;
206
207
%%
208
209
void
210
internal_function
211
FREE_EXPRESSION (struct expression *exp)
212
{
213
  if (exp == NULL)
214
    return;
215
216
  /* Handle the recursive case.  */
217
  switch (exp->nargs)
218
    {
219
    case 3:
220
      FREE_EXPRESSION (exp->val.args[2]);
221
      /* FALLTHROUGH */
222
    case 2:
223
      FREE_EXPRESSION (exp->val.args[1]);
224
      /* FALLTHROUGH */
225
    case 1:
226
      FREE_EXPRESSION (exp->val.args[0]);
227
      /* FALLTHROUGH */
228
    default:
229
      break;
230
    }
231
232
  free (exp);
233
}
234
235
236
static int
237
yylex (YYSTYPE *lval, const char **pexp)
238
{
239
  const char *exp = *pexp;
240
  int result;
241
242
  while (1)
243
    {
244
      if (exp[0] == '\0')
245
	{
246
	  *pexp = exp;
247
	  return YYEOF;
248
	}
249
250
      if (exp[0] != ' ' && exp[0] != '\t')
251
	break;
252
253
      ++exp;
254
    }
255
256
  result = *exp++;
257
  switch (result)
258
    {
259
    case '0': case '1': case '2': case '3': case '4':
260
    case '5': case '6': case '7': case '8': case '9':
261
      {
262
	unsigned long int n = result - '0';
263
	while (exp[0] >= '0' && exp[0] <= '9')
264
	  {
265
	    n *= 10;
266
	    n += exp[0] - '0';
267
	    ++exp;
268
	  }
269
	lval->num = n;
270
	result = NUMBER;
271
      }
272
      break;
273
274
    case '=':
275
      if (exp[0] == '=')
276
	{
277
	  ++exp;
278
	  lval->op = equal;
279
	  result = EQUOP2;
280
	}
281
      else
282
	result = YYERRCODE;
283
      break;
284
285
    case '!':
286
      if (exp[0] == '=')
287
	{
288
	  ++exp;
289
	  lval->op = not_equal;
290
	  result = EQUOP2;
291
	}
292
      break;
293
294
    case '&':
295
    case '|':
296
      if (exp[0] == result)
297
	++exp;
298
      else
299
	result = YYERRCODE;
300
      break;
301
302
    case '<':
303
      if (exp[0] == '=')
304
	{
305
	  ++exp;
306
	  lval->op = less_or_equal;
307
	}
308
      else
309
	lval->op = less_than;
310
      result = CMPOP2;
311
      break;
312
313
    case '>':
314
      if (exp[0] == '=')
315
	{
316
	  ++exp;
317
	  lval->op = greater_or_equal;
318
	}
319
      else
320
	lval->op = greater_than;
321
      result = CMPOP2;
322
      break;
323
324
    case '*':
325
      lval->op = mult;
326
      result = MULOP2;
327
      break;
328
329
    case '/':
330
      lval->op = divide;
331
      result = MULOP2;
332
      break;
333
334
    case '%':
335
      lval->op = module;
336
      result = MULOP2;
337
      break;
338
339
    case '+':
340
      lval->op = plus;
341
      result = ADDOP2;
342
      break;
343
344
    case '-':
345
      lval->op = minus;
346
      result = ADDOP2;
347
      break;
348
349
    case 'n':
350
    case '?':
351
    case ':':
352
    case '(':
353
    case ')':
354
      /* Nothing, just return the character.  */
355
      break;
356
357
    case ';':
358
    case '\n':
359
    case '\0':
360
      /* Be safe and let the user call this function again.  */
361
      --exp;
362
      result = YYEOF;
363
      break;
364
365
    default:
366
      result = YYERRCODE;
367
#if YYDEBUG != 0
368
      --exp;
369
#endif
370
      break;
371
    }
372
373
  *pexp = exp;
374
375
  return result;
376
}
377
378
379
static void
380
yyerror (const char *str)
381
{
382
  /* Do nothing.  We don't print error messages here.  */
383
}
(-)a/intl/printf-args.c (-142 lines)
Lines 1-142 Link Here
1
/* Decomposed printf argument list.
2
   Copyright (C) 1999, 2002-2003, 2005-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#include <config.h>
20
21
/* Specification.  */
22
#include "printf-args.h"
23
24
#ifdef STATIC
25
STATIC
26
#endif
27
int
28
printf_fetchargs (va_list args, arguments *a)
29
{
30
  size_t i;
31
  argument *ap;
32
33
  for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
34
    switch (ap->type)
35
      {
36
      case TYPE_SCHAR:
37
	ap->a.a_schar = va_arg (args, /*signed char*/ int);
38
	break;
39
      case TYPE_UCHAR:
40
	ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
41
	break;
42
      case TYPE_SHORT:
43
	ap->a.a_short = va_arg (args, /*short*/ int);
44
	break;
45
      case TYPE_USHORT:
46
	ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
47
	break;
48
      case TYPE_INT:
49
	ap->a.a_int = va_arg (args, int);
50
	break;
51
      case TYPE_UINT:
52
	ap->a.a_uint = va_arg (args, unsigned int);
53
	break;
54
      case TYPE_LONGINT:
55
	ap->a.a_longint = va_arg (args, long int);
56
	break;
57
      case TYPE_ULONGINT:
58
	ap->a.a_ulongint = va_arg (args, unsigned long int);
59
	break;
60
#ifdef HAVE_LONG_LONG_INT
61
      case TYPE_LONGLONGINT:
62
	ap->a.a_longlongint = va_arg (args, long long int);
63
	break;
64
      case TYPE_ULONGLONGINT:
65
	ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
66
	break;
67
#endif
68
      case TYPE_DOUBLE:
69
	ap->a.a_double = va_arg (args, double);
70
	break;
71
#ifdef HAVE_LONG_DOUBLE
72
      case TYPE_LONGDOUBLE:
73
	ap->a.a_longdouble = va_arg (args, long double);
74
	break;
75
#endif
76
      case TYPE_CHAR:
77
	ap->a.a_char = va_arg (args, int);
78
	break;
79
#ifdef HAVE_WINT_T
80
      case TYPE_WIDE_CHAR:
81
	/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
82
	   default argument promotions", this is not the case in mingw32,
83
	   where wint_t is 'unsigned short'.  */
84
	ap->a.a_wide_char =
85
	  (sizeof (wint_t) < sizeof (int)
86
	   ? va_arg (args, int)
87
	   : va_arg (args, wint_t));
88
	break;
89
#endif
90
      case TYPE_STRING:
91
	ap->a.a_string = va_arg (args, const char *);
92
	/* A null pointer is an invalid argument for "%s", but in practice
93
	   it occurs quite frequently in printf statements that produce
94
	   debug output.  Use a fallback in this case.  */
95
	if (ap->a.a_string == NULL)
96
	  ap->a.a_string = "(NULL)";
97
	break;
98
#ifdef HAVE_WCHAR_T
99
      case TYPE_WIDE_STRING:
100
	ap->a.a_wide_string = va_arg (args, const wchar_t *);
101
	/* A null pointer is an invalid argument for "%ls", but in practice
102
	   it occurs quite frequently in printf statements that produce
103
	   debug output.  Use a fallback in this case.  */
104
	if (ap->a.a_wide_string == NULL)
105
	  {
106
	    static const wchar_t wide_null_string[] =
107
	      {
108
		(wchar_t)'(',
109
		(wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
110
		(wchar_t)')',
111
		(wchar_t)0
112
	      };
113
	    ap->a.a_wide_string = wide_null_string;
114
	  }
115
	break;
116
#endif
117
      case TYPE_POINTER:
118
	ap->a.a_pointer = va_arg (args, void *);
119
	break;
120
      case TYPE_COUNT_SCHAR_POINTER:
121
	ap->a.a_count_schar_pointer = va_arg (args, signed char *);
122
	break;
123
      case TYPE_COUNT_SHORT_POINTER:
124
	ap->a.a_count_short_pointer = va_arg (args, short *);
125
	break;
126
      case TYPE_COUNT_INT_POINTER:
127
	ap->a.a_count_int_pointer = va_arg (args, int *);
128
	break;
129
      case TYPE_COUNT_LONGINT_POINTER:
130
	ap->a.a_count_longint_pointer = va_arg (args, long int *);
131
	break;
132
#ifdef HAVE_LONG_LONG_INT
133
      case TYPE_COUNT_LONGLONGINT_POINTER:
134
	ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
135
	break;
136
#endif
137
      default:
138
	/* Unknown type.  */
139
	return -1;
140
      }
141
  return 0;
142
}
(-)a/intl/printf-args.h (-137 lines)
Lines 1-137 Link Here
1
/* Decomposed printf argument list.
2
   Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _PRINTF_ARGS_H
20
#define _PRINTF_ARGS_H
21
22
/* Get size_t.  */
23
#include <stddef.h>
24
25
/* Get wchar_t.  */
26
#ifdef HAVE_WCHAR_T
27
# include <stddef.h>
28
#endif
29
30
/* Get wint_t.  */
31
#ifdef HAVE_WINT_T
32
# include <wchar.h>
33
#endif
34
35
/* Get va_list.  */
36
#include <stdarg.h>
37
38
39
/* Argument types */
40
typedef enum
41
{
42
  TYPE_NONE,
43
  TYPE_SCHAR,
44
  TYPE_UCHAR,
45
  TYPE_SHORT,
46
  TYPE_USHORT,
47
  TYPE_INT,
48
  TYPE_UINT,
49
  TYPE_LONGINT,
50
  TYPE_ULONGINT,
51
#ifdef HAVE_LONG_LONG_INT
52
  TYPE_LONGLONGINT,
53
  TYPE_ULONGLONGINT,
54
#endif
55
  TYPE_DOUBLE,
56
#ifdef HAVE_LONG_DOUBLE
57
  TYPE_LONGDOUBLE,
58
#endif
59
  TYPE_CHAR,
60
#ifdef HAVE_WINT_T
61
  TYPE_WIDE_CHAR,
62
#endif
63
  TYPE_STRING,
64
#ifdef HAVE_WCHAR_T
65
  TYPE_WIDE_STRING,
66
#endif
67
  TYPE_POINTER,
68
  TYPE_COUNT_SCHAR_POINTER,
69
  TYPE_COUNT_SHORT_POINTER,
70
  TYPE_COUNT_INT_POINTER,
71
  TYPE_COUNT_LONGINT_POINTER
72
#ifdef HAVE_LONG_LONG_INT
73
, TYPE_COUNT_LONGLONGINT_POINTER
74
#endif
75
} arg_type;
76
77
/* Polymorphic argument */
78
typedef struct
79
{
80
  arg_type type;
81
  union
82
  {
83
    signed char			a_schar;
84
    unsigned char		a_uchar;
85
    short			a_short;
86
    unsigned short		a_ushort;
87
    int				a_int;
88
    unsigned int		a_uint;
89
    long int			a_longint;
90
    unsigned long int		a_ulongint;
91
#ifdef HAVE_LONG_LONG_INT
92
    long long int		a_longlongint;
93
    unsigned long long int	a_ulonglongint;
94
#endif
95
    float			a_float;
96
    double			a_double;
97
#ifdef HAVE_LONG_DOUBLE
98
    long double			a_longdouble;
99
#endif
100
    int				a_char;
101
#ifdef HAVE_WINT_T
102
    wint_t			a_wide_char;
103
#endif
104
    const char*			a_string;
105
#ifdef HAVE_WCHAR_T
106
    const wchar_t*		a_wide_string;
107
#endif
108
    void*			a_pointer;
109
    signed char *		a_count_schar_pointer;
110
    short *			a_count_short_pointer;
111
    int *			a_count_int_pointer;
112
    long int *			a_count_longint_pointer;
113
#ifdef HAVE_LONG_LONG_INT
114
    long long int *		a_count_longlongint_pointer;
115
#endif
116
  }
117
  a;
118
}
119
argument;
120
121
typedef struct
122
{
123
  size_t count;
124
  argument *arg;
125
}
126
arguments;
127
128
129
/* Fetch the arguments, putting them into a. */
130
#ifdef STATIC
131
STATIC
132
#else
133
extern
134
#endif
135
int printf_fetchargs (va_list args, arguments *a);
136
137
#endif /* _PRINTF_ARGS_H */
(-)a/intl/printf-parse.c (-544 lines)
Lines 1-544 Link Here
1
/* Formatted output to strings.
2
   Copyright (C) 1999-2000, 2002-2003, 2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#include <config.h>
20
21
/* Specification.  */
22
#if WIDE_CHAR_VERSION
23
# include "wprintf-parse.h"
24
#else
25
# include "printf-parse.h"
26
#endif
27
28
/* Get size_t, NULL.  */
29
#include <stddef.h>
30
31
/* Get intmax_t.  */
32
#if HAVE_STDINT_H_WITH_UINTMAX
33
# include <stdint.h>
34
#endif
35
#if HAVE_INTTYPES_H_WITH_UINTMAX
36
# include <inttypes.h>
37
#endif
38
39
/* malloc(), realloc(), free().  */
40
#include <stdlib.h>
41
42
/* Checked size_t computations.  */
43
#include "xsize.h"
44
45
#if WIDE_CHAR_VERSION
46
# define PRINTF_PARSE wprintf_parse
47
# define CHAR_T wchar_t
48
# define DIRECTIVE wchar_t_directive
49
# define DIRECTIVES wchar_t_directives
50
#else
51
# define PRINTF_PARSE printf_parse
52
# define CHAR_T char
53
# define DIRECTIVE char_directive
54
# define DIRECTIVES char_directives
55
#endif
56
57
#ifdef STATIC
58
STATIC
59
#endif
60
int
61
PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
62
{
63
  const CHAR_T *cp = format;		/* pointer into format */
64
  size_t arg_posn = 0;		/* number of regular arguments consumed */
65
  size_t d_allocated;			/* allocated elements of d->dir */
66
  size_t a_allocated;			/* allocated elements of a->arg */
67
  size_t max_width_length = 0;
68
  size_t max_precision_length = 0;
69
70
  d->count = 0;
71
  d_allocated = 1;
72
  d->dir = malloc (d_allocated * sizeof (DIRECTIVE));
73
  if (d->dir == NULL)
74
    /* Out of memory.  */
75
    return -1;
76
77
  a->count = 0;
78
  a_allocated = 0;
79
  a->arg = NULL;
80
81
#define REGISTER_ARG(_index_,_type_) \
82
  {									\
83
    size_t n = (_index_);						\
84
    if (n >= a_allocated)						\
85
      {									\
86
	size_t memory_size;						\
87
	argument *memory;						\
88
									\
89
	a_allocated = xtimes (a_allocated, 2);				\
90
	if (a_allocated <= n)						\
91
	  a_allocated = xsum (n, 1);					\
92
	memory_size = xtimes (a_allocated, sizeof (argument));		\
93
	if (size_overflow_p (memory_size))				\
94
	  /* Overflow, would lead to out of memory.  */			\
95
	  goto error;							\
96
	memory = (a->arg						\
97
		  ? realloc (a->arg, memory_size)			\
98
		  : malloc (memory_size));				\
99
	if (memory == NULL)						\
100
	  /* Out of memory.  */						\
101
	  goto error;							\
102
	a->arg = memory;						\
103
      }									\
104
    while (a->count <= n)						\
105
      a->arg[a->count++].type = TYPE_NONE;				\
106
    if (a->arg[n].type == TYPE_NONE)					\
107
      a->arg[n].type = (_type_);					\
108
    else if (a->arg[n].type != (_type_))				\
109
      /* Ambiguous type for positional argument.  */			\
110
      goto error;							\
111
  }
112
113
  while (*cp != '\0')
114
    {
115
      CHAR_T c = *cp++;
116
      if (c == '%')
117
	{
118
	  size_t arg_index = ARG_NONE;
119
	  DIRECTIVE *dp = &d->dir[d->count];/* pointer to next directive */
120
121
	  /* Initialize the next directive.  */
122
	  dp->dir_start = cp - 1;
123
	  dp->flags = 0;
124
	  dp->width_start = NULL;
125
	  dp->width_end = NULL;
126
	  dp->width_arg_index = ARG_NONE;
127
	  dp->precision_start = NULL;
128
	  dp->precision_end = NULL;
129
	  dp->precision_arg_index = ARG_NONE;
130
	  dp->arg_index = ARG_NONE;
131
132
	  /* Test for positional argument.  */
133
	  if (*cp >= '0' && *cp <= '9')
134
	    {
135
	      const CHAR_T *np;
136
137
	      for (np = cp; *np >= '0' && *np <= '9'; np++)
138
		;
139
	      if (*np == '$')
140
		{
141
		  size_t n = 0;
142
143
		  for (np = cp; *np >= '0' && *np <= '9'; np++)
144
		    n = xsum (xtimes (n, 10), *np - '0');
145
		  if (n == 0)
146
		    /* Positional argument 0.  */
147
		    goto error;
148
		  if (size_overflow_p (n))
149
		    /* n too large, would lead to out of memory later.  */
150
		    goto error;
151
		  arg_index = n - 1;
152
		  cp = np + 1;
153
		}
154
	    }
155
156
	  /* Read the flags.  */
157
	  for (;;)
158
	    {
159
	      if (*cp == '\'')
160
		{
161
		  dp->flags |= FLAG_GROUP;
162
		  cp++;
163
		}
164
	      else if (*cp == '-')
165
		{
166
		  dp->flags |= FLAG_LEFT;
167
		  cp++;
168
		}
169
	      else if (*cp == '+')
170
		{
171
		  dp->flags |= FLAG_SHOWSIGN;
172
		  cp++;
173
		}
174
	      else if (*cp == ' ')
175
		{
176
		  dp->flags |= FLAG_SPACE;
177
		  cp++;
178
		}
179
	      else if (*cp == '#')
180
		{
181
		  dp->flags |= FLAG_ALT;
182
		  cp++;
183
		}
184
	      else if (*cp == '0')
185
		{
186
		  dp->flags |= FLAG_ZERO;
187
		  cp++;
188
		}
189
	      else
190
		break;
191
	    }
192
193
	  /* Parse the field width.  */
194
	  if (*cp == '*')
195
	    {
196
	      dp->width_start = cp;
197
	      cp++;
198
	      dp->width_end = cp;
199
	      if (max_width_length < 1)
200
		max_width_length = 1;
201
202
	      /* Test for positional argument.  */
203
	      if (*cp >= '0' && *cp <= '9')
204
		{
205
		  const CHAR_T *np;
206
207
		  for (np = cp; *np >= '0' && *np <= '9'; np++)
208
		    ;
209
		  if (*np == '$')
210
		    {
211
		      size_t n = 0;
212
213
		      for (np = cp; *np >= '0' && *np <= '9'; np++)
214
			n = xsum (xtimes (n, 10), *np - '0');
215
		      if (n == 0)
216
			/* Positional argument 0.  */
217
			goto error;
218
		      if (size_overflow_p (n))
219
			/* n too large, would lead to out of memory later.  */
220
			goto error;
221
		      dp->width_arg_index = n - 1;
222
		      cp = np + 1;
223
		    }
224
		}
225
	      if (dp->width_arg_index == ARG_NONE)
226
		{
227
		  dp->width_arg_index = arg_posn++;
228
		  if (dp->width_arg_index == ARG_NONE)
229
		    /* arg_posn wrapped around.  */
230
		    goto error;
231
		}
232
	      REGISTER_ARG (dp->width_arg_index, TYPE_INT);
233
	    }
234
	  else if (*cp >= '0' && *cp <= '9')
235
	    {
236
	      size_t width_length;
237
238
	      dp->width_start = cp;
239
	      for (; *cp >= '0' && *cp <= '9'; cp++)
240
		;
241
	      dp->width_end = cp;
242
	      width_length = dp->width_end - dp->width_start;
243
	      if (max_width_length < width_length)
244
		max_width_length = width_length;
245
	    }
246
247
	  /* Parse the precision.  */
248
	  if (*cp == '.')
249
	    {
250
	      cp++;
251
	      if (*cp == '*')
252
		{
253
		  dp->precision_start = cp - 1;
254
		  cp++;
255
		  dp->precision_end = cp;
256
		  if (max_precision_length < 2)
257
		    max_precision_length = 2;
258
259
		  /* Test for positional argument.  */
260
		  if (*cp >= '0' && *cp <= '9')
261
		    {
262
		      const CHAR_T *np;
263
264
		      for (np = cp; *np >= '0' && *np <= '9'; np++)
265
			;
266
		      if (*np == '$')
267
			{
268
			  size_t n = 0;
269
270
			  for (np = cp; *np >= '0' && *np <= '9'; np++)
271
			    n = xsum (xtimes (n, 10), *np - '0');
272
			  if (n == 0)
273
			    /* Positional argument 0.  */
274
			    goto error;
275
			  if (size_overflow_p (n))
276
			    /* n too large, would lead to out of memory
277
			       later.  */
278
			    goto error;
279
			  dp->precision_arg_index = n - 1;
280
			  cp = np + 1;
281
			}
282
		    }
283
		  if (dp->precision_arg_index == ARG_NONE)
284
		    {
285
		      dp->precision_arg_index = arg_posn++;
286
		      if (dp->precision_arg_index == ARG_NONE)
287
			/* arg_posn wrapped around.  */
288
			goto error;
289
		    }
290
		  REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
291
		}
292
	      else
293
		{
294
		  size_t precision_length;
295
296
		  dp->precision_start = cp - 1;
297
		  for (; *cp >= '0' && *cp <= '9'; cp++)
298
		    ;
299
		  dp->precision_end = cp;
300
		  precision_length = dp->precision_end - dp->precision_start;
301
		  if (max_precision_length < precision_length)
302
		    max_precision_length = precision_length;
303
		}
304
	    }
305
306
	  {
307
	    arg_type type;
308
309
	    /* Parse argument type/size specifiers.  */
310
	    {
311
	      int flags = 0;
312
313
	      for (;;)
314
		{
315
		  if (*cp == 'h')
316
		    {
317
		      flags |= (1 << (flags & 1));
318
		      cp++;
319
		    }
320
		  else if (*cp == 'L')
321
		    {
322
		      flags |= 4;
323
		      cp++;
324
		    }
325
		  else if (*cp == 'l')
326
		    {
327
		      flags += 8;
328
		      cp++;
329
		    }
330
#ifdef HAVE_INTMAX_T
331
		  else if (*cp == 'j')
332
		    {
333
		      if (sizeof (intmax_t) > sizeof (long))
334
			{
335
			  /* intmax_t = long long */
336
			  flags += 16;
337
			}
338
		      else if (sizeof (intmax_t) > sizeof (int))
339
			{
340
			  /* intmax_t = long */
341
			  flags += 8;
342
			}
343
		      cp++;
344
		    }
345
#endif
346
		  else if (*cp == 'z' || *cp == 'Z')
347
		    {
348
		      /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
349
			 because the warning facility in gcc-2.95.2 understands
350
			 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784).  */
351
		      if (sizeof (size_t) > sizeof (long))
352
			{
353
			  /* size_t = long long */
354
			  flags += 16;
355
			}
356
		      else if (sizeof (size_t) > sizeof (int))
357
			{
358
			  /* size_t = long */
359
			  flags += 8;
360
			}
361
		      cp++;
362
		    }
363
		  else if (*cp == 't')
364
		    {
365
		      if (sizeof (ptrdiff_t) > sizeof (long))
366
			{
367
			  /* ptrdiff_t = long long */
368
			  flags += 16;
369
			}
370
		      else if (sizeof (ptrdiff_t) > sizeof (int))
371
			{
372
			  /* ptrdiff_t = long */
373
			  flags += 8;
374
			}
375
		      cp++;
376
		    }
377
		  else
378
		    break;
379
		}
380
381
	      /* Read the conversion character.  */
382
	      c = *cp++;
383
	      switch (c)
384
		{
385
		case 'd': case 'i':
386
#ifdef HAVE_LONG_LONG_INT
387
		  /* If 'long long' exists and is larger than 'long':  */
388
		  if (flags >= 16 || (flags & 4))
389
		    type = TYPE_LONGLONGINT;
390
		  else
391
#endif
392
		  /* If 'long long' exists and is the same as 'long', we parse
393
		     "lld" into TYPE_LONGINT.  */
394
		  if (flags >= 8)
395
		    type = TYPE_LONGINT;
396
		  else if (flags & 2)
397
		    type = TYPE_SCHAR;
398
		  else if (flags & 1)
399
		    type = TYPE_SHORT;
400
		  else
401
		    type = TYPE_INT;
402
		  break;
403
		case 'o': case 'u': case 'x': case 'X':
404
#ifdef HAVE_LONG_LONG_INT
405
		  /* If 'long long' exists and is larger than 'long':  */
406
		  if (flags >= 16 || (flags & 4))
407
		    type = TYPE_ULONGLONGINT;
408
		  else
409
#endif
410
		  /* If 'unsigned long long' exists and is the same as
411
		     'unsigned long', we parse "llu" into TYPE_ULONGINT.  */
412
		  if (flags >= 8)
413
		    type = TYPE_ULONGINT;
414
		  else if (flags & 2)
415
		    type = TYPE_UCHAR;
416
		  else if (flags & 1)
417
		    type = TYPE_USHORT;
418
		  else
419
		    type = TYPE_UINT;
420
		  break;
421
		case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
422
		case 'a': case 'A':
423
#ifdef HAVE_LONG_DOUBLE
424
		  if (flags >= 16 || (flags & 4))
425
		    type = TYPE_LONGDOUBLE;
426
		  else
427
#endif
428
		  type = TYPE_DOUBLE;
429
		  break;
430
		case 'c':
431
		  if (flags >= 8)
432
#ifdef HAVE_WINT_T
433
		    type = TYPE_WIDE_CHAR;
434
#else
435
		    goto error;
436
#endif
437
		  else
438
		    type = TYPE_CHAR;
439
		  break;
440
#ifdef HAVE_WINT_T
441
		case 'C':
442
		  type = TYPE_WIDE_CHAR;
443
		  c = 'c';
444
		  break;
445
#endif
446
		case 's':
447
		  if (flags >= 8)
448
#ifdef HAVE_WCHAR_T
449
		    type = TYPE_WIDE_STRING;
450
#else
451
		    goto error;
452
#endif
453
		  else
454
		    type = TYPE_STRING;
455
		  break;
456
#ifdef HAVE_WCHAR_T
457
		case 'S':
458
		  type = TYPE_WIDE_STRING;
459
		  c = 's';
460
		  break;
461
#endif
462
		case 'p':
463
		  type = TYPE_POINTER;
464
		  break;
465
		case 'n':
466
#ifdef HAVE_LONG_LONG_INT
467
		  /* If 'long long' exists and is larger than 'long':  */
468
		  if (flags >= 16 || (flags & 4))
469
		    type = TYPE_COUNT_LONGLONGINT_POINTER;
470
		  else
471
#endif
472
		  /* If 'long long' exists and is the same as 'long', we parse
473
		     "lln" into TYPE_COUNT_LONGINT_POINTER.  */
474
		  if (flags >= 8)
475
		    type = TYPE_COUNT_LONGINT_POINTER;
476
		  else if (flags & 2)
477
		    type = TYPE_COUNT_SCHAR_POINTER;
478
		  else if (flags & 1)
479
		    type = TYPE_COUNT_SHORT_POINTER;
480
		  else
481
		    type = TYPE_COUNT_INT_POINTER;
482
		  break;
483
		case '%':
484
		  type = TYPE_NONE;
485
		  break;
486
		default:
487
		  /* Unknown conversion character.  */
488
		  goto error;
489
		}
490
	    }
491
492
	    if (type != TYPE_NONE)
493
	      {
494
		dp->arg_index = arg_index;
495
		if (dp->arg_index == ARG_NONE)
496
		  {
497
		    dp->arg_index = arg_posn++;
498
		    if (dp->arg_index == ARG_NONE)
499
		      /* arg_posn wrapped around.  */
500
		      goto error;
501
		  }
502
		REGISTER_ARG (dp->arg_index, type);
503
	      }
504
	    dp->conversion = c;
505
	    dp->dir_end = cp;
506
	  }
507
508
	  d->count++;
509
	  if (d->count >= d_allocated)
510
	    {
511
	      size_t memory_size;
512
	      DIRECTIVE *memory;
513
514
	      d_allocated = xtimes (d_allocated, 2);
515
	      memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
516
	      if (size_overflow_p (memory_size))
517
		/* Overflow, would lead to out of memory.  */
518
		goto error;
519
	      memory = realloc (d->dir, memory_size);
520
	      if (memory == NULL)
521
		/* Out of memory.  */
522
		goto error;
523
	      d->dir = memory;
524
	    }
525
	}
526
    }
527
  d->dir[d->count].dir_start = cp;
528
529
  d->max_width_length = max_width_length;
530
  d->max_precision_length = max_precision_length;
531
  return 0;
532
533
error:
534
  if (a->arg)
535
    free (a->arg);
536
  if (d->dir)
537
    free (d->dir);
538
  return -1;
539
}
540
541
#undef DIRECTIVES
542
#undef DIRECTIVE
543
#undef CHAR_T
544
#undef PRINTF_PARSE
(-)a/intl/printf-parse.h (-75 lines)
Lines 1-75 Link Here
1
/* Parse printf format string.
2
   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _PRINTF_PARSE_H
20
#define _PRINTF_PARSE_H
21
22
#include "printf-args.h"
23
24
25
/* Flags */
26
#define FLAG_GROUP	 1	/* ' flag */
27
#define FLAG_LEFT	 2	/* - flag */
28
#define FLAG_SHOWSIGN	 4	/* + flag */
29
#define FLAG_SPACE	 8	/* space flag */
30
#define FLAG_ALT	16	/* # flag */
31
#define FLAG_ZERO	32
32
33
/* arg_index value indicating that no argument is consumed.  */
34
#define ARG_NONE	(~(size_t)0)
35
36
/* A parsed directive.  */
37
typedef struct
38
{
39
  const char* dir_start;
40
  const char* dir_end;
41
  int flags;
42
  const char* width_start;
43
  const char* width_end;
44
  size_t width_arg_index;
45
  const char* precision_start;
46
  const char* precision_end;
47
  size_t precision_arg_index;
48
  char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
49
  size_t arg_index;
50
}
51
char_directive;
52
53
/* A parsed format string.  */
54
typedef struct
55
{
56
  size_t count;
57
  char_directive *dir;
58
  size_t max_width_length;
59
  size_t max_precision_length;
60
}
61
char_directives;
62
63
64
/* Parses the format string.  Fills in the number N of directives, and fills
65
   in directives[0], ..., directives[N-1], and sets directives[N].dir_start
66
   to the end of the format string.  Also fills in the arg_type fields of the
67
   arguments and the needed count of arguments.  */
68
#ifdef STATIC
69
STATIC
70
#else
71
extern
72
#endif
73
int printf_parse (const char *format, char_directives *d, arguments *a);
74
75
#endif /* _PRINTF_PARSE_H */
(-)a/intl/printf.c (-422 lines)
Lines 1-422 Link Here
1
/* Formatted output to strings, using POSIX/XSI format strings with positions.
2
   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2003.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifdef HAVE_CONFIG_H
21
# include <config.h>
22
#endif
23
24
#ifdef __GNUC__
25
# define alloca __builtin_alloca
26
# define HAVE_ALLOCA 1
27
#else
28
# ifdef _MSC_VER
29
#  include <malloc.h>
30
#  define alloca _alloca
31
# else
32
#  if defined HAVE_ALLOCA_H || defined _LIBC
33
#   include <alloca.h>
34
#  else
35
#   ifdef _AIX
36
 #pragma alloca
37
#   else
38
#    ifndef alloca
39
char *alloca ();
40
#    endif
41
#   endif
42
#  endif
43
# endif
44
#endif
45
46
#include <stdio.h>
47
48
#if !HAVE_POSIX_PRINTF
49
50
#include <errno.h>
51
#include <limits.h>
52
#include <stdlib.h>
53
#include <string.h>
54
55
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW.  */
56
#ifndef EOVERFLOW
57
# define EOVERFLOW E2BIG
58
#endif
59
60
/* When building a DLL, we must export some functions.  Note that because
61
   the functions are only defined for binary backward compatibility, we
62
   don't need to use __declspec(dllimport) in any case.  */
63
#if defined _MSC_VER && BUILDING_DLL
64
# define DLL_EXPORTED __declspec(dllexport)
65
#else
66
# define DLL_EXPORTED
67
#endif
68
69
#define STATIC static
70
71
/* This needs to be consistent with libgnuintl.h.in.  */
72
#if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__
73
/* Don't break __attribute__((format(printf,M,N))).
74
   This redefinition is only possible because the libc in NetBSD, Cygwin,
75
   mingw does not have a function __printf__.  */
76
# define libintl_printf __printf__
77
#endif
78
79
/* Define auxiliary functions declared in "printf-args.h".  */
80
#include "printf-args.c"
81
82
/* Define auxiliary functions declared in "printf-parse.h".  */
83
#include "printf-parse.c"
84
85
/* Define functions declared in "vasnprintf.h".  */
86
#define vasnprintf libintl_vasnprintf
87
#include "vasnprintf.c"
88
#if 0 /* not needed */
89
#define asnprintf libintl_asnprintf
90
#include "asnprintf.c"
91
#endif
92
93
DLL_EXPORTED
94
int
95
libintl_vfprintf (FILE *stream, const char *format, va_list args)
96
{
97
  if (strchr (format, '$') == NULL)
98
    return vfprintf (stream, format, args);
99
  else
100
    {
101
      size_t length;
102
      char *result = libintl_vasnprintf (NULL, &length, format, args);
103
      int retval = -1;
104
      if (result != NULL)
105
	{
106
	  size_t written = fwrite (result, 1, length, stream);
107
	  free (result);
108
	  if (written == length)
109
	    {
110
	      if (length > INT_MAX)
111
		errno = EOVERFLOW;
112
	      else
113
		retval = length;
114
	    }
115
	}
116
      return retval;
117
    }
118
}
119
120
DLL_EXPORTED
121
int
122
libintl_fprintf (FILE *stream, const char *format, ...)
123
{
124
  va_list args;
125
  int retval;
126
127
  va_start (args, format);
128
  retval = libintl_vfprintf (stream, format, args);
129
  va_end (args);
130
  return retval;
131
}
132
133
DLL_EXPORTED
134
int
135
libintl_vprintf (const char *format, va_list args)
136
{
137
  return libintl_vfprintf (stdout, format, args);
138
}
139
140
DLL_EXPORTED
141
int
142
libintl_printf (const char *format, ...)
143
{
144
  va_list args;
145
  int retval;
146
147
  va_start (args, format);
148
  retval = libintl_vprintf (format, args);
149
  va_end (args);
150
  return retval;
151
}
152
153
DLL_EXPORTED
154
int
155
libintl_vsprintf (char *resultbuf, const char *format, va_list args)
156
{
157
  if (strchr (format, '$') == NULL)
158
    return vsprintf (resultbuf, format, args);
159
  else
160
    {
161
      size_t length = (size_t) ~0 / (4 * sizeof (char));
162
      char *result = libintl_vasnprintf (resultbuf, &length, format, args);
163
      if (result != resultbuf)
164
	{
165
	  free (result);
166
	  return -1;
167
	}
168
      if (length > INT_MAX)
169
	{
170
	  errno = EOVERFLOW;
171
	  return -1;
172
	}
173
      else
174
	return length;
175
    }
176
}
177
178
DLL_EXPORTED
179
int
180
libintl_sprintf (char *resultbuf, const char *format, ...)
181
{
182
  va_list args;
183
  int retval;
184
185
  va_start (args, format);
186
  retval = libintl_vsprintf (resultbuf, format, args);
187
  va_end (args);
188
  return retval;
189
}
190
191
#if HAVE_SNPRINTF
192
193
# if HAVE_DECL__SNPRINTF
194
   /* Windows.  */
195
#  define system_vsnprintf _vsnprintf
196
# else
197
   /* Unix.  */
198
#  define system_vsnprintf vsnprintf
199
# endif
200
201
DLL_EXPORTED
202
int
203
libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args)
204
{
205
  if (strchr (format, '$') == NULL)
206
    return system_vsnprintf (resultbuf, length, format, args);
207
  else
208
    {
209
      size_t maxlength = length;
210
      char *result = libintl_vasnprintf (resultbuf, &length, format, args);
211
      if (result != resultbuf)
212
	{
213
	  if (maxlength > 0)
214
	    {
215
	      size_t pruned_length =
216
		(length < maxlength ? length : maxlength - 1);
217
	      memcpy (resultbuf, result, pruned_length);
218
	      resultbuf[pruned_length] = '\0';
219
	    }
220
	  free (result);
221
	}
222
      if (length > INT_MAX)
223
	{
224
	  errno = EOVERFLOW;
225
	  return -1;
226
	}
227
      else
228
	return length;
229
    }
230
}
231
232
DLL_EXPORTED
233
int
234
libintl_snprintf (char *resultbuf, size_t length, const char *format, ...)
235
{
236
  va_list args;
237
  int retval;
238
239
  va_start (args, format);
240
  retval = libintl_vsnprintf (resultbuf, length, format, args);
241
  va_end (args);
242
  return retval;
243
}
244
245
#endif
246
247
#if HAVE_ASPRINTF
248
249
DLL_EXPORTED
250
int
251
libintl_vasprintf (char **resultp, const char *format, va_list args)
252
{
253
  size_t length;
254
  char *result = libintl_vasnprintf (NULL, &length, format, args);
255
  if (result == NULL)
256
    return -1;
257
  if (length > INT_MAX)
258
    {
259
      free (result);
260
      errno = EOVERFLOW;
261
      return -1;
262
    }
263
  *resultp = result;
264
  return length;
265
}
266
267
DLL_EXPORTED
268
int
269
libintl_asprintf (char **resultp, const char *format, ...)
270
{
271
  va_list args;
272
  int retval;
273
274
  va_start (args, format);
275
  retval = libintl_vasprintf (resultp, format, args);
276
  va_end (args);
277
  return retval;
278
}
279
280
#endif
281
282
#if HAVE_FWPRINTF
283
284
#include <wchar.h>
285
286
#define WIDE_CHAR_VERSION 1
287
288
/* Define auxiliary functions declared in "wprintf-parse.h".  */
289
#include "printf-parse.c"
290
291
/* Define functions declared in "vasnprintf.h".  */
292
#define vasnwprintf libintl_vasnwprintf
293
#include "vasnprintf.c"
294
#if 0 /* not needed */
295
#define asnwprintf libintl_asnwprintf
296
#include "asnprintf.c"
297
#endif
298
299
# if HAVE_DECL__SNWPRINTF
300
   /* Windows.  */
301
#  define system_vswprintf _vsnwprintf
302
# else
303
   /* Unix.  */
304
#  define system_vswprintf vswprintf
305
# endif
306
307
DLL_EXPORTED
308
int
309
libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args)
310
{
311
  if (wcschr (format, '$') == NULL)
312
    return vfwprintf (stream, format, args);
313
  else
314
    {
315
      size_t length;
316
      wchar_t *result = libintl_vasnwprintf (NULL, &length, format, args);
317
      int retval = -1;
318
      if (result != NULL)
319
	{
320
	  size_t i;
321
	  for (i = 0; i < length; i++)
322
	    if (fputwc (result[i], stream) == WEOF)
323
	      break;
324
	  free (result);
325
	  if (i == length)
326
	    {
327
	      if (length > INT_MAX)
328
		errno = EOVERFLOW;
329
	      else
330
		retval = length;
331
	    }
332
	}
333
      return retval;
334
    }
335
}
336
337
DLL_EXPORTED
338
int
339
libintl_fwprintf (FILE *stream, const wchar_t *format, ...)
340
{
341
  va_list args;
342
  int retval;
343
344
  va_start (args, format);
345
  retval = libintl_vfwprintf (stream, format, args);
346
  va_end (args);
347
  return retval;
348
}
349
350
DLL_EXPORTED
351
int
352
libintl_vwprintf (const wchar_t *format, va_list args)
353
{
354
  return libintl_vfwprintf (stdout, format, args);
355
}
356
357
DLL_EXPORTED
358
int
359
libintl_wprintf (const wchar_t *format, ...)
360
{
361
  va_list args;
362
  int retval;
363
364
  va_start (args, format);
365
  retval = libintl_vwprintf (format, args);
366
  va_end (args);
367
  return retval;
368
}
369
370
DLL_EXPORTED
371
int
372
libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_list args)
373
{
374
  if (wcschr (format, '$') == NULL)
375
    return system_vswprintf (resultbuf, length, format, args);
376
  else
377
    {
378
      size_t maxlength = length;
379
      wchar_t *result = libintl_vasnwprintf (resultbuf, &length, format, args);
380
      if (result != resultbuf)
381
	{
382
	  if (maxlength > 0)
383
	    {
384
	      size_t pruned_length =
385
		(length < maxlength ? length : maxlength - 1);
386
	      memcpy (resultbuf, result, pruned_length * sizeof (wchar_t));
387
	      resultbuf[pruned_length] = 0;
388
	    }
389
	  free (result);
390
	  /* Unlike vsnprintf, which has to return the number of character that
391
	     would have been produced if the resultbuf had been sufficiently
392
	     large, the vswprintf function has to return a negative value if
393
	     the resultbuf was not sufficiently large.  */
394
	  if (length >= maxlength)
395
	    return -1;
396
	}
397
      if (length > INT_MAX)
398
	{
399
	  errno = EOVERFLOW;
400
	  return -1;
401
	}
402
      else
403
	return length;
404
    }
405
}
406
407
DLL_EXPORTED
408
int
409
libintl_swprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, ...)
410
{
411
  va_list args;
412
  int retval;
413
414
  va_start (args, format);
415
  retval = libintl_vswprintf (resultbuf, length, format, args);
416
  va_end (args);
417
  return retval;
418
}
419
420
#endif
421
422
#endif
(-)a/intl/ref-add.sin (-31 lines)
Lines 1-31 Link Here
1
# Add this package to a list of references stored in a text file.
2
#
3
#   Copyright (C) 2000 Free Software Foundation, Inc.
4
#
5
#   This program is free software; you can redistribute it and/or modify it
6
#   under the terms of the GNU Library General Public License as published
7
#   by the Free Software Foundation; either version 2, or (at your option)
8
#   any later version.
9
#
10
#   This program is distributed in the hope that it will be useful,
11
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
#   Library General Public License for more details.
14
#
15
#   You should have received a copy of the GNU Library General Public
16
#   License along with this program; if not, write to the Free Software
17
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
#   USA.
19
#
20
# Written by Bruno Haible <haible@clisp.cons.org>.
21
#
22
/^# Packages using this file: / {
23
  s/# Packages using this file://
24
  ta
25
  :a
26
  s/ @PACKAGE@ / @PACKAGE@ /
27
  tb
28
  s/ $/ @PACKAGE@ /
29
  :b
30
  s/^/# Packages using this file:/
31
}
(-)a/intl/ref-del.sin (-26 lines)
Lines 1-26 Link Here
1
# Remove this package from a list of references stored in a text file.
2
#
3
#   Copyright (C) 2000 Free Software Foundation, Inc.
4
#
5
#   This program is free software; you can redistribute it and/or modify it
6
#   under the terms of the GNU Library General Public License as published
7
#   by the Free Software Foundation; either version 2, or (at your option)
8
#   any later version.
9
#
10
#   This program is distributed in the hope that it will be useful,
11
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
#   Library General Public License for more details.
14
#
15
#   You should have received a copy of the GNU Library General Public
16
#   License along with this program; if not, write to the Free Software
17
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
#   USA.
19
#
20
# Written by Bruno Haible <haible@clisp.cons.org>.
21
#
22
/^# Packages using this file: / {
23
  s/# Packages using this file://
24
  s/ @PACKAGE@ / /
25
  s/^/# Packages using this file:/
26
}
(-)a/intl/relocatable.c (-468 lines)
Lines 1-468 Link Here
1
/* Provide relocatable packages.
2
   Copyright (C) 2003-2006 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2003.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
21
/* Tell glibc's <stdio.h> to provide a prototype for getline().
22
   This must come before <config.h> because <config.h> may include
23
   <features.h>, and once <features.h> has been included, it's too late.  */
24
#ifndef _GNU_SOURCE
25
# define _GNU_SOURCE	1
26
#endif
27
28
#include <config.h>
29
30
/* Specification.  */
31
#include "relocatable.h"
32
33
#if ENABLE_RELOCATABLE
34
35
#include <stddef.h>
36
#include <stdio.h>
37
#include <stdlib.h>
38
#include <string.h>
39
40
#ifdef NO_XMALLOC
41
# define xmalloc malloc
42
#else
43
# include "xalloc.h"
44
#endif
45
46
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
47
# define WIN32_LEAN_AND_MEAN
48
# include <windows.h>
49
#endif
50
51
#if DEPENDS_ON_LIBCHARSET
52
# include <libcharset.h>
53
#endif
54
#if DEPENDS_ON_LIBICONV && HAVE_ICONV
55
# include <iconv.h>
56
#endif
57
#if DEPENDS_ON_LIBINTL && ENABLE_NLS
58
# include <libintl.h>
59
#endif
60
61
/* Faked cheap 'bool'.  */
62
#undef bool
63
#undef false
64
#undef true
65
#define bool int
66
#define false 0
67
#define true 1
68
69
/* Pathname support.
70
   ISSLASH(C)           tests whether C is a directory separator character.
71
   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
72
 */
73
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
74
  /* Win32, Cygwin, OS/2, DOS */
75
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
76
# define HAS_DEVICE(P) \
77
    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
78
     && (P)[1] == ':')
79
# define IS_PATH_WITH_DIR(P) \
80
    (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
81
# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
82
#else
83
  /* Unix */
84
# define ISSLASH(C) ((C) == '/')
85
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
86
# define FILE_SYSTEM_PREFIX_LEN(P) 0
87
#endif
88
89
/* Original installation prefix.  */
90
static char *orig_prefix;
91
static size_t orig_prefix_len;
92
/* Current installation prefix.  */
93
static char *curr_prefix;
94
static size_t curr_prefix_len;
95
/* These prefixes do not end in a slash.  Anything that will be concatenated
96
   to them must start with a slash.  */
97
98
/* Sets the original and the current installation prefix of this module.
99
   Relocation simply replaces a pathname starting with the original prefix
100
   by the corresponding pathname with the current prefix instead.  Both
101
   prefixes should be directory names without trailing slash (i.e. use ""
102
   instead of "/").  */
103
static void
104
set_this_relocation_prefix (const char *orig_prefix_arg,
105
			    const char *curr_prefix_arg)
106
{
107
  if (orig_prefix_arg != NULL && curr_prefix_arg != NULL
108
      /* Optimization: if orig_prefix and curr_prefix are equal, the
109
	 relocation is a nop.  */
110
      && strcmp (orig_prefix_arg, curr_prefix_arg) != 0)
111
    {
112
      /* Duplicate the argument strings.  */
113
      char *memory;
114
115
      orig_prefix_len = strlen (orig_prefix_arg);
116
      curr_prefix_len = strlen (curr_prefix_arg);
117
      memory = (char *) xmalloc (orig_prefix_len + 1 + curr_prefix_len + 1);
118
#ifdef NO_XMALLOC
119
      if (memory != NULL)
120
#endif
121
	{
122
	  memcpy (memory, orig_prefix_arg, orig_prefix_len + 1);
123
	  orig_prefix = memory;
124
	  memory += orig_prefix_len + 1;
125
	  memcpy (memory, curr_prefix_arg, curr_prefix_len + 1);
126
	  curr_prefix = memory;
127
	  return;
128
	}
129
    }
130
  orig_prefix = NULL;
131
  curr_prefix = NULL;
132
  /* Don't worry about wasted memory here - this function is usually only
133
     called once.  */
134
}
135
136
/* Sets the original and the current installation prefix of the package.
137
   Relocation simply replaces a pathname starting with the original prefix
138
   by the corresponding pathname with the current prefix instead.  Both
139
   prefixes should be directory names without trailing slash (i.e. use ""
140
   instead of "/").  */
141
void
142
set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg)
143
{
144
  set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
145
146
  /* Now notify all dependent libraries.  */
147
#if DEPENDS_ON_LIBCHARSET
148
  libcharset_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
149
#endif
150
#if DEPENDS_ON_LIBICONV && HAVE_ICONV && _LIBICONV_VERSION >= 0x0109
151
  libiconv_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
152
#endif
153
#if DEPENDS_ON_LIBINTL && ENABLE_NLS && defined libintl_set_relocation_prefix
154
  libintl_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
155
#endif
156
}
157
158
#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR)
159
160
/* Convenience function:
161
   Computes the current installation prefix, based on the original
162
   installation prefix, the original installation directory of a particular
163
   file, and the current pathname of this file.  Returns NULL upon failure.  */
164
#ifdef IN_LIBRARY
165
#define compute_curr_prefix local_compute_curr_prefix
166
static
167
#endif
168
const char *
169
compute_curr_prefix (const char *orig_installprefix,
170
		     const char *orig_installdir,
171
		     const char *curr_pathname)
172
{
173
  const char *curr_installdir;
174
  const char *rel_installdir;
175
176
  if (curr_pathname == NULL)
177
    return NULL;
178
179
  /* Determine the relative installation directory, relative to the prefix.
180
     This is simply the difference between orig_installprefix and
181
     orig_installdir.  */
182
  if (strncmp (orig_installprefix, orig_installdir, strlen (orig_installprefix))
183
      != 0)
184
    /* Shouldn't happen - nothing should be installed outside $(prefix).  */
185
    return NULL;
186
  rel_installdir = orig_installdir + strlen (orig_installprefix);
187
188
  /* Determine the current installation directory.  */
189
  {
190
    const char *p_base = curr_pathname + FILE_SYSTEM_PREFIX_LEN (curr_pathname);
191
    const char *p = curr_pathname + strlen (curr_pathname);
192
    char *q;
193
194
    while (p > p_base)
195
      {
196
	p--;
197
	if (ISSLASH (*p))
198
	  break;
199
      }
200
201
    q = (char *) xmalloc (p - curr_pathname + 1);
202
#ifdef NO_XMALLOC
203
    if (q == NULL)
204
      return NULL;
205
#endif
206
    memcpy (q, curr_pathname, p - curr_pathname);
207
    q[p - curr_pathname] = '\0';
208
    curr_installdir = q;
209
  }
210
211
  /* Compute the current installation prefix by removing the trailing
212
     rel_installdir from it.  */
213
  {
214
    const char *rp = rel_installdir + strlen (rel_installdir);
215
    const char *cp = curr_installdir + strlen (curr_installdir);
216
    const char *cp_base =
217
      curr_installdir + FILE_SYSTEM_PREFIX_LEN (curr_installdir);
218
219
    while (rp > rel_installdir && cp > cp_base)
220
      {
221
	bool same = false;
222
	const char *rpi = rp;
223
	const char *cpi = cp;
224
225
	while (rpi > rel_installdir && cpi > cp_base)
226
	  {
227
	    rpi--;
228
	    cpi--;
229
	    if (ISSLASH (*rpi) || ISSLASH (*cpi))
230
	      {
231
		if (ISSLASH (*rpi) && ISSLASH (*cpi))
232
		  same = true;
233
		break;
234
	      }
235
	    /* Do case-insensitive comparison if the filesystem is always or
236
	       often case-insensitive.  It's better to accept the comparison
237
	       if the difference is only in case, rather than to fail.  */
238
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
239
	    /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */
240
	    if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
241
		!= (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
242
	      break;
243
#else
244
	    if (*rpi != *cpi)
245
	      break;
246
#endif
247
	  }
248
	if (!same)
249
	  break;
250
	/* The last pathname component was the same.  opi and cpi now point
251
	   to the slash before it.  */
252
	rp = rpi;
253
	cp = cpi;
254
      }
255
256
    if (rp > rel_installdir)
257
      /* Unexpected: The curr_installdir does not end with rel_installdir.  */
258
      return NULL;
259
260
    {
261
      size_t curr_prefix_len = cp - curr_installdir;
262
      char *curr_prefix;
263
264
      curr_prefix = (char *) xmalloc (curr_prefix_len + 1);
265
#ifdef NO_XMALLOC
266
      if (curr_prefix == NULL)
267
	return NULL;
268
#endif
269
      memcpy (curr_prefix, curr_installdir, curr_prefix_len);
270
      curr_prefix[curr_prefix_len] = '\0';
271
272
      return curr_prefix;
273
    }
274
  }
275
}
276
277
#endif /* !IN_LIBRARY || PIC */
278
279
#if defined PIC && defined INSTALLDIR
280
281
/* Full pathname of shared library, or NULL.  */
282
static char *shared_library_fullname;
283
284
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
285
286
/* Determine the full pathname of the shared library when it is loaded.  */
287
288
BOOL WINAPI
289
DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
290
{
291
  (void) reserved;
292
293
  if (event == DLL_PROCESS_ATTACH)
294
    {
295
      /* The DLL is being loaded into an application's address range.  */
296
      static char location[MAX_PATH];
297
298
      if (!GetModuleFileName (module_handle, location, sizeof (location)))
299
	/* Shouldn't happen.  */
300
	return FALSE;
301
302
      if (!IS_PATH_WITH_DIR (location))
303
	/* Shouldn't happen.  */
304
	return FALSE;
305
306
      {
307
#if defined __CYGWIN__
308
	/* On Cygwin, we need to convert paths coming from Win32 system calls
309
	   to the Unix-like slashified notation.  */
310
	static char location_as_posix_path[2 * MAX_PATH];
311
	/* There's no error return defined for cygwin_conv_to_posix_path.
312
	   See cygwin-api/func-cygwin-conv-to-posix-path.html.
313
	   Does it overflow the buffer of expected size MAX_PATH or does it
314
	   truncate the path?  I don't know.  Let's catch both.  */
315
	cygwin_conv_to_posix_path (location, location_as_posix_path);
316
	location_as_posix_path[MAX_PATH - 1] = '\0';
317
	if (strlen (location_as_posix_path) >= MAX_PATH - 1)
318
	  /* A sign of buffer overflow or path truncation.  */
319
	  return FALSE;
320
	shared_library_fullname = strdup (location_as_posix_path);
321
#else
322
	shared_library_fullname = strdup (location);
323
#endif
324
      }
325
    }
326
327
  return TRUE;
328
}
329
330
#else /* Unix except Cygwin */
331
332
static void
333
find_shared_library_fullname ()
334
{
335
#if defined __linux__ && __GLIBC__ >= 2
336
  /* Linux has /proc/self/maps. glibc 2 has the getline() function.  */
337
  FILE *fp;
338
339
  /* Open the current process' maps file.  It describes one VMA per line.  */
340
  fp = fopen ("/proc/self/maps", "r");
341
  if (fp)
342
    {
343
      unsigned long address = (unsigned long) &find_shared_library_fullname;
344
      for (;;)
345
	{
346
	  unsigned long start, end;
347
	  int c;
348
349
	  if (fscanf (fp, "%lx-%lx", &start, &end) != 2)
350
	    break;
351
	  if (address >= start && address <= end - 1)
352
	    {
353
	      /* Found it.  Now see if this line contains a filename.  */
354
	      while (c = getc (fp), c != EOF && c != '\n' && c != '/')
355
		continue;
356
	      if (c == '/')
357
		{
358
		  size_t size;
359
		  int len;
360
361
		  ungetc (c, fp);
362
		  shared_library_fullname = NULL; size = 0;
363
		  len = getline (&shared_library_fullname, &size, fp);
364
		  if (len >= 0)
365
		    {
366
		      /* Success: filled shared_library_fullname.  */
367
		      if (len > 0 && shared_library_fullname[len - 1] == '\n')
368
			shared_library_fullname[len - 1] = '\0';
369
		    }
370
		}
371
	      break;
372
	    }
373
	  while (c = getc (fp), c != EOF && c != '\n')
374
	    continue;
375
	}
376
      fclose (fp);
377
    }
378
#endif
379
}
380
381
#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */
382
383
/* Return the full pathname of the current shared library.
384
   Return NULL if unknown.
385
   Guaranteed to work only on Linux, Cygwin and Woe32.  */
386
static char *
387
get_shared_library_fullname ()
388
{
389
#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__)
390
  static bool tried_find_shared_library_fullname;
391
  if (!tried_find_shared_library_fullname)
392
    {
393
      find_shared_library_fullname ();
394
      tried_find_shared_library_fullname = true;
395
    }
396
#endif
397
  return shared_library_fullname;
398
}
399
400
#endif /* PIC */
401
402
/* Returns the pathname, relocated according to the current installation
403
   directory.  */
404
const char *
405
relocate (const char *pathname)
406
{
407
#if defined PIC && defined INSTALLDIR
408
  static int initialized;
409
410
  /* Initialization code for a shared library.  */
411
  if (!initialized)
412
    {
413
      /* At this point, orig_prefix and curr_prefix likely have already been
414
	 set through the main program's set_program_name_and_installdir
415
	 function.  This is sufficient in the case that the library has
416
	 initially been installed in the same orig_prefix.  But we can do
417
	 better, to also cover the cases that 1. it has been installed
418
	 in a different prefix before being moved to orig_prefix and (later)
419
	 to curr_prefix, 2. unlike the program, it has not moved away from
420
	 orig_prefix.  */
421
      const char *orig_installprefix = INSTALLPREFIX;
422
      const char *orig_installdir = INSTALLDIR;
423
      const char *curr_prefix_better;
424
425
      curr_prefix_better =
426
	compute_curr_prefix (orig_installprefix, orig_installdir,
427
			     get_shared_library_fullname ());
428
      if (curr_prefix_better == NULL)
429
	curr_prefix_better = curr_prefix;
430
431
      set_relocation_prefix (orig_installprefix, curr_prefix_better);
432
433
      initialized = 1;
434
    }
435
#endif
436
437
  /* Note: It is not necessary to perform case insensitive comparison here,
438
     even for DOS-like filesystems, because the pathname argument was
439
     typically created from the same Makefile variable as orig_prefix came
440
     from.  */
441
  if (orig_prefix != NULL && curr_prefix != NULL
442
      && strncmp (pathname, orig_prefix, orig_prefix_len) == 0)
443
    {
444
      if (pathname[orig_prefix_len] == '\0')
445
	/* pathname equals orig_prefix.  */
446
	return curr_prefix;
447
      if (ISSLASH (pathname[orig_prefix_len]))
448
	{
449
	  /* pathname starts with orig_prefix.  */
450
	  const char *pathname_tail = &pathname[orig_prefix_len];
451
	  char *result =
452
	    (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);
453
454
#ifdef NO_XMALLOC
455
	  if (result != NULL)
456
#endif
457
	    {
458
	      memcpy (result, curr_prefix, curr_prefix_len);
459
	      strcpy (result + curr_prefix_len, pathname_tail);
460
	      return result;
461
	    }
462
	}
463
    }
464
  /* Nothing to relocate.  */
465
  return pathname;
466
}
467
468
#endif
(-)a/intl/relocatable.h (-79 lines)
Lines 1-79 Link Here
1
/* Provide relocatable packages.
2
   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
3
   Written by Bruno Haible <bruno@clisp.org>, 2003.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifndef _RELOCATABLE_H
21
#define _RELOCATABLE_H
22
23
#ifdef __cplusplus
24
extern "C" {
25
#endif
26
27
28
/* This can be enabled through the configure --enable-relocatable option.  */
29
#if ENABLE_RELOCATABLE
30
31
/* When building a DLL, we must export some functions.  Note that because
32
   this is a private .h file, we don't need to use __declspec(dllimport)
33
   in any case.  */
34
#if HAVE_VISIBILITY && BUILDING_DLL
35
# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default")))
36
#elif defined _MSC_VER && BUILDING_DLL
37
# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
38
#else
39
# define RELOCATABLE_DLL_EXPORTED
40
#endif
41
42
/* Sets the original and the current installation prefix of the package.
43
   Relocation simply replaces a pathname starting with the original prefix
44
   by the corresponding pathname with the current prefix instead.  Both
45
   prefixes should be directory names without trailing slash (i.e. use ""
46
   instead of "/").  */
47
extern RELOCATABLE_DLL_EXPORTED void
48
       set_relocation_prefix (const char *orig_prefix,
49
			      const char *curr_prefix);
50
51
/* Returns the pathname, relocated according to the current installation
52
   directory.  */
53
extern const char * relocate (const char *pathname);
54
55
/* Memory management: relocate() leaks memory, because it has to construct
56
   a fresh pathname.  If this is a problem because your program calls
57
   relocate() frequently, think about caching the result.  */
58
59
/* Convenience function:
60
   Computes the current installation prefix, based on the original
61
   installation prefix, the original installation directory of a particular
62
   file, and the current pathname of this file.  Returns NULL upon failure.  */
63
extern const char * compute_curr_prefix (const char *orig_installprefix,
64
					 const char *orig_installdir,
65
					 const char *curr_pathname);
66
67
#else
68
69
/* By default, we use the hardwired pathnames.  */
70
#define relocate(pathname) (pathname)
71
72
#endif
73
74
75
#ifdef __cplusplus
76
}
77
#endif
78
79
#endif /* _RELOCATABLE_H */
(-)a/intl/textdomain.c (-141 lines)
Lines 1-141 Link Here
1
/* Implementation of the textdomain(3) function.
2
   Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include <stdlib.h>
24
#include <string.h>
25
26
#include "gettextP.h"
27
#ifdef _LIBC
28
# include <libintl.h>
29
#else
30
# include "libgnuintl.h"
31
#endif
32
33
/* Handle multi-threaded applications.  */
34
#ifdef _LIBC
35
# include <bits/libc-lock.h>
36
# define gl_rwlock_define __libc_rwlock_define
37
# define gl_rwlock_wrlock __libc_rwlock_wrlock
38
# define gl_rwlock_unlock __libc_rwlock_unlock
39
#else
40
# include "lock.h"
41
#endif
42
43
/* The internal variables in the standalone libintl.a must have different
44
   names than the internal variables in GNU libc, otherwise programs
45
   using libintl.a cannot be linked statically.  */
46
#if !defined _LIBC
47
# define _nl_default_default_domain libintl_nl_default_default_domain
48
# define _nl_current_default_domain libintl_nl_current_default_domain
49
#endif
50
51
/* @@ end of prolog @@ */
52
53
/* Name of the default text domain.  */
54
extern const char _nl_default_default_domain[] attribute_hidden;
55
56
/* Default text domain in which entries for gettext(3) are to be found.  */
57
extern const char *_nl_current_default_domain attribute_hidden;
58
59
60
/* Names for the libintl functions are a problem.  They must not clash
61
   with existing names and they should follow ANSI C.  But this source
62
   code is also used in GNU C Library where the names have a __
63
   prefix.  So we have to make a difference here.  */
64
#ifdef _LIBC
65
# define TEXTDOMAIN __textdomain
66
# ifndef strdup
67
#  define strdup(str) __strdup (str)
68
# endif
69
#else
70
# define TEXTDOMAIN libintl_textdomain
71
#endif
72
73
/* Lock variable to protect the global data in the gettext implementation.  */
74
gl_rwlock_define (extern, _nl_state_lock attribute_hidden)
75
76
/* Set the current default message catalog to DOMAINNAME.
77
   If DOMAINNAME is null, return the current default.
78
   If DOMAINNAME is "", reset to the default of "messages".  */
79
char *
80
TEXTDOMAIN (const char *domainname)
81
{
82
  char *new_domain;
83
  char *old_domain;
84
85
  /* A NULL pointer requests the current setting.  */
86
  if (domainname == NULL)
87
    return (char *) _nl_current_default_domain;
88
89
  gl_rwlock_wrlock (_nl_state_lock);
90
91
  old_domain = (char *) _nl_current_default_domain;
92
93
  /* If domain name is the null string set to default domain "messages".  */
94
  if (domainname[0] == '\0'
95
      || strcmp (domainname, _nl_default_default_domain) == 0)
96
    {
97
      _nl_current_default_domain = _nl_default_default_domain;
98
      new_domain = (char *) _nl_current_default_domain;
99
    }
100
  else if (strcmp (domainname, old_domain) == 0)
101
    /* This can happen and people will use it to signal that some
102
       environment variable changed.  */
103
    new_domain = old_domain;
104
  else
105
    {
106
      /* If the following malloc fails `_nl_current_default_domain'
107
	 will be NULL.  This value will be returned and so signals we
108
	 are out of core.  */
109
#if defined _LIBC || defined HAVE_STRDUP
110
      new_domain = strdup (domainname);
111
#else
112
      size_t len = strlen (domainname) + 1;
113
      new_domain = (char *) malloc (len);
114
      if (new_domain != NULL)
115
	memcpy (new_domain, domainname, len);
116
#endif
117
118
      if (new_domain != NULL)
119
	_nl_current_default_domain = new_domain;
120
    }
121
122
  /* We use this possibility to signal a change of the loaded catalogs
123
     since this is most likely the case and there is no other easy we
124
     to do it.  Do it only when the call was successful.  */
125
  if (new_domain != NULL)
126
    {
127
      ++_nl_msg_cat_cntr;
128
129
      if (old_domain != new_domain && old_domain != _nl_default_default_domain)
130
	free (old_domain);
131
    }
132
133
  gl_rwlock_unlock (_nl_state_lock);
134
135
  return new_domain;
136
}
137
138
#ifdef _LIBC
139
/* Alias for function name in GNU C Library.  */
140
weak_alias (__textdomain, textdomain);
141
#endif
(-)a/intl/vasnprintf.c (-890 lines)
Lines 1-890 Link Here
1
/* vsprintf with automatic memory allocation.
2
   Copyright (C) 1999, 2002-2006 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
20
   This must come before <config.h> because <config.h> may include
21
   <features.h>, and once <features.h> has been included, it's too late.  */
22
#ifndef _GNU_SOURCE
23
# define _GNU_SOURCE    1
24
#endif
25
26
#include <config.h>
27
#ifndef IN_LIBINTL
28
# include <alloca.h>
29
#endif
30
31
/* Specification.  */
32
#if WIDE_CHAR_VERSION
33
# include "vasnwprintf.h"
34
#else
35
# include "vasnprintf.h"
36
#endif
37
38
#include <stdio.h>	/* snprintf(), sprintf() */
39
#include <stdlib.h>	/* abort(), malloc(), realloc(), free() */
40
#include <string.h>	/* memcpy(), strlen() */
41
#include <errno.h>	/* errno */
42
#include <limits.h>	/* CHAR_BIT */
43
#include <float.h>	/* DBL_MAX_EXP, LDBL_MAX_EXP */
44
#if WIDE_CHAR_VERSION
45
# include "wprintf-parse.h"
46
#else
47
# include "printf-parse.h"
48
#endif
49
50
/* Checked size_t computations.  */
51
#include "xsize.h"
52
53
#ifdef HAVE_WCHAR_T
54
# ifdef HAVE_WCSLEN
55
#  define local_wcslen wcslen
56
# else
57
   /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
58
      a dependency towards this library, here is a local substitute.
59
      Define this substitute only once, even if this file is included
60
      twice in the same compilation unit.  */
61
#  ifndef local_wcslen_defined
62
#   define local_wcslen_defined 1
63
static size_t
64
local_wcslen (const wchar_t *s)
65
{
66
  const wchar_t *ptr;
67
68
  for (ptr = s; *ptr != (wchar_t) 0; ptr++)
69
    ;
70
  return ptr - s;
71
}
72
#  endif
73
# endif
74
#endif
75
76
#if WIDE_CHAR_VERSION
77
# define VASNPRINTF vasnwprintf
78
# define CHAR_T wchar_t
79
# define DIRECTIVE wchar_t_directive
80
# define DIRECTIVES wchar_t_directives
81
# define PRINTF_PARSE wprintf_parse
82
# define USE_SNPRINTF 1
83
# if HAVE_DECL__SNWPRINTF
84
   /* On Windows, the function swprintf() has a different signature than
85
      on Unix; we use the _snwprintf() function instead.  */
86
#  define SNPRINTF _snwprintf
87
# else
88
   /* Unix.  */
89
#  define SNPRINTF swprintf
90
# endif
91
#else
92
# define VASNPRINTF vasnprintf
93
# define CHAR_T char
94
# define DIRECTIVE char_directive
95
# define DIRECTIVES char_directives
96
# define PRINTF_PARSE printf_parse
97
# define USE_SNPRINTF (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF)
98
# if HAVE_DECL__SNPRINTF
99
   /* Windows.  */
100
#  define SNPRINTF _snprintf
101
# else
102
   /* Unix.  */
103
#  define SNPRINTF snprintf
104
# endif
105
#endif
106
107
CHAR_T *
108
VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list args)
109
{
110
  DIRECTIVES d;
111
  arguments a;
112
113
  if (PRINTF_PARSE (format, &d, &a) < 0)
114
    {
115
      errno = EINVAL;
116
      return NULL;
117
    }
118
119
#define CLEANUP() \
120
  free (d.dir);								\
121
  if (a.arg)								\
122
    free (a.arg);
123
124
  if (printf_fetchargs (args, &a) < 0)
125
    {
126
      CLEANUP ();
127
      errno = EINVAL;
128
      return NULL;
129
    }
130
131
  {
132
    size_t buf_neededlength;
133
    CHAR_T *buf;
134
    CHAR_T *buf_malloced;
135
    const CHAR_T *cp;
136
    size_t i;
137
    DIRECTIVE *dp;
138
    /* Output string accumulator.  */
139
    CHAR_T *result;
140
    size_t allocated;
141
    size_t length;
142
143
    /* Allocate a small buffer that will hold a directive passed to
144
       sprintf or snprintf.  */
145
    buf_neededlength =
146
      xsum4 (7, d.max_width_length, d.max_precision_length, 6);
147
#if HAVE_ALLOCA
148
    if (buf_neededlength < 4000 / sizeof (CHAR_T))
149
      {
150
	buf = (CHAR_T *) alloca (buf_neededlength * sizeof (CHAR_T));
151
	buf_malloced = NULL;
152
      }
153
    else
154
#endif
155
      {
156
	size_t buf_memsize = xtimes (buf_neededlength, sizeof (CHAR_T));
157
	if (size_overflow_p (buf_memsize))
158
	  goto out_of_memory_1;
159
	buf = (CHAR_T *) malloc (buf_memsize);
160
	if (buf == NULL)
161
	  goto out_of_memory_1;
162
	buf_malloced = buf;
163
      }
164
165
    if (resultbuf != NULL)
166
      {
167
	result = resultbuf;
168
	allocated = *lengthp;
169
      }
170
    else
171
      {
172
	result = NULL;
173
	allocated = 0;
174
      }
175
    length = 0;
176
    /* Invariants:
177
       result is either == resultbuf or == NULL or malloc-allocated.
178
       If length > 0, then result != NULL.  */
179
180
    /* Ensures that allocated >= needed.  Aborts through a jump to
181
       out_of_memory if needed is SIZE_MAX or otherwise too big.  */
182
#define ENSURE_ALLOCATION(needed) \
183
    if ((needed) > allocated)						     \
184
      {									     \
185
	size_t memory_size;						     \
186
	CHAR_T *memory;							     \
187
									     \
188
	allocated = (allocated > 0 ? xtimes (allocated, 2) : 12);	     \
189
	if ((needed) > allocated)					     \
190
	  allocated = (needed);						     \
191
	memory_size = xtimes (allocated, sizeof (CHAR_T));		     \
192
	if (size_overflow_p (memory_size))				     \
193
	  goto out_of_memory;						     \
194
	if (result == resultbuf || result == NULL)			     \
195
	  memory = (CHAR_T *) malloc (memory_size);			     \
196
	else								     \
197
	  memory = (CHAR_T *) realloc (result, memory_size);		     \
198
	if (memory == NULL)						     \
199
	  goto out_of_memory;						     \
200
	if (result == resultbuf && length > 0)				     \
201
	  memcpy (memory, result, length * sizeof (CHAR_T));		     \
202
	result = memory;						     \
203
      }
204
205
    for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
206
      {
207
	if (cp != dp->dir_start)
208
	  {
209
	    size_t n = dp->dir_start - cp;
210
	    size_t augmented_length = xsum (length, n);
211
212
	    ENSURE_ALLOCATION (augmented_length);
213
	    memcpy (result + length, cp, n * sizeof (CHAR_T));
214
	    length = augmented_length;
215
	  }
216
	if (i == d.count)
217
	  break;
218
219
	/* Execute a single directive.  */
220
	if (dp->conversion == '%')
221
	  {
222
	    size_t augmented_length;
223
224
	    if (!(dp->arg_index == ARG_NONE))
225
	      abort ();
226
	    augmented_length = xsum (length, 1);
227
	    ENSURE_ALLOCATION (augmented_length);
228
	    result[length] = '%';
229
	    length = augmented_length;
230
	  }
231
	else
232
	  {
233
	    if (!(dp->arg_index != ARG_NONE))
234
	      abort ();
235
236
	    if (dp->conversion == 'n')
237
	      {
238
		switch (a.arg[dp->arg_index].type)
239
		  {
240
		  case TYPE_COUNT_SCHAR_POINTER:
241
		    *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
242
		    break;
243
		  case TYPE_COUNT_SHORT_POINTER:
244
		    *a.arg[dp->arg_index].a.a_count_short_pointer = length;
245
		    break;
246
		  case TYPE_COUNT_INT_POINTER:
247
		    *a.arg[dp->arg_index].a.a_count_int_pointer = length;
248
		    break;
249
		  case TYPE_COUNT_LONGINT_POINTER:
250
		    *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
251
		    break;
252
#ifdef HAVE_LONG_LONG_INT
253
		  case TYPE_COUNT_LONGLONGINT_POINTER:
254
		    *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
255
		    break;
256
#endif
257
		  default:
258
		    abort ();
259
		  }
260
	      }
261
	    else
262
	      {
263
		arg_type type = a.arg[dp->arg_index].type;
264
		CHAR_T *p;
265
		unsigned int prefix_count;
266
		int prefixes[2];
267
#if !USE_SNPRINTF
268
		size_t tmp_length;
269
		CHAR_T tmpbuf[700];
270
		CHAR_T *tmp;
271
272
		/* Allocate a temporary buffer of sufficient size for calling
273
		   sprintf.  */
274
		{
275
		  size_t width;
276
		  size_t precision;
277
278
		  width = 0;
279
		  if (dp->width_start != dp->width_end)
280
		    {
281
		      if (dp->width_arg_index != ARG_NONE)
282
			{
283
			  int arg;
284
285
			  if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
286
			    abort ();
287
			  arg = a.arg[dp->width_arg_index].a.a_int;
288
			  width = (arg < 0 ? (unsigned int) (-arg) : arg);
289
			}
290
		      else
291
			{
292
			  const CHAR_T *digitp = dp->width_start;
293
294
			  do
295
			    width = xsum (xtimes (width, 10), *digitp++ - '0');
296
			  while (digitp != dp->width_end);
297
			}
298
		    }
299
300
		  precision = 6;
301
		  if (dp->precision_start != dp->precision_end)
302
		    {
303
		      if (dp->precision_arg_index != ARG_NONE)
304
			{
305
			  int arg;
306
307
			  if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
308
			    abort ();
309
			  arg = a.arg[dp->precision_arg_index].a.a_int;
310
			  precision = (arg < 0 ? 0 : arg);
311
			}
312
		      else
313
			{
314
			  const CHAR_T *digitp = dp->precision_start + 1;
315
316
			  precision = 0;
317
			  while (digitp != dp->precision_end)
318
			    precision = xsum (xtimes (precision, 10), *digitp++ - '0');
319
			}
320
		    }
321
322
		  switch (dp->conversion)
323
		    {
324
325
		    case 'd': case 'i': case 'u':
326
# ifdef HAVE_LONG_LONG_INT
327
		      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
328
			tmp_length =
329
			  (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
330
					  * 0.30103 /* binary -> decimal */
331
					 )
332
			  + 1; /* turn floor into ceil */
333
		      else
334
# endif
335
		      if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
336
			tmp_length =
337
			  (unsigned int) (sizeof (unsigned long) * CHAR_BIT
338
					  * 0.30103 /* binary -> decimal */
339
					 )
340
			  + 1; /* turn floor into ceil */
341
		      else
342
			tmp_length =
343
			  (unsigned int) (sizeof (unsigned int) * CHAR_BIT
344
					  * 0.30103 /* binary -> decimal */
345
					 )
346
			  + 1; /* turn floor into ceil */
347
		      if (tmp_length < precision)
348
			tmp_length = precision;
349
		      /* Multiply by 2, as an estimate for FLAG_GROUP.  */
350
		      tmp_length = xsum (tmp_length, tmp_length);
351
		      /* Add 1, to account for a leading sign.  */
352
		      tmp_length = xsum (tmp_length, 1);
353
		      break;
354
355
		    case 'o':
356
# ifdef HAVE_LONG_LONG_INT
357
		      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
358
			tmp_length =
359
			  (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
360
					  * 0.333334 /* binary -> octal */
361
					 )
362
			  + 1; /* turn floor into ceil */
363
		      else
364
# endif
365
		      if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
366
			tmp_length =
367
			  (unsigned int) (sizeof (unsigned long) * CHAR_BIT
368
					  * 0.333334 /* binary -> octal */
369
					 )
370
			  + 1; /* turn floor into ceil */
371
		      else
372
			tmp_length =
373
			  (unsigned int) (sizeof (unsigned int) * CHAR_BIT
374
					  * 0.333334 /* binary -> octal */
375
					 )
376
			  + 1; /* turn floor into ceil */
377
		      if (tmp_length < precision)
378
			tmp_length = precision;
379
		      /* Add 1, to account for a leading sign.  */
380
		      tmp_length = xsum (tmp_length, 1);
381
		      break;
382
383
		    case 'x': case 'X':
384
# ifdef HAVE_LONG_LONG_INT
385
		      if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
386
			tmp_length =
387
			  (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
388
					  * 0.25 /* binary -> hexadecimal */
389
					 )
390
			  + 1; /* turn floor into ceil */
391
		      else
392
# endif
393
		      if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
394
			tmp_length =
395
			  (unsigned int) (sizeof (unsigned long) * CHAR_BIT
396
					  * 0.25 /* binary -> hexadecimal */
397
					 )
398
			  + 1; /* turn floor into ceil */
399
		      else
400
			tmp_length =
401
			  (unsigned int) (sizeof (unsigned int) * CHAR_BIT
402
					  * 0.25 /* binary -> hexadecimal */
403
					 )
404
			  + 1; /* turn floor into ceil */
405
		      if (tmp_length < precision)
406
			tmp_length = precision;
407
		      /* Add 2, to account for a leading sign or alternate form.  */
408
		      tmp_length = xsum (tmp_length, 2);
409
		      break;
410
411
		    case 'f': case 'F':
412
# ifdef HAVE_LONG_DOUBLE
413
		      if (type == TYPE_LONGDOUBLE)
414
			tmp_length =
415
			  (unsigned int) (LDBL_MAX_EXP
416
					  * 0.30103 /* binary -> decimal */
417
					  * 2 /* estimate for FLAG_GROUP */
418
					 )
419
			  + 1 /* turn floor into ceil */
420
			  + 10; /* sign, decimal point etc. */
421
		      else
422
# endif
423
			tmp_length =
424
			  (unsigned int) (DBL_MAX_EXP
425
					  * 0.30103 /* binary -> decimal */
426
					  * 2 /* estimate for FLAG_GROUP */
427
					 )
428
			  + 1 /* turn floor into ceil */
429
			  + 10; /* sign, decimal point etc. */
430
		      tmp_length = xsum (tmp_length, precision);
431
		      break;
432
433
		    case 'e': case 'E': case 'g': case 'G':
434
		    case 'a': case 'A':
435
		      tmp_length =
436
			12; /* sign, decimal point, exponent etc. */
437
		      tmp_length = xsum (tmp_length, precision);
438
		      break;
439
440
		    case 'c':
441
# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION
442
		      if (type == TYPE_WIDE_CHAR)
443
			tmp_length = MB_CUR_MAX;
444
		      else
445
# endif
446
			tmp_length = 1;
447
		      break;
448
449
		    case 's':
450
# ifdef HAVE_WCHAR_T
451
		      if (type == TYPE_WIDE_STRING)
452
			{
453
			  tmp_length =
454
			    local_wcslen (a.arg[dp->arg_index].a.a_wide_string);
455
456
#  if !WIDE_CHAR_VERSION
457
			  tmp_length = xtimes (tmp_length, MB_CUR_MAX);
458
#  endif
459
			}
460
		      else
461
# endif
462
			tmp_length = strlen (a.arg[dp->arg_index].a.a_string);
463
		      break;
464
465
		    case 'p':
466
		      tmp_length =
467
			(unsigned int) (sizeof (void *) * CHAR_BIT
468
					* 0.25 /* binary -> hexadecimal */
469
				       )
470
			  + 1 /* turn floor into ceil */
471
			  + 2; /* account for leading 0x */
472
		      break;
473
474
		    default:
475
		      abort ();
476
		    }
477
478
		  if (tmp_length < width)
479
		    tmp_length = width;
480
481
		  tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
482
		}
483
484
		if (tmp_length <= sizeof (tmpbuf) / sizeof (CHAR_T))
485
		  tmp = tmpbuf;
486
		else
487
		  {
488
		    size_t tmp_memsize = xtimes (tmp_length, sizeof (CHAR_T));
489
490
		    if (size_overflow_p (tmp_memsize))
491
		      /* Overflow, would lead to out of memory.  */
492
		      goto out_of_memory;
493
		    tmp = (CHAR_T *) malloc (tmp_memsize);
494
		    if (tmp == NULL)
495
		      /* Out of memory.  */
496
		      goto out_of_memory;
497
		  }
498
#endif
499
500
		/* Construct the format string for calling snprintf or
501
		   sprintf.  */
502
		p = buf;
503
		*p++ = '%';
504
		if (dp->flags & FLAG_GROUP)
505
		  *p++ = '\'';
506
		if (dp->flags & FLAG_LEFT)
507
		  *p++ = '-';
508
		if (dp->flags & FLAG_SHOWSIGN)
509
		  *p++ = '+';
510
		if (dp->flags & FLAG_SPACE)
511
		  *p++ = ' ';
512
		if (dp->flags & FLAG_ALT)
513
		  *p++ = '#';
514
		if (dp->flags & FLAG_ZERO)
515
		  *p++ = '0';
516
		if (dp->width_start != dp->width_end)
517
		  {
518
		    size_t n = dp->width_end - dp->width_start;
519
		    memcpy (p, dp->width_start, n * sizeof (CHAR_T));
520
		    p += n;
521
		  }
522
		if (dp->precision_start != dp->precision_end)
523
		  {
524
		    size_t n = dp->precision_end - dp->precision_start;
525
		    memcpy (p, dp->precision_start, n * sizeof (CHAR_T));
526
		    p += n;
527
		  }
528
529
		switch (type)
530
		  {
531
#ifdef HAVE_LONG_LONG_INT
532
		  case TYPE_LONGLONGINT:
533
		  case TYPE_ULONGLONGINT:
534
		    *p++ = 'l';
535
		    /*FALLTHROUGH*/
536
#endif
537
		  case TYPE_LONGINT:
538
		  case TYPE_ULONGINT:
539
#ifdef HAVE_WINT_T
540
		  case TYPE_WIDE_CHAR:
541
#endif
542
#ifdef HAVE_WCHAR_T
543
		  case TYPE_WIDE_STRING:
544
#endif
545
		    *p++ = 'l';
546
		    break;
547
#ifdef HAVE_LONG_DOUBLE
548
		  case TYPE_LONGDOUBLE:
549
		    *p++ = 'L';
550
		    break;
551
#endif
552
		  default:
553
		    break;
554
		  }
555
		*p = dp->conversion;
556
#if USE_SNPRINTF
557
		p[1] = '%';
558
		p[2] = 'n';
559
		p[3] = '\0';
560
#else
561
		p[1] = '\0';
562
#endif
563
564
		/* Construct the arguments for calling snprintf or sprintf.  */
565
		prefix_count = 0;
566
		if (dp->width_arg_index != ARG_NONE)
567
		  {
568
		    if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
569
		      abort ();
570
		    prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
571
		  }
572
		if (dp->precision_arg_index != ARG_NONE)
573
		  {
574
		    if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
575
		      abort ();
576
		    prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
577
		  }
578
579
#if USE_SNPRINTF
580
		/* Prepare checking whether snprintf returns the count
581
		   via %n.  */
582
		ENSURE_ALLOCATION (xsum (length, 1));
583
		result[length] = '\0';
584
#endif
585
586
		for (;;)
587
		  {
588
		    size_t maxlen;
589
		    int count;
590
		    int retcount;
591
592
		    maxlen = allocated - length;
593
		    count = -1;
594
		    retcount = 0;
595
596
#if USE_SNPRINTF
597
# define SNPRINTF_BUF(arg) \
598
		    switch (prefix_count)				    \
599
		      {							    \
600
		      case 0:						    \
601
			retcount = SNPRINTF (result + length, maxlen, buf,  \
602
					     arg, &count);		    \
603
			break;						    \
604
		      case 1:						    \
605
			retcount = SNPRINTF (result + length, maxlen, buf,  \
606
					     prefixes[0], arg, &count);	    \
607
			break;						    \
608
		      case 2:						    \
609
			retcount = SNPRINTF (result + length, maxlen, buf,  \
610
					     prefixes[0], prefixes[1], arg, \
611
					     &count);			    \
612
			break;						    \
613
		      default:						    \
614
			abort ();					    \
615
		      }
616
#else
617
# define SNPRINTF_BUF(arg) \
618
		    switch (prefix_count)				    \
619
		      {							    \
620
		      case 0:						    \
621
			count = sprintf (tmp, buf, arg);		    \
622
			break;						    \
623
		      case 1:						    \
624
			count = sprintf (tmp, buf, prefixes[0], arg);	    \
625
			break;						    \
626
		      case 2:						    \
627
			count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
628
					 arg);				    \
629
			break;						    \
630
		      default:						    \
631
			abort ();					    \
632
		      }
633
#endif
634
635
		    switch (type)
636
		      {
637
		      case TYPE_SCHAR:
638
			{
639
			  int arg = a.arg[dp->arg_index].a.a_schar;
640
			  SNPRINTF_BUF (arg);
641
			}
642
			break;
643
		      case TYPE_UCHAR:
644
			{
645
			  unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
646
			  SNPRINTF_BUF (arg);
647
			}
648
			break;
649
		      case TYPE_SHORT:
650
			{
651
			  int arg = a.arg[dp->arg_index].a.a_short;
652
			  SNPRINTF_BUF (arg);
653
			}
654
			break;
655
		      case TYPE_USHORT:
656
			{
657
			  unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
658
			  SNPRINTF_BUF (arg);
659
			}
660
			break;
661
		      case TYPE_INT:
662
			{
663
			  int arg = a.arg[dp->arg_index].a.a_int;
664
			  SNPRINTF_BUF (arg);
665
			}
666
			break;
667
		      case TYPE_UINT:
668
			{
669
			  unsigned int arg = a.arg[dp->arg_index].a.a_uint;
670
			  SNPRINTF_BUF (arg);
671
			}
672
			break;
673
		      case TYPE_LONGINT:
674
			{
675
			  long int arg = a.arg[dp->arg_index].a.a_longint;
676
			  SNPRINTF_BUF (arg);
677
			}
678
			break;
679
		      case TYPE_ULONGINT:
680
			{
681
			  unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
682
			  SNPRINTF_BUF (arg);
683
			}
684
			break;
685
#ifdef HAVE_LONG_LONG_INT
686
		      case TYPE_LONGLONGINT:
687
			{
688
			  long long int arg = a.arg[dp->arg_index].a.a_longlongint;
689
			  SNPRINTF_BUF (arg);
690
			}
691
			break;
692
		      case TYPE_ULONGLONGINT:
693
			{
694
			  unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
695
			  SNPRINTF_BUF (arg);
696
			}
697
			break;
698
#endif
699
		      case TYPE_DOUBLE:
700
			{
701
			  double arg = a.arg[dp->arg_index].a.a_double;
702
			  SNPRINTF_BUF (arg);
703
			}
704
			break;
705
#ifdef HAVE_LONG_DOUBLE
706
		      case TYPE_LONGDOUBLE:
707
			{
708
			  long double arg = a.arg[dp->arg_index].a.a_longdouble;
709
			  SNPRINTF_BUF (arg);
710
			}
711
			break;
712
#endif
713
		      case TYPE_CHAR:
714
			{
715
			  int arg = a.arg[dp->arg_index].a.a_char;
716
			  SNPRINTF_BUF (arg);
717
			}
718
			break;
719
#ifdef HAVE_WINT_T
720
		      case TYPE_WIDE_CHAR:
721
			{
722
			  wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
723
			  SNPRINTF_BUF (arg);
724
			}
725
			break;
726
#endif
727
		      case TYPE_STRING:
728
			{
729
			  const char *arg = a.arg[dp->arg_index].a.a_string;
730
			  SNPRINTF_BUF (arg);
731
			}
732
			break;
733
#ifdef HAVE_WCHAR_T
734
		      case TYPE_WIDE_STRING:
735
			{
736
			  const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
737
			  SNPRINTF_BUF (arg);
738
			}
739
			break;
740
#endif
741
		      case TYPE_POINTER:
742
			{
743
			  void *arg = a.arg[dp->arg_index].a.a_pointer;
744
			  SNPRINTF_BUF (arg);
745
			}
746
			break;
747
		      default:
748
			abort ();
749
		      }
750
751
#if USE_SNPRINTF
752
		    /* Portability: Not all implementations of snprintf()
753
		       are ISO C 99 compliant.  Determine the number of
754
		       bytes that snprintf() has produced or would have
755
		       produced.  */
756
		    if (count >= 0)
757
		      {
758
			/* Verify that snprintf() has NUL-terminated its
759
			   result.  */
760
			if (count < maxlen && result[length + count] != '\0')
761
			  abort ();
762
			/* Portability hack.  */
763
			if (retcount > count)
764
			  count = retcount;
765
		      }
766
		    else
767
		      {
768
			/* snprintf() doesn't understand the '%n'
769
			   directive.  */
770
			if (p[1] != '\0')
771
			  {
772
			    /* Don't use the '%n' directive; instead, look
773
			       at the snprintf() return value.  */
774
			    p[1] = '\0';
775
			    continue;
776
			  }
777
			else
778
			  {
779
			    /* Look at the snprintf() return value.  */
780
			    if (retcount < 0)
781
			      {
782
				/* HP-UX 10.20 snprintf() is doubly deficient:
783
				   It doesn't understand the '%n' directive,
784
				   *and* it returns -1 (rather than the length
785
				   that would have been required) when the
786
				   buffer is too small.  */
787
				size_t bigger_need =
788
				  xsum (xtimes (allocated, 2), 12);
789
				ENSURE_ALLOCATION (bigger_need);
790
				continue;
791
			      }
792
			    else
793
			      count = retcount;
794
			  }
795
		      }
796
#endif
797
798
		    /* Attempt to handle failure.  */
799
		    if (count < 0)
800
		      {
801
			if (!(result == resultbuf || result == NULL))
802
			  free (result);
803
			if (buf_malloced != NULL)
804
			  free (buf_malloced);
805
			CLEANUP ();
806
			errno = EINVAL;
807
			return NULL;
808
		      }
809
810
#if !USE_SNPRINTF
811
		    if (count >= tmp_length)
812
		      /* tmp_length was incorrectly calculated - fix the
813
			 code above!  */
814
		      abort ();
815
#endif
816
817
		    /* Make room for the result.  */
818
		    if (count >= maxlen)
819
		      {
820
			/* Need at least count bytes.  But allocate
821
			   proportionally, to avoid looping eternally if
822
			   snprintf() reports a too small count.  */
823
			size_t n =
824
			  xmax (xsum (length, count), xtimes (allocated, 2));
825
826
			ENSURE_ALLOCATION (n);
827
#if USE_SNPRINTF
828
			continue;
829
#endif
830
		      }
831
832
#if USE_SNPRINTF
833
		    /* The snprintf() result did fit.  */
834
#else
835
		    /* Append the sprintf() result.  */
836
		    memcpy (result + length, tmp, count * sizeof (CHAR_T));
837
		    if (tmp != tmpbuf)
838
		      free (tmp);
839
#endif
840
841
		    length += count;
842
		    break;
843
		  }
844
	      }
845
	  }
846
      }
847
848
    /* Add the final NUL.  */
849
    ENSURE_ALLOCATION (xsum (length, 1));
850
    result[length] = '\0';
851
852
    if (result != resultbuf && length + 1 < allocated)
853
      {
854
	/* Shrink the allocated memory if possible.  */
855
	CHAR_T *memory;
856
857
	memory = (CHAR_T *) realloc (result, (length + 1) * sizeof (CHAR_T));
858
	if (memory != NULL)
859
	  result = memory;
860
      }
861
862
    if (buf_malloced != NULL)
863
      free (buf_malloced);
864
    CLEANUP ();
865
    *lengthp = length;
866
    /* Note that we can produce a big string of a length > INT_MAX.  POSIX
867
       says that snprintf() fails with errno = EOVERFLOW in this case, but
868
       that's only because snprintf() returns an 'int'.  This function does
869
       not have this limitation.  */
870
    return result;
871
872
  out_of_memory:
873
    if (!(result == resultbuf || result == NULL))
874
      free (result);
875
    if (buf_malloced != NULL)
876
      free (buf_malloced);
877
  out_of_memory_1:
878
    CLEANUP ();
879
    errno = ENOMEM;
880
    return NULL;
881
  }
882
}
883
884
#undef SNPRINTF
885
#undef USE_SNPRINTF
886
#undef PRINTF_PARSE
887
#undef DIRECTIVES
888
#undef DIRECTIVE
889
#undef CHAR_T
890
#undef VASNPRINTF
(-)a/intl/vasnprintf.h (-78 lines)
Lines 1-78 Link Here
1
/* vsprintf with automatic memory allocation.
2
   Copyright (C) 2002-2004 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _VASNPRINTF_H
20
#define _VASNPRINTF_H
21
22
/* Get va_list.  */
23
#include <stdarg.h>
24
25
/* Get size_t.  */
26
#include <stddef.h>
27
28
#ifndef __attribute__
29
/* This feature is available in gcc versions 2.5 and later.  */
30
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
31
#  define __attribute__(Spec) /* empty */
32
# endif
33
/* The __-protected variants of `format' and `printf' attributes
34
   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
35
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
36
#  define __format__ format
37
#  define __printf__ printf
38
# endif
39
#endif
40
41
#ifdef	__cplusplus
42
extern "C" {
43
#endif
44
45
/* Write formatted output to a string dynamically allocated with malloc().
46
   You can pass a preallocated buffer for the result in RESULTBUF and its
47
   size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
48
   If successful, return the address of the string (this may be = RESULTBUF
49
   if no dynamic memory allocation was necessary) and set *LENGTHP to the
50
   number of resulting bytes, excluding the trailing NUL.  Upon error, set
51
   errno and return NULL.
52
53
   When dynamic memory allocation occurs, the preallocated buffer is left
54
   alone (with possibly modified contents).  This makes it possible to use
55
   a statically allocated or stack-allocated buffer, like this:
56
57
          char buf[100];
58
          size_t len = sizeof (buf);
59
          char *output = vasnprintf (buf, &len, format, args);
60
          if (output == NULL)
61
            ... error handling ...;
62
          else
63
            {
64
              ... use the output string ...;
65
              if (output != buf)
66
                free (output);
67
            }
68
  */
69
extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
70
       __attribute__ ((__format__ (__printf__, 3, 4)));
71
extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
72
       __attribute__ ((__format__ (__printf__, 3, 0)));
73
74
#ifdef	__cplusplus
75
}
76
#endif
77
78
#endif /* _VASNPRINTF_H */
(-)a/intl/vasnwprintf.h (-46 lines)
Lines 1-46 Link Here
1
/* vswprintf with automatic memory allocation.
2
   Copyright (C) 2002-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _VASNWPRINTF_H
20
#define _VASNWPRINTF_H
21
22
/* Get va_list.  */
23
#include <stdarg.h>
24
25
/* Get wchar_t, size_t.  */
26
#include <stddef.h>
27
28
#ifdef	__cplusplus
29
extern "C" {
30
#endif
31
32
/* Write formatted output to a string dynamically allocated with malloc().
33
   You can pass a preallocated buffer for the result in RESULTBUF and its
34
   size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
35
   If successful, return the address of the string (this may be = RESULTBUF
36
   if no dynamic memory allocation was necessary) and set *LENGTHP to the
37
   number of resulting bytes, excluding the trailing NUL.  Upon error, set
38
   errno and return NULL.  */
39
extern wchar_t * asnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, ...);
40
extern wchar_t * vasnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, va_list args);
41
42
#ifdef	__cplusplus
43
}
44
#endif
45
46
#endif /* _VASNWPRINTF_H */
(-)a/intl/version.c (-26 lines)
Lines 1-26 Link Here
1
/* libintl library version.
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifdef HAVE_CONFIG_H
20
# include <config.h>
21
#endif
22
23
#include "libgnuintl.h"
24
25
/* Version number: (major<<16) + (minor<<8) + subminor */
26
int libintl_version = LIBINTL_VERSION;
(-)a/intl/wprintf-parse.h (-75 lines)
Lines 1-75 Link Here
1
/* Parse printf format string.
2
   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
3
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
19
#ifndef _WPRINTF_PARSE_H
20
#define _WPRINTF_PARSE_H
21
22
#include "printf-args.h"
23
24
25
/* Flags */
26
#define FLAG_GROUP	 1	/* ' flag */
27
#define FLAG_LEFT	 2	/* - flag */
28
#define FLAG_SHOWSIGN	 4	/* + flag */
29
#define FLAG_SPACE	 8	/* space flag */
30
#define FLAG_ALT	16	/* # flag */
31
#define FLAG_ZERO	32
32
33
/* arg_index value indicating that no argument is consumed.  */
34
#define ARG_NONE	(~(size_t)0)
35
36
/* A parsed directive.  */
37
typedef struct
38
{
39
  const wchar_t* dir_start;
40
  const wchar_t* dir_end;
41
  int flags;
42
  const wchar_t* width_start;
43
  const wchar_t* width_end;
44
  size_t width_arg_index;
45
  const wchar_t* precision_start;
46
  const wchar_t* precision_end;
47
  size_t precision_arg_index;
48
  wchar_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */
49
  size_t arg_index;
50
}
51
wchar_t_directive;
52
53
/* A parsed format string.  */
54
typedef struct
55
{
56
  size_t count;
57
  wchar_t_directive *dir;
58
  size_t max_width_length;
59
  size_t max_precision_length;
60
}
61
wchar_t_directives;
62
63
64
/* Parses the format string.  Fills in the number N of directives, and fills
65
   in directives[0], ..., directives[N-1], and sets directives[N].dir_start
66
   to the end of the format string.  Also fills in the arg_type fields of the
67
   arguments and the needed count of arguments.  */
68
#ifdef STATIC
69
STATIC
70
#else
71
extern
72
#endif
73
int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
74
75
#endif /* _WPRINTF_PARSE_H */
(-)a/intl/xsize.h (-109 lines)
Lines 1-109 Link Here
1
/* xsize.h -- Checked size_t computations.
2
3
   Copyright (C) 2003 Free Software Foundation, Inc.
4
5
   This program is free software; you can redistribute it and/or modify it
6
   under the terms of the GNU Library General Public License as published
7
   by the Free Software Foundation; either version 2, or (at your option)
8
   any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
15
   You should have received a copy of the GNU Library General Public
16
   License along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
   USA.  */
19
20
#ifndef _XSIZE_H
21
#define _XSIZE_H
22
23
/* Get size_t.  */
24
#include <stddef.h>
25
26
/* Get SIZE_MAX.  */
27
#include <limits.h>
28
#if HAVE_STDINT_H
29
# include <stdint.h>
30
#endif
31
32
/* The size of memory objects is often computed through expressions of
33
   type size_t. Example:
34
      void* p = malloc (header_size + n * element_size).
35
   These computations can lead to overflow.  When this happens, malloc()
36
   returns a piece of memory that is way too small, and the program then
37
   crashes while attempting to fill the memory.
38
   To avoid this, the functions and macros in this file check for overflow.
39
   The convention is that SIZE_MAX represents overflow.
40
   malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
41
   implementation that uses mmap --, it's recommended to use size_overflow_p()
42
   or size_in_bounds_p() before invoking malloc().
43
   The example thus becomes:
44
      size_t size = xsum (header_size, xtimes (n, element_size));
45
      void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
46
*/
47
48
/* Convert an arbitrary value >= 0 to type size_t.  */
49
#define xcast_size_t(N) \
50
  ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
51
52
/* Sum of two sizes, with overflow check.  */
53
static inline size_t
54
#if __GNUC__ >= 3
55
__attribute__ ((__pure__))
56
#endif
57
xsum (size_t size1, size_t size2)
58
{
59
  size_t sum = size1 + size2;
60
  return (sum >= size1 ? sum : SIZE_MAX);
61
}
62
63
/* Sum of three sizes, with overflow check.  */
64
static inline size_t
65
#if __GNUC__ >= 3
66
__attribute__ ((__pure__))
67
#endif
68
xsum3 (size_t size1, size_t size2, size_t size3)
69
{
70
  return xsum (xsum (size1, size2), size3);
71
}
72
73
/* Sum of four sizes, with overflow check.  */
74
static inline size_t
75
#if __GNUC__ >= 3
76
__attribute__ ((__pure__))
77
#endif
78
xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
79
{
80
  return xsum (xsum (xsum (size1, size2), size3), size4);
81
}
82
83
/* Maximum of two sizes, with overflow check.  */
84
static inline size_t
85
#if __GNUC__ >= 3
86
__attribute__ ((__pure__))
87
#endif
88
xmax (size_t size1, size_t size2)
89
{
90
  /* No explicit check is needed here, because for any n:
91
     max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX.  */
92
  return (size1 >= size2 ? size1 : size2);
93
}
94
95
/* Multiplication of a count with an element size, with overflow check.
96
   The count must be >= 0 and the element size must be > 0.
97
   This is a macro, not an inline function, so that it works correctly even
98
   when N is of a wider tupe and N > SIZE_MAX.  */
99
#define xtimes(N, ELSIZE) \
100
  ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
101
102
/* Check for overflow.  */
103
#define size_overflow_p(SIZE) \
104
  ((SIZE) == SIZE_MAX)
105
/* Check against overflow.  */
106
#define size_in_bounds_p(SIZE) \
107
  ((SIZE) != SIZE_MAX)
108
109
#endif /* _XSIZE_H */
(-)a/m4/gettext.m4 (-126 / +93 lines)
Lines 1-41 Link Here
1
# gettext.m4 serial 59 (gettext-0.16.1)
1
# gettext.m4 serial 71 (gettext-0.20.2)
2
dnl Copyright (C) 1995-2006 Free Software Foundation, Inc.
2
dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
5
dnl with or without modifications, as long as this notice is preserved.
6
dnl
6
dnl
7
dnl This file can can be used in projects which are not available under
7
dnl This file can be used in projects which are not available under
8
dnl the GNU General Public License or the GNU Library General Public
8
dnl the GNU General Public License or the GNU Lesser General Public
9
dnl License but which still want to provide support for the GNU gettext
9
dnl License but which still want to provide support for the GNU gettext
10
dnl functionality.
10
dnl functionality.
11
dnl Please note that the actual code of the GNU gettext library is covered
11
dnl Please note that the actual code of the GNU gettext library is covered
12
dnl by the GNU Library General Public License, and the rest of the GNU
12
dnl by the GNU Lesser General Public License, and the rest of the GNU
13
dnl gettext package package is covered by the GNU General Public License.
13
dnl gettext package is covered by the GNU General Public License.
14
dnl They are *not* in the public domain.
14
dnl They are *not* in the public domain.
15
15
16
dnl Authors:
16
dnl Authors:
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18
dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2006.
18
dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
19
19
20
dnl Macro to add for using GNU gettext.
20
dnl Macro to add for using GNU gettext.
21
21
22
dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
22
dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
23
dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
23
dnl INTLSYMBOL must be one of 'external', 'use-libtool'.
24
dnl    default (if it is not specified or empty) is 'no-libtool'.
24
dnl    INTLSYMBOL should be 'external' for packages other than GNU gettext, and
25
dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
25
dnl    'use-libtool' for the packages 'gettext-runtime' and 'gettext-tools'.
26
dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
27
dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
26
dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
28
dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
27
dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
29
dnl    depending on --{enable,disable}-{shared,static} and on the presence of
28
dnl    depending on --{enable,disable}-{shared,static} and on the presence of
30
dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
29
dnl    AM-DISABLE-SHARED).
31
dnl    $(top_builddir)/intl/libintl.a will be created.
32
dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
30
dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
33
dnl    implementations (in libc or libintl) without the ngettext() function
31
dnl    implementations (in libc or libintl) without the ngettext() function
34
dnl    will be ignored.  If NEEDSYMBOL is specified and is
32
dnl    will be ignored.  If NEEDSYMBOL is specified and is
35
dnl    'need-formatstring-macros', then GNU gettext implementations that don't
33
dnl    'need-formatstring-macros', then GNU gettext implementations that don't
36
dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
34
dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
37
dnl INTLDIR is used to find the intl libraries.  If empty,
35
dnl INTLDIR is used to find the intl libraries.  If empty,
38
dnl    the value `$(top_builddir)/intl/' is used.
36
dnl    the value '$(top_builddir)/intl/' is used.
39
dnl
37
dnl
40
dnl The result of the configuration is one of three cases:
38
dnl The result of the configuration is one of three cases:
41
dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
39
dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
Lines 57-73 dnl Link Here
57
AC_DEFUN([AM_GNU_GETTEXT],
55
AC_DEFUN([AM_GNU_GETTEXT],
58
[
56
[
59
  dnl Argument checking.
57
  dnl Argument checking.
60
  ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
58
  ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [use-libtool], ,
61
    [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
59
    [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
62
])])])])])
60
])])])])
61
  ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
62
    [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported.
63
])])
63
  ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
64
  ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
64
    [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
65
    [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
65
])])])])
66
])])])])
66
  define([gt_included_intl],
67
  define([gt_included_intl],
67
    ifelse([$1], [external],
68
    ifelse([$1], [external], [no], [yes]))
68
      ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
69
      [yes]))
70
  define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
71
  gt_NEEDS_INIT
69
  gt_NEEDS_INIT
72
  AM_GNU_GETTEXT_NEED([$2])
70
  AM_GNU_GETTEXT_NEED([$2])
73
71
Lines 89-101 AC_DEFUN([AM_GNU_GETTEXT], Link Here
89
  dnl again, outside any 'if'. There are two solutions:
87
  dnl again, outside any 'if'. There are two solutions:
90
  dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
88
  dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
91
  dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
89
  dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
92
  dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
90
  dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it.
93
  dnl documented, we avoid it.
94
  ifelse(gt_included_intl, yes, , [
91
  ifelse(gt_included_intl, yes, , [
95
    AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
92
    AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
96
  ])
93
  ])
97
94
98
  dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
95
  dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
99
  gt_INTL_MACOSX
96
  gt_INTL_MACOSX
100
97
101
  dnl Set USE_NLS.
98
  dnl Set USE_NLS.
Lines 123-133 AC_DEFUN([AM_GNU_GETTEXT], Link Here
123
    gt_use_preinstalled_gnugettext=no
120
    gt_use_preinstalled_gnugettext=no
124
    ifelse(gt_included_intl, yes, [
121
    ifelse(gt_included_intl, yes, [
125
      AC_MSG_CHECKING([whether included gettext is requested])
122
      AC_MSG_CHECKING([whether included gettext is requested])
126
      AC_ARG_WITH(included-gettext,
123
      AC_ARG_WITH([included-gettext],
127
        [  --with-included-gettext use the GNU gettext library included here],
124
        [  --with-included-gettext use the GNU gettext library included here],
128
        nls_cv_force_use_gnu_gettext=$withval,
125
        nls_cv_force_use_gnu_gettext=$withval,
129
        nls_cv_force_use_gnu_gettext=no)
126
        nls_cv_force_use_gnu_gettext=no)
130
      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
127
      AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
131
128
132
      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
129
      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
133
      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
130
      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
Lines 155-166 changequote([,])dnl Link Here
155
        fi
152
        fi
156
153
157
        AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
154
        AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
158
         [AC_TRY_LINK([#include <libintl.h>
155
         [AC_LINK_IFELSE(
159
$gt_revision_test_code
156
            [AC_LANG_PROGRAM(
157
               [[
158
#include <libintl.h>
159
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
160
extern int _nl_msg_cat_cntr;
160
extern int _nl_msg_cat_cntr;
161
extern int *_nl_domain_bindings;],
161
extern int *_nl_domain_bindings;
162
            [bindtextdomain ("", "");
162
#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings)
163
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
163
#else
164
#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
165
#endif
166
$gt_revision_test_code
167
               ]],
168
               [[
169
bindtextdomain ("", "");
170
return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
171
               ]])],
164
            [eval "$gt_func_gnugettext_libc=yes"],
172
            [eval "$gt_func_gnugettext_libc=yes"],
165
            [eval "$gt_func_gnugettext_libc=no"])])
173
            [eval "$gt_func_gnugettext_libc=no"])])
166
174
Lines 181-215 return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_b Link Here
181
            gt_save_LIBS="$LIBS"
189
            gt_save_LIBS="$LIBS"
182
            LIBS="$LIBS $LIBINTL"
190
            LIBS="$LIBS $LIBINTL"
183
            dnl Now see whether libintl exists and does not depend on libiconv.
191
            dnl Now see whether libintl exists and does not depend on libiconv.
184
            AC_TRY_LINK([#include <libintl.h>
192
            AC_LINK_IFELSE(
185
$gt_revision_test_code
193
              [AC_LANG_PROGRAM(
194
                 [[
195
#include <libintl.h>
196
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
186
extern int _nl_msg_cat_cntr;
197
extern int _nl_msg_cat_cntr;
187
extern
198
extern
188
#ifdef __cplusplus
199
#ifdef __cplusplus
189
"C"
200
"C"
190
#endif
201
#endif
191
const char *_nl_expand_alias (const char *);],
202
const char *_nl_expand_alias (const char *);
192
              [bindtextdomain ("", "");
203
#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))
193
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
204
#else
205
#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
206
#endif
207
$gt_revision_test_code
208
                 ]],
209
                 [[
210
bindtextdomain ("", "");
211
return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
212
                 ]])],
194
              [eval "$gt_func_gnugettext_libintl=yes"],
213
              [eval "$gt_func_gnugettext_libintl=yes"],
195
              [eval "$gt_func_gnugettext_libintl=no"])
214
              [eval "$gt_func_gnugettext_libintl=no"])
196
            dnl Now see whether libintl exists and depends on libiconv.
215
            dnl Now see whether libintl exists and depends on libiconv.
197
            if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
216
            if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
198
              LIBS="$LIBS $LIBICONV"
217
              LIBS="$LIBS $LIBICONV"
199
              AC_TRY_LINK([#include <libintl.h>
218
              AC_LINK_IFELSE(
200
$gt_revision_test_code
219
                [AC_LANG_PROGRAM(
220
                   [[
221
#include <libintl.h>
222
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
201
extern int _nl_msg_cat_cntr;
223
extern int _nl_msg_cat_cntr;
202
extern
224
extern
203
#ifdef __cplusplus
225
#ifdef __cplusplus
204
"C"
226
"C"
205
#endif
227
#endif
206
const char *_nl_expand_alias (const char *);],
228
const char *_nl_expand_alias (const char *);
207
                [bindtextdomain ("", "");
229
#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))
208
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
230
#else
209
               [LIBINTL="$LIBINTL $LIBICONV"
231
#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
210
                LTLIBINTL="$LTLIBINTL $LTLIBICONV"
232
#endif
211
                eval "$gt_func_gnugettext_libintl=yes"
233
$gt_revision_test_code
212
               ])
234
                   ]],
235
                   [[
236
bindtextdomain ("", "");
237
return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
238
                   ]])],
239
                [LIBINTL="$LIBINTL $LIBICONV"
240
                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
241
                 eval "$gt_func_gnugettext_libintl=yes"
242
                ])
213
            fi
243
            fi
214
            CPPFLAGS="$gt_save_CPPFLAGS"
244
            CPPFLAGS="$gt_save_CPPFLAGS"
215
            LIBS="$gt_save_LIBS"])
245
            LIBS="$gt_save_LIBS"])
Lines 243-250 return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a Link Here
243
        dnl Mark actions used to generate GNU NLS library.
273
        dnl Mark actions used to generate GNU NLS library.
244
        BUILD_INCLUDED_LIBINTL=yes
274
        BUILD_INCLUDED_LIBINTL=yes
245
        USE_INCLUDED_LIBINTL=yes
275
        USE_INCLUDED_LIBINTL=yes
246
        LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
276
        LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD"
247
        LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
277
        LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD"
248
        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
278
        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
249
      fi
279
      fi
250
280
Lines 267-273 return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a Link Here
267
297
268
    if test "$gt_use_preinstalled_gnugettext" = "yes" \
298
    if test "$gt_use_preinstalled_gnugettext" = "yes" \
269
       || test "$nls_cv_use_gnu_gettext" = "yes"; then
299
       || test "$nls_cv_use_gnu_gettext" = "yes"; then
270
      AC_DEFINE(ENABLE_NLS, 1,
300
      AC_DEFINE([ENABLE_NLS], [1],
271
        [Define to 1 if translation of program messages to the user's native language
301
        [Define to 1 if translation of program messages to the user's native language
272
   is requested.])
302
   is requested.])
273
    else
303
    else
Lines 301-309 return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a Link Here
301
      fi
331
      fi
302
332
303
      dnl For backward compatibility. Some packages may be using this.
333
      dnl For backward compatibility. Some packages may be using this.
304
      AC_DEFINE(HAVE_GETTEXT, 1,
334
      AC_DEFINE([HAVE_GETTEXT], [1],
305
       [Define if the GNU gettext() function is already present or preinstalled.])
335
       [Define if the GNU gettext() function is already present or preinstalled.])
306
      AC_DEFINE(HAVE_DCGETTEXT, 1,
336
      AC_DEFINE([HAVE_DCGETTEXT], [1],
307
       [Define if the GNU dcgettext() function is already present or preinstalled.])
337
       [Define if the GNU dcgettext() function is already present or preinstalled.])
308
    fi
338
    fi
309
339
Lines 312-402 return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a Link Here
312
  fi
342
  fi
313
343
314
  ifelse(gt_included_intl, yes, [
344
  ifelse(gt_included_intl, yes, [
315
    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
345
    dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes'
316
    dnl to 'yes' because some of the testsuite requires it.
346
    dnl because some of the testsuite requires it.
317
    if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
347
    BUILD_INCLUDED_LIBINTL=yes
318
      BUILD_INCLUDED_LIBINTL=yes
319
    fi
320
348
321
    dnl Make all variables we use known to autoconf.
349
    dnl Make all variables we use known to autoconf.
322
    AC_SUBST(BUILD_INCLUDED_LIBINTL)
350
    AC_SUBST([BUILD_INCLUDED_LIBINTL])
323
    AC_SUBST(USE_INCLUDED_LIBINTL)
351
    AC_SUBST([USE_INCLUDED_LIBINTL])
324
    AC_SUBST(CATOBJEXT)
352
    AC_SUBST([CATOBJEXT])
325
326
    dnl For backward compatibility. Some configure.ins may be using this.
327
    nls_cv_header_intl=
328
    nls_cv_header_libgt=
329
330
    dnl For backward compatibility. Some Makefiles may be using this.
331
    DATADIRNAME=share
332
    AC_SUBST(DATADIRNAME)
333
334
    dnl For backward compatibility. Some Makefiles may be using this.
335
    INSTOBJEXT=.mo
336
    AC_SUBST(INSTOBJEXT)
337
338
    dnl For backward compatibility. Some Makefiles may be using this.
339
    GENCAT=gencat
340
    AC_SUBST(GENCAT)
341
342
    dnl For backward compatibility. Some Makefiles may be using this.
343
    INTLOBJS=
344
    if test "$USE_INCLUDED_LIBINTL" = yes; then
345
      INTLOBJS="\$(GETTOBJS)"
346
    fi
347
    AC_SUBST(INTLOBJS)
348
349
    dnl Enable libtool support if the surrounding package wishes it.
350
    INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
351
    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
352
  ])
353
  ])
353
354
354
  dnl For backward compatibility. Some Makefiles may be using this.
355
  dnl For backward compatibility. Some Makefiles may be using this.
355
  INTLLIBS="$LIBINTL"
356
  INTLLIBS="$LIBINTL"
356
  AC_SUBST(INTLLIBS)
357
  AC_SUBST([INTLLIBS])
357
358
358
  dnl Make all documented variables known to autoconf.
359
  dnl Make all documented variables known to autoconf.
359
  AC_SUBST(LIBINTL)
360
  AC_SUBST([LIBINTL])
360
  AC_SUBST(LTLIBINTL)
361
  AC_SUBST([LTLIBINTL])
361
  AC_SUBST(POSUB)
362
  AC_SUBST([POSUB])
362
])
363
364
365
dnl Checks for special options needed on MacOS X.
366
dnl Defines INTL_MACOSX_LIBS.
367
AC_DEFUN([gt_INTL_MACOSX],
368
[
369
  dnl Check for API introduced in MacOS X 10.2.
370
  AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
371
    gt_cv_func_CFPreferencesCopyAppValue,
372
    [gt_save_LIBS="$LIBS"
373
     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
374
     AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>],
375
       [CFPreferencesCopyAppValue(NULL, NULL)],
376
       [gt_cv_func_CFPreferencesCopyAppValue=yes],
377
       [gt_cv_func_CFPreferencesCopyAppValue=no])
378
     LIBS="$gt_save_LIBS"])
379
  if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
380
    AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1,
381
      [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
382
  fi
383
  dnl Check for API introduced in MacOS X 10.3.
384
  AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent,
385
    [gt_save_LIBS="$LIBS"
386
     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
387
     AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();],
388
       [gt_cv_func_CFLocaleCopyCurrent=yes],
389
       [gt_cv_func_CFLocaleCopyCurrent=no])
390
     LIBS="$gt_save_LIBS"])
391
  if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
392
    AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1,
393
      [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
394
  fi
395
  INTL_MACOSX_LIBS=
396
  if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
397
    INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
398
  fi
399
  AC_SUBST([INTL_MACOSX_LIBS])
400
])
363
])
401
364
402
365
Lines 417-419 AC_DEFUN([AM_GNU_GETTEXT_NEED], Link Here
417
380
418
dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
381
dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
419
AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
382
AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
383
384
385
dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version])
386
AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], [])
(-)a/m4/iconv.m4 (-29 / +216 lines)
Lines 1-5 Link Here
1
# iconv.m4 serial AM4 (gettext-0.11.3)
1
# iconv.m4 serial 21
2
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
2
dnl Copyright (C) 2000-2002, 2007-2014, 2016-2020 Free Software Foundation,
3
dnl Inc.
3
dnl This file is free software; the Free Software Foundation
4
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
6
dnl with or without modifications, as long as this notice is preserved.
Lines 21-26 AC_DEFUN([AM_ICONV_LINK], Link Here
21
[
22
[
22
  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
23
  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
23
  dnl those with the standalone portable GNU libiconv installed).
24
  dnl those with the standalone portable GNU libiconv installed).
25
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
24
26
25
  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
27
  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
26
  dnl accordingly.
28
  dnl accordingly.
Lines 29-62 AC_DEFUN([AM_ICONV_LINK], Link Here
29
  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
31
  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
30
  dnl because if the user has installed libiconv and not disabled its use
32
  dnl because if the user has installed libiconv and not disabled its use
31
  dnl via --without-libiconv-prefix, he wants to use it. The first
33
  dnl via --without-libiconv-prefix, he wants to use it. The first
32
  dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
34
  dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
33
  am_save_CPPFLAGS="$CPPFLAGS"
35
  am_save_CPPFLAGS="$CPPFLAGS"
34
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
36
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
35
37
36
  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
38
  AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
37
    am_cv_func_iconv="no, consider installing GNU libiconv"
39
    am_cv_func_iconv="no, consider installing GNU libiconv"
38
    am_cv_lib_iconv=no
40
    am_cv_lib_iconv=no
39
    AC_TRY_LINK([#include <stdlib.h>
41
    AC_LINK_IFELSE(
40
#include <iconv.h>],
42
      [AC_LANG_PROGRAM(
41
      [iconv_t cd = iconv_open("","");
43
         [[
42
       iconv(cd,NULL,NULL,NULL,NULL);
44
#include <stdlib.h>
43
       iconv_close(cd);],
45
#include <iconv.h>
44
      am_cv_func_iconv=yes)
46
         ]],
47
         [[iconv_t cd = iconv_open("","");
48
           iconv(cd,NULL,NULL,NULL,NULL);
49
           iconv_close(cd);]])],
50
      [am_cv_func_iconv=yes])
45
    if test "$am_cv_func_iconv" != yes; then
51
    if test "$am_cv_func_iconv" != yes; then
46
      am_save_LIBS="$LIBS"
52
      am_save_LIBS="$LIBS"
47
      LIBS="$LIBS $LIBICONV"
53
      LIBS="$LIBS $LIBICONV"
48
      AC_TRY_LINK([#include <stdlib.h>
54
      AC_LINK_IFELSE(
49
#include <iconv.h>],
55
        [AC_LANG_PROGRAM(
50
        [iconv_t cd = iconv_open("","");
56
           [[
51
         iconv(cd,NULL,NULL,NULL,NULL);
57
#include <stdlib.h>
52
         iconv_close(cd);],
58
#include <iconv.h>
53
        am_cv_lib_iconv=yes
59
           ]],
54
        am_cv_func_iconv=yes)
60
           [[iconv_t cd = iconv_open("","");
61
             iconv(cd,NULL,NULL,NULL,NULL);
62
             iconv_close(cd);]])],
63
        [am_cv_lib_iconv=yes]
64
        [am_cv_func_iconv=yes])
55
      LIBS="$am_save_LIBS"
65
      LIBS="$am_save_LIBS"
56
    fi
66
    fi
57
  ])
67
  ])
58
  if test "$am_cv_func_iconv" = yes; then
68
  if test "$am_cv_func_iconv" = yes; then
59
    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
69
    AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
70
      dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
71
      dnl Solaris 10.
72
      am_save_LIBS="$LIBS"
73
      if test $am_cv_lib_iconv = yes; then
74
        LIBS="$LIBS $LIBICONV"
75
      fi
76
      am_cv_func_iconv_works=no
77
      for ac_iconv_const in '' 'const'; do
78
        AC_RUN_IFELSE(
79
          [AC_LANG_PROGRAM(
80
             [[
81
#include <iconv.h>
82
#include <string.h>
83
84
#ifndef ICONV_CONST
85
# define ICONV_CONST $ac_iconv_const
86
#endif
87
             ]],
88
             [[int result = 0;
89
  /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
90
     returns.  */
91
  {
92
    iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
93
    if (cd_utf8_to_88591 != (iconv_t)(-1))
94
      {
95
        static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
96
        char buf[10];
97
        ICONV_CONST char *inptr = input;
98
        size_t inbytesleft = strlen (input);
99
        char *outptr = buf;
100
        size_t outbytesleft = sizeof (buf);
101
        size_t res = iconv (cd_utf8_to_88591,
102
                            &inptr, &inbytesleft,
103
                            &outptr, &outbytesleft);
104
        if (res == 0)
105
          result |= 1;
106
        iconv_close (cd_utf8_to_88591);
107
      }
108
  }
109
  /* Test against Solaris 10 bug: Failures are not distinguishable from
110
     successful returns.  */
111
  {
112
    iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
113
    if (cd_ascii_to_88591 != (iconv_t)(-1))
114
      {
115
        static ICONV_CONST char input[] = "\263";
116
        char buf[10];
117
        ICONV_CONST char *inptr = input;
118
        size_t inbytesleft = strlen (input);
119
        char *outptr = buf;
120
        size_t outbytesleft = sizeof (buf);
121
        size_t res = iconv (cd_ascii_to_88591,
122
                            &inptr, &inbytesleft,
123
                            &outptr, &outbytesleft);
124
        if (res == 0)
125
          result |= 2;
126
        iconv_close (cd_ascii_to_88591);
127
      }
128
  }
129
  /* Test against AIX 6.1..7.1 bug: Buffer overrun.  */
130
  {
131
    iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
132
    if (cd_88591_to_utf8 != (iconv_t)(-1))
133
      {
134
        static ICONV_CONST char input[] = "\304";
135
        static char buf[2] = { (char)0xDE, (char)0xAD };
136
        ICONV_CONST char *inptr = input;
137
        size_t inbytesleft = 1;
138
        char *outptr = buf;
139
        size_t outbytesleft = 1;
140
        size_t res = iconv (cd_88591_to_utf8,
141
                            &inptr, &inbytesleft,
142
                            &outptr, &outbytesleft);
143
        if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
144
          result |= 4;
145
        iconv_close (cd_88591_to_utf8);
146
      }
147
  }
148
#if 0 /* This bug could be worked around by the caller.  */
149
  /* Test against HP-UX 11.11 bug: Positive return value instead of 0.  */
150
  {
151
    iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
152
    if (cd_88591_to_utf8 != (iconv_t)(-1))
153
      {
154
        static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
155
        char buf[50];
156
        ICONV_CONST char *inptr = input;
157
        size_t inbytesleft = strlen (input);
158
        char *outptr = buf;
159
        size_t outbytesleft = sizeof (buf);
160
        size_t res = iconv (cd_88591_to_utf8,
161
                            &inptr, &inbytesleft,
162
                            &outptr, &outbytesleft);
163
        if ((int)res > 0)
164
          result |= 8;
165
        iconv_close (cd_88591_to_utf8);
166
      }
167
  }
168
#endif
169
  /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
170
     provided.  */
171
  {
172
    /* Try standardized names.  */
173
    iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
174
    /* Try IRIX, OSF/1 names.  */
175
    iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
176
    /* Try AIX names.  */
177
    iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
178
    /* Try HP-UX names.  */
179
    iconv_t cd4 = iconv_open ("utf8", "eucJP");
180
    if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
181
        && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
182
      result |= 16;
183
    if (cd1 != (iconv_t)(-1))
184
      iconv_close (cd1);
185
    if (cd2 != (iconv_t)(-1))
186
      iconv_close (cd2);
187
    if (cd3 != (iconv_t)(-1))
188
      iconv_close (cd3);
189
    if (cd4 != (iconv_t)(-1))
190
      iconv_close (cd4);
191
  }
192
  return result;
193
]])],
194
          [am_cv_func_iconv_works=yes], ,
195
          [case "$host_os" in
196
             aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
197
             *)            am_cv_func_iconv_works="guessing yes" ;;
198
           esac])
199
        test "$am_cv_func_iconv_works" = no || break
200
      done
201
      LIBS="$am_save_LIBS"
202
    ])
203
    case "$am_cv_func_iconv_works" in
204
      *no) am_func_iconv=no am_cv_lib_iconv=no ;;
205
      *)   am_func_iconv=yes ;;
206
    esac
207
  else
208
    am_func_iconv=no am_cv_lib_iconv=no
209
  fi
210
  if test "$am_func_iconv" = yes; then
211
    AC_DEFINE([HAVE_ICONV], [1],
212
      [Define if you have the iconv() function and it works.])
60
  fi
213
  fi
61
  if test "$am_cv_lib_iconv" = yes; then
214
  if test "$am_cv_lib_iconv" = yes; then
62
    AC_MSG_CHECKING([how to link with libiconv])
215
    AC_MSG_CHECKING([how to link with libiconv])
Lines 68-101 AC_DEFUN([AM_ICONV_LINK], Link Here
68
    LIBICONV=
221
    LIBICONV=
69
    LTLIBICONV=
222
    LTLIBICONV=
70
  fi
223
  fi
71
  AC_SUBST(LIBICONV)
224
  AC_SUBST([LIBICONV])
72
  AC_SUBST(LTLIBICONV)
225
  AC_SUBST([LTLIBICONV])
73
])
226
])
74
227
75
AC_DEFUN([AM_ICONV],
228
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
229
dnl avoid warnings like
230
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
231
dnl This is tricky because of the way 'aclocal' is implemented:
232
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
233
dnl   Otherwise aclocal's initial scan pass would miss the macro definition.
234
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
235
dnl   Otherwise aclocal would emit many "Use of uninitialized value $1"
236
dnl   warnings.
237
m4_define([gl_iconv_AC_DEFUN],
238
  m4_version_prereq([2.64],
239
    [[AC_DEFUN_ONCE(
240
        [$1], [$2])]],
241
    [m4_ifdef([gl_00GNULIB],
242
       [[AC_DEFUN_ONCE(
243
           [$1], [$2])]],
244
       [[AC_DEFUN(
245
           [$1], [$2])]])]))
246
gl_iconv_AC_DEFUN([AM_ICONV],
76
[
247
[
77
  AM_ICONV_LINK
248
  AM_ICONV_LINK
78
  if test "$am_cv_func_iconv" = yes; then
249
  if test "$am_cv_func_iconv" = yes; then
79
    AC_MSG_CHECKING([for iconv declaration])
250
    AC_MSG_CHECKING([for iconv declaration])
80
    AC_CACHE_VAL(am_cv_proto_iconv, [
251
    AC_CACHE_VAL([am_cv_proto_iconv], [
81
      AC_TRY_COMPILE([
252
      AC_COMPILE_IFELSE(
253
        [AC_LANG_PROGRAM(
254
           [[
82
#include <stdlib.h>
255
#include <stdlib.h>
83
#include <iconv.h>
256
#include <iconv.h>
84
extern
257
extern
85
#ifdef __cplusplus
258
#ifdef __cplusplus
86
"C"
259
"C"
87
#endif
260
#endif
88
#if defined(__STDC__) || defined(__cplusplus)
261
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
89
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
262
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
90
#else
263
#else
91
size_t iconv();
264
size_t iconv();
92
#endif
265
#endif
93
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
266
           ]],
267
           [[]])],
268
        [am_cv_proto_iconv_arg1=""],
269
        [am_cv_proto_iconv_arg1="const"])
94
      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
270
      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
95
    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
271
    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
96
    AC_MSG_RESULT([$]{ac_t:-
272
    AC_MSG_RESULT([
97
         }[$]am_cv_proto_iconv)
273
         $am_cv_proto_iconv])
98
    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
274
  else
99
      [Define as const if the declaration of iconv() needs const.])
275
    dnl When compiling GNU libiconv on a system that does not have iconv yet,
276
    dnl pick the POSIX compliant declaration without 'const'.
277
    am_cv_proto_iconv_arg1=""
100
  fi
278
  fi
279
  AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
280
    [Define as const if the declaration of iconv() needs const.])
281
  dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
282
  m4_ifdef([gl_ICONV_H_DEFAULTS],
283
    [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
284
     if test -n "$am_cv_proto_iconv_arg1"; then
285
       ICONV_CONST="const"
286
     fi
287
    ])
101
])
288
])
(-)a/m4/lib-ld.m4 (-78 / +136 lines)
Lines 1-110 Link Here
1
# lib-ld.m4 serial 3 (gettext-0.13)
1
# lib-ld.m4 serial 9
2
dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
2
dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
5
dnl with or without modifications, as long as this notice is preserved.
6
6
7
dnl Subroutines of libtool.m4,
7
dnl Subroutines of libtool.m4,
8
dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
8
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9
dnl with libtool.m4.
9
dnl collision with libtool.m4.
10
10
11
dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
11
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
12
AC_DEFUN([AC_LIB_PROG_LD_GNU],
12
AC_DEFUN([AC_LIB_PROG_LD_GNU],
13
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
13
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
14
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
14
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
15
case `$LD -v 2>&1 </dev/null` in
15
case `$LD -v 2>&1 </dev/null` in
16
*GNU* | *'with BFD'*)
16
*GNU* | *'with BFD'*)
17
  acl_cv_prog_gnu_ld=yes ;;
17
  acl_cv_prog_gnu_ld=yes
18
  ;;
18
*)
19
*)
19
  acl_cv_prog_gnu_ld=no ;;
20
  acl_cv_prog_gnu_ld=no
21
  ;;
20
esac])
22
esac])
21
with_gnu_ld=$acl_cv_prog_gnu_ld
23
with_gnu_ld=$acl_cv_prog_gnu_ld
22
])
24
])
23
25
24
dnl From libtool-1.4. Sets the variable LD.
26
dnl From libtool-2.4. Sets the variable LD.
25
AC_DEFUN([AC_LIB_PROG_LD],
27
AC_DEFUN([AC_LIB_PROG_LD],
26
[AC_ARG_WITH(gnu-ld,
28
[AC_REQUIRE([AC_PROG_CC])dnl
27
[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
28
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
29
AC_REQUIRE([AC_PROG_CC])dnl
30
AC_REQUIRE([AC_CANONICAL_HOST])dnl
29
AC_REQUIRE([AC_CANONICAL_HOST])dnl
30
31
AC_ARG_WITH([gnu-ld],
32
    [AS_HELP_STRING([--with-gnu-ld],
33
        [assume the C compiler uses GNU ld [default=no]])],
34
    [test "$withval" = no || with_gnu_ld=yes],
35
    [with_gnu_ld=no])dnl
36
31
# Prepare PATH_SEPARATOR.
37
# Prepare PATH_SEPARATOR.
32
# The user is always right.
38
# The user is always right.
33
if test "${PATH_SEPARATOR+set}" != set; then
39
if test "${PATH_SEPARATOR+set}" != set; then
34
  echo "#! /bin/sh" >conf$$.sh
40
  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
35
  echo  "exit 0"   >>conf$$.sh
41
  # contains only /bin. Note that ksh looks also at the FPATH variable,
36
  chmod +x conf$$.sh
42
  # so we have to set that as well for the test.
37
  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
43
  PATH_SEPARATOR=:
38
    PATH_SEPARATOR=';'
44
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
39
  else
45
    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
40
    PATH_SEPARATOR=:
46
           || PATH_SEPARATOR=';'
41
  fi
47
       }
42
  rm -f conf$$.sh
43
fi
48
fi
44
ac_prog=ld
49
45
if test "$GCC" = yes; then
50
if test -n "$LD"; then
46
  # Check if gcc -print-prog-name=ld gives a path.
51
  AC_MSG_CHECKING([for ld])
47
  AC_MSG_CHECKING([for ld used by GCC])
52
elif test "$GCC" = yes; then
48
  case $host in
53
  AC_MSG_CHECKING([for ld used by $CC])
49
  *-*-mingw*)
50
    # gcc leaves a trailing carriage return which upsets mingw
51
    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
52
  *)
53
    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
54
  esac
55
  case $ac_prog in
56
    # Accept absolute paths.
57
    [[\\/]* | [A-Za-z]:[\\/]*)]
58
      [re_direlt='/[^/][^/]*/\.\./']
59
      # Canonicalize the path of ld
60
      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
61
      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
62
	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
63
      done
64
      test -z "$LD" && LD="$ac_prog"
65
      ;;
66
  "")
67
    # If it fails, then pretend we aren't using GCC.
68
    ac_prog=ld
69
    ;;
70
  *)
71
    # If it is relative, then search for the first ld in PATH.
72
    with_gnu_ld=unknown
73
    ;;
74
  esac
75
elif test "$with_gnu_ld" = yes; then
54
elif test "$with_gnu_ld" = yes; then
76
  AC_MSG_CHECKING([for GNU ld])
55
  AC_MSG_CHECKING([for GNU ld])
77
else
56
else
78
  AC_MSG_CHECKING([for non-GNU ld])
57
  AC_MSG_CHECKING([for non-GNU ld])
79
fi
58
fi
80
AC_CACHE_VAL(acl_cv_path_LD,
59
if test -n "$LD"; then
81
[if test -z "$LD"; then
60
  # Let the user override the test with a path.
82
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
61
  :
83
  for ac_dir in $PATH; do
62
else
84
    test -z "$ac_dir" && ac_dir=.
63
  AC_CACHE_VAL([acl_cv_path_LD],
85
    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
64
  [
86
      acl_cv_path_LD="$ac_dir/$ac_prog"
65
    acl_cv_path_LD= # Final result of this test
87
      # Check to see if the program is GNU ld.  I'd rather use --version,
66
    ac_prog=ld # Program to search in $PATH
88
      # but apparently some GNU ld's only accept -v.
67
    if test "$GCC" = yes; then
89
      # Break only if it was the GNU/non-GNU ld that we prefer.
68
      # Check if gcc -print-prog-name=ld gives a path.
90
      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
69
      case $host in
91
      *GNU* | *'with BFD'*)
70
        *-*-mingw*)
92
	test "$with_gnu_ld" != no && break ;;
71
          # gcc leaves a trailing carriage return which upsets mingw
93
      *)
72
          acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
94
	test "$with_gnu_ld" != yes && break ;;
73
        *)
74
          acl_output=`($CC -print-prog-name=ld) 2>&5` ;;
75
      esac
76
      case $acl_output in
77
        # Accept absolute paths.
78
        [[\\/]]* | ?:[[\\/]]*)
79
          re_direlt='/[[^/]][[^/]]*/\.\./'
80
          # Canonicalize the pathname of ld
81
          acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'`
82
          while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do
83
            acl_output=`echo $acl_output | sed "s%$re_direlt%/%"`
84
          done
85
          # Got the pathname. No search in PATH is needed.
86
          acl_cv_path_LD="$acl_output"
87
          ac_prog=
88
          ;;
89
        "")
90
          # If it fails, then pretend we aren't using GCC.
91
          ;;
92
        *)
93
          # If it is relative, then search for the first ld in PATH.
94
          with_gnu_ld=unknown
95
          ;;
95
      esac
96
      esac
96
    fi
97
    fi
97
  done
98
    if test -n "$ac_prog"; then
98
  IFS="$ac_save_ifs"
99
      # Search for $ac_prog in $PATH.
99
else
100
      acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
100
  acl_cv_path_LD="$LD" # Let the user override the test with a path.
101
      for ac_dir in $PATH; do
101
fi])
102
        IFS="$acl_save_ifs"
102
LD="$acl_cv_path_LD"
103
        test -z "$ac_dir" && ac_dir=.
104
        if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
105
          acl_cv_path_LD="$ac_dir/$ac_prog"
106
          # Check to see if the program is GNU ld.  I'd rather use --version,
107
          # but apparently some variants of GNU ld only accept -v.
108
          # Break only if it was the GNU/non-GNU ld that we prefer.
109
          case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
110
            *GNU* | *'with BFD'*)
111
              test "$with_gnu_ld" != no && break
112
              ;;
113
            *)
114
              test "$with_gnu_ld" != yes && break
115
              ;;
116
          esac
117
        fi
118
      done
119
      IFS="$acl_save_ifs"
120
    fi
121
    case $host in
122
      *-*-aix*)
123
        AC_COMPILE_IFELSE(
124
          [AC_LANG_SOURCE(
125
             [[#if defined __powerpc64__ || defined _ARCH_PPC64
126
                int ok;
127
               #else
128
                error fail
129
               #endif
130
             ]])],
131
          [# The compiler produces 64-bit code. Add option '-b64' so that the
132
           # linker groks 64-bit object files.
133
           case "$acl_cv_path_LD " in
134
             *" -b64 "*) ;;
135
             *) acl_cv_path_LD="$acl_cv_path_LD -b64" ;;
136
           esac
137
          ], [])
138
        ;;
139
      sparc64-*-netbsd*)
140
        AC_COMPILE_IFELSE(
141
          [AC_LANG_SOURCE(
142
             [[#if defined __sparcv9 || defined __arch64__
143
                int ok;
144
               #else
145
                error fail
146
               #endif
147
             ]])],
148
          [],
149
          [# The compiler produces 32-bit code. Add option '-m elf32_sparc'
150
           # so that the linker groks 32-bit object files.
151
           case "$acl_cv_path_LD " in
152
             *" -m elf32_sparc "*) ;;
153
             *) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;;
154
           esac
155
          ])
156
        ;;
157
    esac
158
  ])
159
  LD="$acl_cv_path_LD"
160
fi
103
if test -n "$LD"; then
161
if test -n "$LD"; then
104
  AC_MSG_RESULT($LD)
162
  AC_MSG_RESULT([$LD])
105
else
163
else
106
  AC_MSG_RESULT(no)
164
  AC_MSG_RESULT([no])
165
  AC_MSG_ERROR([no acceptable ld found in \$PATH])
107
fi
166
fi
108
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
109
AC_LIB_PROG_LD_GNU
167
AC_LIB_PROG_LD_GNU
110
])
168
])
(-)a/m4/lib-link.m4 (-104 / +260 lines)
Lines 1-58 Link Here
1
# lib-link.m4 serial 9 (gettext-0.16)
1
# lib-link.m4 serial 31
2
dnl Copyright (C) 2001-2006 Free Software Foundation, Inc.
2
dnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
5
dnl with or without modifications, as long as this notice is preserved.
6
6
7
dnl From Bruno Haible.
7
dnl From Bruno Haible.
8
8
9
AC_PREREQ(2.50)
9
AC_PREREQ([2.61])
10
10
11
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
11
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12
dnl the libraries corresponding to explicit and implicit dependencies.
12
dnl the libraries corresponding to explicit and implicit dependencies.
13
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
13
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14
dnl augments the CPPFLAGS variable.
14
dnl augments the CPPFLAGS variable.
15
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
15
AC_DEFUN([AC_LIB_LINKFLAGS],
17
AC_DEFUN([AC_LIB_LINKFLAGS],
16
[
18
[
17
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
19
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
18
  AC_REQUIRE([AC_LIB_RPATH])
20
  AC_REQUIRE([AC_LIB_RPATH])
19
  define([Name],[translit([$1],[./-], [___])])
21
  pushdef([Name],[m4_translit([$1],[./+-], [____])])
20
  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
22
  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
21
                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
23
                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
22
  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
24
  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
23
    AC_LIB_LINKFLAGS_BODY([$1], [$2])
25
    AC_LIB_LINKFLAGS_BODY([$1], [$2])
24
    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
26
    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
25
    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
27
    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
26
    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
28
    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29
    ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
27
  ])
30
  ])
28
  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
31
  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
29
  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
32
  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
30
  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
33
  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
34
  LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
31
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
35
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
32
  AC_SUBST([LIB]NAME)
36
  AC_SUBST([LIB]NAME)
33
  AC_SUBST([LTLIB]NAME)
37
  AC_SUBST([LTLIB]NAME)
38
  AC_SUBST([LIB]NAME[_PREFIX])
34
  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
39
  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
35
  dnl results of this search when this library appears as a dependency.
40
  dnl results of this search when this library appears as a dependency.
36
  HAVE_LIB[]NAME=yes
41
  HAVE_LIB[]NAME=yes
37
  undefine([Name])
42
  popdef([NAME])
38
  undefine([NAME])
43
  popdef([Name])
39
])
44
])
40
45
41
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
46
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
42
dnl searches for libname and the libraries corresponding to explicit and
47
dnl searches for libname and the libraries corresponding to explicit and
43
dnl implicit dependencies, together with the specified include files and
48
dnl implicit dependencies, together with the specified include files and
44
dnl the ability to compile and link the specified testcode. If found, it
49
dnl the ability to compile and link the specified testcode. The missing-message
45
dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
50
dnl defaults to 'no' and may contain additional hints for the user.
46
dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
51
dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
52
dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
47
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
53
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
48
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
54
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
55
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
56
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
49
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
57
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
50
[
58
[
51
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
59
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
52
  AC_REQUIRE([AC_LIB_RPATH])
60
  AC_REQUIRE([AC_LIB_RPATH])
53
  define([Name],[translit([$1],[./-], [___])])
61
  pushdef([Name],[m4_translit([$1],[./+-], [____])])
54
  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62
  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
55
                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
63
                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
56
64
57
  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
65
  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
58
  dnl accordingly.
66
  dnl accordingly.
Lines 66-78 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], Link Here
66
74
67
  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
75
  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
68
    ac_save_LIBS="$LIBS"
76
    ac_save_LIBS="$LIBS"
69
    LIBS="$LIBS $LIB[]NAME"
77
    dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
70
    AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
78
    dnl because these -l options might require -L options that are present in
79
    dnl LIBS. -l options benefit only from the -L options listed before it.
80
    dnl Otherwise, add it to the front of LIBS, because it may be a static
81
    dnl library that depends on another static library that is present in LIBS.
82
    dnl Static libraries benefit only from the static libraries listed after
83
    dnl it.
84
    case " $LIB[]NAME" in
85
      *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86
      *)       LIBS="$LIB[]NAME $LIBS" ;;
87
    esac
88
    AC_LINK_IFELSE(
89
      [AC_LANG_PROGRAM([[$3]], [[$4]])],
90
      [ac_cv_lib[]Name=yes],
91
      [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
71
    LIBS="$ac_save_LIBS"
92
    LIBS="$ac_save_LIBS"
72
  ])
93
  ])
73
  if test "$ac_cv_lib[]Name" = yes; then
94
  if test "$ac_cv_lib[]Name" = yes; then
74
    HAVE_LIB[]NAME=yes
95
    HAVE_LIB[]NAME=yes
75
    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
96
    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
76
    AC_MSG_CHECKING([how to link with lib[]$1])
97
    AC_MSG_CHECKING([how to link with lib[]$1])
77
    AC_MSG_RESULT([$LIB[]NAME])
98
    AC_MSG_RESULT([$LIB[]NAME])
78
  else
99
  else
Lines 82-107 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], Link Here
82
    CPPFLAGS="$ac_save_CPPFLAGS"
103
    CPPFLAGS="$ac_save_CPPFLAGS"
83
    LIB[]NAME=
104
    LIB[]NAME=
84
    LTLIB[]NAME=
105
    LTLIB[]NAME=
106
    LIB[]NAME[]_PREFIX=
85
  fi
107
  fi
86
  AC_SUBST([HAVE_LIB]NAME)
108
  AC_SUBST([HAVE_LIB]NAME)
87
  AC_SUBST([LIB]NAME)
109
  AC_SUBST([LIB]NAME)
88
  AC_SUBST([LTLIB]NAME)
110
  AC_SUBST([LTLIB]NAME)
89
  undefine([Name])
111
  AC_SUBST([LIB]NAME[_PREFIX])
90
  undefine([NAME])
112
  popdef([NAME])
113
  popdef([Name])
91
])
114
])
92
115
93
dnl Determine the platform dependent parameters needed to use rpath:
116
dnl Determine the platform dependent parameters needed to use rpath:
94
dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
117
dnl   acl_libext,
95
dnl hardcode_direct, hardcode_minus_L.
118
dnl   acl_shlibext,
119
dnl   acl_libname_spec,
120
dnl   acl_library_names_spec,
121
dnl   acl_hardcode_libdir_flag_spec,
122
dnl   acl_hardcode_libdir_separator,
123
dnl   acl_hardcode_direct,
124
dnl   acl_hardcode_minus_L.
96
AC_DEFUN([AC_LIB_RPATH],
125
AC_DEFUN([AC_LIB_RPATH],
97
[
126
[
98
  dnl Tell automake >= 1.10 to complain if config.rpath is missing.
127
  dnl Complain if config.rpath is missing.
99
  m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
128
  AC_REQUIRE_AUX_FILE([config.rpath])
100
  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
129
  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
101
  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
130
  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
102
  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
131
  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
103
  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
132
  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
104
  AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
133
  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
105
    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
134
    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
106
    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
135
    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
107
    . ./conftest.sh
136
    . ./conftest.sh
Lines 109-143 AC_DEFUN([AC_LIB_RPATH], Link Here
109
    acl_cv_rpath=done
138
    acl_cv_rpath=done
110
  ])
139
  ])
111
  wl="$acl_cv_wl"
140
  wl="$acl_cv_wl"
112
  libext="$acl_cv_libext"
141
  acl_libext="$acl_cv_libext"
113
  shlibext="$acl_cv_shlibext"
142
  acl_shlibext="$acl_cv_shlibext"
114
  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
143
  acl_libname_spec="$acl_cv_libname_spec"
115
  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
144
  acl_library_names_spec="$acl_cv_library_names_spec"
116
  hardcode_direct="$acl_cv_hardcode_direct"
145
  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
117
  hardcode_minus_L="$acl_cv_hardcode_minus_L"
146
  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
147
  acl_hardcode_direct="$acl_cv_hardcode_direct"
148
  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
118
  dnl Determine whether the user wants rpath handling at all.
149
  dnl Determine whether the user wants rpath handling at all.
119
  AC_ARG_ENABLE(rpath,
150
  AC_ARG_ENABLE([rpath],
120
    [  --disable-rpath         do not hardcode runtime library paths],
151
    [  --disable-rpath         do not hardcode runtime library paths],
121
    :, enable_rpath=yes)
152
    :, enable_rpath=yes)
122
])
153
])
123
154
155
dnl AC_LIB_FROMPACKAGE(name, package)
156
dnl declares that libname comes from the given package. The configure file
157
dnl will then not have a --with-libname-prefix option but a
158
dnl --with-package-prefix option. Several libraries can come from the same
159
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
160
dnl macro call that searches for libname.
161
AC_DEFUN([AC_LIB_FROMPACKAGE],
162
[
163
  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
164
                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
165
  define([acl_frompackage_]NAME, [$2])
166
  popdef([NAME])
167
  pushdef([PACK],[$2])
168
  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
169
                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
170
  define([acl_libsinpackage_]PACKUP,
171
    m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
172
  popdef([PACKUP])
173
  popdef([PACK])
174
])
175
124
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
176
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
125
dnl the libraries corresponding to explicit and implicit dependencies.
177
dnl the libraries corresponding to explicit and implicit dependencies.
126
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
178
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
179
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
180
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
127
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
181
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
128
[
182
[
129
  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
183
  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
130
  define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
184
  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
131
                               [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
185
                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
186
  pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
187
  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
188
                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
189
  pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
132
  dnl By default, look in $includedir and $libdir.
190
  dnl By default, look in $includedir and $libdir.
133
  use_additional=yes
191
  use_additional=yes
134
  AC_LIB_WITH_FINAL_PREFIX([
192
  AC_LIB_WITH_FINAL_PREFIX([
135
    eval additional_includedir=\"$includedir\"
193
    eval additional_includedir=\"$includedir\"
136
    eval additional_libdir=\"$libdir\"
194
    eval additional_libdir=\"$libdir\"
195
    eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
196
    eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
137
  ])
197
  ])
138
  AC_LIB_ARG_WITH([lib$1-prefix],
198
  AC_ARG_WITH(PACK[-prefix],
139
[  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
199
[[  --with-]]PACK[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
140
  --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
200
  --without-]]PACK[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
141
[
201
[
142
    if test "X$withval" = "Xno"; then
202
    if test "X$withval" = "Xno"; then
143
      use_additional=no
203
      use_additional=no
Lines 146-163 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
146
        AC_LIB_WITH_FINAL_PREFIX([
206
        AC_LIB_WITH_FINAL_PREFIX([
147
          eval additional_includedir=\"$includedir\"
207
          eval additional_includedir=\"$includedir\"
148
          eval additional_libdir=\"$libdir\"
208
          eval additional_libdir=\"$libdir\"
209
          eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
210
          eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
149
        ])
211
        ])
150
      else
212
      else
151
        additional_includedir="$withval/include"
213
        additional_includedir="$withval/include"
152
        additional_libdir="$withval/$acl_libdirstem"
214
        additional_libdir="$withval/$acl_libdirstem"
215
        additional_libdir2="$withval/$acl_libdirstem2"
216
        additional_libdir3="$withval/$acl_libdirstem3"
153
      fi
217
      fi
154
    fi
218
    fi
155
])
219
])
220
  if test "X$additional_libdir2" = "X$additional_libdir"; then
221
    additional_libdir2=
222
  fi
223
  if test "X$additional_libdir3" = "X$additional_libdir"; then
224
    additional_libdir3=
225
  fi
156
  dnl Search the library and its dependencies in $additional_libdir and
226
  dnl Search the library and its dependencies in $additional_libdir and
157
  dnl $LDFLAGS. Using breadth-first-seach.
227
  dnl $LDFLAGS. Using breadth-first-seach.
158
  LIB[]NAME=
228
  LIB[]NAME=
159
  LTLIB[]NAME=
229
  LTLIB[]NAME=
160
  INC[]NAME=
230
  INC[]NAME=
231
  LIB[]NAME[]_PREFIX=
232
  dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
233
  dnl computed. So it has to be reset here.
234
  HAVE_LIB[]NAME=
161
  rpathdirs=
235
  rpathdirs=
162
  ltrpathdirs=
236
  ltrpathdirs=
163
  names_already_handled=
237
  names_already_handled=
Lines 177-183 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
177
        names_already_handled="$names_already_handled $name"
251
        names_already_handled="$names_already_handled $name"
178
        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
252
        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
179
        dnl or AC_LIB_HAVE_LINKFLAGS call.
253
        dnl or AC_LIB_HAVE_LINKFLAGS call.
180
        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
254
        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
181
        eval value=\"\$HAVE_LIB$uppername\"
255
        eval value=\"\$HAVE_LIB$uppername\"
182
        if test -n "$value"; then
256
        if test -n "$value"; then
183
          if test "$value" = yes; then
257
          if test "$value" = yes; then
Lines 197-225 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
197
          found_la=
271
          found_la=
198
          found_so=
272
          found_so=
199
          found_a=
273
          found_a=
274
          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
275
          if test -n "$acl_shlibext"; then
276
            shrext=".$acl_shlibext"             # typically: shrext=.so
277
          else
278
            shrext=
279
          fi
200
          if test $use_additional = yes; then
280
          if test $use_additional = yes; then
201
            if test -n "$shlibext" \
281
            for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do
202
               && { test -f "$additional_libdir/lib$name.$shlibext" \
282
              if test "X$found_dir" = "X"; then
203
                    || { test "$shlibext" = dll \
283
                eval dir=\$$additional_libdir_variable
204
                         && test -f "$additional_libdir/lib$name.dll.a"; }; }; then
284
                if test -n "$dir"; then
205
              found_dir="$additional_libdir"
285
                  dnl The same code as in the loop below:
206
              if test -f "$additional_libdir/lib$name.$shlibext"; then
286
                  dnl First look for a shared library.
207
                found_so="$additional_libdir/lib$name.$shlibext"
287
                  if test -n "$acl_shlibext"; then
208
              else
288
                    if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
209
                found_so="$additional_libdir/lib$name.dll.a"
289
                      found_dir="$dir"
210
              fi
290
                      found_so="$dir/$libname$shrext"
211
              if test -f "$additional_libdir/lib$name.la"; then
291
                    else
212
                found_la="$additional_libdir/lib$name.la"
292
                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
213
              fi
293
                        ver=`(cd "$dir" && \
214
            else
294
                              for f in "$libname$shrext".*; do echo "$f"; done \
215
              if test -f "$additional_libdir/lib$name.$libext"; then
295
                              | sed -e "s,^$libname$shrext\\\\.,," \
216
                found_dir="$additional_libdir"
296
                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
217
                found_a="$additional_libdir/lib$name.$libext"
297
                              | sed 1q ) 2>/dev/null`
218
                if test -f "$additional_libdir/lib$name.la"; then
298
                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
219
                  found_la="$additional_libdir/lib$name.la"
299
                          found_dir="$dir"
300
                          found_so="$dir/$libname$shrext.$ver"
301
                        fi
302
                      else
303
                        eval library_names=\"$acl_library_names_spec\"
304
                        for f in $library_names; do
305
                          if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
306
                            found_dir="$dir"
307
                            found_so="$dir/$f"
308
                            break
309
                          fi
310
                        done
311
                      fi
312
                    fi
313
                  fi
314
                  dnl Then look for a static library.
315
                  if test "X$found_dir" = "X"; then
316
                    if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
317
                      found_dir="$dir"
318
                      found_a="$dir/$libname.$acl_libext"
319
                    fi
320
                  fi
321
                  if test "X$found_dir" != "X"; then
322
                    if test -f "$dir/$libname.la"; then
323
                      found_la="$dir/$libname.la"
324
                    fi
325
                  fi
220
                fi
326
                fi
221
              fi
327
              fi
222
            fi
328
            done
223
          fi
329
          fi
224
          if test "X$found_dir" = "X"; then
330
          if test "X$found_dir" = "X"; then
225
            for x in $LDFLAGS $LTLIB[]NAME; do
331
            for x in $LDFLAGS $LTLIB[]NAME; do
Lines 227-252 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
227
              case "$x" in
333
              case "$x" in
228
                -L*)
334
                -L*)
229
                  dir=`echo "X$x" | sed -e 's/^X-L//'`
335
                  dir=`echo "X$x" | sed -e 's/^X-L//'`
230
                  if test -n "$shlibext" \
336
                  dnl First look for a shared library.
231
                     && { test -f "$dir/lib$name.$shlibext" \
337
                  if test -n "$acl_shlibext"; then
232
                          || { test "$shlibext" = dll \
338
                    if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
233
                               && test -f "$dir/lib$name.dll.a"; }; }; then
339
                      found_dir="$dir"
234
                    found_dir="$dir"
340
                      found_so="$dir/$libname$shrext"
235
                    if test -f "$dir/lib$name.$shlibext"; then
236
                      found_so="$dir/lib$name.$shlibext"
237
                    else
341
                    else
238
                      found_so="$dir/lib$name.dll.a"
342
                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
239
                    fi
343
                        ver=`(cd "$dir" && \
240
                    if test -f "$dir/lib$name.la"; then
344
                              for f in "$libname$shrext".*; do echo "$f"; done \
241
                      found_la="$dir/lib$name.la"
345
                              | sed -e "s,^$libname$shrext\\\\.,," \
346
                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
347
                              | sed 1q ) 2>/dev/null`
348
                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
349
                          found_dir="$dir"
350
                          found_so="$dir/$libname$shrext.$ver"
351
                        fi
352
                      else
353
                        eval library_names=\"$acl_library_names_spec\"
354
                        for f in $library_names; do
355
                          if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
356
                            found_dir="$dir"
357
                            found_so="$dir/$f"
358
                            break
359
                          fi
360
                        done
361
                      fi
242
                    fi
362
                    fi
243
                  else
363
                  fi
244
                    if test -f "$dir/lib$name.$libext"; then
364
                  dnl Then look for a static library.
365
                  if test "X$found_dir" = "X"; then
366
                    if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
245
                      found_dir="$dir"
367
                      found_dir="$dir"
246
                      found_a="$dir/lib$name.$libext"
368
                      found_a="$dir/$libname.$acl_libext"
247
                      if test -f "$dir/lib$name.la"; then
369
                    fi
248
                        found_la="$dir/lib$name.la"
370
                  fi
249
                      fi
371
                  if test "X$found_dir" != "X"; then
372
                    if test -f "$dir/$libname.la"; then
373
                      found_la="$dir/$libname.la"
250
                    fi
374
                    fi
251
                  fi
375
                  fi
252
                  ;;
376
                  ;;
Lines 263-269 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
263
              dnl Linking with a shared library. We attempt to hardcode its
387
              dnl Linking with a shared library. We attempt to hardcode its
264
              dnl directory into the executable's runpath, unless it's the
388
              dnl directory into the executable's runpath, unless it's the
265
              dnl standard /usr/lib.
389
              dnl standard /usr/lib.
266
              if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
390
              if test "$enable_rpath" = no \
391
                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
392
                 || test "X$found_dir" = "X/usr/$acl_libdirstem2" \
393
                 || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then
267
                dnl No hardcoding is needed.
394
                dnl No hardcoding is needed.
268
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
395
                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
269
              else
396
              else
Lines 282-293 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
282
                  ltrpathdirs="$ltrpathdirs $found_dir"
409
                  ltrpathdirs="$ltrpathdirs $found_dir"
283
                fi
410
                fi
284
                dnl The hardcoding into $LIBNAME is system dependent.
411
                dnl The hardcoding into $LIBNAME is system dependent.
285
                if test "$hardcode_direct" = yes; then
412
                if test "$acl_hardcode_direct" = yes; then
286
                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
413
                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
287
                  dnl resulting binary.
414
                  dnl resulting binary.
288
                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
415
                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
289
                else
416
                else
290
                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
417
                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
291
                    dnl Use an explicit option to hardcode DIR into the resulting
418
                    dnl Use an explicit option to hardcode DIR into the resulting
292
                    dnl binary.
419
                    dnl binary.
293
                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
420
                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
Lines 318-330 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
318
                    if test -z "$haveit"; then
445
                    if test -z "$haveit"; then
319
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
446
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
320
                    fi
447
                    fi
321
                    if test "$hardcode_minus_L" != no; then
448
                    if test "$acl_hardcode_minus_L" != no; then
322
                      dnl FIXME: Not sure whether we should use
449
                      dnl FIXME: Not sure whether we should use
323
                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
450
                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
324
                      dnl here.
451
                      dnl here.
325
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
452
                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
326
                    else
453
                    else
327
                      dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
454
                      dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
328
                      dnl here, because this doesn't fit in flags passed to the
455
                      dnl here, because this doesn't fit in flags passed to the
329
                      dnl compiler. So give up. No hardcoding. This affects only
456
                      dnl compiler. So give up. No hardcoding. This affects only
330
                      dnl very old systems.
457
                      dnl very old systems.
Lines 351-356 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
351
            case "$found_dir" in
478
            case "$found_dir" in
352
              */$acl_libdirstem | */$acl_libdirstem/)
479
              */$acl_libdirstem | */$acl_libdirstem/)
353
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
480
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
481
                if test "$name" = '$1'; then
482
                  LIB[]NAME[]_PREFIX="$basedir"
483
                fi
484
                additional_includedir="$basedir/include"
485
                ;;
486
              */$acl_libdirstem2 | */$acl_libdirstem2/)
487
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
488
                if test "$name" = '$1'; then
489
                  LIB[]NAME[]_PREFIX="$basedir"
490
                fi
491
                additional_includedir="$basedir/include"
492
                ;;
493
              */$acl_libdirstem3 | */$acl_libdirstem3/)
494
                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`
495
                if test "$name" = '$1'; then
496
                  LIB[]NAME[]_PREFIX="$basedir"
497
                fi
354
                additional_includedir="$basedir/include"
498
                additional_includedir="$basedir/include"
355
                ;;
499
                ;;
356
            esac
500
            esac
Lines 403-419 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
403
              for dep in $dependency_libs; do
547
              for dep in $dependency_libs; do
404
                case "$dep" in
548
                case "$dep" in
405
                  -L*)
549
                  -L*)
406
                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
550
                    dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
407
                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
551
                    dnl Potentially add $dependency_libdir to $LIBNAME and $LTLIBNAME.
408
                    dnl But don't add it
552
                    dnl But don't add it
409
                    dnl   1. if it's the standard /usr/lib,
553
                    dnl   1. if it's the standard /usr/lib,
410
                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
554
                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
411
                    dnl   3. if it's already present in $LDFLAGS or the already
555
                    dnl   3. if it's already present in $LDFLAGS or the already
412
                    dnl      constructed $LIBNAME,
556
                    dnl      constructed $LIBNAME,
413
                    dnl   4. if it doesn't exist as a directory.
557
                    dnl   4. if it doesn't exist as a directory.
414
                    if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
558
                    if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \
559
                       && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \
560
                       && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then
415
                      haveit=
561
                      haveit=
416
                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
562
                      if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \
563
                         || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \
564
                         || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then
417
                        if test -n "$GCC"; then
565
                        if test -n "$GCC"; then
418
                          case $host_os in
566
                          case $host_os in
419
                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
567
                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
Lines 424-452 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
424
                        haveit=
572
                        haveit=
425
                        for x in $LDFLAGS $LIB[]NAME; do
573
                        for x in $LDFLAGS $LIB[]NAME; do
426
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
574
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
427
                          if test "X$x" = "X-L$additional_libdir"; then
575
                          if test "X$x" = "X-L$dependency_libdir"; then
428
                            haveit=yes
576
                            haveit=yes
429
                            break
577
                            break
430
                          fi
578
                          fi
431
                        done
579
                        done
432
                        if test -z "$haveit"; then
580
                        if test -z "$haveit"; then
433
                          if test -d "$additional_libdir"; then
581
                          if test -d "$dependency_libdir"; then
434
                            dnl Really add $additional_libdir to $LIBNAME.
582
                            dnl Really add $dependency_libdir to $LIBNAME.
435
                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
583
                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$dependency_libdir"
436
                          fi
584
                          fi
437
                        fi
585
                        fi
438
                        haveit=
586
                        haveit=
439
                        for x in $LDFLAGS $LTLIB[]NAME; do
587
                        for x in $LDFLAGS $LTLIB[]NAME; do
440
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
588
                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
441
                          if test "X$x" = "X-L$additional_libdir"; then
589
                          if test "X$x" = "X-L$dependency_libdir"; then
442
                            haveit=yes
590
                            haveit=yes
443
                            break
591
                            break
444
                          fi
592
                          fi
445
                        done
593
                        done
446
                        if test -z "$haveit"; then
594
                        if test -z "$haveit"; then
447
                          if test -d "$additional_libdir"; then
595
                          if test -d "$dependency_libdir"; then
448
                            dnl Really add $additional_libdir to $LTLIBNAME.
596
                            dnl Really add $dependency_libdir to $LTLIBNAME.
449
                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
597
                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$dependency_libdir"
450
                          fi
598
                          fi
451
                        fi
599
                        fi
452
                      fi
600
                      fi
Lines 512-529 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
512
    done
660
    done
513
  done
661
  done
514
  if test "X$rpathdirs" != "X"; then
662
  if test "X$rpathdirs" != "X"; then
515
    if test -n "$hardcode_libdir_separator"; then
663
    if test -n "$acl_hardcode_libdir_separator"; then
516
      dnl Weird platform: only the last -rpath option counts, the user must
664
      dnl Weird platform: only the last -rpath option counts, the user must
517
      dnl pass all path elements in one option. We can arrange that for a
665
      dnl pass all path elements in one option. We can arrange that for a
518
      dnl single library, but not when more than one $LIBNAMEs are used.
666
      dnl single library, but not when more than one $LIBNAMEs are used.
519
      alldirs=
667
      alldirs=
520
      for found_dir in $rpathdirs; do
668
      for found_dir in $rpathdirs; do
521
        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
669
        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
522
      done
670
      done
523
      dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
671
      dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
524
      acl_save_libdir="$libdir"
672
      acl_save_libdir="$libdir"
525
      libdir="$alldirs"
673
      libdir="$alldirs"
526
      eval flag=\"$hardcode_libdir_flag_spec\"
674
      eval flag=\"$acl_hardcode_libdir_flag_spec\"
527
      libdir="$acl_save_libdir"
675
      libdir="$acl_save_libdir"
528
      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
676
      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
529
    else
677
    else
Lines 531-537 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
531
      for found_dir in $rpathdirs; do
679
      for found_dir in $rpathdirs; do
532
        acl_save_libdir="$libdir"
680
        acl_save_libdir="$libdir"
533
        libdir="$found_dir"
681
        libdir="$found_dir"
534
        eval flag=\"$hardcode_libdir_flag_spec\"
682
        eval flag=\"$acl_hardcode_libdir_flag_spec\"
535
        libdir="$acl_save_libdir"
683
        libdir="$acl_save_libdir"
536
        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
684
        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
537
      done
685
      done
Lines 544-549 AC_DEFUN([AC_LIB_LINKFLAGS_BODY], Link Here
544
      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
692
      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
545
    done
693
    done
546
  fi
694
  fi
695
  popdef([PACKLIBS])
696
  popdef([PACKUP])
697
  popdef([PACK])
698
  popdef([NAME])
547
])
699
])
548
700
549
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
701
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
Lines 580-586 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], Link Here
580
  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
732
  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
581
  $1=
733
  $1=
582
  if test "$enable_rpath" != no; then
734
  if test "$enable_rpath" != no; then
583
    if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
735
    if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
584
      dnl Use an explicit option to hardcode directories into the resulting
736
      dnl Use an explicit option to hardcode directories into the resulting
585
      dnl binary.
737
      dnl binary.
586
      rpathdirs=
738
      rpathdirs=
Lines 589-595 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], Link Here
589
        if test -n "$next"; then
741
        if test -n "$next"; then
590
          dir="$next"
742
          dir="$next"
591
          dnl No need to hardcode the standard /usr/lib.
743
          dnl No need to hardcode the standard /usr/lib.
592
          if test "X$dir" != "X/usr/$acl_libdirstem"; then
744
          if test "X$dir" != "X/usr/$acl_libdirstem" \
745
             && test "X$dir" != "X/usr/$acl_libdirstem2" \
746
             && test "X$dir" != "X/usr/$acl_libdirstem3"; then
593
            rpathdirs="$rpathdirs $dir"
747
            rpathdirs="$rpathdirs $dir"
594
          fi
748
          fi
595
          next=
749
          next=
Lines 598-604 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], Link Here
598
            -L) next=yes ;;
752
            -L) next=yes ;;
599
            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
753
            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
600
                 dnl No need to hardcode the standard /usr/lib.
754
                 dnl No need to hardcode the standard /usr/lib.
601
                 if test "X$dir" != "X/usr/$acl_libdirstem"; then
755
                 if test "X$dir" != "X/usr/$acl_libdirstem" \
756
                    && test "X$dir" != "X/usr/$acl_libdirstem2" \
757
                    && test "X$dir" != "X/usr/$acl_libdirstem3"; then
602
                   rpathdirs="$rpathdirs $dir"
758
                   rpathdirs="$rpathdirs $dir"
603
                 fi
759
                 fi
604
                 next= ;;
760
                 next= ;;
Lines 614-629 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], Link Here
614
          done
770
          done
615
        else
771
        else
616
          dnl The linker is used for linking directly.
772
          dnl The linker is used for linking directly.
617
          if test -n "$hardcode_libdir_separator"; then
773
          if test -n "$acl_hardcode_libdir_separator"; then
618
            dnl Weird platform: only the last -rpath option counts, the user
774
            dnl Weird platform: only the last -rpath option counts, the user
619
            dnl must pass all path elements in one option.
775
            dnl must pass all path elements in one option.
620
            alldirs=
776
            alldirs=
621
            for dir in $rpathdirs; do
777
            for dir in $rpathdirs; do
622
              alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$dir"
778
              alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
623
            done
779
            done
624
            acl_save_libdir="$libdir"
780
            acl_save_libdir="$libdir"
625
            libdir="$alldirs"
781
            libdir="$alldirs"
626
            eval flag=\"$hardcode_libdir_flag_spec\"
782
            eval flag=\"$acl_hardcode_libdir_flag_spec\"
627
            libdir="$acl_save_libdir"
783
            libdir="$acl_save_libdir"
628
            $1="$flag"
784
            $1="$flag"
629
          else
785
          else
Lines 631-637 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], Link Here
631
            for dir in $rpathdirs; do
787
            for dir in $rpathdirs; do
632
              acl_save_libdir="$libdir"
788
              acl_save_libdir="$libdir"
633
              libdir="$dir"
789
              libdir="$dir"
634
              eval flag=\"$hardcode_libdir_flag_spec\"
790
              eval flag=\"$acl_hardcode_libdir_flag_spec\"
635
              libdir="$acl_save_libdir"
791
              libdir="$acl_save_libdir"
636
              $1="${$1}${$1:+ }$flag"
792
              $1="${$1}${$1:+ }$flag"
637
            done
793
            done
(-)a/m4/lib-prefix.m4 (-38 / +173 lines)
Lines 1-18 Link Here
1
# lib-prefix.m4 serial 5 (gettext-0.15)
1
# lib-prefix.m4 serial 17
2
dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
2
dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
5
dnl with or without modifications, as long as this notice is preserved.
6
6
7
dnl From Bruno Haible.
7
dnl From Bruno Haible.
8
8
9
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
10
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
11
dnl require excessive bracketing.
12
ifdef([AC_HELP_STRING],
13
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
14
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
15
16
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
9
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
17
dnl to access previously installed libraries. The basic assumption is that
10
dnl to access previously installed libraries. The basic assumption is that
18
dnl a user will want packages to use other packages he previously installed
11
dnl a user will want packages to use other packages he previously installed
Lines 32-40 AC_DEFUN([AC_LIB_PREFIX], Link Here
32
    eval additional_includedir=\"$includedir\"
25
    eval additional_includedir=\"$includedir\"
33
    eval additional_libdir=\"$libdir\"
26
    eval additional_libdir=\"$libdir\"
34
  ])
27
  ])
35
  AC_LIB_ARG_WITH([lib-prefix],
28
  AC_ARG_WITH([lib-prefix],
36
[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
29
[[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
37
  --without-lib-prefix    don't search for libraries in includedir and libdir],
30
  --without-lib-prefix    don't search for libraries in includedir and libdir]],
38
[
31
[
39
    if test "X$withval" = "Xno"; then
32
    if test "X$withval" = "Xno"; then
40
      use_additional=no
33
      use_additional=no
Lines 153-185 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], Link Here
153
  prefix="$acl_save_prefix"
146
  prefix="$acl_save_prefix"
154
])
147
])
155
148
156
dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing
149
dnl AC_LIB_PREPARE_MULTILIB creates
157
dnl the basename of the libdir, either "lib" or "lib64".
150
dnl - a function acl_is_expected_elfclass, that tests whether standard input
151
dn;   has a 32-bit or 64-bit ELF header, depending on the host CPU ABI,
152
dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing
153
dnl   the basename of the libdir to try in turn, either "lib" or "lib64" or
154
dnl   "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar.
158
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
155
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
159
[
156
[
160
  dnl There is no formal standard regarding lib and lib64. The current
157
  dnl There is no formal standard regarding lib, lib32, and lib64.
161
  dnl practice is that on a system supporting 32-bit and 64-bit instruction
158
  dnl On most glibc systems, the current practice is that on a system supporting
162
  dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit
159
  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
163
  dnl libraries go under $prefix/lib. We determine the compiler's default
160
  dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on
164
  dnl mode by looking at the compiler's library search path. If at least
161
  dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go
165
  dnl of its elements ends in /lib64 or points to a directory whose absolute
162
  dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib.
166
  dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the
163
  dnl We determine the compiler's default mode by looking at the compiler's
167
  dnl default, namely "lib".
164
  dnl library search path. If at least one of its elements ends in /lib64 or
168
  acl_libdirstem=lib
165
  dnl points to a directory whose absolute pathname ends in /lib64, we use that
169
  searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
166
  dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default,
170
  if test -n "$searchpath"; then
167
  dnl namely "lib".
171
    acl_save_IFS="${IFS= 	}"; IFS=":"
168
  dnl On Solaris systems, the current practice is that on a system supporting
172
    for searchdir in $searchpath; do
169
  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
173
      if test -d "$searchdir"; then
170
  dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
174
        case "$searchdir" in
171
  dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
175
          */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
172
  AC_REQUIRE([AC_CANONICAL_HOST])
176
          *) searchdir=`cd "$searchdir" && pwd`
173
  AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
177
             case "$searchdir" in
174
178
               */lib64 ) acl_libdirstem=lib64 ;;
175
  AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
179
             esac ;;
176
    [AC_EGREP_CPP([Extensible Linking Format],
180
        esac
177
       [#ifdef __ELF__
181
      fi
178
        Extensible Linking Format
182
    done
179
        #endif
183
    IFS="$acl_save_IFS"
180
       ],
181
       [gl_cv_elf=yes],
182
       [gl_cv_elf=no])
183
     ])
184
  if test $gl_cv_elf; then
185
    # Extract the ELF class of a file (5th byte) in decimal.
186
    # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
187
    if od -A x < /dev/null >/dev/null 2>/dev/null; then
188
      # Use POSIX od.
189
      func_elfclass ()
190
      {
191
        od -A n -t d1 -j 4 -N 1
192
      }
193
    else
194
      # Use BSD hexdump.
195
      func_elfclass ()
196
      {
197
        dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
198
        echo
199
      }
200
    fi
201
changequote(,)dnl
202
    case $HOST_CPU_C_ABI_32BIT in
203
      yes)
204
        # 32-bit ABI.
205
        acl_is_expected_elfclass ()
206
        {
207
          test "`func_elfclass | sed -e 's/[ 	]//g'`" = 1
208
        }
209
        ;;
210
      no)
211
        # 64-bit ABI.
212
        acl_is_expected_elfclass ()
213
        {
214
          test "`func_elfclass | sed -e 's/[ 	]//g'`" = 2
215
        }
216
        ;;
217
      *)
218
        # Unknown.
219
        acl_is_expected_elfclass ()
220
        {
221
          :
222
        }
223
        ;;
224
    esac
225
changequote([,])dnl
226
  else
227
    acl_is_expected_elfclass ()
228
    {
229
      :
230
    }
184
  fi
231
  fi
232
233
  dnl Allow the user to override the result by setting acl_cv_libdirstems.
234
  AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
235
    [acl_cv_libdirstems],
236
    [dnl Try 'lib' first, because that's the default for libdir in GNU, see
237
     dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.
238
     acl_libdirstem=lib
239
     acl_libdirstem2=
240
     acl_libdirstem3=
241
     case "$host_os" in
242
       solaris*)
243
         dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
244
         dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>.
245
         dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
246
         dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
247
         dnl symlink is missing, so we set acl_libdirstem2 too.
248
         if test $HOST_CPU_C_ABI_32BIT = no; then
249
           acl_libdirstem2=lib/64
250
           case "$host_cpu" in
251
             sparc*)        acl_libdirstem3=lib/sparcv9 ;;
252
             i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
253
           esac
254
         fi
255
         ;;
256
       *)
257
         dnl If $CC generates code for a 32-bit ABI, the libraries are
258
         dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64.
259
         dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries
260
         dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32.
261
         dnl Find the compiler's search path. However, non-system compilers
262
         dnl sometimes have odd library search paths. But we can't simply invoke
263
         dnl '/usr/bin/gcc -print-search-dirs' because that would not take into
264
         dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS.
265
         searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
266
                     | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
267
         if test $HOST_CPU_C_ABI_32BIT != no; then
268
           # 32-bit or unknown ABI.
269
           if test -d /usr/lib32; then
270
             acl_libdirstem2=lib32
271
           fi
272
         fi
273
         if test $HOST_CPU_C_ABI_32BIT != yes; then
274
           # 64-bit or unknown ABI.
275
           if test -d /usr/lib64; then
276
             acl_libdirstem3=lib64
277
           fi
278
         fi
279
         if test -n "$searchpath"; then
280
           acl_save_IFS="${IFS= 	}"; IFS=":"
281
           for searchdir in $searchpath; do
282
             if test -d "$searchdir"; then
283
               case "$searchdir" in
284
                 */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
285
                 */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
286
                 */../ | */.. )
287
                   # Better ignore directories of this form. They are misleading.
288
                   ;;
289
                 *) searchdir=`cd "$searchdir" && pwd`
290
                    case "$searchdir" in
291
                      */lib32 ) acl_libdirstem2=lib32 ;;
292
                      */lib64 ) acl_libdirstem3=lib64 ;;
293
                    esac ;;
294
               esac
295
             fi
296
           done
297
           IFS="$acl_save_IFS"
298
           if test $HOST_CPU_C_ABI_32BIT = yes; then
299
             # 32-bit ABI.
300
             acl_libdirstem3=
301
           fi
302
           if test $HOST_CPU_C_ABI_32BIT = no; then
303
             # 64-bit ABI.
304
             acl_libdirstem2=
305
           fi
306
         fi
307
         ;;
308
     esac
309
     test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
310
     test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
311
     acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
312
    ])
313
  dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and
314
  dnl acl_libdirstem3.
315
changequote(,)dnl
316
  acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
317
  acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
318
  acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
319
changequote([,])dnl
185
])
320
])
(-)a/m4/nls.m4 (-10 / +11 lines)
Lines 1-31 Link Here
1
# nls.m4 serial 3 (gettext-0.15)
1
# nls.m4 serial 6 (gettext-0.20.2)
2
dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc.
2
dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2020 Free
3
dnl Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
4
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
6
dnl with or without modifications, as long as this notice is preserved.
6
dnl
7
dnl
7
dnl This file can can be used in projects which are not available under
8
dnl This file can be used in projects which are not available under
8
dnl the GNU General Public License or the GNU Library General Public
9
dnl the GNU General Public License or the GNU Lesser General Public
9
dnl License but which still want to provide support for the GNU gettext
10
dnl License but which still want to provide support for the GNU gettext
10
dnl functionality.
11
dnl functionality.
11
dnl Please note that the actual code of the GNU gettext library is covered
12
dnl Please note that the actual code of the GNU gettext library is covered
12
dnl by the GNU Library General Public License, and the rest of the GNU
13
dnl by the GNU Lesser General Public License, and the rest of the GNU
13
dnl gettext package package is covered by the GNU General Public License.
14
dnl gettext package is covered by the GNU General Public License.
14
dnl They are *not* in the public domain.
15
dnl They are *not* in the public domain.
15
16
16
dnl Authors:
17
dnl Authors:
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18
dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18
dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19
dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19
20
20
AC_PREREQ(2.50)
21
AC_PREREQ([2.50])
21
22
22
AC_DEFUN([AM_NLS],
23
AC_DEFUN([AM_NLS],
23
[
24
[
24
  AC_MSG_CHECKING([whether NLS is requested])
25
  AC_MSG_CHECKING([whether NLS is requested])
25
  dnl Default is enabled NLS
26
  dnl Default is enabled NLS
26
  AC_ARG_ENABLE(nls,
27
  AC_ARG_ENABLE([nls],
27
    [  --disable-nls           do not use Native Language Support],
28
    [  --disable-nls           do not use Native Language Support],
28
    USE_NLS=$enableval, USE_NLS=yes)
29
    USE_NLS=$enableval, USE_NLS=yes)
29
  AC_MSG_RESULT($USE_NLS)
30
  AC_MSG_RESULT([$USE_NLS])
30
  AC_SUBST(USE_NLS)
31
  AC_SUBST([USE_NLS])
31
])
32
])
(-)a/m4/po.m4 (-46 / +68 lines)
Lines 1-32 Link Here
1
# po.m4 serial 13 (gettext-0.15)
1
# po.m4 serial 31 (gettext-0.20.2)
2
dnl Copyright (C) 1995-2006 Free Software Foundation, Inc.
2
dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
5
dnl with or without modifications, as long as this notice is preserved.
6
dnl
6
dnl
7
dnl This file can can be used in projects which are not available under
7
dnl This file can be used in projects which are not available under
8
dnl the GNU General Public License or the GNU Library General Public
8
dnl the GNU General Public License or the GNU Lesser General Public
9
dnl License but which still want to provide support for the GNU gettext
9
dnl License but which still want to provide support for the GNU gettext
10
dnl functionality.
10
dnl functionality.
11
dnl Please note that the actual code of the GNU gettext library is covered
11
dnl Please note that the actual code of the GNU gettext library is covered
12
dnl by the GNU Library General Public License, and the rest of the GNU
12
dnl by the GNU Lesser General Public License, and the rest of the GNU
13
dnl gettext package package is covered by the GNU General Public License.
13
dnl gettext package is covered by the GNU General Public License.
14
dnl They are *not* in the public domain.
14
dnl They are *not* in the public domain.
15
15
16
dnl Authors:
16
dnl Authors:
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18
dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
18
dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19
19
20
AC_PREREQ(2.50)
20
AC_PREREQ([2.60])
21
21
22
dnl Checks for all prerequisites of the po subdirectory.
22
dnl Checks for all prerequisites of the po subdirectory.
23
AC_DEFUN([AM_PO_SUBDIRS],
23
AC_DEFUN([AM_PO_SUBDIRS],
24
[
24
[
25
  AC_REQUIRE([AC_PROG_MAKE_SET])dnl
25
  AC_REQUIRE([AC_PROG_MAKE_SET])dnl
26
  AC_REQUIRE([AC_PROG_INSTALL])dnl
26
  AC_REQUIRE([AC_PROG_INSTALL])dnl
27
  AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
27
  AC_REQUIRE([AC_PROG_MKDIR_P])dnl
28
  AC_REQUIRE([AC_PROG_SED])dnl
28
  AC_REQUIRE([AM_NLS])dnl
29
  AC_REQUIRE([AM_NLS])dnl
29
30
31
  dnl Release version of the gettext macros. This is used to ensure that
32
  dnl the gettext macros and po/Makefile.in.in are in sync.
33
  AC_SUBST([GETTEXT_MACRO_VERSION], [0.20])
34
30
  dnl Perform the following tests also if --disable-nls has been given,
35
  dnl Perform the following tests also if --disable-nls has been given,
31
  dnl because they are needed for "make dist" to work.
36
  dnl because they are needed for "make dist" to work.
32
37
Lines 37-52 AC_DEFUN([AM_PO_SUBDIRS], Link Here
37
    [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
42
    [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
38
     (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
43
     (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
39
    :)
44
    :)
40
  AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
45
  AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
41
46
42
  dnl Test whether it is GNU msgfmt >= 0.15.
47
  dnl Test whether it is GNU msgfmt >= 0.15.
43
changequote(,)dnl
44
  case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
45
    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
46
    *) MSGFMT_015=$MSGFMT ;;
47
  esac
48
changequote([,])dnl
49
  AC_SUBST([MSGFMT_015])
50
changequote(,)dnl
48
changequote(,)dnl
51
  case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
49
  case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
52
    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
50
    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
Lines 78-88 changequote([,])dnl Link Here
78
  AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
76
  AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
79
    [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
77
    [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
80
78
81
  dnl Installation directories.
79
  dnl Test whether it is GNU msgmerge >= 0.20.
82
  dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
80
  if LC_ALL=C $MSGMERGE --help | grep ' --for-msgfmt ' >/dev/null; then
83
  dnl have to define it here, so that it can be used in po/Makefile.
81
    MSGMERGE_FOR_MSGFMT_OPTION='--for-msgfmt'
84
  test -n "$localedir" || localedir='${datadir}/locale'
82
  else
85
  AC_SUBST([localedir])
83
    dnl Test whether it is GNU msgmerge >= 0.12.
84
    if LC_ALL=C $MSGMERGE --help | grep ' --no-fuzzy-matching ' >/dev/null; then
85
      MSGMERGE_FOR_MSGFMT_OPTION='--no-fuzzy-matching --no-location --quiet'
86
    else
87
      dnl With these old versions, $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) is
88
      dnl slow. But this is not a big problem, as such old gettext versions are
89
      dnl hardly in use any more.
90
      MSGMERGE_FOR_MSGFMT_OPTION='--no-location --quiet'
91
    fi
92
  fi
93
  AC_SUBST([MSGMERGE_FOR_MSGFMT_OPTION])
94
95
  dnl Support for AM_XGETTEXT_OPTION.
96
  test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
97
  AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
86
98
87
  AC_CONFIG_COMMANDS([po-directories], [[
99
  AC_CONFIG_COMMANDS([po-directories], [[
88
    for ac_file in $CONFIG_FILES; do
100
    for ac_file in $CONFIG_FILES; do
Lines 94-100 changequote([,])dnl Link Here
94
      case "$ac_file" in */Makefile.in)
106
      case "$ac_file" in */Makefile.in)
95
        # Adjust a relative srcdir.
107
        # Adjust a relative srcdir.
96
        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
108
        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
97
        ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
109
        ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
98
        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
110
        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
99
        # In autoconf-2.13 it is called $ac_given_srcdir.
111
        # In autoconf-2.13 it is called $ac_given_srcdir.
100
        # In autoconf-2.50 it is called $srcdir.
112
        # In autoconf-2.50 it is called $srcdir.
Lines 110-116 changequote([,])dnl Link Here
110
        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
122
        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
111
          rm -f "$ac_dir/POTFILES"
123
          rm -f "$ac_dir/POTFILES"
112
          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
124
          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
113
          cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
125
          gt_tab=`printf '\t'`
126
          cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
114
          POMAKEFILEDEPS="POTFILES.in"
127
          POMAKEFILEDEPS="POTFILES.in"
115
          # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
128
          # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
116
          # on $ac_dir but don't depend on user-specified configuration
129
          # on $ac_dir but don't depend on user-specified configuration
Lines 120-133 changequote([,])dnl Link Here
120
            if test -n "$OBSOLETE_ALL_LINGUAS"; then
133
            if test -n "$OBSOLETE_ALL_LINGUAS"; then
121
              test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
134
              test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
122
            fi
135
            fi
123
            ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
136
            ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
124
            # Hide the ALL_LINGUAS assigment from automake < 1.5.
125
            eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
126
            POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
137
            POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
127
          else
138
          else
128
            # The set of available languages was given in configure.in.
139
            # The set of available languages was given in configure.in.
129
            # Hide the ALL_LINGUAS assigment from automake < 1.5.
140
            ALL_LINGUAS=$OBSOLETE_ALL_LINGUAS
130
            eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
131
          fi
141
          fi
132
          # Compute POFILES
142
          # Compute POFILES
133
          # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
143
          # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
Lines 198-206 changequote([,])dnl Link Here
198
      esac
208
      esac
199
    done]],
209
    done]],
200
   [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
210
   [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
201
    # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
211
    # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS.
202
    # from automake < 1.5.
212
    OBSOLETE_ALL_LINGUAS="$ALL_LINGUAS"
203
    eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
204
    # Capture the value of LINGUAS because we need it to compute CATALOGS.
213
    # Capture the value of LINGUAS because we need it to compute CATALOGS.
205
    LINGUAS="${LINGUAS-%UNSET%}"
214
    LINGUAS="${LINGUAS-%UNSET%}"
206
   ])
215
   ])
Lines 218-224 AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], Link Here
218
changequote(,)dnl
227
changequote(,)dnl
219
  # Adjust a relative srcdir.
228
  # Adjust a relative srcdir.
220
  ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
229
  ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
221
  ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
230
  ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
222
  ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
231
  ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
223
  # In autoconf-2.13 it is called $ac_given_srcdir.
232
  # In autoconf-2.13 it is called $ac_given_srcdir.
224
  # In autoconf-2.50 it is called $srcdir.
233
  # In autoconf-2.50 it is called $srcdir.
Lines 246-251 EOT Link Here
246
  fi
255
  fi
247
256
248
  # A sed script that extracts the value of VARIABLE from a Makefile.
257
  # A sed script that extracts the value of VARIABLE from a Makefile.
258
  tab=`printf '\t'`
249
  sed_x_variable='
259
  sed_x_variable='
250
# Test if the hold space is empty.
260
# Test if the hold space is empty.
251
x
261
x
Lines 253-261 s/P/P/ Link Here
253
x
263
x
254
ta
264
ta
255
# Yes it was empty. Look if we have the expected variable definition.
265
# Yes it was empty. Look if we have the expected variable definition.
256
/^[	 ]*VARIABLE[	 ]*=/{
266
/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
257
  # Seen the first line of the variable definition.
267
  # Seen the first line of the variable definition.
258
  s/^[	 ]*VARIABLE[	 ]*=//
268
  s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
259
  ba
269
  ba
260
}
270
}
261
bd
271
bd
Lines 300-314 changequote([,])dnl Link Here
300
  fi
310
  fi
301
  if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
311
  if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
302
    # The LINGUAS file contains the set of available languages.
312
    # The LINGUAS file contains the set of available languages.
303
    ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
313
    ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
304
    POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
314
    POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
305
  else
315
  else
306
    # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
316
    # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
307
    sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
317
    sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
308
    ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
318
    ALL_LINGUAS=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
309
  fi
319
  fi
310
  # Hide the ALL_LINGUAS assigment from automake < 1.5.
311
  eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
312
  # Compute POFILES
320
  # Compute POFILES
313
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
321
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
314
  # Compute UPDATEPOFILES
322
  # Compute UPDATEPOFILES
Lines 318-326 changequote([,])dnl Link Here
318
  # Compute GMOFILES
326
  # Compute GMOFILES
319
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
327
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
320
  # Compute PROPERTIESFILES
328
  # Compute PROPERTIESFILES
321
  # as      $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
329
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(DOMAIN)_$(lang).properties)
322
  # Compute CLASSFILES
330
  # Compute CLASSFILES
323
  # as      $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
331
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(DOMAIN)_$(lang).class)
324
  # Compute QMFILES
332
  # Compute QMFILES
325
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
333
  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
326
  # Compute MSGFILES
334
  # Compute MSGFILES
Lines 345-352 changequote([,])dnl Link Here
345
    UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
353
    UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
346
    DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
354
    DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
347
    GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
355
    GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
348
    PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
356
    PROPERTIESFILES="$PROPERTIESFILES \$(srcdir)/\$(DOMAIN)_$lang.properties"
349
    CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
357
    CLASSFILES="$CLASSFILES \$(srcdir)/\$(DOMAIN)_$lang.class"
350
    QMFILES="$QMFILES $srcdirpre$lang.qm"
358
    QMFILES="$QMFILES $srcdirpre$lang.qm"
351
    frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
359
    frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
352
    MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
360
    MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
Lines 397-410 changequote([,])dnl Link Here
397
  fi
405
  fi
398
406
399
  sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
407
  sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
408
  tab=`printf '\t'`
400
  if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
409
  if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
401
    # Add dependencies that cannot be formulated as a simple suffix rule.
410
    # Add dependencies that cannot be formulated as a simple suffix rule.
402
    for lang in $ALL_LINGUAS; do
411
    for lang in $ALL_LINGUAS; do
403
      frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
412
      frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
404
      cat >> "$ac_file.tmp" <<EOF
413
      cat >> "$ac_file.tmp" <<EOF
405
$frobbedlang.msg: $lang.po
414
$frobbedlang.msg: $lang.po
406
	@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
415
${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
407
	\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
416
${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
408
EOF
417
EOF
409
    done
418
    done
410
  fi
419
  fi
Lines 414-421 EOF Link Here
414
      frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
423
      frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
415
      cat >> "$ac_file.tmp" <<EOF
424
      cat >> "$ac_file.tmp" <<EOF
416
$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
425
$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
417
	@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
426
${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
418
	\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
427
${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
419
EOF
428
EOF
420
    done
429
    done
421
  fi
430
  fi
Lines 426-428 EOF Link Here
426
  fi
435
  fi
427
  mv "$ac_file.tmp" "$ac_file"
436
  mv "$ac_file.tmp" "$ac_file"
428
])
437
])
438
439
dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
440
AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
441
[
442
  XGETTEXT_EXTRA_OPTIONS=
443
])
444
445
dnl Registers an option to be passed to xgettext in the po subdirectory.
446
AC_DEFUN([AM_XGETTEXT_OPTION],
447
[
448
  AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
449
  XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
450
])
(-)a/m4/progtest.m4 (-20 / +19 lines)
Lines 1-22 Link Here
1
# progtest.m4 serial 4 (gettext-0.14.2)
1
# progtest.m4 serial 8 (gettext-0.20.2)
2
dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc.
2
dnl Copyright (C) 1996-2003, 2005, 2008-2020 Free Software Foundation, Inc.
3
dnl This file is free software; the Free Software Foundation
3
dnl This file is free software; the Free Software Foundation
4
dnl gives unlimited permission to copy and/or distribute it,
4
dnl gives unlimited permission to copy and/or distribute it,
5
dnl with or without modifications, as long as this notice is preserved.
5
dnl with or without modifications, as long as this notice is preserved.
6
dnl
6
dnl
7
dnl This file can can be used in projects which are not available under
7
dnl This file can be used in projects which are not available under
8
dnl the GNU General Public License or the GNU Library General Public
8
dnl the GNU General Public License or the GNU Lesser General Public
9
dnl License but which still want to provide support for the GNU gettext
9
dnl License but which still want to provide support for the GNU gettext
10
dnl functionality.
10
dnl functionality.
11
dnl Please note that the actual code of the GNU gettext library is covered
11
dnl Please note that the actual code of the GNU gettext library is covered
12
dnl by the GNU Library General Public License, and the rest of the GNU
12
dnl by the GNU Lesser General Public License, and the rest of the GNU
13
dnl gettext package package is covered by the GNU General Public License.
13
dnl gettext package is covered by the GNU General Public License.
14
dnl They are *not* in the public domain.
14
dnl They are *not* in the public domain.
15
15
16
dnl Authors:
16
dnl Authors:
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
17
dnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
18
18
19
AC_PREREQ(2.50)
19
AC_PREREQ([2.50])
20
20
21
# Search path for a program which passes the given test.
21
# Search path for a program which passes the given test.
22
22
Lines 27-41 AC_DEFUN([AM_PATH_PROG_WITH_TEST], Link Here
27
# Prepare PATH_SEPARATOR.
27
# Prepare PATH_SEPARATOR.
28
# The user is always right.
28
# The user is always right.
29
if test "${PATH_SEPARATOR+set}" != set; then
29
if test "${PATH_SEPARATOR+set}" != set; then
30
  echo "#! /bin/sh" >conf$$.sh
30
  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
31
  echo  "exit 0"   >>conf$$.sh
31
  # contains only /bin. Note that ksh looks also at the FPATH variable,
32
  chmod +x conf$$.sh
32
  # so we have to set that as well for the test.
33
  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
33
  PATH_SEPARATOR=:
34
    PATH_SEPARATOR=';'
34
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
35
  else
35
    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
36
    PATH_SEPARATOR=:
36
           || PATH_SEPARATOR=';'
37
  fi
37
       }
38
  rm -f conf$$.sh
39
fi
38
fi
40
39
41
# Find out how to test for executable files. Don't use a zero-byte file,
40
# Find out how to test for executable files. Don't use a zero-byte file,
Lines 55-61 rm -f conf$$.file Link Here
55
# Extract the first word of "$2", so it can be a program name with args.
54
# Extract the first word of "$2", so it can be a program name with args.
56
set dummy $2; ac_word=[$]2
55
set dummy $2; ac_word=[$]2
57
AC_MSG_CHECKING([for $ac_word])
56
AC_MSG_CHECKING([for $ac_word])
58
AC_CACHE_VAL(ac_cv_path_$1,
57
AC_CACHE_VAL([ac_cv_path_$1],
59
[case "[$]$1" in
58
[case "[$]$1" in
60
  [[\\/]]* | ?:[[\\/]]*)
59
  [[\\/]]* | ?:[[\\/]]*)
61
    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
60
    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
Lines 84-92 ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" Link Here
84
esac])dnl
83
esac])dnl
85
$1="$ac_cv_path_$1"
84
$1="$ac_cv_path_$1"
86
if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
85
if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
87
  AC_MSG_RESULT([$]$1)
86
  AC_MSG_RESULT([$][$1])
88
else
87
else
89
  AC_MSG_RESULT(no)
88
  AC_MSG_RESULT([no])
90
fi
89
fi
91
AC_SUBST($1)dnl
90
AC_SUBST([$1])dnl
92
])
91
])
(-)a/po/Makefile.in.in (-57 / +164 lines)
Lines 1-19 Link Here
1
# Makefile for PO directory in any package using GNU gettext.
1
# Makefile for PO directory in any package using GNU gettext.
2
# Copyright (C) 1995-1997, 2000-2006 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
2
# Copyright (C) 1995-2000 Ulrich Drepper <drepper@gnu.ai.mit.edu>
3
# Copyright (C) 2000-2020 Free Software Foundation, Inc.
3
#
4
#
4
# This file can be copied and used freely without restrictions.  It can
5
# Copying and distribution of this file, with or without modification,
5
# be used in projects which are not available under the GNU General Public
6
# are permitted in any medium without royalty provided the copyright
6
# License but which still want to provide support for the GNU gettext
7
# notice and this notice are preserved.  This file is offered as-is,
7
# functionality.
8
# without any warranty.
8
# Please note that the actual code of GNU gettext is covered by the GNU
9
# General Public License and is *not* in the public domain.
10
#
9
#
11
# Origin: gettext-0.16
10
# Origin: gettext-0.21
11
GETTEXT_MACRO_VERSION = 0.20
12
12
13
PACKAGE = @PACKAGE@
13
PACKAGE = @PACKAGE@
14
VERSION = @VERSION@
14
VERSION = @VERSION@
15
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
15
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
16
16
17
SED = @SED@
17
SHELL = /bin/sh
18
SHELL = /bin/sh
18
@SET_MAKE@
19
@SET_MAKE@
19
20
Lines 43-62 install_sh = $(SHELL) @install_sh@ Link Here
43
MKDIR_P = @MKDIR_P@
44
MKDIR_P = @MKDIR_P@
44
mkdir_p = @mkdir_p@
45
mkdir_p = @mkdir_p@
45
46
47
# When building gettext-tools, we prefer to use the built programs
48
# rather than installed programs.  However, we can't do that when we
49
# are cross compiling.
50
CROSS_COMPILING = @CROSS_COMPILING@
51
46
GMSGFMT_ = @GMSGFMT@
52
GMSGFMT_ = @GMSGFMT@
47
GMSGFMT_no = @GMSGFMT@
53
GMSGFMT_no = @GMSGFMT@
48
GMSGFMT_yes = @GMSGFMT_015@
54
GMSGFMT_yes = @GMSGFMT_015@
49
GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
55
GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
50
MSGFMT_ = @MSGFMT@
51
MSGFMT_no = @MSGFMT@
52
MSGFMT_yes = @MSGFMT_015@
53
MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
54
XGETTEXT_ = @XGETTEXT@
56
XGETTEXT_ = @XGETTEXT@
55
XGETTEXT_no = @XGETTEXT@
57
XGETTEXT_no = @XGETTEXT@
56
XGETTEXT_yes = @XGETTEXT_015@
58
XGETTEXT_yes = @XGETTEXT_015@
57
XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
59
XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
58
MSGMERGE = msgmerge
60
MSGMERGE = @MSGMERGE@
59
MSGMERGE_UPDATE = @MSGMERGE@ --update
61
MSGMERGE_UPDATE = @MSGMERGE@ --update
62
MSGMERGE_FOR_MSGFMT_OPTION = @MSGMERGE_FOR_MSGFMT_OPTION@
60
MSGINIT = msginit
63
MSGINIT = msginit
61
MSGCONV = msgconv
64
MSGCONV = msgconv
62
MSGFILTER = msgfilter
65
MSGFILTER = msgfilter
Lines 75-126 POTFILES = \ Link Here
75
78
76
CATALOGS = @CATALOGS@
79
CATALOGS = @CATALOGS@
77
80
81
POFILESDEPS_ = $(srcdir)/$(DOMAIN).pot
82
POFILESDEPS_yes = $(POFILESDEPS_)
83
POFILESDEPS_no =
84
POFILESDEPS = $(POFILESDEPS_$(PO_DEPENDS_ON_POT))
85
86
DISTFILESDEPS_ = update-po
87
DISTFILESDEPS_yes = $(DISTFILESDEPS_)
88
DISTFILESDEPS_no =
89
DISTFILESDEPS = $(DISTFILESDEPS_$(DIST_DEPENDS_ON_UPDATE_PO))
90
78
# Makevars gets inserted here. (Don't remove this line!)
91
# Makevars gets inserted here. (Don't remove this line!)
79
92
80
.SUFFIXES:
93
all: all-@USE_NLS@
81
.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
82
94
83
.po.mo:
84
	@echo "$(MSGFMT) -c -o $@ $<"; \
85
	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
86
95
96
.SUFFIXES:
97
.SUFFIXES: .po .gmo .sed .sin .nop .po-create .po-update
98
99
# The .pot file, stamp-po, .po files, and .gmo files appear in release tarballs.
100
# The GNU Coding Standards say in
101
# <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>:
102
#   "GNU distributions usually contain some files which are not source files
103
#    ... . Since these files normally appear in the source directory, they
104
#    should always appear in the source directory, not in the build directory.
105
#    So Makefile rules to update them should put the updated files in the
106
#    source directory."
107
# Therefore we put these files in the source directory, not the build directory.
108
109
# During .po -> .gmo conversion, take into account the most recent changes to
110
# the .pot file. This eliminates the need to update the .po files when the
111
# .pot file has changed, which would be troublesome if the .po files are put
112
# under version control.
113
$(GMOFILES): $(srcdir)/$(DOMAIN).pot
87
.po.gmo:
114
.po.gmo:
88
	@lang=`echo $* | sed -e 's,.*/,,'`; \
115
	@lang=`echo $* | sed -e 's,.*/,,'`; \
89
	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
116
	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
90
	echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
117
	echo "$${cdcmd}rm -f $${lang}.gmo && $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) -o $${lang}.1po $${lang}.po $(DOMAIN).pot && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.1po && rm -f $${lang}.1po"; \
91
	cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
118
	cd $(srcdir) && \
119
	rm -f $${lang}.gmo && \
120
	$(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) -o $${lang}.1po $${lang}.po $(DOMAIN).pot && \
121
	$(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.1po && \
122
	mv t-$${lang}.gmo $${lang}.gmo && \
123
	rm -f $${lang}.1po
92
124
93
.sin.sed:
125
.sin.sed:
94
	sed -e '/^#/d' $< > t-$@
126
	sed -e '/^#/d' $< > t-$@
95
	mv t-$@ $@
127
	mv t-$@ $@
96
128
97
129
98
all: all-@USE_NLS@
130
all-yes: $(srcdir)/stamp-po
99
100
all-yes: stamp-po
101
all-no:
131
all-no:
102
132
133
# Ensure that the gettext macros and this Makefile.in.in are in sync.
134
CHECK_MACRO_VERSION = \
135
	test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \
136
	  || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \
137
	       exit 1; \
138
	     }
139
103
# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
140
# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
104
# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
141
# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
105
# we don't want to bother translators with empty POT files). We assume that
142
# we don't want to bother translators with empty POT files). We assume that
106
# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
143
# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
107
# In this case, stamp-po is a nop (i.e. a phony target).
144
# In this case, $(srcdir)/stamp-po is a nop (i.e. a phony target).
108
145
109
# stamp-po is a timestamp denoting the last time at which the CATALOGS have
146
# $(srcdir)/stamp-po is a timestamp denoting the last time at which the CATALOGS
110
# been loosely updated. Its purpose is that when a developer or translator
147
# have been loosely updated. Its purpose is that when a developer or translator
111
# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
148
# checks out the package from a version control system, and the $(DOMAIN).pot
112
# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
149
# file is not under version control, "make" will update the $(DOMAIN).pot and
113
# invocations of "make" will do nothing. This timestamp would not be necessary
150
# the $(CATALOGS), but subsequent invocations of "make" will do nothing. This
114
# if updating the $(CATALOGS) would always touch them; however, the rule for
151
# timestamp would not be necessary if updating the $(CATALOGS) would always
115
# $(POFILES) has been designed to not touch files that don't need to be
152
# touch them; however, the rule for $(POFILES) has been designed to not touch
116
# changed.
153
# files that don't need to be changed.
117
stamp-po: $(srcdir)/$(DOMAIN).pot
154
$(srcdir)/stamp-po: $(srcdir)/$(DOMAIN).pot
155
	@$(CHECK_MACRO_VERSION)
118
	test ! -f $(srcdir)/$(DOMAIN).pot || \
156
	test ! -f $(srcdir)/$(DOMAIN).pot || \
119
	  test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
157
	  test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
120
	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
158
	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
121
	  echo "touch stamp-po" && \
159
	  echo "touch $(srcdir)/stamp-po" && \
122
	  echo timestamp > stamp-poT && \
160
	  echo timestamp > $(srcdir)/stamp-poT && \
123
	  mv stamp-poT stamp-po; \
161
	  mv $(srcdir)/stamp-poT $(srcdir)/stamp-po; \
124
	}
162
	}
125
163
126
# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
164
# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
Lines 129-146 stamp-po: $(srcdir)/$(DOMAIN).pot Link Here
129
167
130
# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
168
# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
131
# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
169
# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
170
# The determination of whether the package xyz is a GNU one is based on the
171
# heuristic whether some file in the top level directory mentions "GNU xyz".
172
# If GNU 'find' is available, we avoid grepping through monster files.
132
$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
173
$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
174
	package_gnu="$(PACKAGE_GNU)"; \
175
	test -n "$$package_gnu" || { \
176
	  if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \
177
	         LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f -size -10000000c -exec grep -i 'GNU @PACKAGE@' /dev/null '{}' ';' 2>/dev/null; \
178
	       else \
179
	         LC_ALL=C grep -i 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null; \
180
	       fi; \
181
	     } | grep -v 'libtool:' >/dev/null; then \
182
	     package_gnu=yes; \
183
	   else \
184
	     package_gnu=no; \
185
	   fi; \
186
	}; \
187
	if test "$$package_gnu" = "yes"; then \
188
	  package_prefix='GNU '; \
189
	else \
190
	  package_prefix=''; \
191
	fi; \
133
	if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
192
	if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
134
	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
193
	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
135
	else \
194
	else \
136
	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
195
	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
137
	fi; \
196
	fi; \
138
	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
197
	case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
139
	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
198
	  '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
140
	  --files-from=$(srcdir)/POTFILES.in \
199
	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
141
	  --copyright-holder='$(COPYRIGHT_HOLDER)' \
200
	      --add-comments=TRANSLATORS: \
142
	  --msgid-bugs-address="$$msgid_bugs_address"
201
	      --files-from=$(srcdir)/POTFILES.in \
202
	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
203
	      --msgid-bugs-address="$$msgid_bugs_address" \
204
	      $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
205
	    ;; \
206
	  *) \
207
	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
208
	      --add-comments=TRANSLATORS: \
209
	      --files-from=$(srcdir)/POTFILES.in \
210
	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
211
	      --package-name="$${package_prefix}@PACKAGE@" \
212
	      --package-version='@VERSION@' \
213
	      --msgid-bugs-address="$$msgid_bugs_address" \
214
	      $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
215
	    ;; \
216
	esac
143
	test ! -f $(DOMAIN).po || { \
217
	test ! -f $(DOMAIN).po || { \
218
	  if test -f $(srcdir)/$(DOMAIN).pot-header; then \
219
	    sed -e '1,/^#$$/d' < $(DOMAIN).po > $(DOMAIN).1po && \
220
	    cat $(srcdir)/$(DOMAIN).pot-header $(DOMAIN).1po > $(DOMAIN).po && \
221
	    rm -f $(DOMAIN).1po \
222
	    || exit 1; \
223
	  fi; \
144
	  if test -f $(srcdir)/$(DOMAIN).pot; then \
224
	  if test -f $(srcdir)/$(DOMAIN).pot; then \
145
	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
225
	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
146
	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
226
	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
Lines 163-174 $(srcdir)/$(DOMAIN).pot: Link Here
163
243
164
# This target rebuilds a PO file if $(DOMAIN).pot has changed.
244
# This target rebuilds a PO file if $(DOMAIN).pot has changed.
165
# Note that a PO file is not touched if it doesn't need to be changed.
245
# Note that a PO file is not touched if it doesn't need to be changed.
166
$(POFILES): $(srcdir)/$(DOMAIN).pot
246
$(POFILES): $(POFILESDEPS)
247
	@test -f $(srcdir)/$(DOMAIN).pot || $(MAKE) $(srcdir)/$(DOMAIN).pot
167
	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
248
	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
168
	if test -f "$(srcdir)/$${lang}.po"; then \
249
	if test -f "$(srcdir)/$${lang}.po"; then \
169
	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
250
	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
170
	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
251
	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot"; \
171
	  cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
252
	  cd $(srcdir) \
253
	    && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
254
	           '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
255
	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
256
	           0.1[6-7] | 0.1[6-7].*) \
257
	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --previous $${lang}.po $(DOMAIN).pot;; \
258
	           *) \
259
	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot;; \
260
	         esac; \
261
	       }; \
172
	else \
262
	else \
173
	  $(MAKE) $${lang}.po-create; \
263
	  $(MAKE) $${lang}.po-create; \
174
	fi
264
	fi
Lines 191-197 install-data: install-data-@USE_NLS@ Link Here
191
	fi
281
	fi
192
install-data-no: all
282
install-data-no: all
193
install-data-yes: all
283
install-data-yes: all
194
	$(mkdir_p) $(DESTDIR)$(datadir)
195
	@catalogs='$(CATALOGS)'; \
284
	@catalogs='$(CATALOGS)'; \
196
	for cat in $$catalogs; do \
285
	for cat in $$catalogs; do \
197
	  cat=`basename $$cat`; \
286
	  cat=`basename $$cat`; \
Lines 243-249 installdirs-data: installdirs-data-@USE_NLS@ Link Here
243
	fi
332
	fi
244
installdirs-data-no:
333
installdirs-data-no:
245
installdirs-data-yes:
334
installdirs-data-yes:
246
	$(mkdir_p) $(DESTDIR)$(datadir)
247
	@catalogs='$(CATALOGS)'; \
335
	@catalogs='$(CATALOGS)'; \
248
	for cat in $$catalogs; do \
336
	for cat in $$catalogs; do \
249
	  cat=`basename $$cat`; \
337
	  cat=`basename $$cat`; \
Lines 303-336 check: all Link Here
303
391
304
info dvi ps pdf html tags TAGS ctags CTAGS ID:
392
info dvi ps pdf html tags TAGS ctags CTAGS ID:
305
393
394
install-dvi install-ps install-pdf install-html:
395
306
mostlyclean:
396
mostlyclean:
307
	rm -f remove-potcdate.sed
397
	rm -f remove-potcdate.sed
308
	rm -f stamp-poT
398
	rm -f $(srcdir)/stamp-poT
309
	rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
399
	rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
310
	rm -fr *.o
400
	rm -fr *.o
311
401
312
clean: mostlyclean
402
clean: mostlyclean
313
403
314
distclean: clean
404
distclean: clean
315
	rm -f Makefile Makefile.in POTFILES *.mo
405
	rm -f Makefile Makefile.in POTFILES
316
406
317
maintainer-clean: distclean
407
maintainer-clean: distclean
318
	@echo "This command is intended for maintainers to use;"
408
	@echo "This command is intended for maintainers to use;"
319
	@echo "it deletes files that may require special tools to rebuild."
409
	@echo "it deletes files that may require special tools to rebuild."
320
	rm -f stamp-po $(GMOFILES)
410
	rm -f $(srcdir)/$(DOMAIN).pot $(srcdir)/stamp-po $(GMOFILES)
321
411
322
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
412
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
323
dist distdir:
413
dist distdir:
324
	$(MAKE) update-po
414
	test -z "$(DISTFILESDEPS)" || $(MAKE) $(DISTFILESDEPS)
325
	@$(MAKE) dist2
415
	@$(MAKE) dist2
326
# This is a separate target because 'update-po' must be executed before.
416
# This is a separate target because 'update-po' must be executed before.
327
dist2: stamp-po $(DISTFILES)
417
dist2: $(srcdir)/stamp-po $(DISTFILES)
328
	dists="$(DISTFILES)"; \
418
	@dists="$(DISTFILES)"; \
329
	if test "$(PACKAGE)" = "gettext-tools"; then \
419
	if test "$(PACKAGE)" = "gettext-tools"; then \
330
	  dists="$$dists Makevars.template"; \
420
	  dists="$$dists Makevars.template"; \
331
	fi; \
421
	fi; \
332
	if test -f $(srcdir)/$(DOMAIN).pot; then \
422
	if test -f $(srcdir)/$(DOMAIN).pot; then \
333
	  dists="$$dists $(DOMAIN).pot stamp-po"; \
423
	  dists="$$dists $(DOMAIN).pot stamp-po"; \
424
	else \
425
	  case $(XGETTEXT) in \
426
	    :) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because a suitable 'xgettext' program was not found in PATH." 1>&2;; \
427
	    *) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because 'xgettext' found no strings to extract. Check the contents of the POTFILES.in file and the XGETTEXT_OPTIONS in the Makevars file." 1>&2;; \
428
	  esac; \
334
	fi; \
429
	fi; \
335
	if test -f $(srcdir)/ChangeLog; then \
430
	if test -f $(srcdir)/ChangeLog; then \
336
	  dists="$$dists ChangeLog"; \
431
	  dists="$$dists ChangeLog"; \
Lines 365-377 update-po: Makefile Link Here
365
460
366
.nop.po-update:
461
.nop.po-update:
367
	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
462
	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
368
	if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
463
	if test "$(PACKAGE)" = "gettext-tools" && test "$(CROSS_COMPILING)" != "yes"; then PATH=`pwd`/../src:$$PATH; fi; \
369
	tmpdir=`pwd`; \
464
	tmpdir=`pwd`; \
370
	echo "$$lang:"; \
465
	echo "$$lang:"; \
371
	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
466
	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
372
	echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
467
	echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
373
	cd $(srcdir); \
468
	cd $(srcdir); \
374
	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
469
	if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
470
	       '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
471
	         $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
472
	       0.1[6-7] | 0.1[6-7].*) \
473
	         $(MSGMERGE) $(MSGMERGE_OPTIONS) --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
474
	       *) \
475
	         $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
476
	     esac; \
477
	   }; then \
375
	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
478
	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
376
	    rm -f $$tmpdir/$$lang.new.po; \
479
	    rm -f $$tmpdir/$$lang.new.po; \
377
	  else \
480
	  else \
Lines 392-400 $(DUMMYPOFILES): Link Here
392
update-gmo: Makefile $(GMOFILES)
495
update-gmo: Makefile $(GMOFILES)
393
	@:
496
	@:
394
497
498
# Recreate Makefile by invoking config.status. Explicitly invoke the shell,
499
# because execution permission bits may not work on the current file system.
500
# Use @SHELL@, which is the shell determined by autoconf for the use by its
501
# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient.
395
Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
502
Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
396
	cd $(top_builddir) \
503
	cd $(top_builddir) \
397
	  && $(SHELL) ./config.status $(subdir)/$@.in po-directories
504
	  && @SHELL@ ./config.status $(subdir)/$@.in po-directories
398
505
399
force:
506
force:
400
507
(-)a/po/Rules-quot (-2 / +17 lines)
Lines 1-4 Link Here
1
# Special Makefile rules for English message catalogs with quotation marks.
1
# Special Makefile rules for English message catalogs with quotation marks.
2
#
3
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
4
# This file, Rules-quot, and its auxiliary files (listed under
5
# DISTFILES.common.extra1) are free software; the Free Software Foundation
6
# gives unlimited permission to use, copy, distribute, and modify them.
2
7
3
DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot
8
DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot
4
9
Lines 14-26 en@boldquot.po-update: en@boldquot.po-update-en Link Here
14
19
15
.insert-header.po-update-en:
20
.insert-header.po-update-en:
16
	@lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \
21
	@lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \
17
	if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \
22
	if test "$(PACKAGE)" = "gettext-tools" && test "$(CROSS_COMPILING)" != "yes"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \
18
	tmpdir=`pwd`; \
23
	tmpdir=`pwd`; \
19
	echo "$$lang:"; \
24
	echo "$$lang:"; \
20
	ll=`echo $$lang | sed -e 's/@.*//'`; \
25
	ll=`echo $$lang | sed -e 's/@.*//'`; \
21
	LC_ALL=C; export LC_ALL; \
26
	LC_ALL=C; export LC_ALL; \
22
	cd $(srcdir); \
27
	cd $(srcdir); \
23
	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 \
28
	if $(MSGINIT) $(MSGINIT_OPTIONS) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null \
29
	   | $(SED) -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | \
30
	   { case `$(MSGFILTER) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
31
	     '' | 0.[0-9] | 0.[0-9].* | 0.1[0-8] | 0.1[0-8].*) \
32
	       $(MSGFILTER) $(SED) -f `echo $$lang | sed -e 's/.*@//'`.sed \
33
	       ;; \
34
	     *) \
35
	       $(MSGFILTER) `echo $$lang | sed -e 's/.*@//'` \
36
	       ;; \
37
	     esac } 2>/dev/null > $$tmpdir/$$lang.new.po \
38
	     ; then \
24
	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
39
	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
25
	    rm -f $$tmpdir/$$lang.new.po; \
40
	    rm -f $$tmpdir/$$lang.new.po; \
26
	  else \
41
	  else \
(-)a/po/en@boldquot.header (-1 / +1 lines)
Lines 2-8 Link Here
2
# The msgids must be ASCII and therefore cannot contain real quotation
2
# The msgids must be ASCII and therefore cannot contain real quotation
3
# characters, only substitutes like grave accent (0x60), apostrophe (0x27)
3
# characters, only substitutes like grave accent (0x60), apostrophe (0x27)
4
# and double quote (0x22). These substitutes look strange; see
4
# and double quote (0x22). These substitutes look strange; see
5
# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
5
# https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
6
#
6
#
7
# This catalog translates grave accent (0x60) and apostrophe (0x27) to
7
# This catalog translates grave accent (0x60) and apostrophe (0x27) to
8
# left single quotation mark (U+2018) and right single quotation mark (U+2019).
8
# left single quotation mark (U+2018) and right single quotation mark (U+2019).
(-)a/po/en@quot.header (-1 / +1 lines)
Lines 2-8 Link Here
2
# The msgids must be ASCII and therefore cannot contain real quotation
2
# The msgids must be ASCII and therefore cannot contain real quotation
3
# characters, only substitutes like grave accent (0x60), apostrophe (0x27)
3
# characters, only substitutes like grave accent (0x60), apostrophe (0x27)
4
# and double quote (0x22). These substitutes look strange; see
4
# and double quote (0x22). These substitutes look strange; see
5
# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
5
# https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
6
#
6
#
7
# This catalog translates grave accent (0x60) and apostrophe (0x27) to
7
# This catalog translates grave accent (0x60) and apostrophe (0x27) to
8
# left single quotation mark (U+2018) and right single quotation mark (U+2019).
8
# left single quotation mark (U+2018) and right single quotation mark (U+2019).
(-)a/po/insert-header.sin (+5 lines)
Lines 1-5 Link Here
1
# Sed script that inserts the file called HEADER before the header entry.
1
# Sed script that inserts the file called HEADER before the header entry.
2
#
2
#
3
# Copyright (C) 2001 Free Software Foundation, Inc.
4
# Written by Bruno Haible <bruno@clisp.org>, 2001.
5
# This file is free software; the Free Software Foundation gives
6
# unlimited permission to use, copy, distribute, and modify it.
7
#
3
# At each occurrence of a line starting with "msgid ", we execute the following
8
# At each occurrence of a line starting with "msgid ", we execute the following
4
# commands. At the first occurrence, insert the file. At the following
9
# commands. At the first occurrence, insert the file. At the following
5
# occurrences, do nothing. The distinction between the first and the following
10
# occurrences, do nothing. The distinction between the first and the following
(-)a/po/remove-potcdate.sin (-2 / +7 lines)
Lines 1-6 Link Here
1
# Sed script that remove the POT-Creation-Date line in the header entry
1
# Sed script that removes the POT-Creation-Date line in the header entry
2
# from a POT file.
2
# from a POT file.
3
#
3
#
4
# Copyright (C) 2002 Free Software Foundation, Inc.
5
# Copying and distribution of this file, with or without modification,
6
# are permitted in any medium without royalty provided the copyright
7
# notice and this notice are preserved.  This file is offered as-is,
8
# without any warranty.
9
#
4
# The distinction between the first and the following occurrences of the
10
# The distinction between the first and the following occurrences of the
5
# pattern is achieved by looking at the hold space.
11
# pattern is achieved by looking at the hold space.
6
/^"POT-Creation-Date: .*"$/{
12
/^"POT-Creation-Date: .*"$/{
7
- 

Return to bug 713442