diff options
author | Pedro J. Ruiz Lopez <holzplatten@es.gnu.org> | 2007-02-18 19:35:04 +0000 |
---|---|---|
committer | Pedro J. Ruiz Lopez <holzplatten@es.gnu.org> | 2007-02-18 19:35:04 +0000 |
commit | d49b34302a70ad948ce9cbf5778b1b39adb4286d (patch) | |
tree | d67ad1453f9380f549d880e5ffbc43df8ba63828 /intl | |
parent | 80f3bd30c7521091c1dea118603b20a76c2a180c (diff) | |
download | idutils-d49b34302a70ad948ce9cbf5778b1b39adb4286d.tar.gz idutils-d49b34302a70ad948ce9cbf5778b1b39adb4286d.tar.bz2 idutils-d49b34302a70ad948ce9cbf5778b1b39adb4286d.zip |
Upgrade to gettext 0.16.1
Diffstat (limited to 'intl')
45 files changed, 3535 insertions, 2485 deletions
diff --git a/intl/ChangeLog b/intl/ChangeLog index 7d1d96e..f23c90b 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,7 @@ +2007-02-18 Pedro J. Ruiz Lopez <holzplatten@es.gnu.org> + + * gettext-0.16.1 released. + 2005-05-23 Bruno Haible <bruno@clisp.org> * gettext-0.14.5 released. @@ -1934,7 +1938,7 @@ * dcgettext.c: Don't use any alloca hack when C_ALLOCA is defined. -1998-05-01 08:47 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * gettext-0.10.35 released. @@ -1988,13 +1992,13 @@ * finddomain.c: Mark internal functions. Use strdup if available. Add memory freeing code for glibc. -1997-10-10 20:00 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * libgettext.h: Fix dummy textdomain and bindtextdomain macros. They should return reasonable values. Reported by Tom Tromey <tromey@cygnus.com>. -1997-09-16 03:33 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * libgettext.h: Define PARAMS also to `args' if __cplusplus is defined. * intlh.inst.in: Likewise. @@ -2002,19 +2006,19 @@ * libintl.glibc: Update from current glibc version. -1997-09-06 02:10 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * intlh.inst.in: Reformat copyright. -1997-08-19 15:22 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * dcgettext.c (DCGETTEXT): Remove wrong comment. -1997-08-16 00:13 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (install-data): Don't change directory to install. -1997-08-01 14:30 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * cat-compat.c: Fix copyright. @@ -2043,7 +2047,7 @@ * bindtextdom.c: Pretty printing. -1997-05-01 02:25 Ulrich Drepper <drepper@cygnus.com> +1999-11-30 Ulrich Drepper <drepper@cygnus.com> * dcgettext.c (guess_category_value): Don't depend on HAVE_LC_MESSAGES. We don't need the macro here. @@ -2057,14 +2061,14 @@ * Makefile.in (CPPFLAGS): New variable. Reported by François Pinard. -Mon Mar 10 06:51:17 1997 Ulrich Drepper <drepper@cygnus.com> +1997-03-10 Ulrich Drepper <drepper@cygnus.com> * Makefile.in: Implement handling of libtool. * gettextP.h: Change data structures for use of generic lowlevel i18n file handling. -Wed Dec 4 20:21:18 1996 Ulrich Drepper <drepper@cygnus.com> +1996-12-04 Ulrich Drepper <drepper@cygnus.com> * textdomain.c: Put parentheses around arguments of memcpy macro definition. @@ -2074,12 +2078,12 @@ Wed Dec 4 20:21:18 1996 Ulrich Drepper <drepper@cygnus.com> * bindtextdom.c: Likewise. Reported by Thomas Esken. -Mon Nov 25 22:57:51 1996 Ulrich Drepper <drepper@cygnus.com> +1996-11-25 Ulrich Drepper <drepper@cygnus.com> * textdomain.c: Move definition of `memcpy` macro to right position. -Fri Nov 22 04:01:58 1996 Ulrich Drepper <drepper@cygnus.com> +1996-11-22 Ulrich Drepper <drepper@cygnus.com> * finddomain.c [!HAVE_STRING_H && !_LIBC]: Define memcpy using bcopy if not already defined. Reported by Thomas Esken. @@ -2088,17 +2092,17 @@ Fri Nov 22 04:01:58 1996 Ulrich Drepper <drepper@cygnus.com> * localealias.c: Likewise. * textdomain.c: Likewise. -Tue Oct 29 11:10:27 1996 Ulrich Drepper <drepper@cygnus.com> +1996-10-29 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (libdir): Change to use exec_prefix instead of prefix. Reported by Knut-HåvardAksnes <etokna@eto.ericsson.se>. -Sat Aug 31 03:07:09 1996 Ulrich Drepper <drepper@cygnus.com> +1996-08-31 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c (_nl_normalize_codeset): We convert to lower case, so don't prepend uppercase `ISO' for only numeric arg. -Fri Jul 19 00:15:46 1996 Ulrich Drepper <drepper@cygnus.com> +1996-07-19 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c: Move inclusion of argz.h, ctype.h, stdlib.h after definition of _GNU_SOURCE. Patch by Roland McGrath. @@ -2110,7 +2114,7 @@ Fri Jul 19 00:15:46 1996 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (install-data): Again work around shells which cannot handle mpty for list. Reported by Jim Meyering. -Sat Jul 13 18:11:35 1996 Ulrich Drepper <drepper@cygnus.com> +1996-07-13 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (install): Split goal. Now depend on install-exec and install-data. @@ -2118,20 +2122,20 @@ Sat Jul 13 18:11:35 1996 Ulrich Drepper <drepper@cygnus.com> install goal. Reported by Karl Berry. -Sat Jun 22 04:58:14 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-22 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (MKINSTALLDIRS): New variable. Path to mkinstalldirs script. (install): use MKINSTALLDIRS variable or if the script is not present try to find it in the $top_scrdir). -Wed Jun 19 02:56:56 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-19 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c: Linux libc *partly* includes the argz_* functions. Grr. Work around by renaming the static version and use macros for renaming. -Tue Jun 18 20:11:17 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-19 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c: Correct presence test macros of __argz_* functions. @@ -2139,11 +2143,11 @@ Tue Jun 18 20:11:17 1996 Ulrich Drepper <drepper@cygnus.com> __argz_* functions are available. Reported by Andreas Schwab. -Thu Jun 13 15:17:44 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-13 Ulrich Drepper <drepper@cygnus.com> * explodename.c, l10nflist.c: Define NULL for dumb systems. -Tue Jun 11 17:05:13 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-11 Ulrich Drepper <drepper@cygnus.com> * intlh.inst.in, libgettext.h (dcgettext): Rename local variable result to __result to prevent name clash. @@ -2155,11 +2159,11 @@ Tue Jun 11 17:05:13 1996 Ulrich Drepper <drepper@cygnus.com> `_nl_msg_cat_cntr' outside __extension__ block to prevent warning from gcc's -Wnested-extern option. -Fri Jun 7 01:58:00 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-07 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (install): Remove comment. -Thu Jun 6 17:28:17 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-06 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (install): Work around for another Buglix stupidity. Always use an `else' close for `if's. Reported by Nelson Beebe. @@ -2167,7 +2171,7 @@ Thu Jun 6 17:28:17 1996 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (intlh.inst): Correct typo in phony rule. Reported by Nelson Beebe. -Thu Jun 6 01:49:52 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-06 Ulrich Drepper <drepper@cygnus.com> * dcgettext.c (read_alias_file): Rename variable alloca_list to block_list as the macro calls assume. @@ -2201,7 +2205,7 @@ Thu Jun 6 01:49:52 1996 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c: Solve some portability problems. Patches partly by Thomas Esken. Add local definition of stpcpy. -Tue Jun 4 02:47:49 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-04 Ulrich Drepper <drepper@cygnus.com> * intlh.inst.in: Don't depend including <locale.h> on HAVE_LOCALE_H. Instead configure must rewrite this fiile @@ -2216,7 +2220,7 @@ Tue Jun 4 02:47:49 1996 Ulrich Drepper <drepper@cygnus.com> because gcc has __buitlin_alloca. Reported by Roland McGrath. -Mon Jun 3 00:32:16 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-03 Ulrich Drepper <drepper@cygnus.com> * Makefile.in (installcheck): New goal to fulfill needs of automake's distcheck. @@ -2238,12 +2242,12 @@ Mon Jun 3 00:32:16 1996 Ulrich Drepper <drepper@cygnus.com> * dcgettext.c [!HAVE_ALLOCA]: Define macro alloca by using malloc. -Sun Jun 2 17:33:06 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-02 Ulrich Drepper <drepper@cygnus.com> * loadmsgcat.c (_nl_load_domain): Parameter is now comes from find_l10nfile. -Sat Jun 1 02:23:03 1996 Ulrich Drepper <drepper@cygnus.com> +1996-06-01 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c (__argz_next): Add definition. @@ -2255,61 +2259,61 @@ Sat Jun 1 02:23:03 1996 Ulrich Drepper <drepper@cygnus.com> * l10nflist.c: Initial revision. -Tue Apr 2 18:51:18 1996 Ulrich Drepper <drepper@myware> +1996-04-02 Ulrich Drepper <drepper@myware> * Makefile.in (all-gettext): New goal. Same as all-yes. -Thu Mar 28 23:01:22 1996 Karl Eichwalder <ke@ke.central.de> +1996-03-29 Karl Eichwalder <ke@ke.central.de> * Makefile.in (gettextsrcdir): Define using @datadir@. -Tue Mar 26 12:39:14 1996 Ulrich Drepper <drepper@myware> +1996-03-26 Ulrich Drepper <drepper@myware> * finddomain.c: Include <ctype.h>. Reported by Roland McGrath. -Sat Mar 23 02:00:35 1996 Ulrich Drepper <drepper@myware> +1996-03-23 Ulrich Drepper <drepper@myware> * finddomain.c (stpcpy): Rename to stpcpy__ to prevent clashing with external declaration. -Sat Mar 2 00:47:09 1996 Ulrich Drepper <drepper@myware> +1996-03-02 Ulrich Drepper <drepper@myware> * Makefile.in (all-no): Rename from all_no. -Sat Feb 17 00:25:59 1996 Ulrich Drepper <drepper@myware> +1996-02-17 Ulrich Drepper <drepper@myware> * gettextP.h [loaded_domain]: Array `successor' must now contain up to 63 elements (because of codeset name normalization). * finddomain.c: Implement codeset name normalization. -Thu Feb 15 04:39:09 1996 Ulrich Drepper <drepper@myware> +1996-02-15 Ulrich Drepper <drepper@myware> * Makefile.in (all): Define to `all-@USE_NLS@'. (all-yes, all_no): New goals. `all-no' is noop, `all-yes' is former all. -Mon Jan 15 21:46:01 1996 Howard Gayle <howard@hal.com> +1996-01-15 Howard Gayle <howard@hal.com> * localealias.c (alias_compare): Increment string pointers in loop of strcasecmp replacement. -Fri Dec 29 21:16:34 1995 Ulrich Drepper <drepper@myware> +1995-12-29 Ulrich Drepper <drepper@myware> * Makefile.in (install-src): Who commented this goal out ? :-) -Fri Dec 29 15:08:16 1995 Ulrich Drepper <drepper@myware> +1995-12-29 Ulrich Drepper <drepper@myware> * dcgettext.c (DCGETTEXT): Save `errno'. Failing system calls should not effect it because a missing catalog is no error. Reported by Harald K<o:>nig <koenig@tat.physik.uni-tuebingen.de>. -Tue Dec 19 22:09:13 1995 Ulrich Drepper <drepper@myware> +1995-12-19 Ulrich Drepper <drepper@myware> * Makefile.in (Makefile): Explicitly use $(SHELL) for running shell scripts. -Fri Dec 15 17:34:59 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> +1995-12-15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makefile.in (install-src): Only install library and header when we use the own implementation. Don't do it when using the @@ -2317,59 +2321,59 @@ Fri Dec 15 17:34:59 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund. * dcgettext.c (find_msg): Must not swap domain->hash_size here. -Sat Dec 9 16:24:37 1995 Ulrich Drepper <drepper@myware> +1995-12-09 Ulrich Drepper <drepper@myware> * localealias.c, libintl.inst, libgettext.h, hash-string.h, gettextP.h, finddomain.c, dcgettext.c, cat-compat.c: Use PARAMS instead of __P. Suggested by Roland McGrath. -Tue Dec 5 11:39:14 1995 Larry Schwimmer <rosebud@cyclone.stanford.edu> +1995-12-05 Larry Schwimmer <rosebud@cyclone.stanford.edu> * libgettext.h: Use `#if !defined (_LIBINTL_H)' instead of `#if !_LIBINTL_H' because Solaris defines _LIBINTL_H as empty. -Mon Dec 4 15:42:07 1995 Ulrich Drepper <drepper@myware> +1995-12-04 Ulrich Drepper <drepper@myware> * Makefile.in (install-src): Install libintl.inst instead of libintl.h.install. -Sat Dec 2 22:51:38 1995 Marcus Daniels <marcus@sysc.pdx.edu> +1995-12-02 Marcus Daniels <marcus@sysc.pdx.edu> * cat-compat.c (textdomain): Reverse order in which files are tried you load. First try local file, when this failed absolute path. -Wed Nov 29 02:03:53 1995 Nelson H. F. Beebe <beebe@math.utah.edu> +1995-11-29 Nelson H. F. Beebe <beebe@math.utah.edu> * cat-compat.c (bindtextdomain): Add missing { }. -Sun Nov 26 18:21:41 1995 Ulrich Drepper <drepper@myware> +1995-11-26 Ulrich Drepper <drepper@myware> * libintl.inst: Add missing __P definition. Reported by Nelson Beebe. * Makefile.in: Add dummy `all' and `dvi' goals. Reported by Tom Tromey. -Sat Nov 25 16:12:01 1995 François Pinard <pinard@iro.umontreal.ca> +1995-11-25 François Pinard <pinard@iro.umontreal.ca> * hash-string.h: Capitalize arguments of macros. -Sat Nov 25 12:01:36 1995 Ulrich Drepper <drepper@myware> +1995-11-25 Ulrich Drepper <drepper@myware> * Makefile.in (DISTFILES): Prevent files names longer than 13 characters. libintl.h.glibc->libintl.glibc, libintl.h.install->libintl.inst. Reported by Joshua R. Poulson. -Sat Nov 25 11:31:12 1995 Eric Backus <ericb@lsid.hp.com> +1995-11-25 Eric Backus <ericb@lsid.hp.com> * dcgettext.c: Fix bug in preprocessor conditionals. -Sat Nov 25 02:35:27 1995 Nelson H. F. Beebe <beebe@math.utah.edu> +1995-11-25 Nelson H. F. Beebe <beebe@math.utah.edu> * libgettext.h: Solaris cc does not understand #if !SYMBOL1 && !SYMBOL2. Sad but true. -Thu Nov 23 16:22:14 1995 Ulrich Drepper <drepper@myware> +1995-11-23 Ulrich Drepper <drepper@myware> * hash-string.h (hash_string): Fix for machine with >32 bit `unsigned long's. @@ -2377,12 +2381,12 @@ Thu Nov 23 16:22:14 1995 Ulrich Drepper <drepper@myware> * dcgettext.c (DCGETTEXT): Fix horrible bug in loop for alternative translation. -Thu Nov 23 01:45:29 1995 Ulrich Drepper <drepper@myware> +1995-11-23 Ulrich Drepper <drepper@myware> * po2tbl.sed.in, linux-msg.sed, xopen-msg.sed: Some further simplifications in message number generation. -Mon Nov 20 21:08:43 1995 Ulrich Drepper <drepper@myware> +1995-11-20 Ulrich Drepper <drepper@myware> * libintl.h.glibc: Use __const instead of const in prototypes. @@ -2395,24 +2399,24 @@ Mon Nov 20 21:08:43 1995 Ulrich Drepper <drepper@myware> * localealias.c (_nl_expand_alias, read_alias_file): Protect prototypes in type casts by __P. -Tue Nov 14 16:43:58 1995 Ulrich Drepper <drepper@myware> +1995-11-14 Ulrich Drepper <drepper@myware> * hash-string.h: Correct prototype for hash_string. -Sun Nov 12 12:42:30 1995 Ulrich Drepper <drepper@myware> +1995-11-12 Ulrich Drepper <drepper@myware> * hash-string.h (hash_string): Add prototype. * gettextP.h: Fix copyright. (SWAP): Add prototype. -Wed Nov 8 22:56:33 1995 Ulrich Drepper <drepper@myware> +1995-11-08 Ulrich Drepper <drepper@myware> * localealias.c (read_alias_file): Forgot sizeof. Avoid calling *printf function. This introduces a big overhead. Patch by Roland McGrath. -Tue Nov 7 14:21:08 1995 Ulrich Drepper <drepper@myware> +1995-11-07 Ulrich Drepper <drepper@myware> * finddomain.c, cat-compat.c: Wrong indentation in #if for stpcpy. @@ -2436,12 +2440,12 @@ Tue Nov 7 14:21:08 1995 Ulrich Drepper <drepper@myware> * Makefile.in: Correct typos in comment. By François Pinard. -Mon Nov 6 00:27:02 1995 Ulrich Drepper <drepper@myware> +1995-11-06 Ulrich Drepper <drepper@myware> * Makefile.in (install-src): Don't install libintl.h and libintl.a if we use an available gettext implementation. -Sun Nov 5 22:02:08 1995 Ulrich Drepper <drepper@myware> +1995-11-05 Ulrich Drepper <drepper@myware> * libgettext.h: Fix typo: HAVE_CATGETTS -> HAVE_CATGETS. Reported by François Pinard. @@ -2451,19 +2455,19 @@ Sun Nov 5 22:02:08 1995 Ulrich Drepper <drepper@myware> * finddomain.c: Comments describing what has to be done should start with FIXME. -Sun Nov 5 19:38:01 1995 Ulrich Drepper <drepper@myware> +1995-11-05 Ulrich Drepper <drepper@myware> * Makefile.in (DISTFILES): Split. Use DISTFILES with normal meaning. DISTFILES.common names the files common to both dist goals. DISTFILES.gettext are the files only distributed in GNU gettext. -Sun Nov 5 17:32:54 1995 Ulrich Drepper <drepper@myware> +1995-11-05 Ulrich Drepper <drepper@myware> * dcgettext.c (DCGETTEXT): Correct searching in derived locales. This was necessary since a change in _nl_find_msg several weeks ago. I really don't know this is still not fixed. -Sun Nov 5 12:43:12 1995 Ulrich Drepper <drepper@myware> +1995-11-05 Ulrich Drepper <drepper@myware> * loadmsgcat.c (_nl_load_domain): Test for FILENAME == NULL. This might mark a special condition. @@ -2475,7 +2479,7 @@ Sun Nov 5 12:43:12 1995 Ulrich Drepper <drepper@myware> * libgettext.h (gettext_const): Rename to gettext_noop. -Fri Nov 3 07:36:50 1995 Ulrich Drepper <drepper@myware> +1995-11-03 Ulrich Drepper <drepper@myware> * finddomain.c (make_entry_rec): Protect against wrong locale names by testing mask. @@ -2483,7 +2487,7 @@ Fri Nov 3 07:36:50 1995 Ulrich Drepper <drepper@myware> * libgettext.h (gettext_const): Add macro definition. Capitalize macro arguments. -Thu Nov 2 23:15:51 1995 Ulrich Drepper <drepper@myware> +1995-11-03 Ulrich Drepper <drepper@myware> * finddomain.c (_nl_find_domain): Test for pointer != NULL before accessing value. @@ -2492,11 +2496,11 @@ Thu Nov 2 23:15:51 1995 Ulrich Drepper <drepper@myware> * gettext.c (NULL): Define as (void*)0 instad of 0. Reported by François Pinard. -Mon Oct 30 21:28:52 1995 Ulrich Drepper <drepper@myware> +1995-10-30 Ulrich Drepper <drepper@myware> * po2tbl.sed.in: Serious typo bug fixed by Jim Meyering. -Sat Oct 28 23:20:47 1995 Ulrich Drepper <drepper@myware> +1995-10-29 Ulrich Drepper <drepper@myware> * libgettext.h: Disable dcgettext optimization for Solaris 2.3. @@ -2504,12 +2508,12 @@ Sat Oct 28 23:20:47 1995 Ulrich Drepper <drepper@myware> Peter Miller reported that tolower in some systems is even dumber than I thought. Protect call by `isupper'. -Fri Oct 27 22:22:51 1995 Ulrich Drepper <drepper@myware> +1995-10-27 Ulrich Drepper <drepper@myware> * Makefile.in (libdir, includedir): New variables. (install-src): Install libintl.a and libintl.h in correct dirs. -Fri Oct 27 22:07:29 1995 Ulrich Drepper <drepper@myware> +1995-10-27 Ulrich Drepper <drepper@myware> * Makefile.in (SOURCES): Fix typo: intrl.compat.c -> intl-compat.c. @@ -2518,13 +2522,13 @@ Fri Oct 27 22:07:29 1995 Ulrich Drepper <drepper@myware> * localealias.c: Fix typo and superflous test. Reported by Christian von Roques. -Fri Oct 6 11:52:05 1995 Ulrich Drepper <drepper@myware> +1995-10-06 Ulrich Drepper <drepper@myware> * finddomain.c (_nl_find_domain): Correct some remainder from the pre-CEN syntax. Now we don't have a constant number of successors anymore. -Wed Sep 27 21:41:13 1995 Ulrich Drepper <drepper@myware> +1995-09-27 Ulrich Drepper <drepper@myware> * Makefile.in (DISTFILES): Add libintl.h.glibc. @@ -2590,7 +2594,7 @@ Wed Sep 27 21:41:13 1995 Ulrich Drepper <drepper@myware> * bindtextdom.c: If compiled in glibc include libintl.h instead of libgettext.h. -Mon Sep 25 22:23:06 1995 Ulrich Drepper <drepper@myware> +1995-09-25 Ulrich Drepper <drepper@myware> * localealias.c (_nl_expand_alias): Don't call bsearch if NMAP <= 0. Reported by Marcus Daniels. @@ -2607,7 +2611,7 @@ Mon Sep 25 22:23:06 1995 Ulrich Drepper <drepper@myware> Fix bug with the strange stpcpy replacement. Reported by Nelson Beebe. -Sat Sep 23 08:23:51 1995 Ulrich Drepper <drepper@myware> +1995-09-23 Ulrich Drepper <drepper@myware> * cat-compat.c: Include <string.h> for stpcpy prototype. @@ -2620,7 +2624,7 @@ Sat Sep 23 08:23:51 1995 Ulrich Drepper <drepper@myware> * finddomain.c (_nl_find_domain): Remove unused variable `application'. -Thu Sep 21 15:51:44 1995 Ulrich Drepper <drepper@myware> +1995-09-21 Ulrich Drepper <drepper@myware> * localealias.c (alias_compare): Use strcasecmp() only if available. Else use @@ -2656,18 +2660,18 @@ Thu Sep 21 15:51:44 1995 Ulrich Drepper <drepper@myware> of the standard libc and so prevent libintl.a from being used standalone. -Sun Sep 17 23:14:49 1995 Ulrich Drepper <drepper@myware> +1995-09-18 Ulrich Drepper <drepper@myware> * finddomain.c: Correct some bugs in handling of CEN standard locale definitions. -Thu Sep 7 01:49:28 1995 Ulrich Drepper <drepper@myware> +1995-09-07 Ulrich Drepper <drepper@myware> * finddomain.c: Implement CEN syntax. * gettextP.h (loaded_domain): Extend number of successors to 31. -Sat Aug 19 19:25:29 1995 Ulrich Drepper <drepper@myware> +1995-08-19 Ulrich Drepper <drepper@myware> * Makefile.in (aliaspath): Remove path to X11 locale dir. @@ -2675,11 +2679,11 @@ Sat Aug 19 19:25:29 1995 Ulrich Drepper <drepper@myware> gettext to install the sources and other packages can use the install goal. -Sat Aug 19 15:19:33 1995 Ulrich Drepper <drepper@myware> +1995-08-19 Ulrich Drepper <drepper@myware> * Makefile.in (uninstall): Remove stuff installed by install-src. -Tue Aug 15 13:13:53 1995 Ulrich Drepper <drepper@myware> +1995-08-15 Ulrich Drepper <drepper@myware> * VERSION.in: Initial revision. @@ -2687,7 +2691,7 @@ Tue Aug 15 13:13:53 1995 Ulrich Drepper <drepper@myware> Add VERSION file. This is not necessary for gettext, but for other packages using this library. -Tue Aug 15 06:16:44 1995 Ulrich Drepper <drepper@myware> +1995-08-15 Ulrich Drepper <drepper@myware> * gettextP.h (_nl_find_domain): New prototype after changing search strategy. @@ -2703,7 +2707,7 @@ Tue Aug 15 06:16:44 1995 Ulrich Drepper <drepper@myware> within one language. Implemented by moving one loop from _nl_find_domain to here. -Mon Aug 14 23:45:50 1995 Ulrich Drepper <drepper@myware> +1995-08-15 Ulrich Drepper <drepper@myware> * Makefile.in (gettextsrcdir): Directory where source of GNU gettext library are made @@ -2712,7 +2716,7 @@ Mon Aug 14 23:45:50 1995 Ulrich Drepper <drepper@myware> (gettext-src): New. Rule to install GNU gettext sources for use in gettextize shell script. -Sun Aug 13 14:40:48 1995 Ulrich Drepper <drepper@myware> +1995-08-13 Ulrich Drepper <drepper@myware> * loadmsgcat.c (_nl_load_domain): Use mmap for loading only when munmap function is @@ -2720,7 +2724,7 @@ Sun Aug 13 14:40:48 1995 Ulrich Drepper <drepper@myware> * Makefile.in (install): Depend on `all' goal. -Wed Aug 9 11:04:33 1995 Ulrich Drepper <drepper@myware> +1995-08-09 Ulrich Drepper <drepper@myware> * localealias.c (read_alias_file): Do not overwrite '\n' when terminating alias value string. @@ -2729,7 +2733,7 @@ Wed Aug 9 11:04:33 1995 Ulrich Drepper <drepper@myware> Handle long lines. Ignore the rest not fitting in the buffer after the initial `fgets' call. -Wed Aug 9 00:54:29 1995 Ulrich Drepper <drepper@myware> +1995-08-09 Ulrich Drepper <drepper@myware> * gettextP.h (_nl_load_domain): Add prototype, replacing prototype for _nl_load_msg_cat. @@ -2745,7 +2749,7 @@ Wed Aug 9 00:54:29 1995 Ulrich Drepper <drepper@myware> * loadmsgcat.c: Better prototypes for xmalloc. -Tue Aug 8 22:30:39 1995 Ulrich Drepper <drepper@myware> +1995-08-09 Ulrich Drepper <drepper@myware> * finddomain.c (_nl_find_domain): Allow alias name to be constructed from the four components. @@ -2762,7 +2766,7 @@ Tue Aug 8 22:30:39 1995 Ulrich Drepper <drepper@myware> * bindtextdom.c: Better prototypes for xmalloc and xstrdup. -Mon Aug 7 23:47:42 1995 Ulrich Drepper <drepper@myware> +1995-08-08 Ulrich Drepper <drepper@myware> * Makefile.in (DISTFILES): gettext.perl is now found in misc/. @@ -2786,22 +2790,22 @@ Mon Aug 7 23:47:42 1995 Ulrich Drepper <drepper@myware> Here we can set a colon separated list of specifications each of the form `language[_territory[.codeset]][@modifier]'. -Sat Aug 5 09:55:42 1995 Ulrich Drepper <drepper@myware> +1995-08-05 Ulrich Drepper <drepper@myware> * finddomain.c (unistd.h): Include to get _PC_PATH_MAX defined on system having it. -Fri Aug 4 22:42:00 1995 Ulrich Drepper <drepper@myware> +1995-08-05 Ulrich Drepper <drepper@myware> * finddomain.c (stpcpy): Include prototype. * Makefile.in (dist): Remove `copying instead' message. -Wed Aug 2 18:52:03 1995 Ulrich Drepper <drepper@myware> +1995-08-02 Ulrich Drepper <drepper@myware> * Makefile.in (ID, TAGS): Do not use $^. -Tue Aug 1 20:07:11 1995 Ulrich Drepper <drepper@myware> +1995-08-02 Ulrich Drepper <drepper@myware> * Makefile.in (TAGS, ID): Use $^ as command argument. (TAGS): Give etags -o option t write to current directory, @@ -2809,7 +2813,7 @@ Tue Aug 1 20:07:11 1995 Ulrich Drepper <drepper@myware> (ID): Use $(srcdir) instead os $(top_srcdir)/src. (distclean): Remove ID. -Sun Jul 30 11:51:46 1995 Ulrich Drepper <drepper@myware> +1995-07-30 Ulrich Drepper <drepper@myware> * Makefile.in (gnulocaledir): New variable, always using share/ for data directory. @@ -2822,17 +2826,17 @@ Sun Jul 30 11:51:46 1995 Ulrich Drepper <drepper@myware> * intl-compat.c (textdomain, bindtextdomain): Undefine macros before function definition. -Sat Jul 22 01:10:02 1995 Ulrich Drepper <drepper@myware> +1995-07-22 Ulrich Drepper <drepper@myware> * libgettext.h (_LIBINTL_H): Protect definition in case where this file is included as libgettext.h on Solaris machines. Add comment about this. -Wed Jul 19 02:36:42 1995 Ulrich Drepper <drepper@myware> +1995-07-19 Ulrich Drepper <drepper@myware> * intl-compat.c (textdomain): Correct typo. -Wed Jul 19 01:51:35 1995 Ulrich Drepper <drepper@myware> +1995-07-19 Ulrich Drepper <drepper@myware> * dcgettext.c (dcgettext): Function now called __dcgettext. @@ -2862,14 +2866,14 @@ Wed Jul 19 01:51:35 1995 Ulrich Drepper <drepper@myware> * finddomain.c (strchr): Define as index if not found in C library. (_nl_find_domain): For relative paths paste / in between. -Tue Jul 18 16:37:45 1995 Ulrich Drepper <drepper@myware> +1995-07-18 Ulrich Drepper <drepper@myware> * loadmsgcat.c, finddomain.c: Add inclusion of sys/types.h. * xopen-msg.sed: Fix bug with `msgstr ""' lines. A little bit better comments. -Tue Jul 18 01:18:27 1995 Ulrich Drepper <drepper@myware> +1995-07-18 Ulrich Drepper <drepper@myware> * Makefile.in: po-mode.el, makelinks, combine-sh are now found in ../misc. @@ -2879,7 +2883,7 @@ Tue Jul 18 01:18:27 1995 Ulrich Drepper <drepper@myware> * libgettext.h, gettextP.h, gettext.h: Uniform test for __STDC__. -Sun Jul 16 22:33:02 1995 Ulrich Drepper <drepper@myware> +1995-07-17 Ulrich Drepper <drepper@myware> * Makefile.in (INSTALL, INSTALL_DATA): New variables. (install-data, uninstall): Install/uninstall .elc file. @@ -2887,12 +2891,12 @@ Sun Jul 16 22:33:02 1995 Ulrich Drepper <drepper@myware> * po-mode.el (Installation comment): Add .pox as possible extension of .po files. -Sun Jul 16 13:23:27 1995 Ulrich Drepper <drepper@myware> +1995-07-16 Ulrich Drepper <drepper@myware> * elisp-comp: Complete new version by François: This does not fail when not compiling in the source directory. -Sun Jul 16 00:12:17 1995 Ulrich Drepper <drepper@myware> +1995-07-16 Ulrich Drepper <drepper@myware> * Makefile.in (../po/cat-id-tbl.o): Use $(MAKE) instead of make for recursive make. @@ -2902,7 +2906,7 @@ Sun Jul 16 00:12:17 1995 Ulrich Drepper <drepper@myware> (install-data, uninstall): @ in multi-line shell command at beginning, not in front of echo. Reported by Eric Backus. -Sat Jul 15 00:21:28 1995 Ulrich Drepper <drepper@myware> +1995-07-15 Ulrich Drepper <drepper@myware> * Makefile.in (DISTFILES): Rename libgettext.perl to gettext.perl to fit in 14 chars @@ -2911,11 +2915,11 @@ Sat Jul 15 00:21:28 1995 Ulrich Drepper <drepper@myware> * gettext.perl: Rename to gettext.perl to fit in 14 chars file systems. -Thu Jul 13 23:17:20 1995 Ulrich Drepper <drepper@myware> +1995-07-14 Ulrich Drepper <drepper@myware> * cat-compat.c: If !STDC_HEADERS try to include malloc.h. -Thu Jul 13 20:55:02 1995 Ulrich Drepper <drepper@myware> +1995-07-14 Ulrich Drepper <drepper@myware> * po2tbl.sed.in: Pretty printing. @@ -2930,7 +2934,7 @@ Thu Jul 13 20:55:02 1995 Ulrich Drepper <drepper@myware> * cat-compat.c (msg_to_cat_id): De-ANSI-fy prototypes. -Thu Jul 13 01:34:33 1995 Ulrich Drepper <drepper@myware> +1995-07-13 Ulrich Drepper <drepper@myware> * Makefile.in (ELCFILES): New variable. (DISTFILES): Add elisp-comp. @@ -2940,7 +2944,7 @@ Thu Jul 13 01:34:33 1995 Ulrich Drepper <drepper@myware> * elisp-comp: Initial revision -Wed Jul 12 16:14:52 1995 Ulrich Drepper <drepper@myware> +1995-07-12 Ulrich Drepper <drepper@myware> * Makefile.in: cat-id-tbl.c is now found in po/. This enables us to use an identical @@ -2950,7 +2954,7 @@ Wed Jul 12 16:14:52 1995 Ulrich Drepper <drepper@myware> * textdomain.c: fix typo (#if def -> #if defined) -Tue Jul 11 18:44:43 1995 Ulrich Drepper <drepper@myware> +1995-07-11 Ulrich Drepper <drepper@myware> * Makefile.in (stamp-cat-id): use top_srcdir to address source files (DISTFILES,distclean): move tupdate.perl to src/ @@ -2958,7 +2962,7 @@ Tue Jul 11 18:44:43 1995 Ulrich Drepper <drepper@myware> * po-to-tbl.sed.in: add additional jump to clear change flag to recognize multiline strings -Tue Jul 11 01:32:50 1995 Ulrich Drepper <drepper@myware> +1995-07-11 Ulrich Drepper <drepper@myware> * textdomain.c: Protect inclusion of stdlib.h and string.h. @@ -2975,7 +2979,7 @@ Tue Jul 11 01:32:50 1995 Ulrich Drepper <drepper@myware> * tupdate.perl.in: Substitute Perl path even in exec line. Don't include entries without translation from old .po file. -Tue Jul 4 00:41:51 1995 Ulrich Drepper <drepper@myware> +1995-07-04 Ulrich Drepper <drepper@myware> * tupdate.perl.in: use "Updated: " in msgid "". @@ -2990,7 +2994,7 @@ Tue Jul 4 00:41:51 1995 Ulrich Drepper <drepper@myware> * cat-compat.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. -Mon Jul 3 23:56:30 1995 Ulrich Drepper <drepper@myware> +1995-07-04 Ulrich Drepper <drepper@myware> * Makefile.in: Use LOCALEDIR instead of DEF_MSG_DOM_DIR. Remove unneeded $(srcdir) from Makefile.in dependency. @@ -3013,11 +3017,11 @@ Mon Jul 3 23:56:30 1995 Ulrich Drepper <drepper@myware> * linux-msg.sed, xopen-msg.sed: Adopt for new .po file format. -Sun Jul 2 23:55:03 1995 Ulrich Drepper <drepper@myware> +1995-07-03 Ulrich Drepper <drepper@myware> * tupdate.perl.in: Complete rewrite for new .po file format. -Sun Jul 2 02:06:50 1995 Ulrich Drepper <drepper@myware> +1995-07-02 Ulrich Drepper <drepper@myware> * First official release. This directory contains all the code needed to internationalize own packages. It provides functions diff --git a/intl/Makefile.in b/intl/Makefile.in index 060ef49..525922e 100644 --- a/intl/Makefile.in +++ b/intl/Makefile.in @@ -1,5 +1,5 @@ # Makefile for directory with message catalog handling library of GNU gettext -# Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc. +# Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published @@ -24,6 +24,17 @@ SHELL = /bin/sh srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = .. + +# The VPATH variables allows builds with $builddir != $srcdir, assuming a +# 'make' program that supports VPATH (such as GNU make). This line is removed +# by autoconf automatically when "$(srcdir)" = ".". +# In this directory, the VPATH handling is particular: +# 1. If INTL_LIBTOOL_SUFFIX_PREFIX is 'l' (indicating a build with libtool), +# the .c -> .lo rules carefully use $(srcdir), so that VPATH can be omitted. +# 2. If PACKAGE = gettext-tools, VPATH _must_ be omitted, because otherwise +# 'make' does the wrong thing if GNU gettext was configured with +# "./configure --srcdir=`pwd`", namely it gets confused by the .lo and .la +# files it finds in srcdir = ../../gettext-runtime/intl. VPATH = $(srcdir) prefix = @prefix@ @@ -31,6 +42,7 @@ exec_prefix = @exec_prefix@ transform = @program_transform_name@ libdir = @libdir@ includedir = @includedir@ +datarootdir = @datarootdir@ datadir = @datadir@ localedir = $(datadir)/locale gettextsrcdir = $(datadir)/gettext/intl @@ -39,8 +51,18 @@ subdir = intl INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -mkinstalldirs = $(SHELL) $(MKINSTALLDIRS) + +# We use $(mkdir_p). +# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as +# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, +# @install_sh@ does not start with $(SHELL), so we add it. +# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined +# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake +# versions, $(mkinstalldirs) and $(install_sh) are unused. +mkinstalldirs = $(SHELL) @install_sh@ -d +install_sh = $(SHELL) @install_sh@ +MKDIR_P = @MKDIR_P@ +mkdir_p = @mkdir_p@ l = @INTL_LIBTOOL_SUFFIX_PREFIX@ @@ -51,15 +73,19 @@ RANLIB = @RANLIB@ YACC = @INTLBISON@ -y -d YFLAGS = --name-prefix=__gettext +# -DBUILDING_LIBINTL: Change expansion of LIBINTL_DLL_EXPORTED macro. +# -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro. DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ --DLIBDIR=\"$(libdir)\" -DIN_LIBINTL \ +-DLIBDIR=\"$(libdir)\" -DBUILDING_LIBINTL -DBUILDING_DLL -DIN_LIBINTL \ -DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\" -DNO_XMALLOC \ -Dset_relocation_prefix=libintl_set_relocation_prefix \ -Drelocate=libintl_relocate \ -DDEPENDS_ON_LIBICONV=1 @DEFS@ CPPFLAGS = @CPPFLAGS@ -CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ +CFLAGS = @CFLAGS@ @CFLAG_VISIBILITY@ +LDFLAGS = @LDFLAGS@ $(LDFLAGS_@WOE32DLL@) +LDFLAGS_yes = -Wl,--export-all-symbols +LDFLAGS_no = LIBS = @LIBS@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) @@ -72,6 +98,7 @@ HEADERS = \ plural-exp.h \ eval-plural.h \ localcharset.h \ + lock.h \ relocatable.h \ xsize.h \ printf-args.h printf-args.c \ @@ -85,6 +112,7 @@ SOURCES = \ dgettext.c \ gettext.c \ finddomain.c \ + hash-string.c \ loadmsgcat.c \ localealias.c \ textdomain.c \ @@ -97,13 +125,16 @@ SOURCES = \ plural.y \ plural-exp.c \ localcharset.c \ + lock.c \ relocatable.c \ langprefs.c \ localename.c \ log.c \ printf.c \ + version.c \ osdep.c \ os2compat.c \ + intl-exports.c \ intl-compat.c OBJECTS = \ bindtextdom.$lo \ @@ -111,6 +142,7 @@ OBJECTS = \ dgettext.$lo \ gettext.$lo \ finddomain.$lo \ + hash-string.$lo \ loadmsgcat.$lo \ localealias.$lo \ textdomain.$lo \ @@ -123,22 +155,25 @@ OBJECTS = \ plural.$lo \ plural-exp.$lo \ localcharset.$lo \ + lock.$lo \ relocatable.$lo \ langprefs.$lo \ localename.$lo \ log.$lo \ printf.$lo \ + version.$lo \ osdep.$lo \ intl-compat.$lo DISTFILES.common = Makefile.in \ -config.charset locale.alias ref-add.sin ref-del.sin $(HEADERS) $(SOURCES) +config.charset locale.alias ref-add.sin ref-del.sin export.h \ +$(HEADERS) $(SOURCES) DISTFILES.generated = plural.c DISTFILES.normal = VERSION -DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc \ -libgnuintl.h_vms Makefile.vms \ -libgnuintl.h.msvc-static libgnuintl.h.msvc-shared README.woe32 Makefile.msvc +DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc README.woe32 DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \ -COPYING.LIB-2 gettext.h libgettext.h plural-eval.c libgnuintl.h +COPYING.LIB-2 gettext.h libgettext.h plural-eval.c libgnuintl.h \ +libgnuintl.h_vms Makefile.vms libgnuintl.h.msvc-static \ +libgnuintl.h.msvc-shared Makefile.msvc all: all-@USE_INCLUDED_LIBINTL@ all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed @@ -154,7 +189,7 @@ libintl.a libgnuintl.a: $(OBJECTS) libintl.la libgnuintl.la: $(OBJECTS) $(LIBTOOL) --mode=link \ $(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \ - $(OBJECTS) @LTLIBICONV@ @INTL_MACOSX_LIBS@ $(LIBS) -lc \ + $(OBJECTS) @LTLIBICONV@ @INTL_MACOSX_LIBS@ $(LIBS) @LTLIBTHREAD@ -lc \ -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \ -rpath $(libdir) \ -no-undefined @@ -164,9 +199,9 @@ libintl.la libgnuintl.la: $(OBJECTS) # according to the libtool documentation, section "Library interface versions". # Maintainers of other packages that include the intl directory must *not* # change these values. -LTV_CURRENT=7 -LTV_REVISION=3 -LTV_AGE=4 +LTV_CURRENT=8 +LTV_REVISION=1 +LTV_AGE=0 .SUFFIXES: .SUFFIXES: .c .y .o .lo .sin .sed @@ -188,6 +223,8 @@ gettext.lo: $(srcdir)/gettext.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/gettext.c finddomain.lo: $(srcdir)/finddomain.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/finddomain.c +hash-string.lo: $(srcdir)/hash-string.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/hash-string.c loadmsgcat.lo: $(srcdir)/loadmsgcat.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/loadmsgcat.c localealias.lo: $(srcdir)/localealias.c @@ -212,6 +249,8 @@ plural-exp.lo: $(srcdir)/plural-exp.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c localcharset.lo: $(srcdir)/localcharset.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c +lock.lo: $(srcdir)/lock.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/lock.c relocatable.lo: $(srcdir)/relocatable.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/relocatable.c langprefs.lo: $(srcdir)/langprefs.c @@ -222,6 +261,8 @@ log.lo: $(srcdir)/log.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/log.c printf.lo: $(srcdir)/printf.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/printf.c +version.lo: $(srcdir)/version.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/version.c osdep.lo: $(srcdir)/osdep.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/osdep.c intl-compat.lo: $(srcdir)/intl-compat.c @@ -237,14 +278,29 @@ ref-del.sed: $(srcdir)/ref-del.sin INCLUDES = -I. -I$(srcdir) -I.. libgnuintl.h: $(srcdir)/libgnuintl.h.in - sed -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \ + sed -e '/IN_LIBGLOCALE/d' \ + -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \ -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ - < $(srcdir)/libgnuintl.h.in > libgnuintl.h - -libintl.h: libgnuintl.h - cp libgnuintl.h libintl.h + < $(srcdir)/libgnuintl.h.in \ + | if test '@WOE32DLL@' = yes; then \ + sed -e 's/extern \([^()]*\);/extern __declspec (dllimport) \1;/'; \ + else \ + cat; \ + fi \ + | sed -e 's/extern \([^"]\)/extern LIBINTL_DLL_EXPORTED \1/' \ + -e "/#define _LIBINTL_H/r $(srcdir)/export.h" \ + | sed -e 's,@''HAVE_VISIBILITY''@,@HAVE_VISIBILITY@,g' \ + > libgnuintl.h + +libintl.h: $(srcdir)/libgnuintl.h.in + sed -e '/IN_LIBGLOCALE/d' \ + -e 's,@''HAVE_POSIX_PRINTF''@,@HAVE_POSIX_PRINTF@,g' \ + -e 's,@''HAVE_ASPRINTF''@,@HAVE_ASPRINTF@,g' \ + -e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \ + -e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \ + < $(srcdir)/libgnuintl.h.in > libintl.h charset.alias: $(srcdir)/config.charset $(SHELL) $(srcdir)/config.charset '@host@' > t-$@ @@ -261,7 +317,7 @@ install: install-exec install-data install-exec: all if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \ && test '@USE_INCLUDED_LIBINTL@' = yes; then \ - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ + $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ $(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \ $(LIBTOOL) --mode=install \ $(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \ @@ -277,7 +333,7 @@ install-exec: all if test "$(PACKAGE)" = "gettext-tools" \ && test '@USE_INCLUDED_LIBINTL@' = no \ && test @GLIBC2@ != no; then \ - $(mkinstalldirs) $(DESTDIR)$(libdir); \ + $(mkdir_p) $(DESTDIR)$(libdir); \ $(LIBTOOL) --mode=install \ $(INSTALL_DATA) libgnuintl.$la $(DESTDIR)$(libdir)/libgnuintl.$la; \ rm -f $(DESTDIR)$(libdir)/preloadable_libintl.so; \ @@ -288,7 +344,7 @@ install-exec: all : ; \ fi if test '@USE_INCLUDED_LIBINTL@' = yes; then \ - test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \ + test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \ temp=$(DESTDIR)$(libdir)/t-charset.alias; \ dest=$(DESTDIR)$(libdir)/charset.alias; \ if test -f $(DESTDIR)$(libdir)/charset.alias; then \ @@ -304,7 +360,7 @@ install-exec: all rm -f $$temp; \ fi; \ fi; \ - $(mkinstalldirs) $(DESTDIR)$(localedir); \ + $(mkdir_p) $(DESTDIR)$(localedir); \ test -f $(DESTDIR)$(localedir)/locale.alias \ && orig=$(DESTDIR)$(localedir)/locale.alias \ || orig=$(srcdir)/locale.alias; \ @@ -318,7 +374,7 @@ install-exec: all fi install-data: all if test "$(PACKAGE)" = "gettext-tools"; then \ - $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \ $(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \ dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \ @@ -346,25 +402,25 @@ install-strip: install installdirs: if { test "$(PACKAGE)" = "gettext-runtime" || test "$(PACKAGE)" = "gettext-tools"; } \ && test '@USE_INCLUDED_LIBINTL@' = yes; then \ - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ + $(mkdir_p) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ else \ : ; \ fi if test "$(PACKAGE)" = "gettext-tools" \ && test '@USE_INCLUDED_LIBINTL@' = no \ && test @GLIBC2@ != no; then \ - $(mkinstalldirs) $(DESTDIR)$(libdir); \ + $(mkdir_p) $(DESTDIR)$(libdir); \ else \ : ; \ fi if test '@USE_INCLUDED_LIBINTL@' = yes; then \ - test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \ - $(mkinstalldirs) $(DESTDIR)$(localedir); \ + test @GLIBC21@ != no || $(mkdir_p) $(DESTDIR)$(libdir); \ + $(mkdir_p) $(DESTDIR)$(localedir); \ else \ : ; \ fi if test "$(PACKAGE)" = "gettext-tools"; then \ - $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ else \ : ; \ fi @@ -426,14 +482,20 @@ info dvi ps pdf html: $(OBJECTS): ../config.h libgnuintl.h 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 -dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h +hash-string.$lo dcigettext.$lo loadmsgcat.$lo: $(srcdir)/hash-string.h explodename.$lo l10nflist.$lo: $(srcdir)/loadinfo.h dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: $(srcdir)/plural-exp.h dcigettext.$lo: $(srcdir)/eval-plural.h localcharset.$lo: $(srcdir)/localcharset.h +bindtextdom.$lo dcigettext.$lo finddomain.$lo loadmsgcat.$lo localealias.$lo lock.$lo log.$lo: $(srcdir)/lock.h localealias.$lo localcharset.$lo relocatable.$lo: $(srcdir)/relocatable.h 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 +# A bison-2.1 generated plural.c includes <libintl.h> if ENABLE_NLS. +PLURAL_DEPS_yes = libintl.h +PLURAL_DEPS_no = +plural.$lo: $(PLURAL_DEPS_@USE_INCLUDED_LIBINTL@) + tags: TAGS TAGS: $(HEADERS) $(SOURCES) @@ -493,7 +555,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status # This would be more efficient, but doesn't work any more with autoconf-2.57, # when AC_CONFIG_FILES([intl/Makefile:somedir/Makefile.in]) is used. -# cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status +# cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ # Tell versions [3.59,3.63) of GNU make not to export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/intl/Makefile.msvc b/intl/Makefile.msvc deleted file mode 100644 index 038321e..0000000 --- a/intl/Makefile.msvc +++ /dev/null @@ -1,254 +0,0 @@ -# -*- Makefile -*- for gettext-runtime/intl - -#### Start of system configuration section. #### - -# Flags that can be set on the nmake command line: -# DLL=1 for compiling a .dll with a stub .lib (default is a static .lib) -# Note that this works only with MFLAGS=-MD. -# MFLAGS={-ML|-MT|-MD} for defining the compilation model -# MFLAGS=-ML (the default) Single-threaded, statically linked - libc.lib -# MFLAGS=-MT Multi-threaded, statically linked - libcmt.lib -# MFLAGS=-MD Multi-threaded, dynamically linked - msvcrt.lib -# DEBUG=1 for compiling with debugging information -# PREFIX=Some\Directory Base directory for installation -# IIPREFIX=Some\\Directory Same thing with doubled backslashes -!if !defined(DLL) -DLL=0 -!endif -!if !defined(DEBUG) -DEBUG=0 -!endif -!if !defined(MFLAGS) -!if !$(DLL) -MFLAGS= -!else -MFLAGS=-MD -!endif -!endif -!if !defined(PREFIX) -PREFIX = c:\usr -!endif -!if !defined(IIPREFIX) -IIPREFIX = c:\\usr -!endif - -# Directories used by "make": -srcdir = . - -# Directories used by "make install": -prefix = $(PREFIX) -exec_prefix = $(prefix) -bindir = $(exec_prefix)\bin -libdir = $(exec_prefix)\lib -includedir = $(prefix)\include -datadir = $(prefix)\share -localedir = $(datadir)\locale -aliaspath = -IIprefix = $(IIPREFIX) -IIexec_prefix = $(IIprefix) -IIbindir = $(IIexec_prefix)\\bin -IIlibdir = $(IIexec_prefix)\\lib -IIincludedir = $(IIprefix)\\include -IIdatadir = $(IIprefix)\\share -IIlocaledir = $(IIdatadir)\\locale -IIaliaspath = - -# Programs used by "make": - -CC = cl - -# Set to -W3 if you want to see maximum amount of warnings, including stupid -# ones. Set to -W1 to avoid warnings about signed/unsigned combinations. -WARN_CFLAGS = -W1 - -!if !$(DLL) -PICFLAGS = -!else -# "-GD" (msvc5) optimizes for DLL. -# mscv4 doesn't know about this flag and ignores it. -# -DBUILDING_LIBINTL: Change expansion of LIBINTL_DLL_EXPORTED macro. -# -DBUILDING_DLL: Change expansion of RELOCATABLE_DLL_EXPORTED macro. -PICFLAGS = -GD -DBUILDING_LIBINTL -DBUILDING_DLL -!endif - -!if $(DEBUG) -OPTIMFLAGS = -Od -Z7 -DEBUGFLAGS = -Z7 -!else -# Some people prefer -O2 -G6 instead of -O1, but -O2 is not reliable in MSVC5. -OPTIMFLAGS = -D_NDEBUG -O1 -DEBUGFLAGS = -!endif - -CFLAGS = $(MFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS) -DHAVE_CONFIG_H -DLOCALEDIR=\"$(IIlocaledir)\" -DLOCALE_ALIAS_PATH=\"$(IIaliaspath)\" -DIN_LIBINTL -DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(IIbindir)\" -DNO_XMALLOC -Dset_relocation_prefix=libintl_set_relocation_prefix -Drelocate=libintl_relocate -DDEPENDS_ON_LIBICONV=1 - -INCLUDES = -I. -I.. -I$(includedir) - -AR = lib -AR_FLAGS = /out: - -LN = copy -RM = -del - -# Programs used by "make install": -INSTALL = copy -INSTALL_PROGRAM = copy -INSTALL_DATA = copy - -#### End of system configuration section. #### - -SHELL = /bin/sh - -OBJECTS = bindtextdom.obj dcgettext.obj dgettext.obj gettext.obj finddomain.obj loadmsgcat.obj localealias.obj textdomain.obj l10nflist.obj explodename.obj dcigettext.obj dcngettext.obj dngettext.obj ngettext.obj plural.obj plural-exp.obj localcharset.obj relocatable.obj langprefs.obj localename.obj log.obj printf.obj osdep.obj intl-compat.obj - -RESOURCES = intl.res - -all : intl.lib libintl.h - -libgnuintl.h : -!if !$(DLL) - $(LN) $(srcdir)\libgnuintl.h.msvc-static libgnuintl.h -!else - $(LN) $(srcdir)\libgnuintl.h.msvc-shared libgnuintl.h -!endif - -bindtextdom.obj : $(srcdir)\bindtextdom.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\bindtextdom.c - -dcgettext.obj : $(srcdir)\dcgettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\dcgettext.c - -dgettext.obj : $(srcdir)\dgettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\dgettext.c - -gettext.obj : $(srcdir)\gettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\gettext.c - -finddomain.obj : $(srcdir)\finddomain.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\finddomain.c - -loadmsgcat.obj : $(srcdir)\loadmsgcat.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h $(srcdir)\hash-string.h $(srcdir)\plural-exp.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\loadmsgcat.c - -localealias.obj : $(srcdir)\localealias.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h $(srcdir)\relocatable.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\localealias.c - -textdomain.obj : $(srcdir)\textdomain.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\textdomain.c - -l10nflist.obj : $(srcdir)\l10nflist.c libgnuintl.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\l10nflist.c - -explodename.obj : $(srcdir)\explodename.c libgnuintl.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\explodename.c - -dcigettext.obj : $(srcdir)\dcigettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h $(srcdir)\hash-string.h $(srcdir)\plural-exp.h $(srcdir)\eval-plural.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\dcigettext.c - -dcngettext.obj : $(srcdir)\dcngettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\dcngettext.c - -dngettext.obj : $(srcdir)\dngettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\dngettext.c - -ngettext.obj : $(srcdir)\ngettext.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\ngettext.c - -plural.obj : $(srcdir)\plural.c libgnuintl.h $(srcdir)\plural-exp.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\plural.c - -plural-exp.obj : $(srcdir)\plural-exp.c libgnuintl.h $(srcdir)\plural-exp.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\plural-exp.c - -localcharset.obj : $(srcdir)\localcharset.c libgnuintl.h $(srcdir)\localcharset.h $(srcdir)\relocatable.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\localcharset.c - -relocatable.obj : $(srcdir)\relocatable.c libgnuintl.h $(srcdir)\relocatable.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\relocatable.c - -langprefs.obj : $(srcdir)\langprefs.c libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\langprefs.c - -localename.obj : $(srcdir)\localename.c libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\localename.c - -log.obj : $(srcdir)\log.c libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\log.c - -printf.obj : $(srcdir)\printf.c libgnuintl.h $(srcdir)\printf-args.h $(srcdir)\printf-args.c $(srcdir)\printf-parse.h $(srcdir)\wprintf-parse.h $(srcdir)\printf-parse.c $(srcdir)\vasnprintf.h $(srcdir)\vasnwprintf.h $(srcdir)\vasnprintf.c - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\printf.c - -osdep.obj : $(srcdir)\osdep.c libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\osdep.c - -intl-compat.obj : $(srcdir)\intl-compat.c libgnuintl.h $(srcdir)\gettextP.h $(srcdir)\gmo.h $(srcdir)\loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c $(srcdir)\intl-compat.c - -!if !$(DLL) - -intl.lib : $(OBJECTS) - -$(RM) intl.lib - $(AR) $(AR_FLAGS)intl.lib $(OBJECTS) - -!else - -# intl.dll and intl.lib are created together. -intl.lib : $(OBJECTS) $(RESOURCES) - $(CC) $(MFLAGS) $(DEBUGFLAGS) -LD $(OBJECTS) $(libdir)\iconv.lib $(RESOURCES) -Feintl.dll - -intl.res : $(srcdir)\..\windows\intl.rc - rc -Fo intl.res $(srcdir)\..\windows\intl.rc - -!endif - -libintl.h : libgnuintl.h - $(LN) libgnuintl.h libintl.h - -install : all force - -mkdir $(prefix) - -mkdir $(includedir) - $(INSTALL_DATA) libintl.h $(includedir)\libintl.h - -mkdir $(exec_prefix) -!if $(DLL) - -mkdir $(bindir) - $(INSTALL_DATA) intl.dll $(bindir)\intl.dll -!endif - -mkdir $(libdir) - $(INSTALL_DATA) intl.lib $(libdir)\intl.lib - -installdirs : force - -mkdir $(prefix) - -mkdir $(includedir) - -mkdir $(exec_prefix) -!if $(DLL) - -mkdir $(bindir) -!endif - -mkdir $(libdir) - -uninstall : force - $(RM) $(includedir)\libintl.h -!if $(DLL) - $(RM) $(bindir)\intl.dll -!endif - $(RM) $(libdir)\intl.lib - -check : all - -mostlyclean : clean - -clean : force - $(RM) libgnuintl.h - $(RM) libintl.h - $(RM) *.obj - $(RM) *.lib - $(RM) *.exp - $(RM) *.dll - $(RM) intl.res - $(RM) core - -distclean : clean - -maintainer-clean : distclean - -force : - diff --git a/intl/Makefile.vms b/intl/Makefile.vms deleted file mode 100644 index aa5be49..0000000 --- a/intl/Makefile.vms +++ /dev/null @@ -1,165 +0,0 @@ -# -*- Makefile -*- for gettext-runtime/intl on VMS using the MMS utility - -#### Start of system configuration section. #### - -# Directories used by "make": -srcdir = - -# Directories used by "make install": -prefix = SYS$DATA:[ -exec_prefix = $(prefix) -bindir = $(exec_prefix).bin -libdir = $(exec_prefix).lib -includedir = $(prefix).include -datadir = $(prefix).share -localedir = $(datadir).locale -aliaspath = $(localedir)] - -# Programs used by "make": - -CC = cc - -# These flags affect binary compatibility. GNU gettext does not need them, -# but other packages do, and we need to be binary compatible with them. -ABIFLAGS = /name=(as_is,short) /float=ieee - -WARN_CFLAGS = /warning - -OPTIMFLAGS = /optimize - -CFLAGS = $(ABIFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS) -DEFS = "VMS=1","HAVE_CONFIG_H=1","LOCALEDIR=""$(localedir)]""","LOCALE_ALIAS_PATH=""$(aliaspath)""","LIBDIR=""$(libdir)]""","IN_LIBINTL=1" - -INCLUDES = /include=([],[-]) - -AR = library -AR_FLAGS = /create - -LN = copy -RM = delete - -# Programs used by "make install": -INSTALL = copy -INSTALL_PROGRAM = copy -INSTALL_DATA = copy - -#### End of system configuration section. #### - -OBJECTS = bindtextdom.obj,dcgettext.obj,dgettext.obj,gettext.obj,finddomain.obj,loadmsgcat.obj,localealias.obj,textdomain.obj,l10nflist.obj,explodename.obj,dcigettext.obj,dcngettext.obj,dngettext.obj,ngettext.obj,plural-parse.obj,plural-exp.obj,localcharset.obj,relocatable.obj,langprefs.obj,localename.obj,log.obj,osdep.obj,intl-compat.obj - -all : intl.olb,libintl.h - write sys$output "Nothing else to be done for 'all'." - -libgnuintl.h : - $(LN) $(srcdir)libgnuintl.h_vms libgnuintl.h - -bindtextdom.obj : $(srcdir)bindtextdom.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)bindtextdom.c - -dcgettext.obj : $(srcdir)dcgettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)dcgettext.c - -dgettext.obj : $(srcdir)dgettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)dgettext.c - -gettext.obj : $(srcdir)gettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)gettext.c - -finddomain.obj : $(srcdir)finddomain.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)finddomain.c - -loadmsgcat.obj : $(srcdir)loadmsgcat.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h,$(srcdir)hash-string.h,$(srcdir)plural-exp.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)loadmsgcat.c - -localealias.obj : $(srcdir)localealias.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h,$(srcdir)relocatable.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)localealias.c - -textdomain.obj : $(srcdir)textdomain.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)textdomain.c - -l10nflist.obj : $(srcdir)l10nflist.c,libgnuintl.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)l10nflist.c - -explodename.obj : $(srcdir)explodename.c,libgnuintl.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)explodename.c - -dcigettext.obj : $(srcdir)dcigettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h,$(srcdir)hash-string.h,$(srcdir)plural-exp.h,$(srcdir)eval-plural.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)dcigettext.c - -dcngettext.obj : $(srcdir)dcngettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)dcngettext.c - -dngettext.obj : $(srcdir)dngettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)dngettext.c - -ngettext.obj : $(srcdir)ngettext.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)ngettext.c - -plural-parse.obj : $(srcdir)plural.c,libgnuintl.h,$(srcdir)plural-exp.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) /obj=plural-parse.obj $(srcdir)plural.c - -plural-exp.obj : $(srcdir)plural-exp.c,libgnuintl.h,$(srcdir)plural-exp.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)plural-exp.c - -localcharset.obj : $(srcdir)localcharset.c,libgnuintl.h,$(srcdir)localcharset.h,$(srcdir)relocatable.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)localcharset.c - -relocatable.obj : $(srcdir)relocatable.c,libgnuintl.h,$(srcdir)relocatable.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)relocatable.c - -langprefs.obj : $(srcdir)langprefs.c,libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)langprefs.c - -localename.obj : $(srcdir)localename.c,libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)localename.c - -log.obj : $(srcdir)log.c,libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)log.c - -osdep.obj : $(srcdir)osdep.c,libgnuintl.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)osdep.c - -intl-compat.obj : $(srcdir)intl-compat.c,libgnuintl.h,$(srcdir)gettextP.h,$(srcdir)gmo.h,$(srcdir)loadinfo.h - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) $(srcdir)intl-compat.c - -intl.olb : $(OBJECTS) - $(AR) $(AR_FLAGS) intl.olb $(OBJECTS) - -libintl.h : libgnuintl.h - $(LN) libgnuintl.h libintl.h - -install : all - create /directory $(prefix)] - create /directory $(includedir)] - $(INSTALL_DATA) libintl.h $(includedir)]libintl.h - create /directory $(exec_prefix)] - create /directory $(libdir)] - $(INSTALL_DATA) intl.olb $(libdir)]intl.olb - -installdirs : - create /directory $(prefix)] - create /directory $(includedir)] - create /directory $(exec_prefix)] - create /directory $(libdir)] - -uninstall : - $(RM) $(includedir)]libintl.h; - $(RM) $(libdir)]intl.lib; - -check : all - write sys$output "Nothing else to be done for 'check'." - -mostlyclean : clean - write sys$output "Nothing else to be done for 'mostlyclean'." - -clean : - $(RM) libgnuintl.h;* - $(RM) libintl.h;* - $(RM) *.obj;* - $(RM) *.olb;* - -distclean : clean - write sys$output "Nothing else to be done for 'distclean'." - -maintainer-clean : distclean - write sys$output "Nothing else to be done for 'maintainer-clean'." diff --git a/intl/README.woe32 b/intl/README.woe32 deleted file mode 100644 index 40e6158..0000000 --- a/intl/README.woe32 +++ /dev/null @@ -1,61 +0,0 @@ -Installation on Woe32 (WinNT/2000/XP, Win95/98/ME): - -- Requires MS Visual C/C++ 4.0 or 5.0 or 6.0 or 7.0. - - Note that binaries created with MSVC 7.0 should not be distributed: They - depend on a closed-source library 'msvcr70.dll' which is not normally part - of a Woe32 installation. You cannot distribute 'msvcr70.dll' with the - binaries - this would be a violation of the GPL and of the Microsoft EULA. - You can distribute the binaries without including 'msvcr70.dll', but this - will cause problems for users that don't have this library on their system. - Therefore it is not recommended. This problem does not occur with MSVC 6.0 - and earlier. - -- Cannot build in a separate directory. - -- Build instructions: - - Make sure that the MSVC4.0 or MSVC5.0 or MSVC6.0 or MSVC7.0 utilities - ("cl" etc.) are found in PATH. In a typical MSVC6.0 installation, this - can be achieved by running - C:\Program Files\Microsoft Visual Studio\VC98\bin\vcvars32.bat - In a typical MSVC7.0 installation, it can be achieved by running - C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\vsvars32.bat - - Decide which compilation model you will use: - MFLAGS=-ML (the default) Single-threaded, statically linked - libc.lib - MFLAGS=-MT Multi-threaded, statically linked - libcmt.lib - MFLAGS=-MD Multi-threaded, dynamically linked - msvcrt.lib - - You need GNU libiconv (version 1.9 or newer) installed under c:\usr. If - you haven't yet, build and install GNU libiconv (version 1.9 or newer) - using the same MFLAGS. Then come back to here, to build GNU gettext. - - For shared library (DLL): - - nmake -f Makefile.msvc DLL=1 MFLAGS=-MD - - For static library: - - nmake -f Makefile.msvc MFLAGS=-MD - - If you want to build both the shared and static library, you have to - unpack the gettext sources twice in different directories. Don't mix - the two formats; you cannot use the libintl.h generated for the static - library together with the shared library or vice versa. - -- Installation: - - Either: - - Copy libintl.h to your header file repository. - Copy intl.lib to your library repository. - If you built for shared library, also copy intl.dll into one of - the directories listed in your PATH, or into the directory containing - the executable which shall make use of libintl. - - Or: - - nmake -f Makefile.msvc DLL=1 MFLAGS=-MD install PREFIX=InstallBaseDirectory - or - nmake -f Makefile.msvc MFLAGS=-MD install PREFIX=InstallBaseDirectory diff --git a/intl/VERSION b/intl/VERSION index ee66b06..2525c4e 100644 --- a/intl/VERSION +++ b/intl/VERSION @@ -1 +1 @@ -GNU gettext library from gettext-0.10.35 +GNU gettext library from gettext-0.16.1 diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index 7a26062..d1b1f90 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -1,5 +1,5 @@ /* Implementation of the bindtextdomain(3) function - Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -24,21 +24,21 @@ #include <stdlib.h> #include <string.h> +#include "gettextP.h" #ifdef _LIBC # include <libintl.h> #else # include "libgnuintl.h" #endif -#include "gettextP.h" +/* Handle multi-threaded applications. */ #ifdef _LIBC -/* We have to handle multi-threaded applications. */ # include <bits/libc-lock.h> +# define gl_rwlock_define __libc_rwlock_define +# define gl_rwlock_wrlock __libc_rwlock_wrlock +# define gl_rwlock_unlock __libc_rwlock_unlock #else -/* Provide dummy implementation if this is outside glibc. */ -# define __libc_rwlock_define(CLASS, NAME) -# define __libc_rwlock_wrlock(NAME) -# define __libc_rwlock_unlock(NAME) +# include "lock.h" #endif /* The internal variables in the standalone libintl.a must have different @@ -59,16 +59,14 @@ /* Contains the default location of the message catalogs. */ extern const char _nl_default_dirname[]; #ifdef _LIBC -extern const char _nl_default_dirname_internal[] attribute_hidden; -#else -# define INTUSE(name) name +libc_hidden_proto (_nl_default_dirname) #endif /* List with bindings of specific domains. */ extern struct binding *_nl_domain_bindings; /* Lock variable to protect the global data in the gettext implementation. */ -__libc_rwlock_define (extern, _nl_state_lock attribute_hidden) +gl_rwlock_define (extern, _nl_state_lock attribute_hidden) /* Names for the libintl functions are a problem. They must not clash @@ -109,7 +107,7 @@ set_binding_values (const char *domainname, return; } - __libc_rwlock_wrlock (_nl_state_lock); + gl_rwlock_wrlock (_nl_state_lock); modified = 0; @@ -144,8 +142,8 @@ set_binding_values (const char *domainname, char *result = binding->dirname; if (strcmp (dirname, result) != 0) { - if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0) - result = (char *) INTUSE(_nl_default_dirname); + if (strcmp (dirname, _nl_default_dirname) == 0) + result = (char *) _nl_default_dirname; else { #if defined _LIBC || defined HAVE_STRDUP @@ -160,7 +158,7 @@ set_binding_values (const char *domainname, if (__builtin_expect (result != NULL, 1)) { - if (binding->dirname != INTUSE(_nl_default_dirname)) + if (binding->dirname != _nl_default_dirname) free (binding->dirname); binding->dirname = result; @@ -201,7 +199,6 @@ set_binding_values (const char *domainname, free (binding->codeset); binding->codeset = result; - binding->codeset_cntr++; modified = 1; } } @@ -214,7 +211,7 @@ set_binding_values (const char *domainname, { /* Simply return the default values. */ if (dirnamep) - *dirnamep = INTUSE(_nl_default_dirname); + *dirnamep = _nl_default_dirname; if (codesetp) *codesetp = NULL; } @@ -236,11 +233,11 @@ set_binding_values (const char *domainname, if (dirname == NULL) /* The default value. */ - dirname = INTUSE(_nl_default_dirname); + dirname = _nl_default_dirname; else { - if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0) - dirname = INTUSE(_nl_default_dirname); + if (strcmp (dirname, _nl_default_dirname) == 0) + dirname = _nl_default_dirname; else { char *result; @@ -263,9 +260,7 @@ set_binding_values (const char *domainname, } else /* The default value. */ - new_binding->dirname = (char *) INTUSE(_nl_default_dirname); - - new_binding->codeset_cntr = 0; + new_binding->dirname = (char *) _nl_default_dirname; if (codesetp) { @@ -287,7 +282,6 @@ set_binding_values (const char *domainname, memcpy (result, codeset, len); #endif codeset = result; - new_binding->codeset_cntr++; } *codesetp = codeset; new_binding->codeset = (char *) codeset; @@ -319,7 +313,7 @@ set_binding_values (const char *domainname, if (0) { failed_codeset: - if (new_binding->dirname != INTUSE(_nl_default_dirname)) + if (new_binding->dirname != _nl_default_dirname) free (new_binding->dirname); failed_dirname: free (new_binding); @@ -335,7 +329,7 @@ set_binding_values (const char *domainname, if (modified) ++_nl_msg_cat_cntr; - __libc_rwlock_unlock (_nl_state_lock); + gl_rwlock_unlock (_nl_state_lock); } /* Specify that the DOMAINNAME message catalog will be found diff --git a/intl/config.charset b/intl/config.charset index 9090c80..e8c258b 100755 --- a/intl/config.charset +++ b/intl/config.charset @@ -1,7 +1,7 @@ #! /bin/sh # Output a system dependent table of character encoding aliases. # -# Copyright (C) 2000-2004 Free Software Foundation, Inc. +# Copyright (C) 2000-2004, 2006 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Library General Public License as published @@ -31,21 +31,21 @@ # The current list of GNU canonical charset names is as follows. # # name MIME? used by which systems -# ASCII, ANSI_X3.4-1968 glibc solaris freebsd darwin -# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd darwin -# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd darwin +# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin +# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd darwin +# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd darwin # ISO-8859-3 Y glibc solaris -# ISO-8859-4 Y osf solaris freebsd darwin -# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd darwin +# ISO-8859-4 Y osf solaris freebsd netbsd darwin +# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd darwin # ISO-8859-6 Y glibc aix hpux solaris -# ISO-8859-7 Y glibc aix hpux irix osf solaris darwin +# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd darwin # ISO-8859-8 Y glibc aix hpux osf solaris # ISO-8859-9 Y glibc aix hpux irix osf solaris darwin -# ISO-8859-13 glibc darwin +# ISO-8859-13 glibc netbsd darwin # ISO-8859-14 glibc # ISO-8859-15 glibc aix osf solaris freebsd darwin -# KOI8-R Y glibc solaris freebsd darwin -# KOI8-U Y glibc freebsd darwin +# KOI8-R Y glibc solaris freebsd netbsd darwin +# KOI8-U Y glibc freebsd netbsd darwin # KOI8-T glibc # CP437 dos # CP775 dos @@ -58,7 +58,7 @@ # CP862 dos # CP864 dos # CP865 dos -# CP866 freebsd darwin dos +# CP866 freebsd netbsd darwin dos # CP869 dos # CP874 woe32 dos # CP922 aix @@ -71,22 +71,22 @@ # CP1125 dos # CP1129 aix # CP1250 woe32 -# CP1251 glibc solaris darwin woe32 +# CP1251 glibc solaris netbsd darwin woe32 # CP1252 aix woe32 # CP1253 woe32 # CP1254 woe32 # CP1255 glibc woe32 # CP1256 woe32 # CP1257 woe32 -# GB2312 Y glibc aix hpux irix solaris freebsd darwin -# EUC-JP Y glibc aix hpux irix osf solaris freebsd darwin -# EUC-KR Y glibc aix hpux irix osf solaris freebsd darwin -# EUC-TW glibc aix hpux irix osf solaris -# BIG5 Y glibc aix hpux osf solaris freebsd darwin +# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin +# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin +# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin +# EUC-TW glibc aix hpux irix osf solaris netbsd +# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin # BIG5-HKSCS glibc solaris # GBK glibc aix osf solaris woe32 dos -# GB18030 glibc solaris -# SHIFT_JIS Y hpux osf solaris freebsd darwin +# GB18030 glibc solaris netbsd +# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin # JOHAB glibc solaris woe32 # TIS-620 glibc aix hpux osf solaris # VISCII Y glibc @@ -100,7 +100,7 @@ # HP-KANA8 hpux # DEC-KANJI osf # DEC-HANYU osf -# UTF-8 Y glibc aix hpux osf solaris darwin +# UTF-8 Y glibc aix hpux osf solaris netbsd darwin # # Note: Names which are not marked as being a MIME name should not be used in # Internet protocols for information interchange (mail, news, etc.). @@ -388,6 +388,8 @@ case "$os" in echo "ISO8859-2 ISO-8859-2" echo "ISO8859-4 ISO-8859-4" echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-13 ISO-8859-13" echo "ISO8859-15 ISO-8859-15" echo "eucCN GB2312" echo "eucJP EUC-JP" @@ -480,7 +482,7 @@ case "$os" in echo "# If you find that the encoding given for your language and" echo "# country is not the one your DOS machine actually uses, just" echo "# correct it in this file, and send a mail to" - echo "# Juan Manuel Guerrero <st001906@hrz1.hrz.tu-darmstadt.de>" + echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>" echo "# and Bruno Haible <bruno@clisp.org>." echo "#" echo "C ASCII" diff --git a/intl/dcigettext.c b/intl/dcigettext.c index c7f4506..5839768 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -1,5 +1,5 @@ /* Implementation of the internal dcigettext function. - Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -27,6 +27,9 @@ # include <config.h> #endif +/* NL_LOCALE_NAME does not work in glibc-2.4. Ignore it. */ +#undef HAVE_NL_LOCALE_NAME + #include <sys/types.h> #ifdef __GNUC__ @@ -87,26 +90,31 @@ extern int errno; # include <sys/param.h> #endif +#if !defined _LIBC && HAVE_NL_LOCALE_NAME +# include <langinfo.h> +#endif + #include "gettextP.h" #include "plural-exp.h" #ifdef _LIBC # include <libintl.h> #else +# ifdef IN_LIBGLOCALE +# include <libintl.h> +# endif # include "libgnuintl.h" #endif #include "hash-string.h" -/* Thread safetyness. */ +/* Handle multi-threaded applications. */ #ifdef _LIBC # include <bits/libc-lock.h> +# define gl_rwlock_define_initialized __libc_rwlock_define_initialized +# define gl_rwlock_rdlock __libc_rwlock_rdlock +# define gl_rwlock_wrlock __libc_rwlock_wrlock +# define gl_rwlock_unlock __libc_rwlock_unlock #else -/* Provide dummy implementation if this is outside glibc. */ -# define __libc_lock_define_initialized(CLASS, NAME) -# define __libc_lock_lock(NAME) -# define __libc_lock_unlock(NAME) -# define __libc_rwlock_define_initialized(CLASS, NAME) -# define __libc_rwlock_rdlock(NAME) -# define __libc_rwlock_unlock(NAME) +# include "lock.h" #endif /* Alignment of types. */ @@ -216,16 +224,31 @@ static void *mempcpy (void *dest, const void *src, size_t n); # define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL) #endif +/* Whether to support different locales in different threads. */ +#if defined _LIBC || HAVE_NL_LOCALE_NAME || (HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS) || defined IN_LIBGLOCALE +# define HAVE_PER_THREAD_LOCALE +#endif + /* This is the type used for the search tree where known translations are stored. */ struct known_translation_t { /* Domain in which to search. */ - char *domainname; + const char *domainname; /* The category. */ int category; +#ifdef HAVE_PER_THREAD_LOCALE + /* Name of the relevant locale category, or "" for the global locale. */ + const char *localename; +#endif + +#ifdef IN_LIBGLOCALE + /* The character encoding. */ + const char *encoding; +#endif + /* State of the catalog counter at the point the string was found. */ int counter; @@ -245,6 +268,8 @@ struct known_translation_t #if defined HAVE_TSEARCH || defined _LIBC # include <search.h> +gl_rwlock_define_initialized (static, tree_lock) + static void *root; # ifdef _LIBC @@ -267,57 +292,86 @@ transcmp (const void *p1, const void *p2) { result = strcmp (s1->domainname, s2->domainname); if (result == 0) - /* We compare the category last (though this is the cheapest - operation) since it is hopefully always the same (namely - LC_MESSAGES). */ - result = s1->category - s2->category; + { +#ifdef HAVE_PER_THREAD_LOCALE + result = strcmp (s1->localename, s2->localename); + if (result == 0) +#endif + { +#ifdef IN_LIBGLOCALE + result = strcmp (s1->encoding, s2->encoding); + if (result == 0) +#endif + /* We compare the category last (though this is the cheapest + operation) since it is hopefully always the same (namely + LC_MESSAGES). */ + result = s1->category - s2->category; + } + } } return result; } #endif -#ifndef INTVARDEF -# define INTVARDEF(name) -#endif -#ifndef INTUSE -# define INTUSE(name) name -#endif - /* Name of the default domain used for gettext(3) prior any call to textdomain(3). The default value for this is "messages". */ const char _nl_default_default_domain[] attribute_hidden = "messages"; +#ifndef IN_LIBGLOCALE /* Value used as the default domain for gettext(3). */ const char *_nl_current_default_domain attribute_hidden = _nl_default_default_domain; +#endif /* Contains the default location of the message catalogs. */ #if defined __EMX__ extern const char _nl_default_dirname[]; #else +# ifdef _LIBC +extern const char _nl_default_dirname[]; +libc_hidden_proto (_nl_default_dirname) +# endif const char _nl_default_dirname[] = LOCALEDIR; -INTVARDEF (_nl_default_dirname) +# ifdef _LIBC +libc_hidden_data_def (_nl_default_dirname) +# endif #endif +#ifndef IN_LIBGLOCALE /* List with bindings of specific domains created by bindtextdomain() calls. */ struct binding *_nl_domain_bindings; +#endif /* Prototypes for local functions. */ static char *plural_lookup (struct loaded_l10nfile *domain, unsigned long int n, const char *translation, size_t translation_len) internal_function; + +#ifdef IN_LIBGLOCALE +static const char *guess_category_value (int category, + const char *categoryname, + const char *localename) + internal_function; +#else static const char *guess_category_value (int category, const char *categoryname) internal_function; +#endif + #ifdef _LIBC # include "../locale/localeinfo.h" -# define category_to_name(category) _nl_category_names[category] +# define category_to_name(category) \ + _nl_category_names.str + _nl_category_name_idxs[category] #else static const char *category_to_name (int category) internal_function; #endif +#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE +static const char *get_output_charset (struct binding *domainbinding) + internal_function; +#endif /* For those loosing systems which don't have `alloca' we have to add @@ -383,9 +437,7 @@ typedef unsigned char transmem_block_t; #endif /* Lock variable to protect the global data in the gettext implementation. */ -#ifdef _LIBC -__libc_rwlock_define_initialized (, _nl_state_lock attribute_hidden) -#endif +gl_rwlock_define_initialized (, _nl_state_lock attribute_hidden) /* Checking whether the binaries runs SUID must be done and glibc provides easier methods therefore we make a difference here. */ @@ -423,9 +475,18 @@ static int enable_secure; /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale and, if PLURAL is nonzero, search over string depending on the plural form determined by N. */ +#ifdef IN_LIBGLOCALE +char * +gl_dcigettext (const char *domainname, + const char *msgid1, const char *msgid2, + int plural, unsigned long int n, + int category, + const char *localename, const char *encoding) +#else char * DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, int plural, unsigned long int n, int category) +#endif { #ifndef HAVE_ALLOCA struct block_list *block_list = NULL; @@ -434,7 +495,8 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, struct binding *binding; const char *categoryname; const char *categoryvalue; - char *dirname, *xdomainname; + const char *dirname; + char *xdomainname; char *single_locale; char *retval; size_t retlen; @@ -443,6 +505,9 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, struct known_translation_t *search; struct known_translation_t **foundp = NULL; size_t msgid_len; +# if defined HAVE_PER_THREAD_LOCALE && !defined IN_LIBGLOCALE + const char *localename; +# endif #endif size_t domainname_len; @@ -459,7 +524,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, : n == 1 ? (char *) msgid1 : (char *) msgid2); #endif - __libc_rwlock_rdlock (_nl_state_lock); + gl_rwlock_rdlock (_nl_state_lock); /* If DOMAINNAME is NULL, we are interested in the default domain. If CATEGORY is not LC_MESSAGES this might not make much sense but the @@ -481,10 +546,45 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, search = (struct known_translation_t *) alloca (offsetof (struct known_translation_t, msgid) + msgid_len); memcpy (search->msgid, msgid1, msgid_len); - search->domainname = (char *) domainname; + search->domainname = domainname; search->category = category; +# ifdef HAVE_PER_THREAD_LOCALE +# ifndef IN_LIBGLOCALE +# ifdef _LIBC + localename = __current_locale_name (category); +# else +# if HAVE_NL_LOCALE_NAME + /* NL_LOCALE_NAME is public glibc API introduced in glibc-2.4. */ + localename = nl_langinfo (NL_LOCALE_NAME (category)); +# else +# if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS + /* The __names field is not public glibc API and must therefore not be used + in code that is installed in public locations. */ + { + locale_t thread_locale = uselocale (NULL); + if (thread_locale != LC_GLOBAL_LOCALE) + localename = thread_locale->__names[category]; + else + localename = ""; + } +# endif +# endif +# endif +# endif + search->localename = localename; +# ifdef IN_LIBGLOCALE + search->encoding = encoding; +# endif +# endif + + /* Since tfind/tsearch manage a balanced tree, concurrent tfind and + tsearch calls can be fatal. */ + gl_rwlock_rdlock (tree_lock); foundp = (struct known_translation_t **) tfind (search, &root, transcmp); + + gl_rwlock_unlock (tree_lock); + freea (search); if (foundp != NULL && (*foundp)->counter == _nl_msg_cat_cntr) { @@ -495,7 +595,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, else retval = (char *) (*foundp)->translation; - __libc_rwlock_unlock (_nl_state_lock); + gl_rwlock_unlock (_nl_state_lock); return retval; } #endif @@ -507,6 +607,12 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, DETERMINE_SECURE; /* First find matching binding. */ +#ifdef IN_LIBGLOCALE + /* We can use a trivial binding, since _nl_find_msg will ignore it anyway, + and _nl_load_domain and _nl_find_domain just pass it through. */ + binding = NULL; + dirname = bindtextdomain (domainname, NULL); +#else for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) { int compare = strcmp (domainname, binding->domainname); @@ -522,44 +628,55 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, } if (binding == NULL) - dirname = (char *) INTUSE(_nl_default_dirname); - else if (IS_ABSOLUTE_PATH (binding->dirname)) - dirname = binding->dirname; + dirname = _nl_default_dirname; else { - /* We have a relative path. Make it absolute now. */ - size_t dirname_len = strlen (binding->dirname) + 1; - size_t path_max; - char *ret; + dirname = binding->dirname; +#endif + if (!IS_ABSOLUTE_PATH (dirname)) + { + /* We have a relative path. Make it absolute now. */ + size_t dirname_len = strlen (dirname) + 1; + size_t path_max; + char *resolved_dirname; + char *ret; - path_max = (unsigned int) PATH_MAX; - path_max += 2; /* The getcwd docs say to do this. */ + path_max = (unsigned int) PATH_MAX; + path_max += 2; /* The getcwd docs say to do this. */ - for (;;) - { - dirname = (char *) alloca (path_max + dirname_len); - ADD_BLOCK (block_list, dirname); + for (;;) + { + resolved_dirname = (char *) alloca (path_max + dirname_len); + ADD_BLOCK (block_list, tmp_dirname); - __set_errno (0); - ret = getcwd (dirname, path_max); - if (ret != NULL || errno != ERANGE) - break; + __set_errno (0); + ret = getcwd (resolved_dirname, path_max); + if (ret != NULL || errno != ERANGE) + break; - path_max += path_max / 2; - path_max += PATH_INCR; - } + path_max += path_max / 2; + path_max += PATH_INCR; + } - if (ret == NULL) - /* We cannot get the current working directory. Don't signal an - error but simply return the default string. */ - goto return_untranslated; + if (ret == NULL) + /* We cannot get the current working directory. Don't signal an + error but simply return the default string. */ + goto return_untranslated; - stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname); + stpcpy (stpcpy (strchr (resolved_dirname, '\0'), "/"), dirname); + dirname = resolved_dirname; + } +#ifndef IN_LIBGLOCALE } +#endif /* Now determine the symbolic name of CATEGORY and its value. */ categoryname = category_to_name (category); +#ifdef IN_LIBGLOCALE + categoryvalue = guess_category_value (category, categoryname, localename); +#else categoryvalue = guess_category_value (category, categoryname); +#endif domainname_len = strlen (domainname); xdomainname = (char *) alloca (strlen (categoryname) @@ -617,7 +734,11 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, if (domain != NULL) { - retval = _nl_find_msg (domain, binding, msgid1, &retlen); +#if defined IN_LIBGLOCALE + retval = _nl_find_msg (domain, binding, encoding, msgid1, &retlen); +#else + retval = _nl_find_msg (domain, binding, msgid1, 1, &retlen); +#endif if (retval == NULL) { @@ -625,8 +746,13 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, for (cnt = 0; domain->successor[cnt] != NULL; ++cnt) { +#if defined IN_LIBGLOCALE + retval = _nl_find_msg (domain->successor[cnt], binding, + encoding, msgid1, &retlen); +#else retval = _nl_find_msg (domain->successor[cnt], binding, - msgid1, &retlen); + msgid1, 1, &retlen); +#endif if (retval != NULL) { @@ -636,6 +762,12 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, } } + /* Returning -1 means that some resource problem exists + (likely memory) and that the strings could not be + converted. Return the original strings. */ + if (__builtin_expect (retval == (char *) -1, 0)) + break; + if (retval != NULL) { /* Found the translation of MSGID1 in domain DOMAIN: @@ -645,25 +777,49 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, if (foundp == NULL) { /* Create a new entry and add it to the search tree. */ + size_t size; struct known_translation_t *newp; - newp = (struct known_translation_t *) - malloc (offsetof (struct known_translation_t, msgid) - + msgid_len + domainname_len + 1); + size = offsetof (struct known_translation_t, msgid) + + msgid_len + domainname_len + 1; +# ifdef HAVE_PER_THREAD_LOCALE + size += strlen (localename) + 1; +# endif + newp = (struct known_translation_t *) malloc (size); if (newp != NULL) { - newp->domainname = - mempcpy (newp->msgid, msgid1, msgid_len); - memcpy (newp->domainname, domainname, domainname_len + 1); + char *new_domainname; +# ifdef HAVE_PER_THREAD_LOCALE + char *new_localename; +# endif + + new_domainname = mempcpy (newp->msgid, msgid1, msgid_len); + memcpy (new_domainname, domainname, domainname_len + 1); +# ifdef HAVE_PER_THREAD_LOCALE + new_localename = new_domainname + domainname_len + 1; + strcpy (new_localename, localename); +# endif + newp->domainname = new_domainname; newp->category = category; +# ifdef HAVE_PER_THREAD_LOCALE + newp->localename = new_localename; +# endif +# ifdef IN_LIBGLOCALE + newp->encoding = encoding; +# endif newp->counter = _nl_msg_cat_cntr; newp->domain = domain; newp->translation = retval; newp->translation_length = retlen; + gl_rwlock_wrlock (tree_lock); + /* Insert the entry in the search tree. */ foundp = (struct known_translation_t **) tsearch (newp, &root, transcmp); + + gl_rwlock_unlock (tree_lock); + if (foundp == NULL || __builtin_expect (*foundp != newp, 0)) /* The insert failed. */ @@ -685,7 +841,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, if (plural) retval = plural_lookup (domain, n, retval, retlen); - __libc_rwlock_unlock (_nl_state_lock); + gl_rwlock_unlock (_nl_state_lock); return retval; } } @@ -694,7 +850,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, return_untranslated: /* Return the untranslated MSGID. */ FREE_BLOCKS (block_list); - __libc_rwlock_unlock (_nl_state_lock); + gl_rwlock_unlock (_nl_state_lock); #ifndef _LIBC if (!ENABLE_SECURE) { @@ -716,11 +872,24 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, } +/* Look up the translation of msgid within DOMAIN_FILE and DOMAINBINDING. + Return it if found. Return NULL if not found or in case of a conversion + failure (problem in the particular message catalog). Return (char *) -1 + in case of a memory allocation failure during conversion (only if + ENCODING != NULL resp. CONVERT == true). */ char * internal_function +#ifdef IN_LIBGLOCALE _nl_find_msg (struct loaded_l10nfile *domain_file, - struct binding *domainbinding, const char *msgid, + struct binding *domainbinding, const char *encoding, + const char *msgid, size_t *lengthp) +#else +_nl_find_msg (struct loaded_l10nfile *domain_file, + struct binding *domainbinding, + const char *msgid, int convert, + size_t *lengthp) +#endif { struct loaded_domain *domain; nls_uint32 nstrings; @@ -728,7 +897,7 @@ _nl_find_msg (struct loaded_l10nfile *domain_file, char *result; size_t resultlen; - if (domain_file->decided == 0) + if (domain_file->decided <= 0) _nl_load_domain (domain_file, domainbinding); if (domain_file->data == NULL) @@ -743,7 +912,7 @@ _nl_find_msg (struct loaded_l10nfile *domain_file, { /* Use the hashing table. */ nls_uint32 len = strlen (msgid); - nls_uint32 hash_val = hash_string (msgid); + nls_uint32 hash_val = __hash_string (msgid); nls_uint32 idx = hash_val % domain->hash_size; nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); @@ -826,195 +995,345 @@ _nl_find_msg (struct loaded_l10nfile *domain_file, } #if defined _LIBC || HAVE_ICONV - if (domain->codeset_cntr - != (domainbinding != NULL ? domainbinding->codeset_cntr : 0)) +# ifdef IN_LIBGLOCALE + if (encoding != NULL) +# else + if (convert) +# endif { - /* The domain's codeset has changed through bind_textdomain_codeset() - since the message catalog was initialized or last accessed. We - have to reinitialize the converter. */ - _nl_free_domain_conv (domain); - _nl_init_domain_conv (domain_file, domain, domainbinding); - } + /* We are supposed to do a conversion. */ +# ifndef IN_LIBGLOCALE + const char *encoding = get_output_charset (domainbinding); +# endif + + /* Search whether a table with converted translations for this + encoding has already been allocated. */ + size_t nconversions = domain->nconversions; + struct converted_domain *convd = NULL; + size_t i; + + for (i = nconversions; i > 0; ) + { + i--; + if (strcmp (domain->conversions[i].encoding, encoding) == 0) + { + convd = &domain->conversions[i]; + break; + } + } - if ( + if (convd == NULL) + { + /* Allocate a table for the converted translations for this + encoding. */ + struct converted_domain *new_conversions = + (struct converted_domain *) + (domain->conversions != NULL + ? realloc (domain->conversions, + (nconversions + 1) * sizeof (struct converted_domain)) + : malloc ((nconversions + 1) * sizeof (struct converted_domain))); + + if (__builtin_expect (new_conversions == NULL, 0)) + /* Nothing we can do, no more memory. We cannot use the + translation because it might be encoded incorrectly. */ + return (char *) -1; + + domain->conversions = new_conversions; + + /* Copy the 'encoding' string to permanent storage. */ + encoding = strdup (encoding); + if (__builtin_expect (encoding == NULL, 0)) + /* Nothing we can do, no more memory. We cannot use the + translation because it might be encoded incorrectly. */ + return (char *) -1; + + convd = &new_conversions[nconversions]; + convd->encoding = encoding; + + /* Find out about the character set the file is encoded with. + This can be found (in textual form) in the entry "". If this + entry does not exist or if this does not contain the 'charset=' + information, we will assume the charset matches the one the + current locale and we don't have to perform any conversion. */ # ifdef _LIBC - domain->conv != (__gconv_t) -1 + convd->conv = (__gconv_t) -1; # else # if HAVE_ICONV - domain->conv != (iconv_t) -1 + convd->conv = (iconv_t) -1; # endif # endif - ) - { - /* We are supposed to do a conversion. First allocate an - appropriate table with the same structure as the table - of translations in the file, where we can put the pointers - to the converted strings in. - There is a slight complication with plural entries. They - are represented by consecutive NUL terminated strings. We - handle this case by converting RESULTLEN bytes, including - NULs. */ - - if (domain->conv_tab == NULL - && ((domain->conv_tab = - (char **) calloc (nstrings + domain->n_sysdep_strings, - sizeof (char *))) - == NULL)) - /* Mark that we didn't succeed allocating a table. */ - domain->conv_tab = (char **) -1; - - if (__builtin_expect (domain->conv_tab == (char **) -1, 0)) - /* Nothing we can do, no more memory. */ - goto converted; - - if (domain->conv_tab[act] == NULL) + { + char *nullentry; + size_t nullentrylen; + + /* Get the header entry. This is a recursion, but it doesn't + reallocate domain->conversions because we pass + encoding = NULL or convert = 0, respectively. */ + nullentry = +# ifdef IN_LIBGLOCALE + _nl_find_msg (domain_file, domainbinding, NULL, "", + &nullentrylen); +# else + _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); +# endif + + if (nullentry != NULL) + { + const char *charsetstr; + + charsetstr = strstr (nullentry, "charset="); + if (charsetstr != NULL) + { + size_t len; + char *charset; + const char *outcharset; + + charsetstr += strlen ("charset="); + len = strcspn (charsetstr, " \t\n"); + + charset = (char *) alloca (len + 1); +# if defined _LIBC || HAVE_MEMPCPY + *((char *) mempcpy (charset, charsetstr, len)) = '\0'; +# else + memcpy (charset, charsetstr, len); + charset[len] = '\0'; +# endif + + outcharset = encoding; + +# ifdef _LIBC + /* We always want to use transliteration. */ + outcharset = norm_add_slashes (outcharset, "TRANSLIT"); + charset = norm_add_slashes (charset, ""); + int r = __gconv_open (outcharset, charset, &convd->conv, + GCONV_AVOID_NOCONV); + if (__builtin_expect (r != __GCONV_OK, 0)) + { + /* If the output encoding is the same there is + nothing to do. Otherwise do not use the + translation at all. */ + if (__builtin_expect (r != __GCONV_NOCONV, 1)) + return NULL; + + convd->conv = (__gconv_t) -1; + } +# else +# if HAVE_ICONV + /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5, + we want to use transliteration. */ +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ + || _LIBICONV_VERSION >= 0x0105 + if (strchr (outcharset, '/') == NULL) + { + char *tmp; + + len = strlen (outcharset); + tmp = (char *) alloca (len + 10 + 1); + memcpy (tmp, outcharset, len); + memcpy (tmp + len, "//TRANSLIT", 10 + 1); + outcharset = tmp; + + convd->conv = iconv_open (outcharset, charset); + + freea (outcharset); + } + else +# endif + convd->conv = iconv_open (outcharset, charset); +# endif +# endif + + freea (charset); + } + } + } + convd->conv_tab = NULL; + /* Here domain->conversions is still == new_conversions. */ + domain->nconversions++; + } + + if ( +# ifdef _LIBC + convd->conv != (__gconv_t) -1 +# else +# if HAVE_ICONV + convd->conv != (iconv_t) -1 +# endif +# endif + ) { - /* We haven't used this string so far, so it is not - translated yet. Do this now. */ - /* We use a bit more efficient memory handling. - We allocate always larger blocks which get used over - time. This is faster than many small allocations. */ - __libc_lock_define_initialized (static, lock) + /* We are supposed to do a conversion. First allocate an + appropriate table with the same structure as the table + of translations in the file, where we can put the pointers + to the converted strings in. + There is a slight complication with plural entries. They + are represented by consecutive NUL terminated strings. We + handle this case by converting RESULTLEN bytes, including + NULs. */ + + if (convd->conv_tab == NULL + && ((convd->conv_tab = + (char **) calloc (nstrings + domain->n_sysdep_strings, + sizeof (char *))) + == NULL)) + /* Mark that we didn't succeed allocating a table. */ + convd->conv_tab = (char **) -1; + + if (__builtin_expect (convd->conv_tab == (char **) -1, 0)) + /* Nothing we can do, no more memory. We cannot use the + translation because it might be encoded incorrectly. */ + return (char *) -1; + + if (convd->conv_tab[act] == NULL) + { + /* We haven't used this string so far, so it is not + translated yet. Do this now. */ + /* We use a bit more efficient memory handling. + We allocate always larger blocks which get used over + time. This is faster than many small allocations. */ + __libc_lock_define_initialized (static, lock) # define INITIAL_BLOCK_SIZE 4080 - static unsigned char *freemem; - static size_t freemem_size; + static unsigned char *freemem; + static size_t freemem_size; - const unsigned char *inbuf; - unsigned char *outbuf; - int malloc_count; + const unsigned char *inbuf; + unsigned char *outbuf; + int malloc_count; # ifndef _LIBC - transmem_block_t *transmem_list = NULL; + transmem_block_t *transmem_list = NULL; # endif - __libc_lock_lock (lock); + __libc_lock_lock (lock); - inbuf = (const unsigned char *) result; - outbuf = freemem + sizeof (size_t); + inbuf = (const unsigned char *) result; + outbuf = freemem + sizeof (size_t); - malloc_count = 0; - while (1) - { - transmem_block_t *newmem; + malloc_count = 0; + while (1) + { + transmem_block_t *newmem; # ifdef _LIBC - size_t non_reversible; - int res; + size_t non_reversible; + int res; - if (freemem_size < sizeof (size_t)) - goto resize_freemem; + if (freemem_size < sizeof (size_t)) + goto resize_freemem; - res = __gconv (domain->conv, - &inbuf, inbuf + resultlen, - &outbuf, - outbuf + freemem_size - sizeof (size_t), - &non_reversible); + res = __gconv (convd->conv, + &inbuf, inbuf + resultlen, + &outbuf, + outbuf + freemem_size - sizeof (size_t), + &non_reversible); - if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT) - break; + if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT) + break; - if (res != __GCONV_FULL_OUTPUT) - { - __libc_lock_unlock (lock); - goto converted; - } + if (res != __GCONV_FULL_OUTPUT) + { + /* We should not use the translation at all, it + is incorrectly encoded. */ + __libc_lock_unlock (lock); + return NULL; + } - inbuf = result; + inbuf = (const unsigned char *) result; # else # if HAVE_ICONV - const char *inptr = (const char *) inbuf; - size_t inleft = resultlen; - char *outptr = (char *) outbuf; - size_t outleft; - - if (freemem_size < sizeof (size_t)) - goto resize_freemem; - - outleft = freemem_size - sizeof (size_t); - if (iconv (domain->conv, - (ICONV_CONST char **) &inptr, &inleft, - &outptr, &outleft) - != (size_t) (-1)) - { - outbuf = (unsigned char *) outptr; - break; - } - if (errno != E2BIG) - { - __libc_lock_unlock (lock); - goto converted; - } + const char *inptr = (const char *) inbuf; + size_t inleft = resultlen; + char *outptr = (char *) outbuf; + size_t outleft; + + if (freemem_size < sizeof (size_t)) + goto resize_freemem; + + outleft = freemem_size - sizeof (size_t); + if (iconv (convd->conv, + (ICONV_CONST char **) &inptr, &inleft, + &outptr, &outleft) + != (size_t) (-1)) + { + outbuf = (unsigned char *) outptr; + break; + } + if (errno != E2BIG) + { + __libc_lock_unlock (lock); + return NULL; + } # endif # endif - resize_freemem: - /* We must allocate a new buffer or resize the old one. */ - if (malloc_count > 0) - { - ++malloc_count; - freemem_size = malloc_count * INITIAL_BLOCK_SIZE; - newmem = (transmem_block_t *) realloc (transmem_list, - freemem_size); + resize_freemem: + /* We must allocate a new buffer or resize the old one. */ + if (malloc_count > 0) + { + ++malloc_count; + freemem_size = malloc_count * INITIAL_BLOCK_SIZE; + newmem = (transmem_block_t *) realloc (transmem_list, + freemem_size); # ifdef _LIBC - if (newmem != NULL) - transmem_list = transmem_list->next; + if (newmem != NULL) + transmem_list = transmem_list->next; + else + { + struct transmem_list *old = transmem_list; + + transmem_list = transmem_list->next; + free (old); + } +# endif + } else { - struct transmem_list *old = transmem_list; - - transmem_list = transmem_list->next; - free (old); + malloc_count = 1; + freemem_size = INITIAL_BLOCK_SIZE; + newmem = (transmem_block_t *) malloc (freemem_size); + } + if (__builtin_expect (newmem == NULL, 0)) + { + freemem = NULL; + freemem_size = 0; + __libc_lock_unlock (lock); + return (char *) -1; } -# endif - } - else - { - malloc_count = 1; - freemem_size = INITIAL_BLOCK_SIZE; - newmem = (transmem_block_t *) malloc (freemem_size); - } - if (__builtin_expect (newmem == NULL, 0)) - { - freemem = NULL; - freemem_size = 0; - __libc_lock_unlock (lock); - goto converted; - } # ifdef _LIBC - /* Add the block to the list of blocks we have to free - at some point. */ - newmem->next = transmem_list; - transmem_list = newmem; + /* Add the block to the list of blocks we have to free + at some point. */ + newmem->next = transmem_list; + transmem_list = newmem; - freemem = newmem->data; - freemem_size -= offsetof (struct transmem_list, data); + freemem = (unsigned char *) newmem->data; + freemem_size -= offsetof (struct transmem_list, data); # else - transmem_list = newmem; - freemem = newmem; + transmem_list = newmem; + freemem = newmem; # endif - outbuf = freemem + sizeof (size_t); + outbuf = freemem + sizeof (size_t); + } + + /* We have now in our buffer a converted string. Put this + into the table of conversions. */ + *(size_t *) freemem = outbuf - freemem - sizeof (size_t); + convd->conv_tab[act] = (char *) freemem; + /* Shrink freemem, but keep it aligned. */ + freemem_size -= outbuf - freemem; + freemem = outbuf; + freemem += freemem_size & (alignof (size_t) - 1); + freemem_size = freemem_size & ~ (alignof (size_t) - 1); + + __libc_lock_unlock (lock); } - /* We have now in our buffer a converted string. Put this - into the table of conversions. */ - *(size_t *) freemem = outbuf - freemem - sizeof (size_t); - domain->conv_tab[act] = (char *) freemem; - /* Shrink freemem, but keep it aligned. */ - freemem_size -= outbuf - freemem; - freemem = outbuf; - freemem += freemem_size & (alignof (size_t) - 1); - freemem_size = freemem_size & ~ (alignof (size_t) - 1); - - __libc_lock_unlock (lock); + /* Now convd->conv_tab[act] contains the translation of all + the plural variants. */ + result = convd->conv_tab[act] + sizeof (size_t); + resultlen = *(size_t *) convd->conv_tab[act]; } - - /* Now domain->conv_tab[act] contains the translation of all - the plural variants. */ - result = domain->conv_tab[act] + sizeof (size_t); - resultlen = *(size_t *) domain->conv_tab[act]; } - converted: /* The result string is converted. */ #endif /* _LIBC || HAVE_ICONV */ @@ -1126,13 +1445,21 @@ category_to_name (int category) or system-dependent defaults. */ static const char * internal_function +#ifdef IN_LIBGLOCALE +guess_category_value (int category, const char *categoryname, + const char *locale) + +#else guess_category_value (int category, const char *categoryname) +#endif { const char *language; +#ifndef IN_LIBGLOCALE const char *locale; -#ifndef _LIBC +# ifndef _LIBC const char *language_default; int locale_defaulted; +# endif #endif /* We use the settings in the following order: @@ -1149,19 +1476,34 @@ guess_category_value (int category, const char *categoryname) - If the system provides both a list of languages and a default locale, the former is used. */ +#ifndef IN_LIBGLOCALE /* Fetch the locale name, through the POSIX method of looking to `LC_ALL', `LC_xxx', and `LANG'. On some systems this can be done by the `setlocale' function itself. */ -#ifdef _LIBC +# ifdef _LIBC locale = __current_locale_name (category); -#else - locale = _nl_locale_name_posix (category, categoryname); - locale_defaulted = 0; - if (locale == NULL) +# else +# if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS + /* The __names field is not public glibc API and must therefore not be used + in code that is installed in public locations. */ + locale_t thread_locale = uselocale (NULL); + if (thread_locale != LC_GLOBAL_LOCALE) + { + locale = thread_locale->__names[category]; + locale_defaulted = 0; + } + else +# endif { - locale = _nl_locale_name_default (); - locale_defaulted = 1; + locale = _nl_locale_name_posix (category, categoryname); + locale_defaulted = 0; + if (locale == NULL) + { + locale = _nl_locale_name_default (); + locale_defaulted = 1; + } } +# endif #endif /* Ignore LANGUAGE and its system-dependent analogon if the locale is set @@ -1183,7 +1525,7 @@ guess_category_value (int category, const char *categoryname) language = getenv ("LANGUAGE"); if (language != NULL && language[0] != '\0') return language; -#ifndef _LIBC +#if !defined IN_LIBGLOCALE && !defined _LIBC /* The next priority value is the locale name, if not defaulted. */ if (locale_defaulted) { @@ -1197,6 +1539,60 @@ guess_category_value (int category, const char *categoryname) return locale; } +#if (defined _LIBC || HAVE_ICONV) && !defined IN_LIBGLOCALE +/* Returns the output charset. */ +static const char * +internal_function +get_output_charset (struct binding *domainbinding) +{ + /* The output charset should normally be determined by the locale. But + sometimes the locale is not used or not correctly set up, so we provide + a possibility for the user to override this: the OUTPUT_CHARSET + environment variable. Moreover, the value specified through + bind_textdomain_codeset overrides both. */ + if (domainbinding != NULL && domainbinding->codeset != NULL) + return domainbinding->codeset; + else + { + /* For speed reasons, we look at the value of OUTPUT_CHARSET only + once. This is a user variable that is not supposed to change + during a program run. */ + static char *output_charset_cache; + static int output_charset_cached; + + if (!output_charset_cached) + { + const char *value = getenv ("OUTPUT_CHARSET"); + + if (value != NULL && value[0] != '\0') + { + size_t len = strlen (value) + 1; + char *value_copy = (char *) malloc (len); + + if (value_copy != NULL) + memcpy (value_copy, value, len); + output_charset_cache = value_copy; + } + output_charset_cached = 1; + } + + if (output_charset_cache != NULL) + return output_charset_cache; + else + { +# ifdef _LIBC + return _NL_CURRENT (LC_CTYPE, CODESET); +# else +# if HAVE_ICONV + extern const char *locale_charset (void); + return locale_charset (); +# endif +# endif + } + } +} +#endif + /* @@ begin of epilog @@ */ /* We don't want libintl.a to depend on any other library. So we @@ -1233,7 +1629,7 @@ libc_freeres_fn (free_mem) { struct binding *oldp = _nl_domain_bindings; _nl_domain_bindings = _nl_domain_bindings->next; - if (oldp->dirname != INTUSE(_nl_default_dirname)) + if (oldp->dirname != _nl_default_dirname) /* Yes, this is a pointer comparison. */ free (oldp->dirname); free (oldp->codeset); diff --git a/intl/explodename.c b/intl/explodename.c index 1361418..8d3e146 100644 --- a/intl/explodename.c +++ b/intl/explodename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1998, 2000-2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1995-1998, 2000-2001, 2003, 2005 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. This program is free software; you can redistribute it and/or modify it @@ -37,11 +37,15 @@ /* @@ end of prolog @@ */ -char * +/* Split a locale name NAME into a leading language part and all the + rest. Return a pointer to the first character after the language, + i.e. to the first byte of the rest. */ +static char *_nl_find_language (const char *name); + +static char * _nl_find_language (const char *name) { - while (name[0] != '\0' && name[0] != '_' && name[0] != '@' - && name[0] != '+' && name[0] != ',') + while (name[0] != '\0' && name[0] != '_' && name[0] != '@' && name[0] != '.') ++name; return (char *) name; @@ -52,10 +56,8 @@ int _nl_explode_name (char *name, const char **language, const char **modifier, const char **territory, const char **codeset, - const char **normalized_codeset, const char **special, - const char **sponsor, const char **revision) + const char **normalized_codeset) { - enum { undecided, xpg, cen } syntax; char *cp; int mask; @@ -63,15 +65,10 @@ _nl_explode_name (char *name, *territory = NULL; *codeset = NULL; *normalized_codeset = NULL; - *special = NULL; - *sponsor = NULL; - *revision = NULL; /* Now we determine the single parts of the locale name. First - look for the language. Termination symbols are `_' and `@' if - we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */ + look for the language. Termination symbols are `_', '.', and `@'. */ mask = 0; - syntax = undecided; *language = cp = name; cp = _nl_find_language (*language); @@ -79,22 +76,23 @@ _nl_explode_name (char *name, /* This does not make sense: language has to be specified. Use this entry as it is without exploding. Perhaps it is an alias. */ cp = strchr (*language, '\0'); - else if (cp[0] == '_') + else { - /* Next is the territory. */ - cp[0] = '\0'; - *territory = ++cp; + if (cp[0] == '_') + { + /* Next is the territory. */ + cp[0] = '\0'; + *territory = ++cp; - while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@' - && cp[0] != '+' && cp[0] != ',' && cp[0] != '_') - ++cp; + while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@') + ++cp; - mask |= TERRITORY; + mask |= XPG_TERRITORY; + } if (cp[0] == '.') { /* Next is the codeset. */ - syntax = xpg; cp[0] = '\0'; *codeset = ++cp; @@ -115,71 +113,21 @@ _nl_explode_name (char *name, } } - if (cp[0] == '@' || (syntax != xpg && cp[0] == '+')) + if (cp[0] == '@') { /* Next is the modifier. */ - syntax = cp[0] == '@' ? xpg : cen; cp[0] = '\0'; *modifier = ++cp; - while (syntax == cen && cp[0] != '\0' && cp[0] != '+' - && cp[0] != ',' && cp[0] != '_') - ++cp; - - mask |= XPG_MODIFIER | CEN_AUDIENCE; - } - - if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_')) - { - syntax = cen; - - if (cp[0] == '+') - { - /* Next is special application (CEN syntax). */ - cp[0] = '\0'; - *special = ++cp; - - while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_') - ++cp; - - mask |= CEN_SPECIAL; - } - - if (cp[0] == ',') - { - /* Next is sponsor (CEN syntax). */ - cp[0] = '\0'; - *sponsor = ++cp; - - while (cp[0] != '\0' && cp[0] != '_') - ++cp; - - mask |= CEN_SPONSOR; - } - - if (cp[0] == '_') - { - /* Next is revision (CEN syntax). */ - cp[0] = '\0'; - *revision = ++cp; - - mask |= CEN_REVISION; - } + if (cp[0] != '\0') + mask |= XPG_MODIFIER; } - /* For CEN syntax values it might be important to have the - separator character in the file name, not for XPG syntax. */ - if (syntax == xpg) - { - if (*territory != NULL && (*territory)[0] == '\0') - mask &= ~TERRITORY; - - if (*codeset != NULL && (*codeset)[0] == '\0') - mask &= ~XPG_CODESET; + if (*territory != NULL && (*territory)[0] == '\0') + mask &= ~XPG_TERRITORY; - if (*modifier != NULL && (*modifier)[0] == '\0') - mask &= ~XPG_MODIFIER; - } + if (*codeset != NULL && (*codeset)[0] == '\0') + mask &= ~XPG_CODESET; return mask; } diff --git a/intl/export.h b/intl/export.h new file mode 100644 index 0000000..b5c47ad --- /dev/null +++ b/intl/export.h @@ -0,0 +1,6 @@ + +#if @HAVE_VISIBILITY@ && BUILDING_LIBINTL +#define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default"))) +#else +#define LIBINTL_DLL_EXPORTED +#endif diff --git a/intl/finddomain.c b/intl/finddomain.c index 498f858..a25bebc 100644 --- a/intl/finddomain.c +++ b/intl/finddomain.c @@ -1,5 +1,5 @@ /* Handle list of needed message catalogs - Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2001, 2003-2006 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@gnu.org>, 1995. This program is free software; you can redistribute it and/or modify it @@ -37,6 +37,17 @@ # include "libgnuintl.h" #endif +/* Handle multi-threaded applications. */ +#ifdef _LIBC +# include <bits/libc-lock.h> +# define gl_rwlock_define_initialized __libc_rwlock_define_initialized +# define gl_rwlock_rdlock __libc_rwlock_rdlock +# define gl_rwlock_wrlock __libc_rwlock_wrlock +# define gl_rwlock_unlock __libc_rwlock_unlock +#else +# include "lock.h" +#endif + /* @@ end of prolog @@ */ /* List of already loaded domains. */ static struct loaded_l10nfile *_nl_loaded_domains; @@ -56,44 +67,41 @@ _nl_find_domain (const char *dirname, char *locale, const char *territory; const char *codeset; const char *normalized_codeset; - const char *special; - const char *sponsor; - const char *revision; const char *alias_value; int mask; /* LOCALE can consist of up to four recognized parts for the XPG syntax: - language[_territory[.codeset]][@modifier] - - and six parts for the CEN syntax: - - language[_territory][+audience][+special][,[sponsor][_revision]] + language[_territory][.codeset][@modifier] Beside the first part all of them are allowed to be missing. If the full specified locale is not found, the less specific one are looked for. The various parts will be stripped off according to the following order: - (1) revision - (2) sponsor - (3) special - (4) codeset - (5) normalized codeset - (6) territory - (7) audience/modifier + (1) codeset + (2) normalized codeset + (3) territory + (4) modifier */ + /* We need to protect modifying the _NL_LOADED_DOMAINS data. */ + gl_rwlock_define_initialized (static, lock); + gl_rwlock_rdlock (lock); + /* If we have already tested for this locale entry there has to be one data set in the list of loaded domains. */ retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, strlen (dirname) + 1, 0, locale, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, domainname, 0); + NULL, NULL, domainname, 0); + + gl_rwlock_unlock (lock); + if (retval != NULL) { /* We know something about this locale. */ int cnt; - if (retval->decided == 0) + if (retval->decided <= 0) _nl_load_domain (retval, domainbinding); if (retval->data != NULL) @@ -101,13 +109,14 @@ _nl_find_domain (const char *dirname, char *locale, for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) { - if (retval->successor[cnt]->decided == 0) + if (retval->successor[cnt]->decided <= 0) _nl_load_domain (retval->successor[cnt], domainbinding); if (retval->successor[cnt]->data != NULL) break; } - return cnt >= 0 ? retval : NULL; + + return retval; /* NOTREACHED */ } @@ -132,30 +141,34 @@ _nl_find_domain (const char *dirname, char *locale, } /* Now we determine the single parts of the locale name. First - look for the language. Termination symbols are `_' and `@' if - we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */ + look for the language. Termination symbols are `_', '.', and `@'. */ mask = _nl_explode_name (locale, &language, &modifier, &territory, - &codeset, &normalized_codeset, &special, - &sponsor, &revision); + &codeset, &normalized_codeset); + + /* We need to protect modifying the _NL_LOADED_DOMAINS data. */ + gl_rwlock_wrlock (lock); /* Create all possible locale entries which might be interested in generalization. */ retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, strlen (dirname) + 1, mask, language, territory, - codeset, normalized_codeset, modifier, special, - sponsor, revision, domainname, 1); + codeset, normalized_codeset, modifier, + domainname, 1); + + gl_rwlock_unlock (lock); + if (retval == NULL) /* This means we are out of core. */ return NULL; - if (retval->decided == 0) + if (retval->decided <= 0) _nl_load_domain (retval, domainbinding); if (retval->data == NULL) { int cnt; for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) { - if (retval->successor[cnt]->decided == 0) + if (retval->successor[cnt]->decided <= 0) _nl_load_domain (retval->successor[cnt], domainbinding); if (retval->successor[cnt]->data != NULL) break; @@ -175,7 +188,10 @@ _nl_find_domain (const char *dirname, char *locale, #ifdef _LIBC -libc_freeres_fn (free_mem) +/* This is called from iconv/gconv_db.c's free_mem, as locales must + be freed before freeing gconv steps arrays. */ +void __libc_freeres_fn_section +_nl_finddomain_subfreeres () { struct loaded_l10nfile *runp = _nl_loaded_domains; diff --git a/intl/gettextP.h b/intl/gettextP.h index 0816bfb..8be38d2 100644 --- a/intl/gettextP.h +++ b/intl/gettextP.h @@ -30,6 +30,52 @@ # endif #endif +#ifdef _LIBC +extern char *__gettext (const char *__msgid); +extern char *__dgettext (const char *__domainname, const char *__msgid); +extern char *__dcgettext (const char *__domainname, const char *__msgid, + int __category); +extern char *__ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n); +extern char *__dngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int n); +extern char *__dcngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category); +extern char *__dcigettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + int __plural, unsigned long int __n, + int __category); +extern char *__textdomain (const char *__domainname); +extern char *__bindtextdomain (const char *__domainname, + const char *__dirname); +extern char *__bind_textdomain_codeset (const char *__domainname, + const char *__codeset); +extern void _nl_finddomain_subfreeres (void) attribute_hidden; +extern void _nl_unload_domain (struct loaded_domain *__domain) + internal_function attribute_hidden; +#else +/* Declare the exported libintl_* functions, in a way that allows us to + call them under their real name. */ +# undef _INTL_REDIRECT_INLINE +# undef _INTL_REDIRECT_MACROS +# define _INTL_REDIRECT_MACROS +# include "libgnuintl.h" +# ifdef IN_LIBGLOCALE +extern char *gl_dcigettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + int __plural, unsigned long int __n, + int __category, + const char *__localename, const char *__encoding); +# else +extern char *libintl_dcigettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + int __plural, unsigned long int __n, + int __category); +# endif +#endif + #include "loadinfo.h" #include "gmo.h" /* Get nls_uint32. */ @@ -77,6 +123,26 @@ struct sysdep_string_desc const char *pointer; }; +/* Cache of translated strings after charset conversion. + Note: The strings are converted to the target encoding only on an as-needed + basis. */ +struct converted_domain +{ + /* The target encoding name. */ + const char *encoding; + /* The descriptor for conversion from the message catalog's encoding to + this target encoding. */ +#ifdef _LIBC + __gconv_t conv; +#else +# if HAVE_ICONV + iconv_t conv; +# endif +#endif + /* The table of translated strings after charset conversion. */ + char **conv_tab; +}; + /* The representation of an opened message catalog. */ struct loaded_domain { @@ -112,15 +178,9 @@ struct loaded_domain /* 1 if the hash table uses a different endianness than this machine. */ int must_swap_hash_tab; - int codeset_cntr; -#ifdef _LIBC - __gconv_t conv; -#else -# if HAVE_ICONV - iconv_t conv; -# endif -#endif - char **conv_tab; + /* Cache of charset conversions of the translated strings. */ + struct converted_domain *conversions; + size_t nconversions; struct expression *plural; unsigned long int nplurals; @@ -140,7 +200,6 @@ struct binding { struct binding *next; char *dirname; - int codeset_cntr; /* Incremented each time codeset changes. */ char *codeset; char domainname[ZERO]; }; @@ -148,7 +207,12 @@ struct binding /* A counter which is incremented each time some previous translations become invalid. This variable is part of the external ABI of the GNU libintl. */ -extern int _nl_msg_cat_cntr; +#ifdef IN_LIBGLOCALE +# include <glocale/config.h> +extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr; +#else +extern LIBINTL_DLL_EXPORTED int _nl_msg_cat_cntr; +#endif #ifndef _LIBC const char *_nl_language_preferences_default (void); @@ -164,53 +228,18 @@ struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale, void _nl_load_domain (struct loaded_l10nfile *__domain, struct binding *__domainbinding) internal_function; -void _nl_unload_domain (struct loaded_domain *__domain) - internal_function; -const char *_nl_init_domain_conv (struct loaded_l10nfile *__domain_file, - struct loaded_domain *__domain, - struct binding *__domainbinding) - internal_function; -void _nl_free_domain_conv (struct loaded_domain *__domain) - internal_function; +#ifdef IN_LIBGLOCALE char *_nl_find_msg (struct loaded_l10nfile *domain_file, - struct binding *domainbinding, const char *msgid, + struct binding *domainbinding, const char *encoding, + const char *msgid, size_t *lengthp) internal_function; - -#ifdef _LIBC -extern char *__gettext (const char *__msgid); -extern char *__dgettext (const char *__domainname, const char *__msgid); -extern char *__dcgettext (const char *__domainname, const char *__msgid, - int __category); -extern char *__ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n); -extern char *__dngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int n); -extern char *__dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category); -extern char *__dcigettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - int __plural, unsigned long int __n, - int __category); -extern char *__textdomain (const char *__domainname); -extern char *__bindtextdomain (const char *__domainname, - const char *__dirname); -extern char *__bind_textdomain_codeset (const char *__domainname, - const char *__codeset); #else -/* Declare the exported libintl_* functions, in a way that allows us to - call them under their real name. */ -# undef _INTL_REDIRECT_INLINE -# undef _INTL_REDIRECT_MACROS -# define _INTL_REDIRECT_MACROS -# include "libgnuintl.h" -extern char *libintl_dcigettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - int __plural, unsigned long int __n, - int __category); +char *_nl_find_msg (struct loaded_l10nfile *domain_file, + struct binding *domainbinding, const char *msgid, + int convert, size_t *lengthp) + internal_function; #endif /* @@ begin of epilog @@ */ diff --git a/intl/hash-string.c b/intl/hash-string.c new file mode 100644 index 0000000..3c513f0 --- /dev/null +++ b/intl/hash-string.c @@ -0,0 +1,51 @@ +/* Implements a string hashing function. + Copyright (C) 1995, 1997, 1998, 2000, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +/* Specification. */ +#include "hash-string.h" + + +/* Defines the so called `hashpjw' function by P.J. Weinberger + [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, + 1986, 1987 Bell Telephone Laboratories, Inc.] */ +unsigned long int +__hash_string (const char *str_param) +{ + unsigned long int hval, g; + const char *str = str_param; + + /* Compute the hash value for the given string. */ + hval = 0; + while (*str != '\0') + { + hval <<= 4; + hval += (unsigned char) *str++; + g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4)); + if (g != 0) + { + hval ^= g >> (HASHWORDBITS - 8); + hval ^= g; + } + } + return hval; +} diff --git a/intl/hash-string.h b/intl/hash-string.h index 2c9a3a5..98c07e4 100644 --- a/intl/hash-string.h +++ b/intl/hash-string.h @@ -1,5 +1,5 @@ /* Description of GNU message catalog format: string hashing function. - Copyright (C) 1995, 1997-1998, 2000-2003 Free Software Foundation, Inc. + Copyright (C) 1995, 1997-1998, 2000-2003, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -22,27 +22,15 @@ #define HASHWORDBITS 32 +#ifndef _LIBC +# ifdef IN_LIBINTL +# define __hash_string libintl_hash_string +# else +# define __hash_string hash_string +# endif +#endif + /* Defines the so called `hashpjw' function by P.J. Weinberger [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, 1986, 1987 Bell Telephone Laboratories, Inc.] */ -static inline unsigned long int -hash_string (const char *str_param) -{ - unsigned long int hval, g; - const char *str = str_param; - - /* Compute the hash value for the given string. */ - hval = 0; - while (*str != '\0') - { - hval <<= 4; - hval += (unsigned char) *str++; - g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4)); - if (g != 0) - { - hval ^= g >> (HASHWORDBITS - 8); - hval ^= g; - } - } - return hval; -} +extern unsigned long int __hash_string (const char *str_param); diff --git a/intl/intl-compat.c b/intl/intl-compat.c index 15be09c..9b9ecbb 100644 --- a/intl/intl-compat.c +++ b/intl/intl-compat.c @@ -1,6 +1,6 @@ /* intl-compat.c - Stub functions to call gettext functions from GNU gettext Library. - Copyright (C) 1995, 2000-2003 Software Foundation, Inc. + Copyright (C) 1995, 2000-2003, 2005 Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -49,7 +49,9 @@ /* When building a DLL, we must export some functions. Note that because the functions are only defined for binary backward compatibility, we don't need to use __declspec(dllimport) in any case. */ -#if defined _MSC_VER && BUILDING_DLL +#if HAVE_VISIBILITY && BUILDING_DLL +# define DLL_EXPORTED __attribute__((__visibility__("default"))) +#elif defined _MSC_VER && BUILDING_DLL # define DLL_EXPORTED __declspec(dllexport) #else # define DLL_EXPORTED diff --git a/intl/intl-exports.c b/intl/intl-exports.c new file mode 100644 index 0000000..7176589 --- /dev/null +++ b/intl/intl-exports.c @@ -0,0 +1,36 @@ +/* List of exported symbols of libintl on Cygwin. + Copyright (C) 2006 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2006. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + + /* IMP(x) is a symbol that contains the address of x. */ +#define IMP(x) _imp__##x + + /* Ensure that the variable x is exported from the library, and that a + pseudo-variable IMP(x) is available. */ +#define VARIABLE(x) \ + /* Export x without redefining x. This code was found by compiling a \ + snippet: \ + extern __declspec(dllexport) int x; int x = 42; */ \ + asm (".section .drectve\n"); \ + asm (".ascii \" -export:" #x ",data\"\n"); \ + asm (".data\n"); \ + /* Allocate a pseudo-variable IMP(x). */ \ + extern int x; \ + void * IMP(x) = &x; + +VARIABLE(libintl_version) diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 0501b97..365aeb7 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. This program is free software; you can redistribute it and/or modify it @@ -82,7 +82,12 @@ static char *stpcpy (char *dest, const char *src); /* Define function which are usually not available. */ -#if !defined _LIBC && !defined HAVE___ARGZ_COUNT +#ifdef _LIBC +# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) +#elif defined HAVE_ARGZ_COUNT +# undef __argz_count +# define __argz_count argz_count +#else /* Returns the number of strings in ARGZ. */ static size_t argz_count__ (const char *argz, size_t len) @@ -99,13 +104,15 @@ argz_count__ (const char *argz, size_t len) } # undef __argz_count # define __argz_count(argz, len) argz_count__ (argz, len) -#else -# ifdef _LIBC -# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) -# endif -#endif /* !_LIBC && !HAVE___ARGZ_COUNT */ +#endif /* !_LIBC && !HAVE_ARGZ_COUNT */ -#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY +#ifdef _LIBC +# define __argz_stringify(argz, len, sep) \ + INTUSE(__argz_stringify) (argz, len, sep) +#elif defined HAVE_ARGZ_STRINGIFY +# undef __argz_stringify +# define __argz_stringify argz_stringify +#else /* Make '\0' separated arg vector ARGZ printable by converting all the '\0's except the last into the character SEP. */ static void @@ -122,14 +129,13 @@ argz_stringify__ (char *argz, size_t len, int sep) } # undef __argz_stringify # define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep) -#else -# ifdef _LIBC -# define __argz_stringify(argz, len, sep) \ - INTUSE(__argz_stringify) (argz, len, sep) -# endif -#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */ +#endif /* !_LIBC && !HAVE_ARGZ_STRINGIFY */ -#if !defined _LIBC && !defined HAVE___ARGZ_NEXT +#ifdef _LIBC +#elif defined HAVE_ARGZ_NEXT +# undef __argz_next +# define __argz_next argz_next +#else static char * argz_next__ (char *argz, size_t argz_len, const char *entry) { @@ -148,7 +154,7 @@ argz_next__ (char *argz, size_t argz_len, const char *entry) } # undef __argz_next # define __argz_next(argz, len, entry) argz_next__ (argz, len, entry) -#endif /* !_LIBC && !HAVE___ARGZ_NEXT */ +#endif /* !_LIBC && !HAVE_ARGZ_NEXT */ /* Return number of bits set in X. */ @@ -170,8 +176,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char *dirlist, size_t dirlist_len, int mask, const char *language, const char *territory, const char *codeset, const char *normalized_codeset, - const char *modifier, const char *special, - const char *sponsor, const char *revision, + const char *modifier, const char *filename, int do_allocate) { char *abs_filename; @@ -190,23 +195,14 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, /* Allocate room for the full file name. */ abs_filename = (char *) malloc (dirlist_len + strlen (language) - + ((mask & TERRITORY) != 0 + + ((mask & XPG_TERRITORY) != 0 ? strlen (territory) + 1 : 0) + ((mask & XPG_CODESET) != 0 ? strlen (codeset) + 1 : 0) + ((mask & XPG_NORM_CODESET) != 0 ? strlen (normalized_codeset) + 1 : 0) - + (((mask & XPG_MODIFIER) != 0 - || (mask & CEN_AUDIENCE) != 0) + + ((mask & XPG_MODIFIER) != 0 ? strlen (modifier) + 1 : 0) - + ((mask & CEN_SPECIAL) != 0 - ? strlen (special) + 1 : 0) - + (((mask & CEN_SPONSOR) != 0 - || (mask & CEN_REVISION) != 0) - ? (1 + ((mask & CEN_SPONSOR) != 0 - ? strlen (sponsor) : 0) - + ((mask & CEN_REVISION) != 0 - ? strlen (revision) + 1 : 0)) : 0) + 1 + strlen (filename) + 1); if (abs_filename == NULL) @@ -224,7 +220,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, cp = stpcpy (cp, language); - if ((mask & TERRITORY) != 0) + if ((mask & XPG_TERRITORY) != 0) { *cp++ = '_'; cp = stpcpy (cp, territory); @@ -239,29 +235,11 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, *cp++ = '.'; cp = stpcpy (cp, normalized_codeset); } - if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0) + if ((mask & XPG_MODIFIER) != 0) { - /* This component can be part of both syntaces but has different - leading characters. For CEN we use `+', else `@'. */ - *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@'; + *cp++ = '@'; cp = stpcpy (cp, modifier); } - if ((mask & CEN_SPECIAL) != 0) - { - *cp++ = '+'; - cp = stpcpy (cp, special); - } - if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0) - { - *cp++ = ','; - if ((mask & CEN_SPONSOR) != 0) - cp = stpcpy (cp, sponsor); - if ((mask & CEN_REVISION) != 0) - { - *cp++ = '_'; - cp = stpcpy (cp, revision); - } - } *cp++ = '/'; stpcpy (cp, filename); @@ -301,7 +279,10 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0)) * sizeof (struct loaded_l10nfile *))); if (retval == NULL) - return NULL; + { + free (abs_filename); + return NULL; + } retval->filename = abs_filename; @@ -332,8 +313,7 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, normalized_codeset. */ for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt) if ((cnt & ~mask) == 0 - && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0) - && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0)) + && !((cnt & XPG_CODESET) != 0 && (cnt & XPG_NORM_CODESET) != 0)) { if (dirlist_count > 1) { @@ -345,15 +325,14 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, retval->successor[entries++] = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt, language, territory, codeset, - normalized_codeset, modifier, special, - sponsor, revision, filename, 1); + normalized_codeset, modifier, filename, + 1); } else retval->successor[entries++] = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, cnt, language, territory, codeset, - normalized_codeset, modifier, special, - sponsor, revision, filename, 1); + normalized_codeset, modifier, filename, 1); } retval->successor[entries] = NULL; diff --git a/intl/langprefs.c b/intl/langprefs.c index 20137b6..59c8def 100644 --- a/intl/langprefs.c +++ b/intl/langprefs.c @@ -1,5 +1,5 @@ /* Determine the user's language preferences. - Copyright (C) 2004-2005 Free Software Foundation, Inc. + Copyright (C) 2004-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -26,16 +26,16 @@ #if HAVE_CFPREFERENCESCOPYAPPVALUE # include <string.h> -# include <CFPreferences.h> -# include <CFPropertyList.h> -# include <CFArray.h> -# include <CFString.h> +# include <CoreFoundation/CFPreferences.h> +# include <CoreFoundation/CFPropertyList.h> +# include <CoreFoundation/CFArray.h> +# include <CoreFoundation/CFString.h> extern void _nl_locale_name_canonicalize (char *name); #endif /* Determine the user's language preferences, as a colon separated list of locale names in XPG syntax - language[_territory[.codeset]][@modifier] + language[_territory][.codeset][@modifier] The result must not be freed; it is statically allocated. The LANGUAGE environment variable does not need to be considered; it is already taken into account by the caller. */ diff --git a/intl/libgnuintl.h.in b/intl/libgnuintl.h.in index d1df17e..5e1ccd6 100644 --- a/intl/libgnuintl.h.in +++ b/intl/libgnuintl.h.in @@ -1,5 +1,5 @@ /* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2004 Free Software Foundation, Inc. + Copyright (C) 1995-1997, 2000-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -52,6 +52,11 @@ extern "C" { #endif +/* Version number: (major<<16) + (minor<<8) + subminor */ +#define LIBINTL_VERSION 0x001000 +extern int libintl_version; + + /* We redirect the functions to those prefixed with "libintl_". This is necessary, because some systems define gettext/textdomain/... in the C library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). @@ -83,7 +88,7 @@ extern "C" { If he doesn't, we choose the method. A third possible method is _INTL_REDIRECT_ASM, supported only by GCC. */ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) -# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) +# if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) # define _INTL_REDIRECT_ASM # else # ifdef __cplusplus @@ -102,11 +107,21 @@ extern "C" { # define _INTL_ASM(cname) #endif +/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return + its n-th argument literally. This enables GCC to warn for example about + printf (gettext ("foo %y")). */ +#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus) +# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n))) +#else +# define _INTL_MAY_RETURN_STRING_ARG(n) +#endif + /* Look up MSGID in the current default message catalog for the current LC_MESSAGES locale. If not found, returns MSGID itself (the default text). */ #ifdef _INTL_REDIRECT_INLINE -extern char *libintl_gettext (const char *__msgid); +extern char *libintl_gettext (const char *__msgid) + _INTL_MAY_RETURN_STRING_ARG (1); static inline char *gettext (const char *__msgid) { return libintl_gettext (__msgid); @@ -116,13 +131,15 @@ static inline char *gettext (const char *__msgid) # define gettext libintl_gettext #endif extern char *gettext (const char *__msgid) - _INTL_ASM (libintl_gettext); + _INTL_ASM (libintl_gettext) + _INTL_MAY_RETURN_STRING_ARG (1); #endif /* Look up MSGID in the DOMAINNAME message catalog for the current LC_MESSAGES locale. */ #ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dgettext (const char *__domainname, const char *__msgid); +extern char *libintl_dgettext (const char *__domainname, const char *__msgid) + _INTL_MAY_RETURN_STRING_ARG (2); static inline char *dgettext (const char *__domainname, const char *__msgid) { return libintl_dgettext (__domainname, __msgid); @@ -132,14 +149,16 @@ static inline char *dgettext (const char *__domainname, const char *__msgid) # define dgettext libintl_dgettext #endif extern char *dgettext (const char *__domainname, const char *__msgid) - _INTL_ASM (libintl_dgettext); + _INTL_ASM (libintl_dgettext) + _INTL_MAY_RETURN_STRING_ARG (2); #endif /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale. */ #ifdef _INTL_REDIRECT_INLINE extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, - int __category); + int __category) + _INTL_MAY_RETURN_STRING_ARG (2); static inline char *dcgettext (const char *__domainname, const char *__msgid, int __category) { @@ -151,7 +170,8 @@ static inline char *dcgettext (const char *__domainname, const char *__msgid, #endif extern char *dcgettext (const char *__domainname, const char *__msgid, int __category) - _INTL_ASM (libintl_dcgettext); + _INTL_ASM (libintl_dcgettext) + _INTL_MAY_RETURN_STRING_ARG (2); #endif @@ -159,7 +179,8 @@ extern char *dcgettext (const char *__domainname, const char *__msgid, number N. */ #ifdef _INTL_REDIRECT_INLINE extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n); + unsigned long int __n) + _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); static inline char *ngettext (const char *__msgid1, const char *__msgid2, unsigned long int __n) { @@ -171,14 +192,16 @@ static inline char *ngettext (const char *__msgid1, const char *__msgid2, #endif extern char *ngettext (const char *__msgid1, const char *__msgid2, unsigned long int __n) - _INTL_ASM (libintl_ngettext); + _INTL_ASM (libintl_ngettext) + _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2); #endif /* Similar to `dgettext' but select the plural form corresponding to the number N. */ #ifdef _INTL_REDIRECT_INLINE extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n); + const char *__msgid2, unsigned long int __n) + _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); static inline char *dngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n) { @@ -191,7 +214,8 @@ static inline char *dngettext (const char *__domainname, const char *__msgid1, extern char *dngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n) - _INTL_ASM (libintl_dngettext); + _INTL_ASM (libintl_dngettext) + _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); #endif /* Similar to `dcgettext' but select the plural form corresponding to the @@ -199,7 +223,8 @@ extern char *dngettext (const char *__domainname, #ifdef _INTL_REDIRECT_INLINE extern char *libintl_dcngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category); + unsigned long int __n, int __category) + _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); static inline char *dcngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n, int __category) @@ -213,10 +238,13 @@ static inline char *dcngettext (const char *__domainname, extern char *dcngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n, int __category) - _INTL_ASM (libintl_dcngettext); + _INTL_ASM (libintl_dcngettext) + _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3); #endif +#ifndef IN_LIBGLOCALE + /* Set the current default message catalog to DOMAINNAME. If DOMAINNAME is null, return the current default. If DOMAINNAME is "", reset to the default of "messages". */ @@ -271,6 +299,8 @@ extern char *bind_textdomain_codeset (const char *__domainname, _INTL_ASM (libintl_bind_textdomain_codeset); #endif +#endif /* IN_LIBGLOCALE */ + /* Support for format strings with positions in *printf(), following the POSIX/XSI specification. @@ -300,6 +330,12 @@ extern int fprintf (FILE *, const char *, ...); extern int vfprintf (FILE *, const char *, va_list); #undef printf +#if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__ +/* Don't break __attribute__((format(printf,M,N))). + This redefinition is only possible because the libc in NetBSD, Cygwin, + mingw does not have a function __printf__. */ +# define libintl_printf __printf__ +#endif #define printf libintl_printf extern int printf (const char *, ...); #undef vprintf diff --git a/intl/libgnuintl.h.msvc-shared b/intl/libgnuintl.h.msvc-shared deleted file mode 100644 index 88a584e..0000000 --- a/intl/libgnuintl.h.msvc-shared +++ /dev/null @@ -1,389 +0,0 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _LIBINTL_H -#define _LIBINTL_H 1 - -#ifdef BUILDING_LIBINTL -#define LIBINTL_DLL_EXPORTED __declspec(dllexport) -#else -#define LIBINTL_DLL_EXPORTED __declspec(dllimport) -#endif - -#include <locale.h> - -/* The LC_MESSAGES locale category is the category used by the functions - gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. - On systems that don't define it, use an arbitrary value instead. - On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) - then includes <libintl.h> (i.e. this file!) and then only defines - LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES - in this case. */ -#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) -# define LC_MESSAGES 1729 -#endif - -/* We define an additional symbol to signal that we use the GNU - implementation of gettext. */ -#define __USE_GNU_GETTEXT 1 - -/* Provide information about the supported file formats. Returns the - maximum minor revision number supported for a given major revision. */ -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ - ((major) == 0 || (major) == 1 ? 1 : -1) - -/* Resolve a platform specific conflict on DJGPP. GNU gettext takes - precedence over _conio_gettext. */ -#ifdef __DJGPP__ -# undef gettext -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/* We redirect the functions to those prefixed with "libintl_". This is - necessary, because some systems define gettext/textdomain/... in the C - library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). - If we used the unprefixed names, there would be cases where the - definition in the C library would override the one in the libintl.so - shared library. Recall that on ELF systems, the symbols are looked - up in the following order: - 1. in the executable, - 2. in the shared libraries specified on the link command line, in order, - 3. in the dependencies of the shared libraries specified on the link - command line, - 4. in the dlopen()ed shared libraries, in the order in which they were - dlopen()ed. - The definition in the C library would override the one in libintl.so if - either - * -lc is given on the link command line and -lintl isn't, or - * -lc is given on the link command line before -lintl, or - * libintl.so is a dependency of a dlopen()ed shared library but not - linked to the executable at link time. - Since Solaris gettext() behaves differently than GNU gettext(), this - would be unacceptable. - - The redirection happens by default through macros in C, so that &gettext - is independent of the compilation unit, but through inline functions in - C++, in order not to interfere with the name mangling of class fields or - class methods called 'gettext'. */ - -/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. - If he doesn't, we choose the method. A third possible method is - _INTL_REDIRECT_ASM, supported only by GCC. */ -#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) -# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) -# define _INTL_REDIRECT_ASM -# else -# ifdef __cplusplus -# define _INTL_REDIRECT_INLINE -# else -# define _INTL_REDIRECT_MACROS -# endif -# endif -#endif -/* Auxiliary macros. */ -#ifdef _INTL_REDIRECT_ASM -# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) -# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring -# define _INTL_STRINGIFY(prefix) #prefix -#else -# define _INTL_ASM(cname) -#endif - -/* Look up MSGID in the current default message catalog for the current - LC_MESSAGES locale. If not found, returns MSGID itself (the default - text). */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_gettext (const char *__msgid); -static inline char *gettext (const char *__msgid) -{ - return libintl_gettext (__msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define gettext libintl_gettext -#endif -extern LIBINTL_DLL_EXPORTED char *gettext (const char *__msgid) - _INTL_ASM (libintl_gettext); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current - LC_MESSAGES locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_dgettext (const char *__domainname, const char *__msgid); -static inline char *dgettext (const char *__domainname, const char *__msgid) -{ - return libintl_dgettext (__domainname, __msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dgettext libintl_dgettext -#endif -extern LIBINTL_DLL_EXPORTED char *dgettext (const char *__domainname, const char *__msgid) - _INTL_ASM (libintl_dgettext); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY - locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_dcgettext (const char *__domainname, const char *__msgid, - int __category); -static inline char *dcgettext (const char *__domainname, const char *__msgid, - int __category) -{ - return libintl_dcgettext (__domainname, __msgid, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcgettext libintl_dcgettext -#endif -extern LIBINTL_DLL_EXPORTED char *dcgettext (const char *__domainname, const char *__msgid, - int __category) - _INTL_ASM (libintl_dcgettext); -#endif - - -/* Similar to `gettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n); -static inline char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) -{ - return libintl_ngettext (__msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define ngettext libintl_ngettext -#endif -extern LIBINTL_DLL_EXPORTED char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_ngettext); -#endif - -/* Similar to `dgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n); -static inline char *dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n) -{ - return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dngettext libintl_dngettext -#endif -extern LIBINTL_DLL_EXPORTED char *dngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_dngettext); -#endif - -/* Similar to `dcgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category); -static inline char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) -{ - return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcngettext libintl_dcngettext -#endif -extern LIBINTL_DLL_EXPORTED char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) - _INTL_ASM (libintl_dcngettext); -#endif - - -/* Set the current default message catalog to DOMAINNAME. - If DOMAINNAME is null, return the current default. - If DOMAINNAME is "", reset to the default of "messages". */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_textdomain (const char *__domainname); -static inline char *textdomain (const char *__domainname) -{ - return libintl_textdomain (__domainname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define textdomain libintl_textdomain -#endif -extern LIBINTL_DLL_EXPORTED char *textdomain (const char *__domainname) - _INTL_ASM (libintl_textdomain); -#endif - -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_bindtextdomain (const char *__domainname, - const char *__dirname); -static inline char *bindtextdomain (const char *__domainname, - const char *__dirname) -{ - return libintl_bindtextdomain (__domainname, __dirname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bindtextdomain libintl_bindtextdomain -#endif -extern LIBINTL_DLL_EXPORTED char *bindtextdomain (const char *__domainname, const char *__dirname) - _INTL_ASM (libintl_bindtextdomain); -#endif - -/* Specify the character encoding in which the messages from the - DOMAINNAME message catalog will be returned. */ -#ifdef _INTL_REDIRECT_INLINE -extern LIBINTL_DLL_EXPORTED char *libintl_bind_textdomain_codeset (const char *__domainname, - const char *__codeset); -static inline char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) -{ - return libintl_bind_textdomain_codeset (__domainname, __codeset); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bind_textdomain_codeset libintl_bind_textdomain_codeset -#endif -extern LIBINTL_DLL_EXPORTED char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) - _INTL_ASM (libintl_bind_textdomain_codeset); -#endif - - -/* Support for format strings with positions in *printf(), following the - POSIX/XSI specification. - Note: These replacements for the *printf() functions are visible only - in source files that #include <libintl.h> or #include "gettext.h". - Packages that use *printf() in source files that don't refer to _() - or gettext() but for which the format string could be the return value - of _() or gettext() need to add this #include. Oh well. */ - -#if !0 - -#include <stdio.h> -#include <stddef.h> - -/* Get va_list. */ -#if __STDC__ || defined __cplusplus || defined _MSC_VER -# include <stdarg.h> -#else -# include <varargs.h> -#endif - -#undef fprintf -#define fprintf libintl_fprintf -extern LIBINTL_DLL_EXPORTED int fprintf (FILE *, const char *, ...); -#undef vfprintf -#define vfprintf libintl_vfprintf -extern LIBINTL_DLL_EXPORTED int vfprintf (FILE *, const char *, va_list); - -#undef printf -#define printf libintl_printf -extern LIBINTL_DLL_EXPORTED int printf (const char *, ...); -#undef vprintf -#define vprintf libintl_vprintf -extern LIBINTL_DLL_EXPORTED int vprintf (const char *, va_list); - -#undef sprintf -#define sprintf libintl_sprintf -extern LIBINTL_DLL_EXPORTED int sprintf (char *, const char *, ...); -#undef vsprintf -#define vsprintf libintl_vsprintf -extern LIBINTL_DLL_EXPORTED int vsprintf (char *, const char *, va_list); - -#if 0 - -#undef snprintf -#define snprintf libintl_snprintf -extern LIBINTL_DLL_EXPORTED int snprintf (char *, size_t, const char *, ...); -#undef vsnprintf -#define vsnprintf libintl_vsnprintf -extern LIBINTL_DLL_EXPORTED int vsnprintf (char *, size_t, const char *, va_list); - -#endif - -#if 0 - -#undef asprintf -#define asprintf libintl_asprintf -extern LIBINTL_DLL_EXPORTED int asprintf (char **, const char *, ...); -#undef vasprintf -#define vasprintf libintl_vasprintf -extern LIBINTL_DLL_EXPORTED int vasprintf (char **, const char *, va_list); - -#endif - -#if 1 - -#undef fwprintf -#define fwprintf libintl_fwprintf -extern LIBINTL_DLL_EXPORTED int fwprintf (FILE *, const wchar_t *, ...); -#undef vfwprintf -#define vfwprintf libintl_vfwprintf -extern LIBINTL_DLL_EXPORTED int vfwprintf (FILE *, const wchar_t *, va_list); - -#undef wprintf -#define wprintf libintl_wprintf -extern LIBINTL_DLL_EXPORTED int wprintf (const wchar_t *, ...); -#undef vwprintf -#define vwprintf libintl_vwprintf -extern LIBINTL_DLL_EXPORTED int vwprintf (const wchar_t *, va_list); - -#undef swprintf -#define swprintf libintl_swprintf -extern LIBINTL_DLL_EXPORTED int swprintf (wchar_t *, size_t, const wchar_t *, ...); -#undef vswprintf -#define vswprintf libintl_vswprintf -extern LIBINTL_DLL_EXPORTED int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); - -#endif - -#endif - - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -#define libintl_set_relocation_prefix libintl_set_relocation_prefix -extern LIBINTL_DLL_EXPORTED void - libintl_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - - -#ifdef __cplusplus -} -#endif - -#endif /* libintl.h */ diff --git a/intl/libgnuintl.h.msvc-static b/intl/libgnuintl.h.msvc-static deleted file mode 100644 index c6818e2..0000000 --- a/intl/libgnuintl.h.msvc-static +++ /dev/null @@ -1,383 +0,0 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ - -#ifndef _LIBINTL_H -#define _LIBINTL_H 1 - -#include <locale.h> - -/* The LC_MESSAGES locale category is the category used by the functions - gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. - On systems that don't define it, use an arbitrary value instead. - On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) - then includes <libintl.h> (i.e. this file!) and then only defines - LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES - in this case. */ -#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) -# define LC_MESSAGES 1729 -#endif - -/* We define an additional symbol to signal that we use the GNU - implementation of gettext. */ -#define __USE_GNU_GETTEXT 1 - -/* Provide information about the supported file formats. Returns the - maximum minor revision number supported for a given major revision. */ -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ - ((major) == 0 || (major) == 1 ? 1 : -1) - -/* Resolve a platform specific conflict on DJGPP. GNU gettext takes - precedence over _conio_gettext. */ -#ifdef __DJGPP__ -# undef gettext -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/* We redirect the functions to those prefixed with "libintl_". This is - necessary, because some systems define gettext/textdomain/... in the C - library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). - If we used the unprefixed names, there would be cases where the - definition in the C library would override the one in the libintl.so - shared library. Recall that on ELF systems, the symbols are looked - up in the following order: - 1. in the executable, - 2. in the shared libraries specified on the link command line, in order, - 3. in the dependencies of the shared libraries specified on the link - command line, - 4. in the dlopen()ed shared libraries, in the order in which they were - dlopen()ed. - The definition in the C library would override the one in libintl.so if - either - * -lc is given on the link command line and -lintl isn't, or - * -lc is given on the link command line before -lintl, or - * libintl.so is a dependency of a dlopen()ed shared library but not - linked to the executable at link time. - Since Solaris gettext() behaves differently than GNU gettext(), this - would be unacceptable. - - The redirection happens by default through macros in C, so that &gettext - is independent of the compilation unit, but through inline functions in - C++, in order not to interfere with the name mangling of class fields or - class methods called 'gettext'. */ - -/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. - If he doesn't, we choose the method. A third possible method is - _INTL_REDIRECT_ASM, supported only by GCC. */ -#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) -# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) -# define _INTL_REDIRECT_ASM -# else -# ifdef __cplusplus -# define _INTL_REDIRECT_INLINE -# else -# define _INTL_REDIRECT_MACROS -# endif -# endif -#endif -/* Auxiliary macros. */ -#ifdef _INTL_REDIRECT_ASM -# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) -# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring -# define _INTL_STRINGIFY(prefix) #prefix -#else -# define _INTL_ASM(cname) -#endif - -/* Look up MSGID in the current default message catalog for the current - LC_MESSAGES locale. If not found, returns MSGID itself (the default - text). */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_gettext (const char *__msgid); -static inline char *gettext (const char *__msgid) -{ - return libintl_gettext (__msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define gettext libintl_gettext -#endif -extern char *gettext (const char *__msgid) - _INTL_ASM (libintl_gettext); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current - LC_MESSAGES locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dgettext (const char *__domainname, const char *__msgid); -static inline char *dgettext (const char *__domainname, const char *__msgid) -{ - return libintl_dgettext (__domainname, __msgid); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dgettext libintl_dgettext -#endif -extern char *dgettext (const char *__domainname, const char *__msgid) - _INTL_ASM (libintl_dgettext); -#endif - -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY - locale. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dcgettext (const char *__domainname, const char *__msgid, - int __category); -static inline char *dcgettext (const char *__domainname, const char *__msgid, - int __category) -{ - return libintl_dcgettext (__domainname, __msgid, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcgettext libintl_dcgettext -#endif -extern char *dcgettext (const char *__domainname, const char *__msgid, - int __category) - _INTL_ASM (libintl_dcgettext); -#endif - - -/* Similar to `gettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n); -static inline char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) -{ - return libintl_ngettext (__msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define ngettext libintl_ngettext -#endif -extern char *ngettext (const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_ngettext); -#endif - -/* Similar to `dgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n); -static inline char *dngettext (const char *__domainname, const char *__msgid1, - const char *__msgid2, unsigned long int __n) -{ - return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dngettext libintl_dngettext -#endif -extern char *dngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n) - _INTL_ASM (libintl_dngettext); -#endif - -/* Similar to `dcgettext' but select the plural form corresponding to the - number N. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category); -static inline char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) -{ - return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define dcngettext libintl_dcngettext -#endif -extern char *dcngettext (const char *__domainname, - const char *__msgid1, const char *__msgid2, - unsigned long int __n, int __category) - _INTL_ASM (libintl_dcngettext); -#endif - - -/* Set the current default message catalog to DOMAINNAME. - If DOMAINNAME is null, return the current default. - If DOMAINNAME is "", reset to the default of "messages". */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_textdomain (const char *__domainname); -static inline char *textdomain (const char *__domainname) -{ - return libintl_textdomain (__domainname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define textdomain libintl_textdomain -#endif -extern char *textdomain (const char *__domainname) - _INTL_ASM (libintl_textdomain); -#endif - -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_bindtextdomain (const char *__domainname, - const char *__dirname); -static inline char *bindtextdomain (const char *__domainname, - const char *__dirname) -{ - return libintl_bindtextdomain (__domainname, __dirname); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bindtextdomain libintl_bindtextdomain -#endif -extern char *bindtextdomain (const char *__domainname, const char *__dirname) - _INTL_ASM (libintl_bindtextdomain); -#endif - -/* Specify the character encoding in which the messages from the - DOMAINNAME message catalog will be returned. */ -#ifdef _INTL_REDIRECT_INLINE -extern char *libintl_bind_textdomain_codeset (const char *__domainname, - const char *__codeset); -static inline char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) -{ - return libintl_bind_textdomain_codeset (__domainname, __codeset); -} -#else -#ifdef _INTL_REDIRECT_MACROS -# define bind_textdomain_codeset libintl_bind_textdomain_codeset -#endif -extern char *bind_textdomain_codeset (const char *__domainname, - const char *__codeset) - _INTL_ASM (libintl_bind_textdomain_codeset); -#endif - - -/* Support for format strings with positions in *printf(), following the - POSIX/XSI specification. - Note: These replacements for the *printf() functions are visible only - in source files that #include <libintl.h> or #include "gettext.h". - Packages that use *printf() in source files that don't refer to _() - or gettext() but for which the format string could be the return value - of _() or gettext() need to add this #include. Oh well. */ - -#if !0 - -#include <stdio.h> -#include <stddef.h> - -/* Get va_list. */ -#if __STDC__ || defined __cplusplus || defined _MSC_VER -# include <stdarg.h> -#else -# include <varargs.h> -#endif - -#undef fprintf -#define fprintf libintl_fprintf -extern int fprintf (FILE *, const char *, ...); -#undef vfprintf -#define vfprintf libintl_vfprintf -extern int vfprintf (FILE *, const char *, va_list); - -#undef printf -#define printf libintl_printf -extern int printf (const char *, ...); -#undef vprintf -#define vprintf libintl_vprintf -extern int vprintf (const char *, va_list); - -#undef sprintf -#define sprintf libintl_sprintf -extern int sprintf (char *, const char *, ...); -#undef vsprintf -#define vsprintf libintl_vsprintf -extern int vsprintf (char *, const char *, va_list); - -#if 0 - -#undef snprintf -#define snprintf libintl_snprintf -extern int snprintf (char *, size_t, const char *, ...); -#undef vsnprintf -#define vsnprintf libintl_vsnprintf -extern int vsnprintf (char *, size_t, const char *, va_list); - -#endif - -#if 0 - -#undef asprintf -#define asprintf libintl_asprintf -extern int asprintf (char **, const char *, ...); -#undef vasprintf -#define vasprintf libintl_vasprintf -extern int vasprintf (char **, const char *, va_list); - -#endif - -#if 1 - -#undef fwprintf -#define fwprintf libintl_fwprintf -extern int fwprintf (FILE *, const wchar_t *, ...); -#undef vfwprintf -#define vfwprintf libintl_vfwprintf -extern int vfwprintf (FILE *, const wchar_t *, va_list); - -#undef wprintf -#define wprintf libintl_wprintf -extern int wprintf (const wchar_t *, ...); -#undef vwprintf -#define vwprintf libintl_vwprintf -extern int vwprintf (const wchar_t *, va_list); - -#undef swprintf -#define swprintf libintl_swprintf -extern int swprintf (wchar_t *, size_t, const wchar_t *, ...); -#undef vswprintf -#define vswprintf libintl_vswprintf -extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); - -#endif - -#endif - - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -#define libintl_set_relocation_prefix libintl_set_relocation_prefix -extern void - libintl_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - - -#ifdef __cplusplus -} -#endif - -#endif /* libintl.h */ diff --git a/intl/libintl.glibc b/intl/libintl.glibc deleted file mode 100644 index 7c10519..0000000 --- a/intl/libintl.glibc +++ /dev/null @@ -1,116 +0,0 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. - This file is derived from the file libgettext.h in the GNU gettext package. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin Street, - Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _LIBINTL_H -#define _LIBINTL_H 1 - -#include <features.h> - -/* We define an additional symbol to signal that we use the GNU - implementation of gettext. */ -#define __USE_GNU_GETTEXT 1 - -__BEGIN_DECLS - -/* Look up MSGID in the current default message catalog for the current - LC_MESSAGES locale. If not found, returns MSGID itself (the default - text). */ -extern char *gettext (__const char *__msgid) __THROW; - -/* Look up MSGID in the DOMAINNAME message catalog for the current - LC_MESSAGES locale. */ -extern char *dgettext (__const char *__domainname, __const char *__msgid) - __THROW; -extern char *__dgettext (__const char *__domainname, __const char *__msgid) - __THROW __attribute_format_arg__ (2); - -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY - locale. */ -extern char *dcgettext (__const char *__domainname, - __const char *__msgid, int __category) __THROW; -extern char *__dcgettext (__const char *__domainname, - __const char *__msgid, int __category) - __THROW __attribute_format_arg__ (2); - - -/* Similar to `gettext' but select the plural form corresponding to the - number N. */ -extern char *ngettext (__const char *__msgid1, __const char *__msgid2, - unsigned long int __n) - __THROW __attribute_format_arg__ (1); - -/* Similar to `dgettext' but select the plural form corresponding to the - number N. */ -extern char *dngettext (__const char *__domainname, __const char *__msgid1, - __const char *__msgid2, unsigned long int __n) - __THROW __attribute_format_arg__ (2); - -/* Similar to `dcgettext' but select the plural form corresponding to the - number N. */ -extern char *dcngettext (__const char *__domainname, __const char *__msgid1, - __const char *__msgid2, unsigned long int __n, - int __category) - __THROW __attribute_format_arg__ (2); - - -/* Set the current default message catalog to DOMAINNAME. - If DOMAINNAME is null, return the current default. - If DOMAINNAME is "", reset to the default of "messages". */ -extern char *textdomain (__const char *__domainname) __THROW; - -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -extern char *bindtextdomain (__const char *__domainname, - __const char *__dirname) __THROW; - -/* Specify the character encoding in which the messages from the - DOMAINNAME message catalog will be returned. */ -extern char *bind_textdomain_codeset (__const char *__domainname, - __const char *__codeset) __THROW; - - -/* Optimized version of the function above. */ -#if defined __OPTIMIZE__ - -/* We need NULL for `gettext'. */ -# define __need_NULL -# include <stddef.h> - -/* We need LC_MESSAGES for `dgettext'. */ -# include <locale.h> - -/* These must be macros. Inlined functions are useless because the - `__builtin_constant_p' predicate in dcgettext would always return - false. */ - -# define gettext(msgid) dgettext (NULL, msgid) - -# define dgettext(domainname, msgid) \ - dcgettext (domainname, msgid, LC_MESSAGES) - -# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n) - -# define dngettext(domainname, msgid1, msgid2, n) \ - dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) - -#endif /* Optimizing. */ - -__END_DECLS - -#endif /* libintl.h */ diff --git a/intl/loadinfo.h b/intl/loadinfo.h index d6408f2..a7a1970 100644 --- a/intl/loadinfo.h +++ b/intl/loadinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-1999, 2000-2003 Free Software Foundation, Inc. +/* Copyright (C) 1996-1999, 2000-2003, 2005-2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -36,6 +36,10 @@ # define internal_function #endif +#ifndef LIBINTL_DLL_EXPORTED +# define LIBINTL_DLL_EXPORTED +#endif + /* Tell the compiler when a conditional or integer expression is almost always true or almost always false. */ #ifndef HAVE_BUILTIN_EXPECT @@ -43,7 +47,7 @@ #endif /* Separator in PATH like lists of pathnames. */ -#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__ +#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ /* Win32, OS/2, DOS */ # define PATH_SEPARATOR ';' #else @@ -52,17 +56,10 @@ #endif /* Encoding of locale name parts. */ -#define CEN_REVISION 1 -#define CEN_SPONSOR 2 -#define CEN_SPECIAL 4 -#define XPG_NORM_CODESET 8 -#define XPG_CODESET 16 -#define TERRITORY 32 -#define CEN_AUDIENCE 64 -#define XPG_MODIFIER 128 - -#define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE) -#define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER) +#define XPG_NORM_CODESET 1 +#define XPG_CODESET 2 +#define XPG_TERRITORY 4 +#define XPG_MODIFIER 8 struct loaded_l10nfile @@ -89,9 +86,9 @@ extern const char *_nl_normalize_codeset (const char *codeset, files of the same kind, sorted in decreasing order of ->filename. DIRLIST and DIRLIST_LEN are an argz list of directories in which to look, containing at least one directory (i.e. DIRLIST_LEN > 0). - MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER, - SPECIAL, SPONSOR, REVISION are the pieces of the locale name, as - produced by _nl_explode_name(). FILENAME is the filename suffix. + MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER + are the pieces of the locale name, as produced by _nl_explode_name(). + FILENAME is the filename suffix. The return value is the lookup result, either found in *L10NFILE_LIST, or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL. If the return value is non-NULL, it is added to *L10NFILE_LIST, and @@ -103,43 +100,33 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, const char *dirlist, size_t dirlist_len, int mask, const char *language, const char *territory, const char *codeset, const char *normalized_codeset, - const char *modifier, const char *special, - const char *sponsor, const char *revision, + const char *modifier, const char *filename, int do_allocate); /* Lookup the real locale name for a locale alias NAME, or NULL if NAME is not a locale alias (but possibly a real locale name). The return value is statically allocated and must not be freed. */ -extern const char *_nl_expand_alias (const char *name); +/* Part of the libintl ABI only for the sake of the gettext.m4 macro. */ +extern LIBINTL_DLL_EXPORTED const char *_nl_expand_alias (const char *name); /* Split a locale name NAME into its pieces: language, modifier, - territory, codeset, special, sponsor, revision. + territory, codeset. NAME gets destructively modified: NUL bytes are inserted here and there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY, - *CODESET, *SPECIAL, *SPONSOR, *REVISION gets assigned either a - pointer into the old NAME string, or NULL. *NORMALIZED_CODESET - gets assigned the expanded *CODESET, if it is different from *CODESET; - this one is dynamically allocated and has to be freed by the caller. + *CODESET gets assigned either a pointer into the old NAME string, or + NULL. *NORMALIZED_CODESET gets assigned the expanded *CODESET, if it + is different from *CODESET; this one is dynamically allocated and has + to be freed by the caller. The return value is a bitmask, where each bit corresponds to one filled-in value: - XPG_MODIFIER, CEN_AUDIENCE for *MODIFIER, - TERRITORY for *TERRITORY, + XPG_MODIFIER for *MODIFIER, + XPG_TERRITORY for *TERRITORY, XPG_CODESET for *CODESET, - XPG_NORM_CODESET for *NORMALIZED_CODESET, - CEN_SPECIAL for *SPECIAL, - CEN_SPONSOR for *SPONSOR, - CEN_REVISION for *REVISION. + XPG_NORM_CODESET for *NORMALIZED_CODESET. */ extern int _nl_explode_name (char *name, const char **language, const char **modifier, const char **territory, const char **codeset, - const char **normalized_codeset, - const char **special, const char **sponsor, - const char **revision); - -/* Split a locale name NAME into a leading language part and all the - rest. Return a pointer to the first character after the language, - i.e. to the first byte of the rest. */ -extern char *_nl_find_language (const char *name); + const char **normalized_codeset); #endif /* loadinfo.h */ diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 0d59ad8..2520c8c 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -1,5 +1,5 @@ /* Load needed message catalogs. - Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -91,6 +91,14 @@ char *alloca (); #ifdef _LIBC # include "../locale/localeinfo.h" +# include <not-cancel.h> +#endif + +/* Handle multi-threaded applications. */ +#ifdef _LIBC +# include <bits/libc-lock.h> +#else +# include "lock.h" #endif /* Provide fallback values for macros that ought to be defined in <inttypes.h>. @@ -457,11 +465,12 @@ char *alloca (); /* Rename the non ISO C functions. This is required by the standard because some ISO C functions will require linking with this object file and the name space must not be polluted. */ -# define open __open -# define close __close -# define read __read -# define mmap __mmap -# define munmap __munmap +# define open(name, flags) open_not_cancel_2 (name, flags) +# define close(fd) close_not_cancel_no_status (fd) +# define read(fd, buf, n) read_not_cancel (fd, buf, n) +# define mmap(addr, len, prot, flags, fd, offset) \ + __mmap (addr, len, prot, flags, fd, offset) +# define munmap(addr, len) __munmap (addr, len) #endif /* For those losing systems which don't have `alloca' we have to add @@ -764,144 +773,6 @@ get_sysdep_segment_value (const char *name) return NULL; } -/* Initialize the codeset dependent parts of an opened message catalog. - Return the header entry. */ -const char * -internal_function -_nl_init_domain_conv (struct loaded_l10nfile *domain_file, - struct loaded_domain *domain, - struct binding *domainbinding) -{ - /* Find out about the character set the file is encoded with. - This can be found (in textual form) in the entry "". If this - entry does not exist or if this does not contain the `charset=' - information, we will assume the charset matches the one the - current locale and we don't have to perform any conversion. */ - char *nullentry; - size_t nullentrylen; - - /* Preinitialize fields, to avoid recursion during _nl_find_msg. */ - domain->codeset_cntr = - (domainbinding != NULL ? domainbinding->codeset_cntr : 0); -#ifdef _LIBC - domain->conv = (__gconv_t) -1; -#else -# if HAVE_ICONV - domain->conv = (iconv_t) -1; -# endif -#endif - domain->conv_tab = NULL; - - /* Get the header entry. */ - nullentry = _nl_find_msg (domain_file, domainbinding, "", &nullentrylen); - - if (nullentry != NULL) - { -#if defined _LIBC || HAVE_ICONV - const char *charsetstr; - - charsetstr = strstr (nullentry, "charset="); - if (charsetstr != NULL) - { - size_t len; - char *charset; - const char *outcharset; - - charsetstr += strlen ("charset="); - len = strcspn (charsetstr, " \t\n"); - - charset = (char *) alloca (len + 1); -# if defined _LIBC || HAVE_MEMPCPY - *((char *) mempcpy (charset, charsetstr, len)) = '\0'; -# else - memcpy (charset, charsetstr, len); - charset[len] = '\0'; -# endif - - /* The output charset should normally be determined by the - locale. But sometimes the locale is not used or not correctly - set up, so we provide a possibility for the user to override - this. Moreover, the value specified through - bind_textdomain_codeset overrides both. */ - if (domainbinding != NULL && domainbinding->codeset != NULL) - outcharset = domainbinding->codeset; - else - { - outcharset = getenv ("OUTPUT_CHARSET"); - if (outcharset == NULL || outcharset[0] == '\0') - { -# ifdef _LIBC - outcharset = _NL_CURRENT (LC_CTYPE, CODESET); -# else -# if HAVE_ICONV - extern const char *locale_charset (void); - outcharset = locale_charset (); -# endif -# endif - } - } - -# ifdef _LIBC - /* We always want to use transliteration. */ - outcharset = norm_add_slashes (outcharset, "TRANSLIT"); - charset = norm_add_slashes (charset, NULL); - if (__gconv_open (outcharset, charset, &domain->conv, - GCONV_AVOID_NOCONV) - != __GCONV_OK) - domain->conv = (__gconv_t) -1; -# else -# if HAVE_ICONV - /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5, - we want to use transliteration. */ -# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ - || _LIBICONV_VERSION >= 0x0105 - if (strchr (outcharset, '/') == NULL) - { - char *tmp; - - len = strlen (outcharset); - tmp = (char *) alloca (len + 10 + 1); - memcpy (tmp, outcharset, len); - memcpy (tmp + len, "//TRANSLIT", 10 + 1); - outcharset = tmp; - - domain->conv = iconv_open (outcharset, charset); - - freea (outcharset); - } - else -# endif - domain->conv = iconv_open (outcharset, charset); -# endif -# endif - - freea (charset); - } -#endif /* _LIBC || HAVE_ICONV */ - } - - return nullentry; -} - -/* Frees the codeset dependent parts of an opened message catalog. */ -void -internal_function -_nl_free_domain_conv (struct loaded_domain *domain) -{ - if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1) - free (domain->conv_tab); - -#ifdef _LIBC - if (domain->conv != (__gconv_t) -1) - __gconv_close (domain->conv); -#else -# if HAVE_ICONV - if (domain->conv != (iconv_t) -1) - iconv_close (domain->conv); -# endif -#endif -} - /* Load the message catalogs specified by FILENAME. If it is no valid message catalog do nothing. */ void @@ -909,7 +780,8 @@ internal_function _nl_load_domain (struct loaded_l10nfile *domain_file, struct binding *domainbinding) { - int fd; + __libc_lock_define_initialized_recursive (static, lock) + int fd = -1; size_t size; #ifdef _LIBC struct stat64 st; @@ -921,8 +793,24 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, struct loaded_domain *domain; int revision; const char *nullentry; + size_t nullentrylen; - domain_file->decided = 1; + __libc_lock_lock_recursive (lock); + if (domain_file->decided != 0) + { + /* There are two possibilities: + + + this is the same thread calling again during this initialization + via _nl_find_msg. We have initialized everything this call needs. + + + this is another thread which tried to initialize this object. + Not necessary anymore since if the lock is available this + is finished. + */ + goto done; + } + + domain_file->decided = -1; domain_file->data = NULL; /* Note that it would be useless to store domainbinding in domain_file @@ -934,12 +822,12 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, specification the locale file name is different for XPG and CEN syntax. */ if (domain_file->filename == NULL) - return; + goto out; /* Try to open the addressed file. */ fd = open (domain_file->filename, O_RDONLY | O_BINARY); if (fd == -1) - return; + goto out; /* We must know about the size of the file. */ if ( @@ -950,11 +838,8 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, #endif || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0) || __builtin_expect (size < sizeof (struct mo_file_header), 0)) - { - /* Something went wrong. */ - close (fd); - return; - } + /* Something went wrong. */ + goto out; #ifdef HAVE_MMAP /* Now we are ready to load the file. If mmap() is available we try @@ -966,6 +851,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, { /* mmap() call was successful. */ close (fd); + fd = -1; use_mmap = 1; } #endif @@ -979,7 +865,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, data = (struct mo_file_header *) malloc (size); if (data == NULL) - return; + goto out; to_read = size; read_ptr = (char *) data; @@ -992,8 +878,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, if (nb == -1 && errno == EINTR) continue; #endif - close (fd); - return; + goto out; } read_ptr += nb; to_read -= nb; @@ -1001,6 +886,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, while (to_read > 0); close (fd); + fd = -1; } /* Using the magic number we can test whether it really is a message @@ -1015,12 +901,12 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, else #endif free (data); - return; + goto out; } domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); if (domain == NULL) - return; + goto out; domain_file->data = domain; domain->data = (char *) data; @@ -1321,7 +1207,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, for (i = 0; i < n_inmem_sysdep_strings; i++) { const char *msgid = inmem_orig_sysdep_tab[i].pointer; - nls_uint32 hash_val = hash_string (msgid); + nls_uint32 hash_val = __hash_string (msgid); nls_uint32 idx = hash_val % domain->hash_size; nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); @@ -1382,28 +1268,55 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, free (data); free (domain); domain_file->data = NULL; - return; + goto out; } - /* Now initialize the character set converter from the character set - the file is encoded with (found in the header entry) to the domain's - specified character set or the locale's character set. */ - nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding); + /* No caches of converted translations so far. */ + domain->conversions = NULL; + domain->nconversions = 0; - /* Also look for a plural specification. */ + /* Get the header entry and look for a plural specification. */ +#ifdef IN_LIBGLOCALE + nullentry = + _nl_find_msg (domain_file, domainbinding, NULL, "", &nullentrylen); +#else + nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); +#endif EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals); + + out: + if (fd != -1) + close (fd); + + domain_file->decided = 1; + + done: + __libc_lock_unlock_recursive (lock); } #ifdef _LIBC void -internal_function +internal_function __libc_freeres_fn_section _nl_unload_domain (struct loaded_domain *domain) { + size_t i; + if (domain->plural != &__gettext_germanic_plural) __gettext_free_exp (domain->plural); - _nl_free_domain_conv (domain); + for (i = 0; i < domain->nconversions; i++) + { + struct converted_domain *convd = &domain->conversions[i]; + + free (convd->encoding); + if (convd->conv_tab != NULL && convd->conv_tab != (char **) -1) + free (convd->conv_tab); + if (convd->conv != (__gconv_t) -1) + __gconv_close (convd->conv); + } + if (domain->conversions != NULL) + free (domain->conversions); if (domain->malloced) free (domain->malloced); diff --git a/intl/localcharset.c b/intl/localcharset.c index 1252f3f..e796ae7 100644 --- a/intl/localcharset.c +++ b/intl/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2004 Free Software Foundation, Inc. + Copyright (C) 2000-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -19,30 +19,18 @@ /* Written by Bruno Haible <bruno@clisp.org>. */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif +#include <config.h> /* Specification. */ #include "localcharset.h" -#if HAVE_STDDEF_H -# include <stddef.h> -#endif - +#include <stddef.h> #include <stdio.h> -#if HAVE_STRING_H -# include <string.h> -#else -# include <strings.h> -#endif -#if HAVE_STDLIB_H -# include <stdlib.h> -#endif +#include <string.h> +#include <stdlib.h> #if defined _WIN32 || defined __WIN32__ -# undef WIN32 /* avoid warning on mingw32 */ -# define WIN32 +# define WIN32_NATIVE #endif #if defined __EMX__ @@ -50,15 +38,19 @@ # define OS2 #endif -#if !defined WIN32 +#if !defined WIN32_NATIVE # if HAVE_LANGINFO_CODESET # include <langinfo.h> # else -# if HAVE_SETLOCALE +# if 0 /* see comment below */ # include <locale.h> # endif # endif -#elif defined WIN32 +# ifdef __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +# endif +#elif defined WIN32_NATIVE # define WIN32_LEAN_AND_MEAN # include <windows.h> #endif @@ -73,6 +65,11 @@ # define relocate(pathname) (pathname) #endif +/* Get LIBDIR. */ +#ifndef LIBDIR +# include "configmake.h" +#endif + #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Win32, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') @@ -107,14 +104,14 @@ static const char * volatile charset_aliases; /* Return a pointer to the contents of the charset.alias file. */ static const char * -get_charset_aliases () +get_charset_aliases (void) { const char *cp; cp = charset_aliases; if (cp == NULL) { -#if !(defined VMS || defined WIN32) +#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__) FILE *fp; const char *dir; const char *base = "charset.alias"; @@ -240,7 +237,7 @@ get_charset_aliases () "DECKOREAN" "\0" "EUC-KR" "\0"; # endif -# if defined WIN32 +# if defined WIN32_NATIVE || defined __CYGWIN__ /* To avoid the troubles of installing a separate file in the same directory as the DLL and of retrieving the DLL's directory at runtime, simply inline the aliases here. */ @@ -249,6 +246,7 @@ get_charset_aliases () "CP1361" "\0" "JOHAB" "\0" "CP20127" "\0" "ASCII" "\0" "CP20866" "\0" "KOI8-R" "\0" + "CP20936" "\0" "GB2312" "\0" "CP21866" "\0" "KOI8-RU" "\0" "CP28591" "\0" "ISO-8859-1" "\0" "CP28592" "\0" "ISO-8859-2" "\0" @@ -259,7 +257,14 @@ get_charset_aliases () "CP28597" "\0" "ISO-8859-7" "\0" "CP28598" "\0" "ISO-8859-8" "\0" "CP28599" "\0" "ISO-8859-9" "\0" - "CP28605" "\0" "ISO-8859-15" "\0"; + "CP28605" "\0" "ISO-8859-15" "\0" + "CP38598" "\0" "ISO-8859-8" "\0" + "CP51932" "\0" "EUC-JP" "\0" + "CP51936" "\0" "GB2312" "\0" + "CP51949" "\0" "EUC-KR" "\0" + "CP51950" "\0" "EUC-TW" "\0" + "CP54936" "\0" "GB18030" "\0" + "CP65001" "\0" "UTF-8" "\0"; # endif #endif @@ -279,18 +284,65 @@ get_charset_aliases () STATIC #endif const char * -locale_charset () +locale_charset (void) { const char *codeset; const char *aliases; -#if !(defined WIN32 || defined OS2) +#if !(defined WIN32_NATIVE || defined OS2) # if HAVE_LANGINFO_CODESET /* Most systems support nl_langinfo (CODESET) nowadays. */ codeset = nl_langinfo (CODESET); +# ifdef __CYGWIN__ + /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always + returns "US-ASCII". As long as this is not fixed, return the suffix + of the locale name from the environment variables (if present) or + the codepage as a number. */ + if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) + { + const char *locale; + static char buf[2 + 10 + 1]; + + locale = getenv ("LC_ALL"); + if (locale == NULL || locale[0] == '\0') + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + } + if (locale != NULL && locale[0] != '\0') + { + /* If the locale name contains an encoding after the dot, return + it. */ + const char *dot = strchr (locale, '.'); + + if (dot != NULL) + { + const char *modifier; + + dot++; + /* Look for the possible @... trailer and remove it, if any. */ + modifier = strchr (dot, '@'); + if (modifier == NULL) + return dot; + if (modifier - dot < sizeof (buf)) + { + memcpy (buf, dot, modifier - dot); + buf [modifier - dot] = '\0'; + return buf; + } + } + } + + /* Woe32 has a function returning the locale's codepage as a number. */ + sprintf (buf, "CP%u", GetACP ()); + codeset = buf; + } +# endif + # else /* On old systems which lack it, use setlocale or getenv. */ @@ -300,7 +352,7 @@ locale_charset () (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't use setlocale here; it would return "C" when it doesn't support the locale name the user has set. */ -# if HAVE_SETLOCALE && 0 +# if 0 locale = setlocale (LC_CTYPE, NULL); # endif if (locale == NULL || locale[0] == '\0') @@ -321,7 +373,7 @@ locale_charset () # endif -#elif defined WIN32 +#elif defined WIN32_NATIVE static char buf[2 + 10 + 1]; diff --git a/intl/localealias.c b/intl/localealias.c index 7a092a0..26122a0 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -1,5 +1,5 @@ /* Handle aliases for locale names. - Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2001, 2003, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -81,11 +81,13 @@ char *alloca (); # endif # define HAVE_MEMPCPY 1 # define HAVE___FSETLOCKING 1 +#endif -/* We need locking here since we can be called from different places. */ +/* Handle multi-threaded applications. */ +#ifdef _LIBC # include <bits/libc-lock.h> - -__libc_lock_define_initialized (static, lock); +#else +# include "lock.h" #endif #ifndef internal_function @@ -120,6 +122,9 @@ __libc_lock_define_initialized (static, lock); #endif +__libc_lock_define_initialized (static, lock) + + struct alias_map { const char *alias; @@ -155,9 +160,7 @@ _nl_expand_alias (const char *name) const char *result = NULL; size_t added; -#ifdef _LIBC __libc_lock_lock (lock); -#endif if (locale_alias_path == NULL) locale_alias_path = LOCALE_ALIAS_PATH; @@ -204,9 +207,7 @@ _nl_expand_alias (const char *name) } while (added != 0); -#ifdef _LIBC __libc_lock_unlock (lock); -#endif return result; } @@ -230,7 +231,13 @@ read_alias_file (const char *fname, int fname_len) memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile); #endif +#ifdef _LIBC + /* Note the file is opened with cancellation in the I/O functions + disabled. */ + fp = fopen (relocate (full_fname), "rc"); +#else fp = fopen (relocate (full_fname), "r"); +#endif freea (full_fname); if (fp == NULL) return 0; @@ -254,11 +261,15 @@ read_alias_file (const char *fname, int fname_len) char *alias; char *value; char *cp; + int complete_line; if (FGETS (buf, sizeof buf, fp) == NULL) /* EOF reached. */ break; + /* Determine whether the line is complete. */ + complete_line = strchr (buf, '\n') != NULL; + cp = buf; /* Ignore leading white space. */ while (isspace ((unsigned char) cp[0])) @@ -280,9 +291,6 @@ read_alias_file (const char *fname, int fname_len) if (cp[0] != '\0') { - size_t alias_len; - size_t value_len; - value = cp++; while (cp[0] != '\0' && !isspace ((unsigned char) cp[0])) ++cp; @@ -298,60 +306,75 @@ read_alias_file (const char *fname, int fname_len) else if (cp[0] != '\0') *cp++ = '\0'; - if (nmap >= maxmap) - if (__builtin_expect (extend_alias_table (), 0)) - return added; +#ifdef IN_LIBGLOCALE + /* glibc's locale.alias contains entries for ja_JP and ko_KR + that make it impossible to use a Japanese or Korean UTF-8 + locale under the name "ja_JP" or "ko_KR". Ignore these + entries. */ + if (strchr (alias, '_') == NULL) +#endif + { + size_t alias_len; + size_t value_len; - alias_len = strlen (alias) + 1; - value_len = strlen (value) + 1; + if (nmap >= maxmap) + if (__builtin_expect (extend_alias_table (), 0)) + goto out; - if (string_space_act + alias_len + value_len > string_space_max) - { - /* Increase size of memory pool. */ - size_t new_size = (string_space_max - + (alias_len + value_len > 1024 - ? alias_len + value_len : 1024)); - char *new_pool = (char *) realloc (string_space, new_size); - if (new_pool == NULL) - return added; - - if (__builtin_expect (string_space != new_pool, 0)) - { - size_t i; + alias_len = strlen (alias) + 1; + value_len = strlen (value) + 1; - for (i = 0; i < nmap; i++) + if (string_space_act + alias_len + value_len > string_space_max) + { + /* Increase size of memory pool. */ + size_t new_size = (string_space_max + + (alias_len + value_len > 1024 + ? alias_len + value_len : 1024)); + char *new_pool = (char *) realloc (string_space, new_size); + if (new_pool == NULL) + goto out; + + if (__builtin_expect (string_space != new_pool, 0)) { - map[i].alias += new_pool - string_space; - map[i].value += new_pool - string_space; + size_t i; + + for (i = 0; i < nmap; i++) + { + map[i].alias += new_pool - string_space; + map[i].value += new_pool - string_space; + } } - } - string_space = new_pool; - string_space_max = new_size; - } + string_space = new_pool; + string_space_max = new_size; + } - map[nmap].alias = memcpy (&string_space[string_space_act], - alias, alias_len); - string_space_act += alias_len; + map[nmap].alias = memcpy (&string_space[string_space_act], + alias, alias_len); + string_space_act += alias_len; - map[nmap].value = memcpy (&string_space[string_space_act], - value, value_len); - string_space_act += value_len; + map[nmap].value = memcpy (&string_space[string_space_act], + value, value_len); + string_space_act += value_len; - ++nmap; - ++added; + ++nmap; + ++added; + } } } /* Possibly not the whole line fits into the buffer. Ignore the rest of the line. */ - while (strchr (buf, '\n') == NULL) - if (FGETS (buf, sizeof buf, fp) == NULL) - /* Make sure the inner loop will be left. The outer loop - will exit at the `feof' test. */ - break; + if (! complete_line) + do + if (FGETS (buf, sizeof buf, fp) == NULL) + /* Make sure the inner loop will be left. The outer loop + will exit at the `feof' test. */ + break; + while (strchr (buf, '\n') == NULL); } + out: /* Should we test for ferror()? I think we have to silently ignore errors. --drepper */ fclose (fp); diff --git a/intl/localename.c b/intl/localename.c index b855ace..e1b4615 100644 --- a/intl/localename.c +++ b/intl/localename.c @@ -1,5 +1,5 @@ /* Determine the current selected locale. - Copyright (C) 1995-1999, 2000-2005 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -29,20 +29,19 @@ #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE # include <string.h> -# include <CFString.h> +# include <CoreFoundation/CFString.h> # if HAVE_CFLOCALECOPYCURRENT -# include <CFLocale.h> +# include <CoreFoundation/CFLocale.h> # elif HAVE_CFPREFERENCESCOPYAPPVALUE -# include <CFPreferences.h> +# include <CoreFoundation/CFPreferences.h> # endif #endif #if defined _WIN32 || defined __WIN32__ -# undef WIN32 /* avoid warning on mingw32 */ -# define WIN32 +# define WIN32_NATIVE #endif -#ifdef WIN32 +#ifdef WIN32_NATIVE # define WIN32_LEAN_AND_MEAN # include <windows.h> /* List of language codes, sorted by value: @@ -974,12 +973,12 @@ _nl_locale_name_canonicalize (char *name) However it does not specify the exact format. Neither do SUSV2 and ISO C 99. So we can use this feature only on selected systems (e.g. those using GNU C Library). */ -#if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2) +#if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2) # define HAVE_LOCALE_NULL #endif /* Determine the current locale's name, and canonicalize it into XPG syntax - language[_territory[.codeset]][@modifier] + language[_territory][.codeset][@modifier] The codeset part in the result is not reliable; the locale_charset() should be used for codeset information instead. The result must not be freed; it is statically allocated. */ @@ -1023,7 +1022,7 @@ _nl_locale_name_default (void) locale, customizing it for each location. POSIX:2001 does not require such a facility. */ -#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined(WIN32)) +#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined(WIN32_NATIVE)) /* The system does not have a way of setting the locale, other than the POSIX specified environment variables. We use C as default locale. */ @@ -1077,7 +1076,7 @@ _nl_locale_name_default (void) # endif -# if defined(WIN32) /* WIN32 */ +# if defined(WIN32_NATIVE) /* WIN32, not Cygwin */ { LCID lcid; LANGID langid; diff --git a/intl/lock.c b/intl/lock.c new file mode 100644 index 0000000..f60a8d9 --- /dev/null +++ b/intl/lock.c @@ -0,0 +1,922 @@ +/* Locking in multithreaded situations. + Copyright (C) 2005-2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, + gthr-win32.h. */ + +#include <config.h> + +#include "lock.h" + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The function to be executed by a dummy thread. */ +static void * +dummy_thread_func (void *arg) +{ + return arg; +} + +int +glthread_in_use (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_t thread; + + if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) + /* Thread creation failed. */ + result = 0; + else + { + /* Thread creation works. */ + void *retval; + if (pthread_join (thread, &retval) != 0) + abort (); + result = 1; + } + tested = 1; + } + return result; +} + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +# if HAVE_PTHREAD_RWLOCK + +# if !defined PTHREAD_RWLOCK_INITIALIZER + +void +glthread_rwlock_init (gl_rwlock_t *lock) +{ + if (pthread_rwlock_init (&lock->rwlock, NULL) != 0) + abort (); + lock->initialized = 1; +} + +void +glthread_rwlock_rdlock (gl_rwlock_t *lock) +{ + if (!lock->initialized) + { + if (pthread_mutex_lock (&lock->guard) != 0) + abort (); + if (!lock->initialized) + glthread_rwlock_init (lock); + if (pthread_mutex_unlock (&lock->guard) != 0) + abort (); + } + if (pthread_rwlock_rdlock (&lock->rwlock) != 0) + abort (); +} + +void +glthread_rwlock_wrlock (gl_rwlock_t *lock) +{ + if (!lock->initialized) + { + if (pthread_mutex_lock (&lock->guard) != 0) + abort (); + if (!lock->initialized) + glthread_rwlock_init (lock); + if (pthread_mutex_unlock (&lock->guard) != 0) + abort (); + } + if (pthread_rwlock_wrlock (&lock->rwlock) != 0) + abort (); +} + +void +glthread_rwlock_unlock (gl_rwlock_t *lock) +{ + if (!lock->initialized) + abort (); + if (pthread_rwlock_unlock (&lock->rwlock) != 0) + abort (); +} + +void +glthread_rwlock_destroy (gl_rwlock_t *lock) +{ + if (!lock->initialized) + abort (); + if (pthread_rwlock_destroy (&lock->rwlock) != 0) + abort (); + lock->initialized = 0; +} + +# endif + +# else + +void +glthread_rwlock_init (gl_rwlock_t *lock) +{ + if (pthread_mutex_init (&lock->lock, NULL) != 0) + abort (); + if (pthread_cond_init (&lock->waiting_readers, NULL) != 0) + abort (); + if (pthread_cond_init (&lock->waiting_writers, NULL) != 0) + abort (); + lock->waiting_writers_count = 0; + lock->runcount = 0; +} + +void +glthread_rwlock_rdlock (gl_rwlock_t *lock) +{ + if (pthread_mutex_lock (&lock->lock) != 0) + abort (); + /* Test whether only readers are currently running, and whether the runcount + field will not overflow. */ + /* POSIX says: "It is implementation-defined whether the calling thread + acquires the lock when a writer does not hold the lock and there are + writers blocked on the lock." Let's say, no: give the writers a higher + priority. */ + while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + if (pthread_cond_wait (&lock->waiting_readers, &lock->lock) != 0) + abort (); + } + lock->runcount++; + if (pthread_mutex_unlock (&lock->lock) != 0) + abort (); +} + +void +glthread_rwlock_wrlock (gl_rwlock_t *lock) +{ + if (pthread_mutex_lock (&lock->lock) != 0) + abort (); + /* Test whether no readers or writers are currently running. */ + while (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + lock->waiting_writers_count++; + if (pthread_cond_wait (&lock->waiting_writers, &lock->lock) != 0) + abort (); + lock->waiting_writers_count--; + } + lock->runcount--; /* runcount becomes -1 */ + if (pthread_mutex_unlock (&lock->lock) != 0) + abort (); +} + +void +glthread_rwlock_unlock (gl_rwlock_t *lock) +{ + if (pthread_mutex_lock (&lock->lock) != 0) + abort (); + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + abort (); + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + abort (); + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers_count > 0) + { + /* Wake up one of the waiting writers. */ + if (pthread_cond_signal (&lock->waiting_writers) != 0) + abort (); + } + else + { + /* Wake up all waiting readers. */ + if (pthread_cond_broadcast (&lock->waiting_readers) != 0) + abort (); + } + } + if (pthread_mutex_unlock (&lock->lock) != 0) + abort (); +} + +void +glthread_rwlock_destroy (gl_rwlock_t *lock) +{ + if (pthread_mutex_destroy (&lock->lock) != 0) + abort (); + if (pthread_cond_destroy (&lock->waiting_readers) != 0) + abort (); + if (pthread_cond_destroy (&lock->waiting_writers) != 0) + abort (); +} + +# endif + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +# if HAVE_PTHREAD_MUTEX_RECURSIVE + +# if !(defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) + +void +glthread_recursive_lock_init (gl_recursive_lock_t *lock) +{ + pthread_mutexattr_t attributes; + + if (pthread_mutexattr_init (&attributes) != 0) + abort (); + if (pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE) != 0) + abort (); + if (pthread_mutex_init (&lock->recmutex, &attributes) != 0) + abort (); + if (pthread_mutexattr_destroy (&attributes) != 0) + abort (); + lock->initialized = 1; +} + +void +glthread_recursive_lock_lock (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + { + if (pthread_mutex_lock (&lock->guard) != 0) + abort (); + if (!lock->initialized) + glthread_recursive_lock_init (lock); + if (pthread_mutex_unlock (&lock->guard) != 0) + abort (); + } + if (pthread_mutex_lock (&lock->recmutex) != 0) + abort (); +} + +void +glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + abort (); + if (pthread_mutex_unlock (&lock->recmutex) != 0) + abort (); +} + +void +glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + abort (); + if (pthread_mutex_destroy (&lock->recmutex) != 0) + abort (); + lock->initialized = 0; +} + +# endif + +# else + +void +glthread_recursive_lock_init (gl_recursive_lock_t *lock) +{ + if (pthread_mutex_init (&lock->mutex, NULL) != 0) + abort (); + lock->owner = (pthread_t) 0; + lock->depth = 0; +} + +void +glthread_recursive_lock_lock (gl_recursive_lock_t *lock) +{ + pthread_t self = pthread_self (); + if (lock->owner != self) + { + if (pthread_mutex_lock (&lock->mutex) != 0) + abort (); + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + abort (); +} + +void +glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) +{ + if (lock->owner != pthread_self ()) + abort (); + if (lock->depth == 0) + abort (); + if (--(lock->depth) == 0) + { + lock->owner = (pthread_t) 0; + if (pthread_mutex_unlock (&lock->mutex) != 0) + abort (); + } +} + +void +glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) +{ + if (lock->owner != (pthread_t) 0) + abort (); + if (pthread_mutex_destroy (&lock->mutex) != 0) + abort (); +} + +# endif + +/* -------------------------- gl_once_t datatype -------------------------- */ + +static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; + +int +glthread_once_singlethreaded (pthread_once_t *once_control) +{ + /* We don't know whether pthread_once_t is an integer type, a floating-point + type, a pointer type, or a structure type. */ + char *firstbyte = (char *)once_control; + if (*firstbyte == *(const char *)&fresh_once) + { + /* First time use of once_control. Invert the first byte. */ + *firstbyte = ~ *(const char *)&fresh_once; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_PTH_THREADS + +/* Use the GNU Pth threads library. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* -------------------------- gl_once_t datatype -------------------------- */ + +void +glthread_once_call (void *arg) +{ + void (**gl_once_temp_addr) (void) = (void (**) (void)) arg; + void (*initfunction) (void) = *gl_once_temp_addr; + initfunction (); +} + +int +glthread_once_singlethreaded (pth_once_t *once_control) +{ + /* We know that pth_once_t is an integer type. */ + if (*once_control == PTH_ONCE_INIT) + { + /* First time use of once_control. Invert the marker. */ + *once_control = ~ PTH_ONCE_INIT; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_SOLARIS_THREADS + +/* Use the old Solaris threads library. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +void +glthread_recursive_lock_init (gl_recursive_lock_t *lock) +{ + if (mutex_init (&lock->mutex, USYNC_THREAD, NULL) != 0) + abort (); + lock->owner = (thread_t) 0; + lock->depth = 0; +} + +void +glthread_recursive_lock_lock (gl_recursive_lock_t *lock) +{ + thread_t self = thr_self (); + if (lock->owner != self) + { + if (mutex_lock (&lock->mutex) != 0) + abort (); + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + abort (); +} + +void +glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) +{ + if (lock->owner != thr_self ()) + abort (); + if (lock->depth == 0) + abort (); + if (--(lock->depth) == 0) + { + lock->owner = (thread_t) 0; + if (mutex_unlock (&lock->mutex) != 0) + abort (); + } +} + +void +glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) +{ + if (lock->owner != (thread_t) 0) + abort (); + if (mutex_destroy (&lock->mutex) != 0) + abort (); +} + +/* -------------------------- gl_once_t datatype -------------------------- */ + +void +glthread_once (gl_once_t *once_control, void (*initfunction) (void)) +{ + if (!once_control->inited) + { + /* Use the mutex to guarantee that if another thread is already calling + the initfunction, this thread waits until it's finished. */ + if (mutex_lock (&once_control->mutex) != 0) + abort (); + if (!once_control->inited) + { + once_control->inited = 1; + initfunction (); + } + if (mutex_unlock (&once_control->mutex) != 0) + abort (); + } +} + +int +glthread_once_singlethreaded (gl_once_t *once_control) +{ + /* We know that gl_once_t contains an integer type. */ + if (!once_control->inited) + { + /* First time use of once_control. Invert the marker. */ + once_control->inited = ~ 0; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_WIN32_THREADS + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +void +glthread_lock_init (gl_lock_t *lock) +{ + InitializeCriticalSection (&lock->lock); + lock->guard.done = 1; +} + +void +glthread_lock_lock (gl_lock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_lock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + EnterCriticalSection (&lock->lock); +} + +void +glthread_lock_unlock (gl_lock_t *lock) +{ + if (!lock->guard.done) + abort (); + LeaveCriticalSection (&lock->lock); +} + +void +glthread_lock_destroy (gl_lock_t *lock) +{ + if (!lock->guard.done) + abort (); + DeleteCriticalSection (&lock->lock); + lock->guard.done = 0; +} + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +static inline void +gl_waitqueue_init (gl_waitqueue_t *wq) +{ + wq->array = NULL; + wq->count = 0; + wq->alloc = 0; + wq->offset = 0; +} + +/* Enqueues the current thread, represented by an event, in a wait queue. + Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ +static HANDLE +gl_waitqueue_add (gl_waitqueue_t *wq) +{ + HANDLE event; + unsigned int index; + + if (wq->count == wq->alloc) + { + unsigned int new_alloc = 2 * wq->alloc + 1; + HANDLE *new_array = + (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); + if (new_array == NULL) + /* No more memory. */ + return INVALID_HANDLE_VALUE; + /* Now is a good opportunity to rotate the array so that its contents + starts at offset 0. */ + if (wq->offset > 0) + { + unsigned int old_count = wq->count; + unsigned int old_alloc = wq->alloc; + unsigned int old_offset = wq->offset; + unsigned int i; + if (old_offset + old_count > old_alloc) + { + unsigned int limit = old_offset + old_count - old_alloc; + for (i = 0; i < limit; i++) + new_array[old_alloc + i] = new_array[i]; + } + for (i = 0; i < old_count; i++) + new_array[i] = new_array[old_offset + i]; + wq->offset = 0; + } + wq->array = new_array; + wq->alloc = new_alloc; + } + event = CreateEvent (NULL, TRUE, FALSE, NULL); + if (event == INVALID_HANDLE_VALUE) + /* No way to allocate an event. */ + return INVALID_HANDLE_VALUE; + index = wq->offset + wq->count; + if (index >= wq->alloc) + index -= wq->alloc; + wq->array[index] = event; + wq->count++; + return event; +} + +/* Notifies the first thread from a wait queue and dequeues it. */ +static inline void +gl_waitqueue_notify_first (gl_waitqueue_t *wq) +{ + SetEvent (wq->array[wq->offset + 0]); + wq->offset++; + wq->count--; + if (wq->count == 0 || wq->offset == wq->alloc) + wq->offset = 0; +} + +/* Notifies all threads from a wait queue and dequeues them all. */ +static inline void +gl_waitqueue_notify_all (gl_waitqueue_t *wq) +{ + unsigned int i; + + for (i = 0; i < wq->count; i++) + { + unsigned int index = wq->offset + i; + if (index >= wq->alloc) + index -= wq->alloc; + SetEvent (wq->array[index]); + } + wq->count = 0; + wq->offset = 0; +} + +void +glthread_rwlock_init (gl_rwlock_t *lock) +{ + InitializeCriticalSection (&lock->lock); + gl_waitqueue_init (&lock->waiting_readers); + gl_waitqueue_init (&lock->waiting_writers); + lock->runcount = 0; + lock->guard.done = 1; +} + +void +glthread_rwlock_rdlock (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_rwlock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + EnterCriticalSection (&lock->lock); + /* Test whether only readers are currently running, and whether the runcount + field will not overflow. */ + if (!(lock->runcount + 1 > 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + HANDLE event = gl_waitqueue_add (&lock->waiting_readers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_readers, incremented lock->runcount. */ + if (!(lock->runcount > 0)) + abort (); + return; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount + 1 > 0)); + } + } + lock->runcount++; + LeaveCriticalSection (&lock->lock); +} + +void +glthread_rwlock_wrlock (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_rwlock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + EnterCriticalSection (&lock->lock); + /* Test whether no readers or writers are currently running. */ + if (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + HANDLE event = gl_waitqueue_add (&lock->waiting_writers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_writers, set lock->runcount = -1. */ + if (!(lock->runcount == -1)) + abort (); + return; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount == 0)); + } + } + lock->runcount--; /* runcount becomes -1 */ + LeaveCriticalSection (&lock->lock); +} + +void +glthread_rwlock_unlock (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + abort (); + EnterCriticalSection (&lock->lock); + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + abort (); + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + abort (); + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers.count > 0) + { + /* Wake up one of the waiting writers. */ + lock->runcount--; + gl_waitqueue_notify_first (&lock->waiting_writers); + } + else + { + /* Wake up all waiting readers. */ + lock->runcount += lock->waiting_readers.count; + gl_waitqueue_notify_all (&lock->waiting_readers); + } + } + LeaveCriticalSection (&lock->lock); +} + +void +glthread_rwlock_destroy (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + abort (); + if (lock->runcount != 0) + abort (); + DeleteCriticalSection (&lock->lock); + if (lock->waiting_readers.array != NULL) + free (lock->waiting_readers.array); + if (lock->waiting_writers.array != NULL) + free (lock->waiting_writers.array); + lock->guard.done = 0; +} + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +void +glthread_recursive_lock_init (gl_recursive_lock_t *lock) +{ + lock->owner = 0; + lock->depth = 0; + InitializeCriticalSection (&lock->lock); + lock->guard.done = 1; +} + +void +glthread_recursive_lock_lock (gl_recursive_lock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_recursive_lock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + { + DWORD self = GetCurrentThreadId (); + if (lock->owner != self) + { + EnterCriticalSection (&lock->lock); + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + abort (); + } +} + +void +glthread_recursive_lock_unlock (gl_recursive_lock_t *lock) +{ + if (lock->owner != GetCurrentThreadId ()) + abort (); + if (lock->depth == 0) + abort (); + if (--(lock->depth) == 0) + { + lock->owner = 0; + LeaveCriticalSection (&lock->lock); + } +} + +void +glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) +{ + if (lock->owner != 0) + abort (); + DeleteCriticalSection (&lock->lock); + lock->guard.done = 0; +} + +/* -------------------------- gl_once_t datatype -------------------------- */ + +void +glthread_once (gl_once_t *once_control, void (*initfunction) (void)) +{ + if (once_control->inited <= 0) + { + if (InterlockedIncrement (&once_control->started) == 0) + { + /* This thread is the first one to come to this once_control. */ + InitializeCriticalSection (&once_control->lock); + EnterCriticalSection (&once_control->lock); + once_control->inited = 0; + initfunction (); + once_control->inited = 1; + LeaveCriticalSection (&once_control->lock); + } + else + { + /* Undo last operation. */ + InterlockedDecrement (&once_control->started); + /* Some other thread has already started the initialization. + Yield the CPU while waiting for the other thread to finish + initializing and taking the lock. */ + while (once_control->inited < 0) + Sleep (0); + if (once_control->inited <= 0) + { + /* Take the lock. This blocks until the other thread has + finished calling the initfunction. */ + EnterCriticalSection (&once_control->lock); + LeaveCriticalSection (&once_control->lock); + if (!(once_control->inited > 0)) + abort (); + } + } + } +} + +#endif + +/* ========================================================================= */ diff --git a/intl/lock.h b/intl/lock.h new file mode 100644 index 0000000..04d1369 --- /dev/null +++ b/intl/lock.h @@ -0,0 +1,833 @@ +/* Locking in multithreaded situations. + Copyright (C) 2005-2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, + gthr-win32.h. */ + +/* This file contains locking primitives for use with a given thread library. + It does not contain primitives for creating threads or for other + synchronization primitives. + + Normal (non-recursive) locks: + Type: gl_lock_t + Declaration: gl_lock_define(extern, name) + Initializer: gl_lock_define_initialized(, name) + Initialization: gl_lock_init (name); + Taking the lock: gl_lock_lock (name); + Releasing the lock: gl_lock_unlock (name); + De-initialization: gl_lock_destroy (name); + + Read-Write (non-recursive) locks: + Type: gl_rwlock_t + Declaration: gl_rwlock_define(extern, name) + Initializer: gl_rwlock_define_initialized(, name) + Initialization: gl_rwlock_init (name); + Taking the lock: gl_rwlock_rdlock (name); + gl_rwlock_wrlock (name); + Releasing the lock: gl_rwlock_unlock (name); + De-initialization: gl_rwlock_destroy (name); + + Recursive locks: + Type: gl_recursive_lock_t + Declaration: gl_recursive_lock_define(extern, name) + Initializer: gl_recursive_lock_define_initialized(, name) + Initialization: gl_recursive_lock_init (name); + Taking the lock: gl_recursive_lock_lock (name); + Releasing the lock: gl_recursive_lock_unlock (name); + De-initialization: gl_recursive_lock_destroy (name); + + Once-only execution: + Type: gl_once_t + Initializer: gl_once_define(extern, name) + Execution: gl_once (name, initfunction); +*/ + + +#ifndef _LOCK_H +#define _LOCK_H + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include <pthread.h> +# include <stdlib.h> + +# ifdef __cplusplus +extern "C" { +# endif + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The pthread_in_use() detection needs to be done at runtime. */ +# define pthread_in_use() \ + glthread_in_use () +extern int glthread_in_use (void); + +# endif + +# if USE_POSIX_THREADS_WEAK + +/* Use weak references to the POSIX threads library. */ + +/* Weak references avoid dragging in external libraries if the other parts + of the program don't use them. Here we use them, because we don't want + every program that uses libintl to depend on libpthread. This assumes + that libpthread would not be loaded after libintl; i.e. if libintl is + loaded first, by an executable that does not depend on libpthread, and + then a module is dynamically loaded that depends on libpthread, libintl + will not be multithread-safe. */ + +/* The way to test at runtime whether libpthread is present is to test + whether a function pointer's value, such as &pthread_mutex_init, is + non-NULL. However, some versions of GCC have a bug through which, in + PIC mode, &foo != NULL always evaluates to true if there is a direct + call to foo(...) in the same function. To avoid this, we test the + address of a function in libpthread that we don't use. */ + +# pragma weak pthread_mutex_init +# pragma weak pthread_mutex_lock +# pragma weak pthread_mutex_unlock +# pragma weak pthread_mutex_destroy +# pragma weak pthread_rwlock_init +# pragma weak pthread_rwlock_rdlock +# pragma weak pthread_rwlock_wrlock +# pragma weak pthread_rwlock_unlock +# pragma weak pthread_rwlock_destroy +# pragma weak pthread_once +# pragma weak pthread_cond_init +# pragma weak pthread_cond_wait +# pragma weak pthread_cond_signal +# pragma weak pthread_cond_broadcast +# pragma weak pthread_cond_destroy +# pragma weak pthread_mutexattr_init +# pragma weak pthread_mutexattr_settype +# pragma weak pthread_mutexattr_destroy +# ifndef pthread_self +# pragma weak pthread_self +# endif + +# if !PTHREAD_IN_USE_DETECTION_HARD +# pragma weak pthread_cancel +# define pthread_in_use() (pthread_cancel != NULL) +# endif + +# else + +# if !PTHREAD_IN_USE_DETECTION_HARD +# define pthread_in_use() 1 +# endif + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef pthread_mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + PTHREAD_MUTEX_INITIALIZER +# define gl_lock_init(NAME) \ + if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort () +# define gl_lock_lock(NAME) \ + if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort () +# define gl_lock_unlock(NAME) \ + if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort () +# define gl_lock_destroy(NAME) \ + if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort () + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +# if HAVE_PTHREAD_RWLOCK + +# ifdef PTHREAD_RWLOCK_INITIALIZER + +typedef pthread_rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_INITIALIZER +# define gl_rwlock_init(NAME) \ + if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) abort () +# define gl_rwlock_rdlock(NAME) \ + if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) abort () +# define gl_rwlock_wrlock(NAME) \ + if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) abort () +# define gl_rwlock_unlock(NAME) \ + if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) abort () +# define gl_rwlock_destroy(NAME) \ + if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) abort () + +# else + +typedef struct + { + int initialized; + pthread_mutex_t guard; /* protects the initialization */ + pthread_rwlock_t rwlock; /* read-write lock */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { 0, PTHREAD_MUTEX_INITIALIZER } +# define gl_rwlock_init(NAME) \ + if (pthread_in_use ()) glthread_rwlock_init (&NAME) +# define gl_rwlock_rdlock(NAME) \ + if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME) +# define gl_rwlock_wrlock(NAME) \ + if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME) +# define gl_rwlock_unlock(NAME) \ + if (pthread_in_use ()) glthread_rwlock_unlock (&NAME) +# define gl_rwlock_destroy(NAME) \ + if (pthread_in_use ()) glthread_rwlock_destroy (&NAME) +extern void glthread_rwlock_init (gl_rwlock_t *lock); +extern void glthread_rwlock_rdlock (gl_rwlock_t *lock); +extern void glthread_rwlock_wrlock (gl_rwlock_t *lock); +extern void glthread_rwlock_unlock (gl_rwlock_t *lock); +extern void glthread_rwlock_destroy (gl_rwlock_t *lock); + +# endif + +# else + +typedef struct + { + pthread_mutex_t lock; /* protects the remaining fields */ + pthread_cond_t waiting_readers; /* waiting readers */ + pthread_cond_t waiting_writers; /* waiting writers */ + unsigned int waiting_writers_count; /* number of waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } +# define gl_rwlock_init(NAME) \ + if (pthread_in_use ()) glthread_rwlock_init (&NAME) +# define gl_rwlock_rdlock(NAME) \ + if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME) +# define gl_rwlock_wrlock(NAME) \ + if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME) +# define gl_rwlock_unlock(NAME) \ + if (pthread_in_use ()) glthread_rwlock_unlock (&NAME) +# define gl_rwlock_destroy(NAME) \ + if (pthread_in_use ()) glthread_rwlock_destroy (&NAME) +extern void glthread_rwlock_init (gl_rwlock_t *lock); +extern void glthread_rwlock_rdlock (gl_rwlock_t *lock); +extern void glthread_rwlock_wrlock (gl_rwlock_t *lock); +extern void glthread_rwlock_unlock (gl_rwlock_t *lock); +extern void glthread_rwlock_destroy (gl_rwlock_t *lock); + +# endif + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +# if HAVE_PTHREAD_MUTEX_RECURSIVE + +# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +typedef pthread_mutex_t gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; +# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER +# define gl_recursive_lock_initializer \ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER +# else +# define gl_recursive_lock_initializer \ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +# endif +# define gl_recursive_lock_init(NAME) \ + if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort () +# define gl_recursive_lock_lock(NAME) \ + if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort () +# define gl_recursive_lock_unlock(NAME) \ + if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort () +# define gl_recursive_lock_destroy(NAME) \ + if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort () + +# else + +typedef struct + { + pthread_mutex_t recmutex; /* recursive mutex */ + pthread_mutex_t guard; /* protects the initialization */ + int initialized; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } +# define gl_recursive_lock_init(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_init (&NAME) +# define gl_recursive_lock_lock(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME) +# define gl_recursive_lock_unlock(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME) +# define gl_recursive_lock_destroy(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME) +extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); + +# endif + +# else + +/* Old versions of POSIX threads on Solaris did not have recursive locks. + We have to implement them ourselves. */ + +typedef struct + { + pthread_mutex_t mutex; + pthread_t owner; + unsigned long depth; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } +# define gl_recursive_lock_init(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_init (&NAME) +# define gl_recursive_lock_lock(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME) +# define gl_recursive_lock_unlock(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME) +# define gl_recursive_lock_destroy(NAME) \ + if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME) +extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); + +# endif + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef pthread_once_t gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; +# define gl_once(NAME, INITFUNCTION) \ + do \ + { \ + if (pthread_in_use ()) \ + { \ + if (pthread_once (&NAME, INITFUNCTION) != 0) \ + abort (); \ + } \ + else \ + { \ + if (glthread_once_singlethreaded (&NAME)) \ + INITFUNCTION (); \ + } \ + } \ + while (0) +extern int glthread_once_singlethreaded (pthread_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_PTH_THREADS + +/* Use the GNU Pth threads library. */ + +# include <pth.h> +# include <stdlib.h> + +# ifdef __cplusplus +extern "C" { +# endif + +# if USE_PTH_THREADS_WEAK + +/* Use weak references to the GNU Pth threads library. */ + +# pragma weak pth_mutex_init +# pragma weak pth_mutex_acquire +# pragma weak pth_mutex_release +# pragma weak pth_rwlock_init +# pragma weak pth_rwlock_acquire +# pragma weak pth_rwlock_release +# pragma weak pth_once + +# pragma weak pth_cancel +# define pth_in_use() (pth_cancel != NULL) + +# else + +# define pth_in_use() 1 + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef pth_mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + PTH_MUTEX_INIT +# define gl_lock_init(NAME) \ + if (pth_in_use() && !pth_mutex_init (&NAME)) abort () +# define gl_lock_lock(NAME) \ + if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort () +# define gl_lock_unlock(NAME) \ + if (pth_in_use() && !pth_mutex_release (&NAME)) abort () +# define gl_lock_destroy(NAME) \ + (void)(&NAME) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef pth_rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + PTH_RWLOCK_INIT +# define gl_rwlock_init(NAME) \ + if (pth_in_use() && !pth_rwlock_init (&NAME)) abort () +# define gl_rwlock_rdlock(NAME) \ + if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) abort () +# define gl_rwlock_wrlock(NAME) \ + if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) abort () +# define gl_rwlock_unlock(NAME) \ + if (pth_in_use() && !pth_rwlock_release (&NAME)) abort () +# define gl_rwlock_destroy(NAME) \ + (void)(&NAME) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* In Pth, mutexes are recursive by default. */ +typedef pth_mutex_t gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + PTH_MUTEX_INIT +# define gl_recursive_lock_init(NAME) \ + if (pth_in_use() && !pth_mutex_init (&NAME)) abort () +# define gl_recursive_lock_lock(NAME) \ + if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort () +# define gl_recursive_lock_unlock(NAME) \ + if (pth_in_use() && !pth_mutex_release (&NAME)) abort () +# define gl_recursive_lock_destroy(NAME) \ + (void)(&NAME) + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef pth_once_t gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; +# define gl_once(NAME, INITFUNCTION) \ + do \ + { \ + if (pth_in_use ()) \ + { \ + void (*gl_once_temp) (void) = INITFUNCTION; \ + if (!pth_once (&NAME, glthread_once_call, &gl_once_temp)) \ + abort (); \ + } \ + else \ + { \ + if (glthread_once_singlethreaded (&NAME)) \ + INITFUNCTION (); \ + } \ + } \ + while (0) +extern void glthread_once_call (void *arg); +extern int glthread_once_singlethreaded (pth_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_SOLARIS_THREADS + +/* Use the old Solaris threads library. */ + +# include <thread.h> +# include <synch.h> +# include <stdlib.h> + +# ifdef __cplusplus +extern "C" { +# endif + +# if USE_SOLARIS_THREADS_WEAK + +/* Use weak references to the old Solaris threads library. */ + +# pragma weak mutex_init +# pragma weak mutex_lock +# pragma weak mutex_unlock +# pragma weak mutex_destroy +# pragma weak rwlock_init +# pragma weak rw_rdlock +# pragma weak rw_wrlock +# pragma weak rw_unlock +# pragma weak rwlock_destroy +# pragma weak thr_self + +# pragma weak thr_suspend +# define thread_in_use() (thr_suspend != NULL) + +# else + +# define thread_in_use() 1 + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + DEFAULTMUTEX +# define gl_lock_init(NAME) \ + if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) abort () +# define gl_lock_lock(NAME) \ + if (thread_in_use () && mutex_lock (&NAME) != 0) abort () +# define gl_lock_unlock(NAME) \ + if (thread_in_use () && mutex_unlock (&NAME) != 0) abort () +# define gl_lock_destroy(NAME) \ + if (thread_in_use () && mutex_destroy (&NAME) != 0) abort () + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + DEFAULTRWLOCK +# define gl_rwlock_init(NAME) \ + if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0) abort () +# define gl_rwlock_rdlock(NAME) \ + if (thread_in_use () && rw_rdlock (&NAME) != 0) abort () +# define gl_rwlock_wrlock(NAME) \ + if (thread_in_use () && rw_wrlock (&NAME) != 0) abort () +# define gl_rwlock_unlock(NAME) \ + if (thread_in_use () && rw_unlock (&NAME) != 0) abort () +# define gl_rwlock_destroy(NAME) \ + if (thread_in_use () && rwlock_destroy (&NAME) != 0) abort () + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* Old Solaris threads did not have recursive locks. + We have to implement them ourselves. */ + +typedef struct + { + mutex_t mutex; + thread_t owner; + unsigned long depth; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { DEFAULTMUTEX, (thread_t) 0, 0 } +# define gl_recursive_lock_init(NAME) \ + if (thread_in_use ()) glthread_recursive_lock_init (&NAME) +# define gl_recursive_lock_lock(NAME) \ + if (thread_in_use ()) glthread_recursive_lock_lock (&NAME) +# define gl_recursive_lock_unlock(NAME) \ + if (thread_in_use ()) glthread_recursive_lock_unlock (&NAME) +# define gl_recursive_lock_destroy(NAME) \ + if (thread_in_use ()) glthread_recursive_lock_destroy (&NAME) +extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef struct + { + volatile int inited; + mutex_t mutex; + } + gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX }; +# define gl_once(NAME, INITFUNCTION) \ + do \ + { \ + if (thread_in_use ()) \ + { \ + glthread_once (&NAME, INITFUNCTION); \ + } \ + else \ + { \ + if (glthread_once_singlethreaded (&NAME)) \ + INITFUNCTION (); \ + } \ + } \ + while (0) +extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void)); +extern int glthread_once_singlethreaded (gl_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WIN32_THREADS + +# include <windows.h> + +# ifdef __cplusplus +extern "C" { +# endif + +/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex, + Semaphore types, because + - we need only to synchronize inside a single process (address space), + not inter-process locking, + - we don't need to support trylock operations. (TryEnterCriticalSection + does not work on Windows 95/98/ME. Packages that need trylock usually + define their own mutex type.) */ + +/* There is no way to statically initialize a CRITICAL_SECTION. It needs + to be done lazily, once only. For this we need spinlocks. */ + +typedef struct { volatile int done; volatile long started; } gl_spinlock_t; + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef struct + { + gl_spinlock_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; + } + gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + { { 0, -1 } } +# define gl_lock_init(NAME) \ + glthread_lock_init (&NAME) +# define gl_lock_lock(NAME) \ + glthread_lock_lock (&NAME) +# define gl_lock_unlock(NAME) \ + glthread_lock_unlock (&NAME) +# define gl_lock_destroy(NAME) \ + glthread_lock_destroy (&NAME) +extern void glthread_lock_init (gl_lock_t *lock); +extern void glthread_lock_lock (gl_lock_t *lock); +extern void glthread_lock_unlock (gl_lock_t *lock); +extern void glthread_lock_destroy (gl_lock_t *lock); + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* It is impossible to implement read-write locks using plain locks, without + introducing an extra thread dedicated to managing read-write locks. + Therefore here we need to use the low-level Event type. */ + +typedef struct + { + HANDLE *array; /* array of waiting threads, each represented by an event */ + unsigned int count; /* number of waiting threads */ + unsigned int alloc; /* length of allocated array */ + unsigned int offset; /* index of first waiting thread in array */ + } + gl_waitqueue_t; +typedef struct + { + gl_spinlock_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; /* protects the remaining fields */ + gl_waitqueue_t waiting_readers; /* waiting readers */ + gl_waitqueue_t waiting_writers; /* waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { { 0, -1 } } +# define gl_rwlock_init(NAME) \ + glthread_rwlock_init (&NAME) +# define gl_rwlock_rdlock(NAME) \ + glthread_rwlock_rdlock (&NAME) +# define gl_rwlock_wrlock(NAME) \ + glthread_rwlock_wrlock (&NAME) +# define gl_rwlock_unlock(NAME) \ + glthread_rwlock_unlock (&NAME) +# define gl_rwlock_destroy(NAME) \ + glthread_rwlock_destroy (&NAME) +extern void glthread_rwlock_init (gl_rwlock_t *lock); +extern void glthread_rwlock_rdlock (gl_rwlock_t *lock); +extern void glthread_rwlock_wrlock (gl_rwlock_t *lock); +extern void glthread_rwlock_unlock (gl_rwlock_t *lock); +extern void glthread_rwlock_destroy (gl_rwlock_t *lock); + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* The Win32 documentation says that CRITICAL_SECTION already implements a + recursive lock. But we need not rely on it: It's easy to implement a + recursive lock without this assumption. */ + +typedef struct + { + gl_spinlock_t guard; /* protects the initialization */ + DWORD owner; + unsigned long depth; + CRITICAL_SECTION lock; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { { 0, -1 }, 0, 0 } +# define gl_recursive_lock_init(NAME) \ + glthread_recursive_lock_init (&NAME) +# define gl_recursive_lock_lock(NAME) \ + glthread_recursive_lock_lock (&NAME) +# define gl_recursive_lock_unlock(NAME) \ + glthread_recursive_lock_unlock (&NAME) +# define gl_recursive_lock_destroy(NAME) \ + glthread_recursive_lock_destroy (&NAME) +extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); +extern void glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef struct + { + volatile int inited; + volatile long started; + CRITICAL_SECTION lock; + } + gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = { -1, -1 }; +# define gl_once(NAME, INITFUNCTION) \ + glthread_once (&NAME, INITFUNCTION) +extern void glthread_once (gl_once_t *once_control, void (*initfunction) (void)); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef int gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) +# define gl_lock_define_initialized(STORAGECLASS, NAME) +# define gl_lock_init(NAME) +# define gl_lock_lock(NAME) +# define gl_lock_unlock(NAME) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef int gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) +# define gl_rwlock_init(NAME) +# define gl_rwlock_rdlock(NAME) +# define gl_rwlock_wrlock(NAME) +# define gl_rwlock_unlock(NAME) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +typedef int gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) +# define gl_recursive_lock_init(NAME) +# define gl_recursive_lock_lock(NAME) +# define gl_recursive_lock_unlock(NAME) + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef int gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = 0; +# define gl_once(NAME, INITFUNCTION) \ + do \ + { \ + if (NAME == 0) \ + { \ + NAME = ~ 0; \ + INITFUNCTION (); \ + } \ + } \ + while (0) + +#endif + +/* ========================================================================= */ + +#endif /* _LOCK_H */ @@ -1,5 +1,5 @@ /* Log file output. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -26,6 +26,13 @@ #include <stdlib.h> #include <string.h> +/* Handle multi-threaded applications. */ +#ifdef _LIBC +# include <bits/libc-lock.h> +#else +# include "lock.h" +#endif + /* Print an ASCII string with quotes and escape sequences where needed. */ static void print_escaped (FILE *stream, const char *str) @@ -48,13 +55,14 @@ print_escaped (FILE *stream, const char *str) putc ('"', stream); } -/* Add to the log file an entry denoting a failed translation. */ -void -_nl_log_untranslated (const char *logfilename, const char *domainname, - const char *msgid1, const char *msgid2, int plural) +static char *last_logfilename = NULL; +static FILE *last_logfile = NULL; +__libc_lock_define_initialized (static, lock) + +static inline void +_nl_log_untranslated_locked (const char *logfilename, const char *domainname, + const char *msgid1, const char *msgid2, int plural) { - static char *last_logfilename = NULL; - static FILE *last_logfile = NULL; FILE *logfile; /* Can we reuse the last opened logfile? */ @@ -96,3 +104,13 @@ _nl_log_untranslated (const char *logfilename, const char *domainname, fprintf (logfile, "\nmsgstr \"\"\n"); putc ('\n', logfile); } + +/* Add to the log file an entry denoting a failed translation. */ +void +_nl_log_untranslated (const char *logfilename, const char *domainname, + const char *msgid1, const char *msgid2, int plural) +{ + __libc_lock_lock (lock); + _nl_log_untranslated_locked (logfilename, domainname, msgid1, msgid2, plural); + __libc_lock_unlock (lock); +} diff --git a/intl/osdep.c b/intl/osdep.c index d2d8575..3cc35c0 100644 --- a/intl/osdep.c +++ b/intl/osdep.c @@ -1,5 +1,5 @@ /* OS dependent parts of libintl. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -16,7 +16,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined __EMX__ +#if defined __CYGWIN__ +# include "intl-exports.c" +#elif defined __EMX__ # include "os2compat.c" #else /* Avoid AIX compiler warning. */ diff --git a/intl/plural-exp.c b/intl/plural-exp.c index 1873be9..f518bf1 100644 --- a/intl/plural-exp.c +++ b/intl/plural-exp.c @@ -1,5 +1,5 @@ /* Expression parsing for plural form selection. - Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc. + Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. This program is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ #include "plural-exp.h" -#if (defined __GNUC__ && !defined __APPLE_CC__) \ +#if (defined __GNUC__ && !(__APPLE_CC__ > 1)) \ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) /* These structs are the constant expression for the germanic plural diff --git a/intl/plural-exp.h b/intl/plural-exp.h index f540184..dc590d3 100644 --- a/intl/plural-exp.h +++ b/intl/plural-exp.h @@ -1,5 +1,5 @@ /* Expression parsing and evaluation for plural form selection. - Copyright (C) 2000-2003 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2005 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. This program is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry, unsigned long int *npluralsp) internal_function; -#if !defined (_LIBC) && !defined (IN_LIBINTL) +#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE) extern unsigned long int plural_eval (struct expression *pexp, unsigned long int n); #endif diff --git a/intl/plural.c b/intl/plural.c index 78a223d..5f73b40 100644 --- a/intl/plural.c +++ b/intl/plural.c @@ -19,7 +19,7 @@ #line 1 "plural.y" /* Expression parsing for plural form selection. - Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc. + Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. This program is free software; you can redistribute it and/or modify it @@ -37,10 +37,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* The bison generated parser uses alloca. AIX 3 forces us to put this - declaration at the beginning of the file. The declaration in bison's - skeleton file comes too late. This must come before <config.h> - because <config.h> may include arbitrary system headers. */ +/* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us + to put this declaration at the beginning of the file. The declaration in + bison's skeleton file comes too late. This must come before <config.h> + because <config.h> may include arbitrary system headers. + This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */ #if defined _AIX && !defined __GNUC__ #pragma alloca #endif @@ -51,6 +52,7 @@ #include <stddef.h> #include <stdlib.h> +#include <string.h> #include "plural-exp.h" /* The main function generated by the parser is called __gettextparse, @@ -62,7 +64,7 @@ #define YYLEX_PARAM &((struct parse_args *) arg)->cp #define YYPARSE_PARAM arg -#line 49 "plural.y" +#line 51 "plural.y" #ifndef YYSTYPE typedef union { unsigned long int num; @@ -72,7 +74,7 @@ typedef union { # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif -#line 55 "plural.y" +#line 57 "plural.y" /* Prototypes for local functions. */ static int yylex (YYSTYPE *lval, const char **pexp); @@ -212,8 +214,8 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 150, 158, 162, 166, 170, 174, 178, 182, 186, - 190, 194, 199 + 0, 152, 160, 164, 168, 172, 176, 180, 184, 188, + 192, 196, 201 }; #endif @@ -296,7 +298,7 @@ static const short yycheck[] = #define YYPURE 1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/home/haible/gnu/arch/linuxlibc6/share/bison/bison.simple" +#line 3 "bison.simple" /* Skeleton output parser for bison, @@ -609,7 +611,7 @@ yystpcpy (yydest, yysrc) # endif #endif -#line 315 "/home/haible/gnu/arch/linuxlibc6/share/bison/bison.simple" +#line 315 "bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed @@ -1003,7 +1005,7 @@ yyreduce: switch (yyn) { case 1: -#line 151 "plural.y" +#line 153 "plural.y" { if (yyvsp[0].exp == NULL) YYABORT; @@ -1011,75 +1013,75 @@ case 1: } break; case 2: -#line 159 "plural.y" +#line 161 "plural.y" { yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp); } break; case 3: -#line 163 "plural.y" +#line 165 "plural.y" { yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp); } break; case 4: -#line 167 "plural.y" +#line 169 "plural.y" { yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp); } break; case 5: -#line 171 "plural.y" +#line 173 "plural.y" { yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); } break; case 6: -#line 175 "plural.y" +#line 177 "plural.y" { yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); } break; case 7: -#line 179 "plural.y" +#line 181 "plural.y" { yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); } break; case 8: -#line 183 "plural.y" +#line 185 "plural.y" { yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); } break; case 9: -#line 187 "plural.y" +#line 189 "plural.y" { yyval.exp = new_exp_1 (lnot, yyvsp[0].exp); } break; case 10: -#line 191 "plural.y" +#line 193 "plural.y" { yyval.exp = new_exp_0 (var); } break; case 11: -#line 195 "plural.y" +#line 197 "plural.y" { if ((yyval.exp = new_exp_0 (num)) != NULL) yyval.exp->val.num = yyvsp[0].num; } break; case 12: -#line 200 "plural.y" +#line 202 "plural.y" { yyval.exp = yyvsp[-1].exp; } break; } -#line 705 "/home/haible/gnu/arch/linuxlibc6/share/bison/bison.simple" +#line 705 "bison.simple" yyvsp -= yylen; @@ -1310,7 +1312,7 @@ yyreturn: #endif return yyresult; } -#line 205 "plural.y" +#line 207 "plural.y" void diff --git a/intl/plural.y b/intl/plural.y index fe79112..45d68e9 100644 --- a/intl/plural.y +++ b/intl/plural.y @@ -1,6 +1,6 @@ %{ /* Expression parsing for plural form selection. - Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc. + Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@cygnus.com>, 2000. This program is free software; you can redistribute it and/or modify it @@ -18,10 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* The bison generated parser uses alloca. AIX 3 forces us to put this - declaration at the beginning of the file. The declaration in bison's - skeleton file comes too late. This must come before <config.h> - because <config.h> may include arbitrary system headers. */ +/* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us + to put this declaration at the beginning of the file. The declaration in + bison's skeleton file comes too late. This must come before <config.h> + because <config.h> may include arbitrary system headers. + This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */ #if defined _AIX && !defined __GNUC__ #pragma alloca #endif @@ -32,6 +33,7 @@ #include <stddef.h> #include <stdlib.h> +#include <string.h> #include "plural-exp.h" /* The main function generated by the parser is called __gettextparse, diff --git a/intl/printf-args.c b/intl/printf-args.c index f975901..ee0faba 100644 --- a/intl/printf-args.c +++ b/intl/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2005-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -16,9 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif +#include <config.h> /* Specification. */ #include "printf-args.h" @@ -59,7 +57,7 @@ printf_fetchargs (va_list args, arguments *a) case TYPE_ULONGINT: ap->a.a_ulongint = va_arg (args, unsigned long int); break; -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: ap->a.a_longlongint = va_arg (args, long long int); break; @@ -80,15 +78,40 @@ printf_fetchargs (va_list args, arguments *a) break; #ifdef HAVE_WINT_T case TYPE_WIDE_CHAR: - ap->a.a_wide_char = va_arg (args, wint_t); + /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by + default argument promotions", this is not the case in mingw32, + where wint_t is 'unsigned short'. */ + ap->a.a_wide_char = + (sizeof (wint_t) < sizeof (int) + ? va_arg (args, int) + : va_arg (args, wint_t)); break; #endif case TYPE_STRING: ap->a.a_string = va_arg (args, const char *); + /* A null pointer is an invalid argument for "%s", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_string == NULL) + ap->a.a_string = "(NULL)"; break; #ifdef HAVE_WCHAR_T case TYPE_WIDE_STRING: ap->a.a_wide_string = va_arg (args, const wchar_t *); + /* A null pointer is an invalid argument for "%ls", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_wide_string == NULL) + { + static const wchar_t wide_null_string[] = + { + (wchar_t)'(', + (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', + (wchar_t)')', + (wchar_t)0 + }; + ap->a.a_wide_string = wide_null_string; + } break; #endif case TYPE_POINTER: @@ -106,7 +129,7 @@ printf_fetchargs (va_list args, arguments *a) case TYPE_COUNT_LONGINT_POINTER: ap->a.a_count_longint_pointer = va_arg (args, long int *); break; -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); break; diff --git a/intl/printf-args.h b/intl/printf-args.h index 625b803..886febe 100644 --- a/intl/printf-args.h +++ b/intl/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -48,7 +48,7 @@ typedef enum TYPE_UINT, TYPE_LONGINT, TYPE_ULONGINT, -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT TYPE_LONGLONGINT, TYPE_ULONGLONGINT, #endif @@ -69,7 +69,7 @@ typedef enum TYPE_COUNT_SHORT_POINTER, TYPE_COUNT_INT_POINTER, TYPE_COUNT_LONGINT_POINTER -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT , TYPE_COUNT_LONGLONGINT_POINTER #endif } arg_type; @@ -88,7 +88,7 @@ typedef struct unsigned int a_uint; long int a_longint; unsigned long int a_ulongint; -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT long long int a_longlongint; unsigned long long int a_ulonglongint; #endif @@ -110,7 +110,7 @@ typedef struct short * a_count_short_pointer; int * a_count_int_pointer; long int * a_count_longint_pointer; -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT long long int * a_count_longlongint_pointer; #endif } diff --git a/intl/printf-parse.c b/intl/printf-parse.c index 20240e3..1a06b1a 100644 --- a/intl/printf-parse.c +++ b/intl/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -16,9 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif +#include <config.h> /* Specification. */ #if WIDE_CHAR_VERSION @@ -385,11 +383,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) switch (c) { case 'd': case 'i': -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT + /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_LONGLONGINT; else #endif + /* If 'long long' exists and is the same as 'long', we parse + "lld" into TYPE_LONGINT. */ if (flags >= 8) type = TYPE_LONGINT; else if (flags & 2) @@ -400,11 +401,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) type = TYPE_INT; break; case 'o': case 'u': case 'x': case 'X': -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT + /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_ULONGLONGINT; else #endif + /* If 'unsigned long long' exists and is the same as + 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ if (flags >= 8) type = TYPE_ULONGINT; else if (flags & 2) @@ -459,11 +463,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) type = TYPE_POINTER; break; case 'n': -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT + /* If 'long long' exists and is larger than 'long': */ if (flags >= 16 || (flags & 4)) type = TYPE_COUNT_LONGLONGINT_POINTER; else #endif + /* If 'long long' exists and is the same as 'long', we parse + "lln" into TYPE_COUNT_LONGINT_POINTER. */ if (flags >= 8) type = TYPE_COUNT_LONGINT_POINTER; else if (flags & 2) diff --git a/intl/printf.c b/intl/printf.c index 5e112b6..004c66f 100644 --- a/intl/printf.c +++ b/intl/printf.c @@ -1,5 +1,5 @@ /* Formatted output to strings, using POSIX/XSI format strings with positions. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2006 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software; you can redistribute it and/or modify it @@ -47,9 +47,16 @@ char *alloca (); #if !HAVE_POSIX_PRINTF +#include <errno.h> +#include <limits.h> #include <stdlib.h> #include <string.h> +/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ +#ifndef EOVERFLOW +# define EOVERFLOW E2BIG +#endif + /* When building a DLL, we must export some functions. Note that because the functions are only defined for binary backward compatibility, we don't need to use __declspec(dllimport) in any case. */ @@ -61,6 +68,14 @@ char *alloca (); #define STATIC static +/* This needs to be consistent with libgnuintl.h.in. */ +#if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__ +/* Don't break __attribute__((format(printf,M,N))). + This redefinition is only possible because the libc in NetBSD, Cygwin, + mingw does not have a function __printf__. */ +# define libintl_printf __printf__ +#endif + /* Define auxiliary functions declared in "printf-args.h". */ #include "printf-args.c" @@ -88,9 +103,15 @@ libintl_vfprintf (FILE *stream, const char *format, va_list args) int retval = -1; if (result != NULL) { - if (fwrite (result, 1, length, stream) == length) - retval = length; + size_t written = fwrite (result, 1, length, stream); free (result); + if (written == length) + { + if (length > INT_MAX) + errno = EOVERFLOW; + else + retval = length; + } } return retval; } @@ -144,6 +165,11 @@ libintl_vsprintf (char *resultbuf, const char *format, va_list args) free (result); return -1; } + if (length > INT_MAX) + { + errno = EOVERFLOW; + return -1; + } else return length; } @@ -186,12 +212,16 @@ libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list a { if (maxlength > 0) { - if (length < maxlength) - abort (); - memcpy (resultbuf, result, maxlength - 1); - resultbuf[maxlength - 1] = '\0'; + size_t pruned_length = + (length < maxlength ? length : maxlength - 1); + memcpy (resultbuf, result, pruned_length); + resultbuf[pruned_length] = '\0'; } free (result); + } + if (length > INT_MAX) + { + errno = EOVERFLOW; return -1; } else @@ -224,6 +254,12 @@ libintl_vasprintf (char **resultp, const char *format, va_list args) char *result = libintl_vasnprintf (NULL, &length, format, args); if (result == NULL) return -1; + if (length > INT_MAX) + { + free (result); + errno = EOVERFLOW; + return -1; + } *resultp = result; return length; } @@ -285,9 +321,14 @@ libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args) for (i = 0; i < length; i++) if (fputwc (result[i], stream) == WEOF) break; - if (i == length) - retval = length; free (result); + if (i == length) + { + if (length > INT_MAX) + errno = EOVERFLOW; + else + retval = length; + } } return retval; } @@ -340,12 +381,22 @@ libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_ { if (maxlength > 0) { - if (length < maxlength) - abort (); - memcpy (resultbuf, result, (maxlength - 1) * sizeof (wchar_t)); - resultbuf[maxlength - 1] = 0; + size_t pruned_length = + (length < maxlength ? length : maxlength - 1); + memcpy (resultbuf, result, pruned_length * sizeof (wchar_t)); + resultbuf[pruned_length] = 0; } free (result); + /* Unlike vsnprintf, which has to return the number of character that + would have been produced if the resultbuf had been sufficiently + large, the vswprintf function has to return a negative value if + the resultbuf was not sufficiently large. */ + if (length >= maxlength) + return -1; + } + if (length > INT_MAX) + { + errno = EOVERFLOW; return -1; } else diff --git a/intl/relocatable.c b/intl/relocatable.c index 5b43d12..5e1dde6 100644 --- a/intl/relocatable.c +++ b/intl/relocatable.c @@ -1,5 +1,5 @@ /* Provide relocatable packages. - Copyright (C) 2003-2004 Free Software Foundation, Inc. + Copyright (C) 2003-2006 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software; you can redistribute it and/or modify it @@ -25,9 +25,7 @@ # define _GNU_SOURCE 1 #endif -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include <config.h> /* Specification. */ #include "relocatable.h" @@ -45,7 +43,7 @@ # include "xalloc.h" #endif -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include <windows.h> #endif @@ -234,6 +232,9 @@ compute_curr_prefix (const char *orig_installprefix, same = true; break; } + /* Do case-insensitive comparison if the filesystem is always or + often case-insensitive. It's better to accept the comparison + if the difference is only in case, rather than to fail. */ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */ if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi) @@ -280,7 +281,7 @@ compute_curr_prefix (const char *orig_installprefix, /* Full pathname of shared library, or NULL. */ static char *shared_library_fullname; -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ /* Determine the full pathname of the shared library when it is loaded. */ @@ -302,13 +303,31 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved) /* Shouldn't happen. */ return FALSE; - shared_library_fullname = strdup (location); + { +#if defined __CYGWIN__ + /* On Cygwin, we need to convert paths coming from Win32 system calls + to the Unix-like slashified notation. */ + static char location_as_posix_path[2 * MAX_PATH]; + /* There's no error return defined for cygwin_conv_to_posix_path. + See cygwin-api/func-cygwin-conv-to-posix-path.html. + Does it overflow the buffer of expected size MAX_PATH or does it + truncate the path? I don't know. Let's catch both. */ + cygwin_conv_to_posix_path (location, location_as_posix_path); + location_as_posix_path[MAX_PATH - 1] = '\0'; + if (strlen (location_as_posix_path) >= MAX_PATH - 1) + /* A sign of buffer overflow or path truncation. */ + return FALSE; + shared_library_fullname = strdup (location_as_posix_path); +#else + shared_library_fullname = strdup (location); +#endif + } } return TRUE; } -#else /* Unix */ +#else /* Unix except Cygwin */ static void find_shared_library_fullname () @@ -359,15 +378,15 @@ find_shared_library_fullname () #endif } -#endif /* WIN32 / Unix */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux and Woe32. */ + Guaranteed to work only on Linux, Cygwin and Woe32. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { diff --git a/intl/relocatable.h b/intl/relocatable.h index 614e64e..f6d3832 100644 --- a/intl/relocatable.h +++ b/intl/relocatable.h @@ -1,5 +1,5 @@ /* Provide relocatable packages. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2005 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software; you can redistribute it and/or modify it @@ -31,7 +31,9 @@ extern "C" { /* When building a DLL, we must export some functions. Note that because this is a private .h file, we don't need to use __declspec(dllimport) in any case. */ -#if defined _MSC_VER && BUILDING_DLL +#if HAVE_VISIBILITY && BUILDING_DLL +# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default"))) +#elif defined _MSC_VER && BUILDING_DLL # define RELOCATABLE_DLL_EXPORTED __declspec(dllexport) #else # define RELOCATABLE_DLL_EXPORTED diff --git a/intl/textdomain.c b/intl/textdomain.c index 2bf6240..c316460 100644 --- a/intl/textdomain.c +++ b/intl/textdomain.c @@ -1,5 +1,5 @@ /* Implementation of the textdomain(3) function. - Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2003, 2005-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -23,21 +23,21 @@ #include <stdlib.h> #include <string.h> +#include "gettextP.h" #ifdef _LIBC # include <libintl.h> #else # include "libgnuintl.h" #endif -#include "gettextP.h" +/* Handle multi-threaded applications. */ #ifdef _LIBC -/* We have to handle multi-threaded applications. */ # include <bits/libc-lock.h> +# define gl_rwlock_define __libc_rwlock_define +# define gl_rwlock_wrlock __libc_rwlock_wrlock +# define gl_rwlock_unlock __libc_rwlock_unlock #else -/* Provide dummy implementation if this is outside glibc. */ -# define __libc_rwlock_define(CLASS, NAME) -# define __libc_rwlock_wrlock(NAME) -# define __libc_rwlock_unlock(NAME) +# include "lock.h" #endif /* The internal variables in the standalone libintl.a must have different @@ -71,7 +71,7 @@ extern const char *_nl_current_default_domain attribute_hidden; #endif /* Lock variable to protect the global data in the gettext implementation. */ -__libc_rwlock_define (extern, _nl_state_lock attribute_hidden) +gl_rwlock_define (extern, _nl_state_lock attribute_hidden) /* Set the current default message catalog to DOMAINNAME. If DOMAINNAME is null, return the current default. @@ -86,7 +86,7 @@ TEXTDOMAIN (const char *domainname) if (domainname == NULL) return (char *) _nl_current_default_domain; - __libc_rwlock_wrlock (_nl_state_lock); + gl_rwlock_wrlock (_nl_state_lock); old_domain = (char *) _nl_current_default_domain; @@ -130,7 +130,7 @@ TEXTDOMAIN (const char *domainname) free (old_domain); } - __libc_rwlock_unlock (_nl_state_lock); + gl_rwlock_unlock (_nl_state_lock); return new_domain; } diff --git a/intl/vasnprintf.c b/intl/vasnprintf.c index f59968f..8b07310 100644 --- a/intl/vasnprintf.c +++ b/intl/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -23,9 +23,7 @@ # define _GNU_SOURCE 1 #endif -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif +#include <config.h> #ifndef IN_LIBINTL # include <alloca.h> #endif @@ -41,7 +39,7 @@ #include <stdlib.h> /* abort(), malloc(), realloc(), free() */ #include <string.h> /* memcpy(), strlen() */ #include <errno.h> /* errno */ -#include <limits.h> /* CHAR_BIT, INT_MAX */ +#include <limits.h> /* CHAR_BIT */ #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ #if WIDE_CHAR_VERSION # include "wprintf-parse.h" @@ -52,11 +50,6 @@ /* Checked size_t computations. */ #include "xsize.h" -/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */ -#ifndef EOVERFLOW -# define EOVERFLOW E2BIG -#endif - #ifdef HAVE_WCHAR_T # ifdef HAVE_WCSLEN # define local_wcslen wcslen @@ -256,7 +249,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar case TYPE_COUNT_LONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longint_pointer = length; break; -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; break; @@ -330,44 +323,43 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar { case 'd': case 'i': case 'u': -# ifdef HAVE_LONG_LONG +# ifdef HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Multiply by 2, as an estimate for FLAG_GROUP. */ + tmp_length = xsum (tmp_length, tmp_length); + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); break; case 'o': -# ifdef HAVE_LONG_LONG +# ifdef HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) @@ -375,26 +367,27 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.333334 /* binary -> octal */ ) - + 1 /* turn floor into ceil */ - + 1; /* account for leading sign */ + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); break; case 'x': case 'X': -# ifdef HAVE_LONG_LONG +# ifdef HAVE_LONG_LONG_INT if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading sign or alternate form */ + + 1; /* turn floor into ceil */ else # endif if (type == TYPE_LONGINT || type == TYPE_ULONGINT) @@ -402,15 +395,17 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading sign or alternate form */ + + 1; /* turn floor into ceil */ else tmp_length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading sign or alternate form */ + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a leading sign or alternate form. */ + tmp_length = xsum (tmp_length, 2); break; case 'f': case 'F': @@ -533,7 +528,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar switch (type) { -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: case TYPE_ULONGLONGINT: *p++ = 'l'; @@ -687,7 +682,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar SNPRINTF_BUF (arg); } break; -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: { long long int arg = a.arg[dp->arg_index].a.a_longlongint; @@ -868,19 +863,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar free (buf_malloced); CLEANUP (); *lengthp = length; - if (length > INT_MAX) - goto length_overflow; + /* Note that we can produce a big string of a length > INT_MAX. POSIX + says that snprintf() fails with errno = EOVERFLOW in this case, but + that's only because snprintf() returns an 'int'. This function does + not have this limitation. */ return result; - length_overflow: - /* We could produce such a big string, but its length doesn't fit into - an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in - this case. */ - if (result != resultbuf) - free (result); - errno = EOVERFLOW; - return NULL; - out_of_memory: if (!(result == resultbuf || result == NULL)) free (result); diff --git a/intl/version.c b/intl/version.c new file mode 100644 index 0000000..a968cf7 --- /dev/null +++ b/intl/version.c @@ -0,0 +1,26 @@ +/* libintl library version. + Copyright (C) 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "libgnuintl.h" + +/* Version number: (major<<16) + (minor<<8) + subminor */ +int libintl_version = LIBINTL_VERSION; |