From: Chris Allegretta Date: Wed, 18 Apr 2001 14:00:10 +0000 (+0000) Subject: Upgrade libintl stuff to gettext 0.10.36 X-Git-Tag: v1.1.0~88 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=819d46ac71921bf794fa7bba8abbe1fe10f67737;p=nano.git Upgrade libintl stuff to gettext 0.10.36 git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@600 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/intl/ChangeLog b/intl/ChangeLog index 19895015..f34e9a11 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,1086 +1,4 @@ -1998-04-29 Ulrich Drepper +2001-03-09 GNU - * intl/localealias.c (read_alias_file): Use unsigned char for - local variables. Remove unused variable tp. - * intl/l10nflist.c (_nl_normalize_codeset): Use unsigned char * - for type of codeset. For loosing Solaris systems. - * intl/loadinfo.h: Adapt prototype of _nl_normalize_codeset. - * intl/bindtextdom.c (BINDTEXTDOMAIN): Don't define local variable - len if not needed. - Patches by Jim Meyering. + * Version 0.10.36 released. -1998-04-28 Ulrich Drepper - - * loadmsgcat.c (_nl_load_domain): Don't assign the element use_mmap if - mmap is not supported. - - * hash-string.h: Don't include . - -1998-04-27 Ulrich Drepper - - * textdomain.c: Use strdup is available. - - * localealias.c: Define HAVE_MEMPCPY so that we can use this - function. Define and use semapahores to protect modfication of - global objects when compiling for glibc. Add code to allow - freeing alias table. - - * l10nflist.c: Don't assume stpcpy not being a macro. - - * gettextP.h: Define internal_function macri if not already done. - Use glibc byte-swap macros instead of defining SWAP when compiled - for glibc. - (struct loaded_domain): Add elements to allow unloading. - - * Makefile.in (distclean): Don't remove libintl.h here. - - * bindtextdomain.c: Carry over changes from glibc. Use strdup if - available. - - * dcgettext.c: Don't assume stpcpy not being a macro. Mark internal - functions. Add memory freeing code for glibc. - - * dgettext.c: Update copyright. - - * explodename.c: Include stdlib.h and string.h only if they exist. - Use strings.h eventually. - - * finddomain.c: Mark internal functions. Use strdup if available. - Add memory freeing code for glibc. - -1997-10-10 20:00 Ulrich Drepper - - * libgettext.h: Fix dummy textdomain and bindtextdomain macros. - They should return reasonable values. - Reported by Tom Tromey . - -1997-09-16 03:33 Ulrich Drepper - - * libgettext.h: Define PARAMS also to `args' if __cplusplus is defined. - * intlh.inst.in: Likewise. - Reported by Jean-Marc Lasgouttes . - - * libintl.glibc: Update from current glibc version. - -1997-09-06 02:10 Ulrich Drepper - - * intlh.inst.in: Reformat copyright. - -1997-08-19 15:22 Ulrich Drepper - - * dcgettext.c (DCGETTEXT): Remove wrong comment. - -1997-08-16 00:13 Ulrich Drepper - - * Makefile.in (install-data): Don't change directory to install. - -1997-08-01 14:30 Ulrich Drepper - - * cat-compat.c: Fix copyright. - - * localealias.c: Don't define strchr unless !HAVE_STRCHR. - - * loadmsgcat.c: Update copyright. Fix typos. - - * l10nflist.c: Don't define strchr unless !HAVE_STRCHR. - (_nl_make_l10nflist): Handle sponsor and revision correctly. - - * gettext.c: Update copyright. - * gettext.h: Likewise. - * hash-string.h: Likewise. - - * finddomain.c: Remoave dead code. Define strchr only if - !HAVE_STRCHR. - - * explodename.c: Include . - - * explodename.c: Reformat copyright text. - (_nl_explode_name): Fix typo. - - * dcgettext.c: Define and use __set_errno. - (guess_category_value): Don't use setlocale if HAVE_LC_MESSAGES is - not defined. - - * bindtextdom.c: Pretty printing. - -1997-05-01 02:25 Ulrich Drepper - - * dcgettext.c (guess_category_value): Don't depend on - HAVE_LC_MESSAGES. We don't need the macro here. - Patch by Bruno Haible . - - * cat-compat.c (textdomain): DoN't refer to HAVE_SETLOCALE_NULL - macro. Instead use HAVE_LOCALE_NULL and define it when using - glibc, as in dcgettext.c. - Patch by Bruno Haible . - - * Makefile.in (CPPFLAGS): New variable. Reported by Franc,ois - Pinard. - -Mon Mar 10 06:51:17 1997 Ulrich Drepper - - * 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 - - * textdomain.c: Put parentheses around arguments of memcpy macro - definition. - * localealias.c: Likewise. - * l10nflist.c: Likewise. - * finddomain.c: Likewise. - * bindtextdom.c: Likewise. - Reported by Thomas Esken. - -Mon Nov 25 22:57:51 1996 Ulrich Drepper - - * textdomain.c: Move definition of `memcpy` macro to right - position. - -Fri Nov 22 04:01:58 1996 Ulrich Drepper - - * finddomain.c [!HAVE_STRING_H && !_LIBC]: Define memcpy using - bcopy if not already defined. Reported by Thomas Esken. - * bindtextdom.c: Likewise. - * l10nflist.c: Likewise. - * localealias.c: Likewise. - * textdomain.c: Likewise. - -Tue Oct 29 11:10:27 1996 Ulrich Drepper - - * Makefile.in (libdir): Change to use exec_prefix instead of - prefix. Reported by Knut-HĂ„vardAksnes . - -Sat Aug 31 03:07:09 1996 Ulrich Drepper - - * 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 - - * l10nflist.c: Move inclusion of argz.h, ctype.h, stdlib.h after - definition of _GNU_SOURCE. Patch by Roland McGrath. - - * Makefile.in (uninstall): Fix another bug with `for' loop and - empty arguments. Patch by Jim Meyering. Correct name os - uninstalled files: no intl- prefix anymore. - - * 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 - - * Makefile.in (install): Split goal. Now depend on install-exec - and install-data. - (install-exec, install-data): New goals. Created from former - install goal. - Reported by Karl Berry. - -Sat Jun 22 04:58:14 1996 Ulrich Drepper - - * 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 - - * 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 - - * l10nflist.c: Correct presence test macros of __argz_* functions. - - * l10nflist.c: Include based on test of it instead when - __argz_* functions are available. - Reported by Andreas Schwab. - -Thu Jun 13 15:17:44 1996 Ulrich Drepper - - * explodename.c, l10nflist.c: Define NULL for dumb systems. - -Tue Jun 11 17:05:13 1996 Ulrich Drepper - - * intlh.inst.in, libgettext.h (dcgettext): Rename local variable - result to __result to prevent name clash. - - * l10nflist.c, localealias.c, dcgettext.c: Define _GNU_SOURCE to - get prototype for stpcpy and strcasecmp. - - * intlh.inst.in, libgettext.h: Move declaration of - `_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 - - * Makefile.in (install): Remove comment. - -Thu Jun 6 17:28:17 1996 Ulrich Drepper - - * Makefile.in (install): Work around for another Buglix stupidity. - Always use an `else' close for `if's. Reported by Nelson Beebe. - - * Makefile.in (intlh.inst): Correct typo in phony rule. - Reported by Nelson Beebe. - -Thu Jun 6 01:49:52 1996 Ulrich Drepper - - * dcgettext.c (read_alias_file): Rename variable alloca_list to - block_list as the macro calls assume. - Patch by Eric Backus. - - * localealias.c [!HAVE_ALLOCA]: Define alloca as macro using - malloc. - (read_alias_file): Rename varriabe alloca_list to block_list as the - macro calls assume. - Patch by Eric Backus. - - * l10nflist.c: Correct conditional for inclusion. - Reported by Roland McGrath. - - * Makefile.in (all): Depend on all-@USE_INCLUDED_LIBINTL@, not - all-@USE_NLS@. - - * Makefile.in (install): intlh.inst comes from local dir, not - $(srcdir). - - * Makefile.in (intlh.inst): Special handling of this goal. If - used in gettext, this is really a rul to construct this file. If - used in any other package it is defined as a .PHONY rule with - empty body. - - * finddomain.c: Extract locale file information handling into - l10nfile.c. Rename local stpcpy__ function to stpcpy. - - * dcgettext.c (stpcpy): Add local definition. - - * 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 - - * intlh.inst.in: Don't depend including on - HAVE_LOCALE_H. Instead configure must rewrite this fiile - depending on the result of the configure run. - - * Makefile.in (install): libintl.inst is now called intlh.inst. - Add rules for updating intlh.inst from intlh.inst.in. - - * libintl.inst: Renamed to intlh.inst.in. - - * localealias.c, dcgettext.c [__GNUC__]: Define HAVE_ALLOCA to 1 - because gcc has __buitlin_alloca. - Reported by Roland McGrath. - -Mon Jun 3 00:32:16 1996 Ulrich Drepper - - * Makefile.in (installcheck): New goal to fulfill needs of - automake's distcheck. - - * Makefile.in (install): Reorder commands so that VERSION is - found. - - * Makefile.in (gettextsrcdir): Now use subdirectory intl/ in - @datadir@/gettext. - (COMSRCS): Add l10nfile.c. - (OBJECTS): Add l10nfile.o. - (DISTFILES): Rename to DISTFILE.normal. Remove $(DISTFILES.common). - (DISTFILE.gettext): Remove $(DISTFILES.common). - (all-gettext): Remove goal. - (install): If $(PACKAGE) = gettext install, otherwose do nothing. No - package but gettext itself should install libintl.h + headers. - (dist): Extend goal to work for gettext, too. - (dist-gettext): Remove goal. - - * dcgettext.c [!HAVE_ALLOCA]: Define macro alloca by using malloc. - -Sun Jun 2 17:33:06 1996 Ulrich Drepper - - * loadmsgcat.c (_nl_load_domain): Parameter is now comes from - find_l10nfile. - -Sat Jun 1 02:23:03 1996 Ulrich Drepper - - * l10nflist.c (__argz_next): Add definition. - - * dcgettext.c [!HAVE_ALLOCA]: Add code for handling missing alloca - code. Use new l10nfile handling. - - * localealias.c [!HAVE_ALLOCA]: Add code for handling missing - alloca code. - - * l10nflist.c: Initial revision. - -Tue Apr 2 18:51:18 1996 Ulrich Drepper - - * Makefile.in (all-gettext): New goal. Same as all-yes. - -Thu Mar 28 23:01:22 1996 Karl Eichwalder - - * Makefile.in (gettextsrcdir): Define using @datadir@. - -Tue Mar 26 12:39:14 1996 Ulrich Drepper - - * finddomain.c: Include . Reported by Roland McGrath. - -Sat Mar 23 02:00:35 1996 Ulrich Drepper - - * finddomain.c (stpcpy): Rename to stpcpy__ to prevent clashing - with external declaration. - -Sat Mar 2 00:47:09 1996 Ulrich Drepper - - * Makefile.in (all-no): Rename from all_no. - -Sat Feb 17 00:25:59 1996 Ulrich Drepper - - * 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 - - * 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 - - * localealias.c (alias_compare): Increment string pointers in loop - of strcasecmp replacement. - -Fri Dec 29 21:16:34 1995 Ulrich Drepper - - * Makefile.in (install-src): Who commented this goal out ? :-) - -Fri Dec 29 15:08:16 1995 Ulrich Drepper - - * dcgettext.c (DCGETTEXT): Save `errno'. Failing system calls - should not effect it because a missing catalog is no error. - Reported by Harald Knig . - -Tue Dec 19 22:09:13 1995 Ulrich Drepper - - * Makefile.in (Makefile): Explicitly use $(SHELL) for running - shell scripts. - -Fri Dec 15 17:34:59 1995 Andreas Schwab - - * Makefile.in (install-src): Only install library and header when - we use the own implementation. Don't do it when using the - system's gettext or catgets functions. - - * dcgettext.c (find_msg): Must not swap domain->hash_size here. - -Sat Dec 9 16:24:37 1995 Ulrich Drepper - - * 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 - - * 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 - - * Makefile.in (install-src): - Install libintl.inst instead of libintl.h.install. - -Sat Dec 2 22:51:38 1995 Marcus Daniels - - * 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 - - * cat-compat.c (bindtextdomain): Add missing { }. - -Sun Nov 26 18:21:41 1995 Ulrich Drepper - - * 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 Franc,ois Pinard - - * hash-string.h: Capitalize arguments of macros. - -Sat Nov 25 12:01:36 1995 Ulrich Drepper - - * 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 - - * dcgettext.c: Fix bug in preprocessor conditionals. - -Sat Nov 25 02:35:27 1995 Nelson H. F. Beebe - - * libgettext.h: Solaris cc does not understand - #if !SYMBOL1 && !SYMBOL2. Sad but true. - -Thu Nov 23 16:22:14 1995 Ulrich Drepper - - * hash-string.h (hash_string): - Fix for machine with >32 bit `unsigned long's. - - * dcgettext.c (DCGETTEXT): - Fix horrible bug in loop for alternative translation. - -Thu Nov 23 01:45:29 1995 Ulrich Drepper - - * 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 - - * libintl.h.glibc: Use __const instead of const in prototypes. - - * Makefile.in (install-src): - Install libintl.h.install instead of libintl.h. This - is a stripped-down version. Suggested by Peter Miller. - - * libintl.h.install, libintl.h.glibc: Initial revision. - - * localealias.c (_nl_expand_alias, read_alias_file): - Protect prototypes in type casts by __P. - -Tue Nov 14 16:43:58 1995 Ulrich Drepper - - * hash-string.h: Correct prototype for hash_string. - -Sun Nov 12 12:42:30 1995 Ulrich Drepper - - * hash-string.h (hash_string): Add prototype. - - * gettextP.h: Fix copyright. - (SWAP): Add prototype. - -Wed Nov 8 22:56:33 1995 Ulrich Drepper - - * 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 - - * finddomain.c, cat-compat.c: Wrong indentation in #if for stpcpy. - - * finddomain.c (stpcpy): - Define substitution function local. The macro was to flaky. - - * cat-compat.c: Fix typo. - - * xopen-msg.sed, linux-msg.sed: - While bringing message number to right place only accept digits. - - * linux-msg.sed, xopen-msg.sed: Now that the counter does not have - leading 0s we don't need to remove them. Reported by Marcus - Daniels. - - * Makefile.in (../po/cat-id-tbl.o): Use $(top_srdir) in - dependency. Reported by Marcus Daniels. - - * cat-compat.c: (stpcpy) [!_LIBC && !HAVE_STPCPY]: Define replacement. - Generally cleanup using #if instead of #ifndef. - - * Makefile.in: Correct typos in comment. By Franc,ois Pinard. - -Mon Nov 6 00:27:02 1995 Ulrich Drepper - - * 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 - - * libgettext.h: Fix typo: HAVE_CATGETTS -> HAVE_CATGETS. Reported - by Franc,ois Pinard. - - * libgettext.h: Use #if instead of #ifdef/#ifndef. - - * finddomain.c: - Comments describing what has to be done should start with FIXME. - -Sun Nov 5 19:38:01 1995 Ulrich Drepper - - * 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 - - * 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 - - * loadmsgcat.c (_nl_load_domain): Test for FILENAME == NULL. This - might mark a special condition. - - * finddomain.c (make_entry_rec): Don't make illegal entry as decided. - - * Makefile.in (dist): Suppress error message when ln failed. - Get files from $(srcdir) explicitly. - - * libgettext.h (gettext_const): Rename to gettext_noop. - -Fri Nov 3 07:36:50 1995 Ulrich Drepper - - * finddomain.c (make_entry_rec): - Protect against wrong locale names by testing mask. - - * libgettext.h (gettext_const): Add macro definition. - Capitalize macro arguments. - -Thu Nov 2 23:15:51 1995 Ulrich Drepper - - * finddomain.c (_nl_find_domain): - Test for pointer != NULL before accessing value. - Reported by Tom Tromey. - - * gettext.c (NULL): - Define as (void*)0 instad of 0. Reported by Franc,ois Pinard. - -Mon Oct 30 21:28:52 1995 Ulrich Drepper - - * po2tbl.sed.in: Serious typo bug fixed by Jim Meyering. - -Sat Oct 28 23:20:47 1995 Ulrich Drepper - - * libgettext.h: Disable dcgettext optimization for Solaris 2.3. - - * localealias.c (alias_compare): - 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 - - * 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 - - * Makefile.in (SOURCES): Fix typo: intrl.compat.c -> intl-compat.c. - - * po2tbl.sed.in: Patch for buggy SEDs by Christian von Roques. - - * localealias.c: - Fix typo and superflous test. Reported by Christian von Roques. - -Fri Oct 6 11:52:05 1995 Ulrich Drepper - - * 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 - - * Makefile.in (DISTFILES): Add libintl.h.glibc. - - * Makefile.in (dist-libc): Add goal for packing sources for glibc. - (COMSRCS, COMHDRS): Splitted to separate sources shared with glibc. - - * loadmsgcat.c: Forget to continue #if line. - - * localealias.c: - [_LIBC]: Rename strcasecmp to __strcasecmp to keep ANSI C name - space clean. - - * dcgettext.c, finddomain.c: Better comment to last change. - - * loadmsgcat.c: - [_LIBC]: Rename fstat, open, close, read, mmap, and munmap to - __fstat, __open, __close, __read, __mmap, and __munmap resp - to keep ANSI C name space clean. - - * finddomain.c: - [_LIBC]: Rename stpcpy to __stpcpy to keep ANSI C name space clean. - - * dcgettext.c: - [_LIBC]: Rename getced and stpcpy to __getcwd and __stpcpy resp to - keep ANSI C name space clean. - - * libgettext.h: - Include sys/types.h for those old SysV systems out there. - Reported by Francesco Potorti`. - - * loadmsgcat.c (use_mmap): Define if compiled for glibc. - - * bindtextdom.c: Include all those standard headers - unconditionally if _LIBC is defined. - - * finddomain.c: Fix 2 times defiend -> defined. - - * textdomain.c: Include libintl.h instead of libgettext.h when - compiling for glibc. Include all those standard headers - unconditionally if _LIBC is defined. - - * localealias.c, loadmsgcat.c: Prepare to be compiled in glibc. - - * gettext.c: - Include libintl.h instead of libgettext.h when compiling for glibc. - Get NULL from stddef.h if we compile for glibc. - - * finddomain.c: Include libintl.h instead of libgettext.h when - compiling for glibc. Include all those standard headers - unconditionally if _LIBC is defined. - - * dcgettext.c: Include all those standard headers unconditionally - if _LIBC is defined. - - * dgettext.c: If compiled in glibc include libintl.h instead of - libgettext.h. - (locale.h): Don't rely on HAVE_LOCALE_H when compiling for glibc. - - * dcgettext.c: If compiled in glibc include libintl.h instead of - libgettext.h. - (getcwd): Don't rely on HAVE_GETCWD when compiling for glibc. - - * bindtextdom.c: - If compiled in glibc include libintl.h instead of libgettext.h. - -Mon Sep 25 22:23:06 1995 Ulrich Drepper - - * localealias.c (_nl_expand_alias): Don't call bsearch if NMAP <= 0. - Reported by Marcus Daniels. - - * cat-compat.c (bindtextdomain): - String used in putenv must not be recycled. - Reported by Marcus Daniels. - - * libgettext.h (__USE_GNU_GETTEXT): - Additional symbol to signal that we use GNU gettext - library. - - * cat-compat.c (bindtextdomain): - Fix bug with the strange stpcpy replacement. - Reported by Nelson Beebe. - -Sat Sep 23 08:23:51 1995 Ulrich Drepper - - * cat-compat.c: Include for stpcpy prototype. - - * localealias.c (read_alias_file): - While expand strdup code temporary variable `cp' hided - higher level variable with same name. Rename to `tp'. - - * textdomain.c (textdomain): - Avoid warning by using temporary variable in strdup code. - - * finddomain.c (_nl_find_domain): Remove unused variable `application'. - -Thu Sep 21 15:51:44 1995 Ulrich Drepper - - * localealias.c (alias_compare): - Use strcasecmp() only if available. Else use - implementation in place. - - * intl-compat.c: - Wrapper functions now call *__ functions instead of __*. - - * libgettext.h: Declare prototypes for *__ functions instead for __*. - - * cat-compat.c, loadmsgcat.c: - Don't use xmalloc, xstrdup, and stpcpy. These functions are not part - of the standard libc and so prevent libintl.a from being used - standalone. - - * bindtextdom.c: - Don't use xmalloc, xstrdup, and stpcpy. These functions are not part - of the standard libc and so prevent libintl.a from being used - standalone. - Rename to bindtextdomain__ if not used in GNU C Library. - - * dgettext.c: - Rename function to dgettext__ if not used in GNU C Library. - - * gettext.c: - Don't use xmalloc, xstrdup, and stpcpy. These functions are not part - of the standard libc and so prevent libintl.a from being used - standalone. - Functions now called gettext__ if not used in GNU C Library. - - * dcgettext.c, localealias.c, textdomain.c, finddomain.c: - Don't use xmalloc, xstrdup, and stpcpy. These functions are not part - of the standard libc and so prevent libintl.a from being used - standalone. - -Sun Sep 17 23:14:49 1995 Ulrich Drepper - - * finddomain.c: Correct some bugs in handling of CEN standard - locale definitions. - -Thu Sep 7 01:49:28 1995 Ulrich Drepper - - * finddomain.c: Implement CEN syntax. - - * gettextP.h (loaded_domain): Extend number of successors to 31. - -Sat Aug 19 19:25:29 1995 Ulrich Drepper - - * Makefile.in (aliaspath): Remove path to X11 locale dir. - - * Makefile.in: Make install-src depend on install. This helps - gettext to install the sources and other packages can use the - install goal. - -Sat Aug 19 15:19:33 1995 Ulrich Drepper - - * Makefile.in (uninstall): Remove stuff installed by install-src. - -Tue Aug 15 13:13:53 1995 Ulrich Drepper - - * VERSION.in: Initial revision. - - * Makefile.in (DISTFILES): - 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 - - * gettextP.h (_nl_find_domain): - New prototype after changing search strategy. - - * finddomain.c (_nl_find_domain): - We now try only to find a specified catalog. Fall back to other - catalogs listed in the locale list is now done in __dcgettext. - - * dcgettext.c (__dcgettext): - Now we provide message fall back even to different languages. - I.e. if a message is not available in one language all the other - in the locale list a tried. Formerly fall back was only possible - within one language. Implemented by moving one loop from - _nl_find_domain to here. - -Mon Aug 14 23:45:50 1995 Ulrich Drepper - - * Makefile.in (gettextsrcdir): - Directory where source of GNU gettext library are made - available. - (INSTALL, INSTALL_DATA): Programs used for installing sources. - (gettext-src): New. Rule to install GNU gettext sources for use in - gettextize shell script. - -Sun Aug 13 14:40:48 1995 Ulrich Drepper - - * loadmsgcat.c (_nl_load_domain): - Use mmap for loading only when munmap function is - also available. - - * Makefile.in (install): Depend on `all' goal. - -Wed Aug 9 11:04:33 1995 Ulrich Drepper - - * localealias.c (read_alias_file): - Do not overwrite '\n' when terminating alias value string. - - * localealias.c (read_alias_file): - 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 - - * gettextP.h (_nl_load_domain): - Add prototype, replacing prototype for _nl_load_msg_cat. - - * finddomain.c (_nl_find_domain): - Remove unneeded variable filename and filename_len. - (expand_alias): Remove prototype because functions does not - exist anymore. - - * localealias.c (read_alias_file): - Change type of fname_len parameter to int. - (xmalloc): Add prototype. - - * loadmsgcat.c: Better prototypes for xmalloc. - -Tue Aug 8 22:30:39 1995 Ulrich Drepper - - * finddomain.c (_nl_find_domain): - Allow alias name to be constructed from the four components. - - * Makefile.in (aliaspath): New variable. Set to preliminary value. - (SOURCES): Add localealias.c. - (OBJECTS): Add localealias.o. - - * gettextP.h: Add prototype for _nl_expand_alias. - - * finddomain.c: Aliasing handled in intl/localealias.c. - - * localealias.c: Aliasing for locale names. - - * bindtextdom.c: Better prototypes for xmalloc and xstrdup. - -Mon Aug 7 23:47:42 1995 Ulrich Drepper - - * Makefile.in (DISTFILES): gettext.perl is now found in misc/. - - * cat-compat.c (bindtextdomain): - Correct implementation. dirname parameter was not used. - Reported by Marcus Daniels. - - * gettextP.h (loaded_domain): - New fields `successor' and `decided' for oo, lazy - message handling implementation. - - * dcgettext.c: - Adopt for oo, lazy message handliing. - Now we can inherit translations from less specific locales. - (find_msg): New function. - - * loadmsgcat.c, finddomain.c: - Complete rewrite. Implement oo, lazy message handling :-). - We now have an additional environment variable `LANGUAGE' with - a higher priority than LC_ALL for the LC_MESSAGE locale. - 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 - - * finddomain.c (unistd.h): - Include to get _PC_PATH_MAX defined on system having it. - -Fri Aug 4 22:42:00 1995 Ulrich Drepper - - * finddomain.c (stpcpy): Include prototype. - - * Makefile.in (dist): Remove `copying instead' message. - -Wed Aug 2 18:52:03 1995 Ulrich Drepper - - * Makefile.in (ID, TAGS): Do not use $^. - -Tue Aug 1 20:07:11 1995 Ulrich Drepper - - * Makefile.in (TAGS, ID): Use $^ as command argument. - (TAGS): Give etags -o option t write to current directory, - not $(srcdir). - (ID): Use $(srcdir) instead os $(top_srcdir)/src. - (distclean): Remove ID. - -Sun Jul 30 11:51:46 1995 Ulrich Drepper - - * Makefile.in (gnulocaledir): - New variable, always using share/ for data directory. - (DEFS): Add GNULOCALEDIR, used in finddomain.c. - - * finddomain.c (_nl_default_dirname): - Set to GNULOCALEDIR, because it always has to point - to the directory where GNU gettext Library writes it to. - - * intl-compat.c (textdomain, bindtextdomain): - Undefine macros before function definition. - -Sat Jul 22 01:10:02 1995 Ulrich Drepper - - * 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 - - * intl-compat.c (textdomain): Correct typo. - -Wed Jul 19 01:51:35 1995 Ulrich Drepper - - * dcgettext.c (dcgettext): Function now called __dcgettext. - - * dgettext.c (dgettext): Now called __dgettext and calls - __dcgettext. - - * gettext.c (gettext): - Function now called __gettext and calls __dgettext. - - * textdomain.c (textdomain): Function now called __textdomain. - - * bindtextdom.c (bindtextdomain): Function now called - __bindtextdomain. - - * intl-compat.c: Initial revision. - - * Makefile.in (SOURCES): Add intl-compat.c. - (OBJECTS): We always compile the GNU gettext library functions. - OBJECTS contains all objects but cat-compat.o, ../po/cat-if-tbl.o, - and intl-compat.o. - (GETTOBJS): Contains now only intl-compat.o. - - * libgettext.h: - Re-include protection matches dualistic character of libgettext.h. - For all functions in GNU gettext library define __ counter part. - - * 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 - - * 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 - - * Makefile.in: - po-mode.el, makelinks, combine-sh are now found in ../misc. - - * po-mode.el, makelinks, combine-sh, elisp-comp: - Moved to ../misc/. - - * libgettext.h, gettextP.h, gettext.h: Uniform test for __STDC__. - -Sun Jul 16 22:33:02 1995 Ulrich Drepper - - * Makefile.in (INSTALL, INSTALL_DATA): New variables. - (install-data, uninstall): Install/uninstall .elc file. - - * po-mode.el (Installation comment): - Add .pox as possible extension of .po files. - -Sun Jul 16 13:23:27 1995 Ulrich Drepper - - * elisp-comp: Complete new version by Franc,ois: This does not - fail when not compiling in the source directory. - -Sun Jul 16 00:12:17 1995 Ulrich Drepper - - * Makefile.in (../po/cat-id-tbl.o): - Use $(MAKE) instead of make for recursive make. - - * Makefile.in (.el.elc): Use $(SHELL) instead of /bin/sh. - (install-exec): Add missing dummy goal. - (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 - - * Makefile.in (DISTFILES): - Rename libgettext.perl to gettext.perl to fit in 14 chars - file systems. - - * gettext.perl: - Rename to gettext.perl to fit in 14 chars file systems. - -Thu Jul 13 23:17:20 1995 Ulrich Drepper - - * cat-compat.c: If !STDC_HEADERS try to include malloc.h. - -Thu Jul 13 20:55:02 1995 Ulrich Drepper - - * po2tbl.sed.in: Pretty printing. - - * linux-msg.sed, xopen-msg.sed: - Correct bugs with handling substitute flags in branches. - - * hash-string.h (hash_string): - Old K&R compilers don't under stand `unsigned char'. - - * gettext.h (nls_uint32): - Some old K&R compilers (eg HP) don't understand `unsigned int'. - - * cat-compat.c (msg_to_cat_id): De-ANSI-fy prototypes. - -Thu Jul 13 01:34:33 1995 Ulrich Drepper - - * Makefile.in (ELCFILES): New variable. - (DISTFILES): Add elisp-comp. - Add implicit rule for .el -> .elc compilation. - (install-data): install $ELCFILES - (clean): renamed po-to-tbl and po-to-msg to po2tbl and po2msg resp. - - * elisp-comp: Initial revision - -Wed Jul 12 16:14:52 1995 Ulrich Drepper - - * Makefile.in: - cat-id-tbl.c is now found in po/. This enables us to use an identical - intl/ directory in all packages. - - * dcgettext.c (dcgettext): hashing does not work for table size <= 2. - - * textdomain.c: fix typo (#if def -> #if defined) - -Tue Jul 11 18:44:43 1995 Ulrich Drepper - - * Makefile.in (stamp-cat-id): use top_srcdir to address source files - (DISTFILES,distclean): move tupdate.perl to src/ - - * 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 - - * textdomain.c: Protect inclusion of stdlib.h and string.h. - - * loadmsgcat.c: Protect inclusion of stdlib.h. - - * libgettext.h: Protect inclusion of locale.h. - Allow use in C++ programs. - Define NULL is not happened already. - - * Makefile.in (DISTFILES): ship po-to-tbl.sed.in instead of - po-to-tbl.sed. - (distclean): remove po-to-tbl.sed and tupdate.perl. - - * 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 - - * tupdate.perl.in: use "Updated: " in msgid "". - - * cat-compat.c: Fix typo (LOCALDIR -> LOCALEDIR). - Define getenv if !__STDC__. - - * bindtextdom.c: Protect stdlib.h and string.h inclusion. - Define free if !__STDC__. - - * finddomain.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. - Define free if !__STDC__. - - * cat-compat.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. - -Mon Jul 3 23:56:30 1995 Ulrich Drepper - - * Makefile.in: Use LOCALEDIR instead of DEF_MSG_DOM_DIR. - Remove unneeded $(srcdir) from Makefile.in dependency. - - * makelinks: Add copyright and short description. - - * po-mode.el: Last version for 0.7. - - * tupdate.perl.in: Fix die message. - - * dcgettext.c: Protect include of string.h. - - * gettext.c: Protect include of stdlib.h and further tries to get NULL. - - * finddomain.c: Some corrections in includes. - - * Makefile.in (INCLUDES): Prune list correct path to Makefile.in. - - * po-to-tbl.sed: Adopt for new .po file format. - - * linux-msg.sed, xopen-msg.sed: Adopt for new .po file format. - -Sun Jul 2 23:55:03 1995 Ulrich Drepper - - * tupdate.perl.in: Complete rewrite for new .po file format. - -Sun Jul 2 02:06:50 1995 Ulrich Drepper - - * First official release. This directory contains all the code - needed to internationalize own packages. It provides functions - which allow to use the X/Open catgets function with an interface - like the Uniforum gettext function. For system which does not - have neither of those a complete implementation is provided. diff --git a/intl/Makefile.in b/intl/Makefile.in index a41fb579..4786e9bf 100644 --- a/intl/Makefile.in +++ b/intl/Makefile.in @@ -1,5 +1,5 @@ # Makefile for directory with message catalog handling in GNU NLS Utilities. -# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. +# Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,73 +30,104 @@ exec_prefix = @exec_prefix@ transform = @program_transform_name@ libdir = $(exec_prefix)/lib includedir = $(prefix)/include -datadir = $(prefix)/@DATADIRNAME@ +datadir = $(prefix)/share localedir = $(datadir)/locale -gnulocaledir = $(prefix)/share/locale gettextsrcdir = @datadir@/gettext/intl -aliaspath = $(localedir):. +aliaspath = $(localedir) subdir = intl INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ MKINSTALLDIRS = @MKINSTALLDIRS@ +mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac` -l = @l@ +l = @INTL_LIBTOOL_SUFFIX_PREFIX@ AR = ar CC = @CC@ LIBTOOL = @LIBTOOL@ RANLIB = @RANLIB@ +YACC = @INTLBISON@ -y -d +YFLAGS = --name-prefix=__gettext -DEFS = -DLOCALEDIR=\"$(localedir)\" -DGNULOCALEDIR=\"$(gnulocaledir)\" \ --DLOCALE_ALIAS_PATH=\"$(aliaspath)\" @DEFS@ +DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ +-DLIBDIR=\"$(libdir)\" @DEFS@ CPPFLAGS = @CPPFLAGS@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) -HEADERS = $(COMHDRS) libgettext.h loadinfo.h +HEADERS = $(COMHDRS) libgnuintl.h libgettext.h loadinfo.h COMHDRS = gettext.h gettextP.h hash-string.h -SOURCES = $(COMSRCS) intl-compat.c cat-compat.c +SOURCES = $(COMSRCS) intl-compat.c COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \ finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \ -explodename.c +explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y \ +localcharset.c OBJECTS = @INTLOBJS@ bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \ finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \ -explodename.$lo -CATOBJS = cat-compat.$lo ../po/cat-id-tbl.$lo +explodename.$lo dcigettext.$lo dcngettext.$lo dngettext.$lo ngettext.$lo \ +plural.$lo localcharset.$lo GETTOBJS = intl-compat.$lo -DISTFILES.common = ChangeLog Makefile.in linux-msg.sed po2tbl.sed.in \ -xopen-msg.sed $(HEADERS) $(SOURCES) +DISTFILES.common = Makefile.in \ +config.charset locale.alias ref-add.sin ref-del.sin $(HEADERS) $(SOURCES) +DISTFILES.generated = plural.c DISTFILES.normal = VERSION -DISTFILES.gettext = libintl.glibc intlh.inst.in +DISTFILES.gettext = libintl.glibc +DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c + +# Libtool's library version information for libintl. +# Before making a gettext release, the gettext maintainer must change this +# 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=1 +LTV_REVISION=0 +LTV_AGE=0 .SUFFIXES: -.SUFFIXES: .c .o .lo +.SUFFIXES: .c .y .o .lo .sin .sed .c.o: $(COMPILE) $< .c.lo: $(LIBTOOL) --mode=compile $(COMPILE) $< -INCLUDES = -I.. -I. -I$(top_srcdir)/intl -I$(top_srcdir)/lib +.y.c: + $(YACC) $(YFLAGS) --output $@ $< + rm -f $*.h -all: all-@USE_INCLUDED_LIBINTL@ +.sin.sed: + sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@ + mv t-$@ $@ + +INCLUDES = -I.. -I. -I$(top_srcdir)/intl -all-yes: libintl.$la intlh.inst -all-no: +all: all-@USE_INCLUDED_LIBINTL@ +all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed +all-no: all-no-@BUILD_INCLUDED_LIBINTL@ +all-no-yes: libgnuintl.$la +all-no-no: -libintl.a: $(OBJECTS) +libintl.a libgnuintl.a: $(OBJECTS) rm -f $@ $(AR) cru $@ $(OBJECTS) $(RANLIB) $@ -libintl.la: $(OBJECTS) - $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJECTS) \ - -version-info 1:0 -rpath $(libdir) +libintl.la libgnuintl.la: $(OBJECTS) + $(LIBTOOL) --mode=link \ + $(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \ + $(OBJECTS) @LIBICONV@ \ + -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \ + -rpath $(libdir) \ + -no-undefined -../po/cat-id-tbl.$lo: ../po/cat-id-tbl.c $(top_srcdir)/po/$(PACKAGE).pot - cd ../po && $(MAKE) cat-id-tbl.$lo +libintl.h: libgnuintl.h + cp $(srcdir)/libgnuintl.h libintl.h + +charset.alias: config.charset + $(SHELL) $(srcdir)/config.charset '@host@' > t-$@ + mv t-$@ $@ check: all @@ -104,36 +135,57 @@ check: all # only use the library should use install instead. # We must not install the libintl.h/libintl.a files if we are on a -# system which has the gettext() function in its C library or in a -# separate library or use the catgets interface. A special case is -# where configure found a previously installed GNU gettext library. +# system which has the GNU gettext() function in its C library or in a +# separate library. # If you want to use the one which comes with this version of the # package, you have to use `configure --with-included-gettext'. install: install-exec install-data install-exec: all if test "$(PACKAGE)" = "gettext" \ && test '@INTLOBJS@' = '$(GETTOBJS)'; then \ - if test -r $(MKINSTALLDIRS); then \ - $(MKINSTALLDIRS) $(libdir) $(includedir); \ - else \ - $(top_srcdir)/mkinstalldirs $(libdir) $(includedir); \ - fi; \ - $(INSTALL_DATA) intlh.inst $(includedir)/libintl.h; \ - $(INSTALL_DATA) libintl.a $(libdir)/libintl.a; \ + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \ + $(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \ + $(LIBTOOL) --mode=install \ + $(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \ + else \ + : ; \ + fi + if test '@USE_INCLUDED_LIBINTL@' = yes; then \ + $(mkinstalldirs) $(DESTDIR)$(libdir); \ + test -f $(DESTDIR)$(libdir)/charset.alias \ + && orig=$(DESTDIR)$(libdir)/charset.alias \ + || orig=charset.alias; \ + temp=$(DESTDIR)$(libdir)/t-charset.alias; \ + dest=$(DESTDIR)$(libdir)/charset.alias; \ + sed -f ref-add.sed $$orig > $$temp; \ + $(INSTALL_DATA) $$temp $$dest; \ + rm -f $$temp; \ + $(mkinstalldirs) $(DESTDIR)$(localedir); \ + test -f $(DESTDIR)$(localedir)/locale.alias \ + && orig=$(DESTDIR)$(localedir)/locale.alias \ + || orig=$(srcdir)/locale.alias; \ + temp=$(DESTDIR)$(localedir)/t-locale.alias; \ + dest=$(DESTDIR)$(localedir)/locale.alias; \ + sed -f ref-add.sed $$orig > $$temp; \ + $(INSTALL_DATA) $$temp $$dest; \ + rm -f $$temp; \ else \ : ; \ fi install-data: all if test "$(PACKAGE)" = "gettext"; then \ - if test -r $(MKINSTALLDIRS); then \ - $(MKINSTALLDIRS) $(gettextsrcdir); \ - else \ - $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \ - fi; \ - $(INSTALL_DATA) VERSION $(gettextsrcdir)/VERSION; \ + $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \ + $(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \ dists="$(DISTFILES.common)"; \ for file in $$dists; do \ - $(INSTALL_DATA) $(srcdir)/$$file $(gettextsrcdir)/$$file; \ + $(INSTALL_DATA) $(srcdir)/$$file \ + $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + chmod a+x $(DESTDIR)$(gettextsrcdir)/config.charset; \ + dists="$(DISTFILES.obsolete)"; \ + for file in $$dists; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ done; \ else \ : ; \ @@ -143,14 +195,51 @@ install-data: all installcheck: uninstall: - dists="$(DISTFILES.common)"; \ - for file in $$dists; do \ - rm -f $(gettextsrcdir)/$$file; \ - done + if test "$(PACKAGE)" = "gettext" \ + && test '@INTLOBJS@' = '$(GETTOBJS)'; then \ + rm -f $(DESTDIR)$(includedir)/libintl.h; \ + $(LIBTOOL) --mode=uninstall \ + rm -f $(DESTDIR)$(libdir)/libintl.$la; \ + else \ + : ; \ + fi + if test '@USE_INCLUDED_LIBINTL@' = yes; then \ + if test -f $(DESTDIR)$(libdir)/charset.alias; then \ + temp=$(DESTDIR)$(libdir)/t-charset.alias; \ + dest=$(DESTDIR)$(libdir)/charset.alias; \ + sed -f ref-del.sed $$dest > $$temp; \ + if grep '^# Packages using this file: $$' $$temp > /dev/null; then \ + rm -f $$dest; \ + else \ + $(INSTALL_DATA) $$temp $$dest; \ + fi; \ + rm -f $$temp; \ + fi; \ + if test -f $(DESTDIR)$(localedir)/locale.alias; then \ + temp=$(DESTDIR)$(localedir)/t-locale.alias; \ + dest=$(DESTDIR)$(localedir)/locale.alias; \ + sed -f ref-del.sed $$dest > $$temp; \ + if grep '^# Packages using this file: $$' $$temp > /dev/null; then \ + rm -f $$dest; \ + else \ + $(INSTALL_DATA) $$temp $$dest; \ + fi; \ + rm -f $$temp; \ + fi; \ + else \ + : ; \ + fi + if test "$(PACKAGE)" = "gettext"; then \ + for file in VERSION ChangeLog $(DISTFILES.common); do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi info dvi: -$(OBJECTS): ../config.h libgettext.h +$(OBJECTS): ../config.h libgnuintl.h bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h @@ -166,12 +255,19 @@ ID: $(HEADERS) $(SOURCES) mostlyclean: - rm -f *.a *.o *.lo core core.* + rm -f *.a *.la *.o *.lo core core.* + rm -f libintl.h charset.alias ref-add.sed ref-del.sed + rm -f -r .libs _libs clean: mostlyclean distclean: clean - rm -f Makefile ID TAGS po2msg.sed po2tbl.sed libintl.h + rm -f Makefile ID TAGS + if test "$(PACKAGE)" = gettext; then \ + rm -f ChangeLog.inst $(DISTFILES.normal); \ + else \ + : ; \ + fi maintainer-clean: distclean @echo "This command is intended for maintainers to use;" @@ -181,34 +277,22 @@ maintainer-clean: distclean # GNU gettext needs not contain the file `VERSION' but contains some # other files which should not be distributed in other packages. distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) -dist distdir: Makefile $(DISTFILES) +dist distdir: Makefile if test "$(PACKAGE)" = gettext; then \ additional="$(DISTFILES.gettext)"; \ else \ additional="$(DISTFILES.normal)"; \ fi; \ - for file in $(DISTFILES.common) $$additional; do \ + $(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \ + for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) $$additional; do \ ln $(srcdir)/$$file $(distdir) 2> /dev/null \ || cp -p $(srcdir)/$$file $(distdir); \ done -dist-libc: - tar zcvf intl-glibc.tar.gz $(COMSRCS) $(COMHDRS) libintl.h.glibc - Makefile: Makefile.in ../config.status cd .. \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status -# The dependency for intlh.inst is different in gettext and all other -# packages. Because we cannot you GNU make features we have to solve -# the problem while rewriting Makefile.in. -@GT_YES@intlh.inst: intlh.inst.in ../config.status -@GT_YES@ cd .. \ -@GT_YES@ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ -@GT_YES@ $(SHELL) ./config.status -@GT_NO@.PHONY: intlh.inst -@GT_NO@intlh.inst: - # 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. .NOEXPORT: diff --git a/intl/VERSION b/intl/VERSION index ee66b061..53ae7785 100644 --- a/intl/VERSION +++ b/intl/VERSION @@ -1 +1 @@ -GNU gettext library from gettext-0.10.35 +GNU gettext library from gettext-0.10.36 diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index d9c3f349..602a6513 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -1,5 +1,5 @@ /* Implementation of the bindtextdomain(3) function - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,32 +19,39 @@ # include #endif -#if defined STDC_HEADERS || defined _LIBC -# include -#else -# ifdef HAVE_MALLOC_H -# include -# else -void free (); -# endif -#endif +#include +#include +#include -#if defined HAVE_STRING_H || defined _LIBC -# include +#ifdef _LIBC +# include #else -# include -# ifndef memcpy -# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) -# endif +# include "libgnuintl.h" #endif +#include "gettextP.h" #ifdef _LIBC -# include +/* We have to handle multi-threaded applications. */ +# include #else -# include "libgettext.h" +/* Provide dummy implementation if this is outside glibc. */ +# define __libc_rwlock_define(CLASS, NAME) +# define __libc_rwlock_wrlock(NAME) +# define __libc_rwlock_unlock(NAME) +#endif + +/* The internal variables in the standalone libintl.a must have different + names than the internal variables in GNU libc, otherwise programs + using libintl.a cannot be linked statically. */ +#if !defined _LIBC +# define _nl_default_dirname _nl_default_dirname__ +# define _nl_domain_bindings _nl_domain_bindings__ +#endif + +/* Some compilers, like SunOS4 cc, don't have offsetof in . */ +#ifndef offsetof +# define offsetof(type,ident) ((size_t)&(((type*)0)->ident)) #endif -#include "gettext.h" -#include "gettextP.h" /* @@ end of prolog @@ */ @@ -54,6 +61,9 @@ extern const char _nl_default_dirname[]; /* 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) + /* Names for the libintl functions are a problem. They must not clash with existing names and they should follow ANSI C. But this source @@ -61,25 +71,48 @@ extern struct binding *_nl_domain_bindings; prefix. So we have to make a difference here. */ #ifdef _LIBC # define BINDTEXTDOMAIN __bindtextdomain +# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset # ifndef strdup # define strdup(str) __strdup (str) # endif #else # define BINDTEXTDOMAIN bindtextdomain__ +# define BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset__ #endif -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -char * -BINDTEXTDOMAIN (domainname, dirname) +/* Prototypes for local functions. */ +static void set_binding_values PARAMS ((const char *domainname, + const char **dirnamep, + const char **codesetp)); + +/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP + to be used for the DOMAINNAME message catalog. + If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not + modified, only the current value is returned. + If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither + modified nor returned. */ +static void +set_binding_values (domainname, dirnamep, codesetp) const char *domainname; - const char *dirname; + const char **dirnamep; + const char **codesetp; { struct binding *binding; + int modified; /* Some sanity checks. */ if (domainname == NULL || domainname[0] == '\0') - return NULL; + { + if (dirnamep) + *dirnamep = NULL; + if (codesetp) + *codesetp = NULL; + return; + } + + __libc_rwlock_wrlock (_nl_state_lock); + + modified = 0; for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) { @@ -95,83 +128,169 @@ BINDTEXTDOMAIN (domainname, dirname) } } - if (dirname == NULL) - /* The current binding has be to returned. */ - return binding == NULL ? (char *) _nl_default_dirname : binding->dirname; - if (binding != NULL) { - /* The domain is already bound. If the new value and the old - one are equal we simply do nothing. Otherwise replace the - old binding. */ - if (strcmp (dirname, binding->dirname) != 0) + if (dirnamep) { - char *new_dirname; + const char *dirname = *dirnamep; - if (strcmp (dirname, _nl_default_dirname) == 0) - new_dirname = (char *) _nl_default_dirname; + if (dirname == NULL) + /* The current binding has be to returned. */ + *dirnamep = binding->dirname; else { + /* The domain is already bound. If the new value and the old + one are equal we simply do nothing. Otherwise replace the + old binding. */ + char *result = binding->dirname; + if (strcmp (dirname, result) != 0) + { + if (strcmp (dirname, _nl_default_dirname) == 0) + result = (char *) _nl_default_dirname; + else + { #if defined _LIBC || defined HAVE_STRDUP - new_dirname = strdup (dirname); - if (new_dirname == NULL) - return NULL; + result = strdup (dirname); #else - size_t len = strlen (dirname) + 1; - new_dirname = (char *) malloc (len); - if (new_dirname == NULL) - return NULL; - - memcpy (new_dirname, dirname, len); + size_t len = strlen (dirname) + 1; + result = (char *) malloc (len); + if (__builtin_expect (result != NULL, 1)) + memcpy (result, dirname, len); #endif + } + + if (__builtin_expect (result != NULL, 1)) + { + if (binding->dirname != _nl_default_dirname) + free (binding->dirname); + + binding->dirname = result; + modified = 1; + } + } + *dirnamep = result; } + } - if (binding->dirname != _nl_default_dirname) - free (binding->dirname); + if (codesetp) + { + const char *codeset = *codesetp; - binding->dirname = new_dirname; + if (codeset == NULL) + /* The current binding has be to returned. */ + *codesetp = binding->codeset; + else + { + /* The domain is already bound. If the new value and the old + one are equal we simply do nothing. Otherwise replace the + old binding. */ + char *result = binding->codeset; + if (result == NULL || strcmp (codeset, result) != 0) + { +#if defined _LIBC || defined HAVE_STRDUP + result = strdup (codeset); +#else + size_t len = strlen (codeset) + 1; + result = (char *) malloc (len); + if (__builtin_expect (result != NULL, 1)) + memcpy (result, codeset, len); +#endif + + if (__builtin_expect (result != NULL, 1)) + { + if (binding->codeset != NULL) + free (binding->codeset); + + binding->codeset = result; + modified = 1; + } + } + *codesetp = result; + } } } + else if ((dirnamep == NULL || *dirnamep == NULL) + && (codesetp == NULL || *codesetp == NULL)) + { + /* Simply return the default values. */ + if (dirnamep) + *dirnamep = _nl_default_dirname; + if (codesetp) + *codesetp = NULL; + } else { /* We have to create a new binding. */ -#if !defined _LIBC && !defined HAVE_STRDUP - size_t len; -#endif + size_t len = strlen (domainname) + 1; struct binding *new_binding = - (struct binding *) malloc (sizeof (*new_binding)); + (struct binding *) malloc (offsetof (struct binding, domainname) + len); + + if (__builtin_expect (new_binding == NULL, 0)) + goto failed; + + memcpy (new_binding->domainname, domainname, len); - if (new_binding == NULL) - return NULL; + if (dirnamep) + { + const char *dirname = *dirnamep; + if (dirname == NULL) + /* The default value. */ + dirname = _nl_default_dirname; + else + { + if (strcmp (dirname, _nl_default_dirname) == 0) + dirname = _nl_default_dirname; + else + { + char *result; #if defined _LIBC || defined HAVE_STRDUP - new_binding->domainname = strdup (domainname); - if (new_binding->domainname == NULL) - return NULL; + result = strdup (dirname); + if (__builtin_expect (result == NULL, 0)) + goto failed_dirname; #else - len = strlen (domainname) + 1; - new_binding->domainname = (char *) malloc (len); - if (new_binding->domainname == NULL) - return NULL; - memcpy (new_binding->domainname, domainname, len); + size_t len = strlen (dirname) + 1; + result = (char *) malloc (len); + if (__builtin_expect (result == NULL, 0)) + goto failed_dirname; + memcpy (result, dirname, len); #endif - - if (strcmp (dirname, _nl_default_dirname) == 0) - new_binding->dirname = (char *) _nl_default_dirname; + dirname = result; + } + } + *dirnamep = dirname; + new_binding->dirname = (char *) dirname; + } else + /* The default value. */ + new_binding->dirname = (char *) _nl_default_dirname; + + if (codesetp) { + const char *codeset = *codesetp; + + if (codeset != NULL) + { + char *result; + #if defined _LIBC || defined HAVE_STRDUP - new_binding->dirname = strdup (dirname); - if (new_binding->dirname == NULL) - return NULL; + result = strdup (codeset); + if (__builtin_expect (result == NULL, 0)) + goto failed_codeset; #else - len = strlen (dirname) + 1; - new_binding->dirname = (char *) malloc (len); - if (new_binding->dirname == NULL) - return NULL; - memcpy (new_binding->dirname, dirname, len); + size_t len = strlen (codeset) + 1; + result = (char *) malloc (len); + if (__builtin_expect (result == NULL, 0)) + goto failed_codeset; + memcpy (result, codeset, len); #endif + codeset = result; + } + *codesetp = codeset; + new_binding->codeset = (char *) codeset; } + else + new_binding->codeset = NULL; /* Now enqueue it. */ if (_nl_domain_bindings == NULL @@ -191,13 +310,55 @@ BINDTEXTDOMAIN (domainname, dirname) binding->next = new_binding; } - binding = new_binding; + modified = 1; + + /* Here we deal with memory allocation failures. */ + if (0) + { + failed_codeset: + if (new_binding->dirname != _nl_default_dirname) + free (new_binding->dirname); + failed_dirname: + free (new_binding); + failed: + if (dirnamep) + *dirnamep = NULL; + if (codesetp) + *codesetp = NULL; + } } - return binding->dirname; + /* If we modified any binding, we flush the caches. */ + if (modified) + ++_nl_msg_cat_cntr; + + __libc_rwlock_unlock (_nl_state_lock); +} + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +char * +BINDTEXTDOMAIN (domainname, dirname) + const char *domainname; + const char *dirname; +{ + set_binding_values (domainname, &dirname, NULL); + return (char *) dirname; +} + +/* Specify the character encoding in which the messages from the + DOMAINNAME message catalog will be returned. */ +char * +BIND_TEXTDOMAIN_CODESET (domainname, codeset) + const char *domainname; + const char *codeset; +{ + set_binding_values (domainname, NULL, &codeset); + return (char *) codeset; } #ifdef _LIBC -/* Alias for function name in GNU C Library. */ +/* Aliases for function names in GNU C Library. */ weak_alias (__bindtextdomain, bindtextdomain); +weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset); #endif diff --git a/intl/dcgettext.c b/intl/dcgettext.c index 0f7bb486..469e78de 100644 --- a/intl/dcgettext.c +++ b/intl/dcgettext.c @@ -1,5 +1,5 @@ /* Implementation of the dcgettext(3) function. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,220 +19,25 @@ # include #endif -#include - -#if defined __GNUC__ && !defined C_ALLOCA -# define alloca __builtin_alloca -# define HAVE_ALLOCA 1 -#else -# if (defined HAVE_ALLOCA_H || defined _LIBC) && !defined C_ALLOCA -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca -char *alloca (); -# endif -# endif -# endif -#endif - -#include -#ifndef errno -extern int errno; -#endif -#ifndef __set_errno -# define __set_errno(val) errno = (val) -#endif - -#if defined STDC_HEADERS || defined _LIBC -# include -#else -char *getenv (); -# ifdef HAVE_MALLOC_H -# include -# else -void free (); -# endif -#endif - -#if defined HAVE_STRING_H || defined _LIBC -# ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -# endif -# include -#else -# include -#endif -#if !HAVE_STRCHR && !defined _LIBC -# ifndef strchr -# define strchr index -# endif -#endif - -#if defined HAVE_UNISTD_H || defined _LIBC -# include -#endif - -#include "gettext.h" #include "gettextP.h" #ifdef _LIBC # include #else -# include "libgettext.h" +# include "libgnuintl.h" #endif -#include "hash-string.h" /* @@ end of prolog @@ */ -#ifdef _LIBC -/* Rename the non ANSI C functions. This is required by the standard - because some ANSI C functions will require linking with this object - file and the name space must not be polluted. */ -# define getcwd __getcwd -# ifndef stpcpy -# define stpcpy __stpcpy -# endif -#else -# if !defined HAVE_GETCWD -char *getwd (); -# define getcwd(buf, max) getwd (buf) -# else -char *getcwd (); -# endif -# ifndef HAVE_STPCPY -static char *stpcpy PARAMS ((char *dest, const char *src)); -# endif -#endif - -/* Amount to increase buffer size by in each try. */ -#define PATH_INCR 32 - -/* The following is from pathmax.h. */ -/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define - PATH_MAX but might cause redefinition warnings when sys/param.h is - later included (as on MORE/BSD 4.3). */ -#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__)) -# include -#endif - -#ifndef _POSIX_PATH_MAX -# define _POSIX_PATH_MAX 255 -#endif - -#if !defined(PATH_MAX) && defined(_PC_PATH_MAX) -# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX)) -#endif - -/* Don't include sys/param.h if it already has been. */ -#if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN) -# include -#endif - -#if !defined(PATH_MAX) && defined(MAXPATHLEN) -# define PATH_MAX MAXPATHLEN -#endif - -#ifndef PATH_MAX -# define PATH_MAX _POSIX_PATH_MAX -#endif - -/* XPG3 defines the result of `setlocale (category, NULL)' as: - ``Directs `setlocale()' to query `category' and return the current - setting of `local'.'' - However it does not specify the exact format. And even worse: POSIX - defines this not at all. So we can use this feature only on selected - system (e.g. those using GNU C Library). */ -#ifdef _LIBC -# define HAVE_LOCALE_NULL -#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[] = "messages"; - -/* Value used as the default domain for gettext(3). */ -const char *_nl_current_default_domain = _nl_default_default_domain; - -/* Contains the default location of the message catalogs. */ -const char _nl_default_dirname[] = GNULOCALEDIR; - -/* List with bindings of specific domains created by bindtextdomain() - calls. */ -struct binding *_nl_domain_bindings; - -/* Prototypes for local functions. */ -static char *find_msg PARAMS ((struct loaded_l10nfile *domain_file, - const char *msgid)) internal_function; -static const char *category_to_name PARAMS ((int category)) internal_function; -static const char *guess_category_value PARAMS ((int category, - const char *categoryname)) - internal_function; - - -/* For those loosing systems which don't have `alloca' we have to add - some additional code emulating it. */ -#ifdef HAVE_ALLOCA -/* Nothing has to be done. */ -# define ADD_BLOCK(list, address) /* nothing */ -# define FREE_BLOCKS(list) /* nothing */ -#else -struct block_list -{ - void *address; - struct block_list *next; -}; -# define ADD_BLOCK(list, addr) \ - do { \ - struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \ - /* If we cannot get a free block we cannot add the new element to \ - the list. */ \ - if (newp != NULL) { \ - newp->address = (addr); \ - newp->next = (list); \ - (list) = newp; \ - } \ - } while (0) -# define FREE_BLOCKS(list) \ - do { \ - while (list != NULL) { \ - struct block_list *old = list; \ - list = list->next; \ - free (old); \ - } \ - } while (0) -# undef alloca -# define alloca(size) (malloc (size)) -#endif /* have alloca */ - - /* Names for the libintl functions are a problem. They must not clash with existing names and they should follow ANSI C. But this source code is also used in GNU C Library where the names have a __ prefix. So we have to make a difference here. */ #ifdef _LIBC # define DCGETTEXT __dcgettext +# define DCIGETTEXT __dcigettext #else # define DCGETTEXT dcgettext__ -#endif - -/* Checking whether the binaries runs SUID must be done and glibc provides - easier methods therefore we make a difference here. */ -#ifdef _LIBC -# define ENABLE_SECURE __libc_enable_secure -# define DETERMINE_SECURE -#else -static int enable_secure; -# define ENABLE_SECURE (enable_secure == 1) -# define DETERMINE_SECURE \ - if (enable_secure == 0) \ - { \ - if (getuid () != geteuid () || getgid () != getegid ()) \ - enable_secure = 1; \ - else \ - enable_secure = -1; \ - } +# define DCIGETTEXT dcigettext__ #endif /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY @@ -243,413 +48,10 @@ DCGETTEXT (domainname, msgid, category) const char *msgid; int category; { -#ifndef HAVE_ALLOCA - struct block_list *block_list = NULL; -#endif - struct loaded_l10nfile *domain; - struct binding *binding; - const char *categoryname; - const char *categoryvalue; - char *dirname, *xdomainname; - char *single_locale; - char *retval; - int saved_errno = errno; - - /* If no real MSGID is given return NULL. */ - if (msgid == NULL) - return NULL; - - /* See whether this is a SUID binary or not. */ - DETERMINE_SECURE; - - /* 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 - definition left this undefined. */ - if (domainname == NULL) - domainname = _nl_current_default_domain; - - /* First find matching binding. */ - for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) - { - int compare = strcmp (domainname, binding->domainname); - if (compare == 0) - /* We found it! */ - break; - if (compare < 0) - { - /* It is not in the list. */ - binding = NULL; - break; - } - } - - if (binding == NULL) - dirname = (char *) _nl_default_dirname; - else if (binding->dirname[0] == '/') - dirname = binding->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; - - path_max = (unsigned int) PATH_MAX; - path_max += 2; /* The getcwd docs say to do this. */ - - dirname = (char *) alloca (path_max + dirname_len); - ADD_BLOCK (block_list, dirname); - - __set_errno (0); - while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE) - { - path_max += PATH_INCR; - dirname = (char *) alloca (path_max + dirname_len); - ADD_BLOCK (block_list, dirname); - __set_errno (0); - } - - if (ret == NULL) - { - /* We cannot get the current working directory. Don't signal an - error but simply return the default string. */ - FREE_BLOCKS (block_list); - __set_errno (saved_errno); - return (char *) msgid; - } - - stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname); - } - - /* Now determine the symbolic name of CATEGORY and its value. */ - categoryname = category_to_name (category); - categoryvalue = guess_category_value (category, categoryname); - - xdomainname = (char *) alloca (strlen (categoryname) - + strlen (domainname) + 5); - ADD_BLOCK (block_list, xdomainname); - - stpcpy (stpcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"), - domainname), - ".mo"); - - /* Creating working area. */ - single_locale = (char *) alloca (strlen (categoryvalue) + 1); - ADD_BLOCK (block_list, single_locale); - - - /* Search for the given string. This is a loop because we perhaps - got an ordered list of languages to consider for the translation. */ - while (1) - { - /* Make CATEGORYVALUE point to the next element of the list. */ - while (categoryvalue[0] != '\0' && categoryvalue[0] == ':') - ++categoryvalue; - if (categoryvalue[0] == '\0') - { - /* The whole contents of CATEGORYVALUE has been searched but - no valid entry has been found. We solve this situation - by implicitly appending a "C" entry, i.e. no translation - will take place. */ - single_locale[0] = 'C'; - single_locale[1] = '\0'; - } - else - { - char *cp = single_locale; - while (categoryvalue[0] != '\0' && categoryvalue[0] != ':') - *cp++ = *categoryvalue++; - *cp = '\0'; - - /* When this is a SUID binary we must not allow accessing files - outside the dedicated directories. */ - if (ENABLE_SECURE - && (memchr (single_locale, '/', - _nl_find_language (single_locale) - single_locale) - != NULL)) - /* Ingore this entry. */ - continue; - } - - /* If the current locale value is C (or POSIX) we don't load a - domain. Return the MSGID. */ - if (strcmp (single_locale, "C") == 0 - || strcmp (single_locale, "POSIX") == 0) - { - FREE_BLOCKS (block_list); - __set_errno (saved_errno); - return (char *) msgid; - } - - - /* Find structure describing the message catalog matching the - DOMAINNAME and CATEGORY. */ - domain = _nl_find_domain (dirname, single_locale, xdomainname); - - if (domain != NULL) - { - retval = find_msg (domain, msgid); - - if (retval == NULL) - { - int cnt; - - for (cnt = 0; domain->successor[cnt] != NULL; ++cnt) - { - retval = find_msg (domain->successor[cnt], msgid); - - if (retval != NULL) - break; - } - } - - if (retval != NULL) - { - FREE_BLOCKS (block_list); - __set_errno (saved_errno); - return retval; - } - } - } - /* NOTREACHED */ + return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category); } #ifdef _LIBC /* Alias for function name in GNU C Library. */ weak_alias (__dcgettext, dcgettext); #endif - - -static char * -internal_function -find_msg (domain_file, msgid) - struct loaded_l10nfile *domain_file; - const char *msgid; -{ - size_t act = 0; - size_t top, bottom; - struct loaded_domain *domain; - - if (domain_file->decided == 0) - _nl_load_domain (domain_file); - - if (domain_file->data == NULL) - return NULL; - - domain = (struct loaded_domain *) domain_file->data; - - /* Locate the MSGID and its translation. */ - if (domain->hash_size > 2 && domain->hash_tab != NULL) - { - /* Use the hashing table. */ - nls_uint32 len = strlen (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)); - nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]); - - if (nstr == 0) - /* Hash table entry is empty. */ - return NULL; - - if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len - && strcmp (msgid, - domain->data + W (domain->must_swap, - domain->orig_tab[nstr - 1].offset)) == 0) - return (char *) domain->data + W (domain->must_swap, - domain->trans_tab[nstr - 1].offset); - - while (1) - { - if (idx >= domain->hash_size - incr) - idx -= domain->hash_size - incr; - else - idx += incr; - - nstr = W (domain->must_swap, domain->hash_tab[idx]); - if (nstr == 0) - /* Hash table entry is empty. */ - return NULL; - - if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len - && strcmp (msgid, - domain->data + W (domain->must_swap, - domain->orig_tab[nstr - 1].offset)) - == 0) - return (char *) domain->data - + W (domain->must_swap, domain->trans_tab[nstr - 1].offset); - } - /* NOTREACHED */ - } - - /* Now we try the default method: binary search in the sorted - array of messages. */ - bottom = 0; - top = domain->nstrings; - while (bottom < top) - { - int cmp_val; - - act = (bottom + top) / 2; - cmp_val = strcmp (msgid, domain->data - + W (domain->must_swap, - domain->orig_tab[act].offset)); - if (cmp_val < 0) - top = act; - else if (cmp_val > 0) - bottom = act + 1; - else - break; - } - - /* If an translation is found return this. */ - return bottom >= top ? NULL : (char *) domain->data - + W (domain->must_swap, - domain->trans_tab[act].offset); -} - - -/* Return string representation of locale CATEGORY. */ -static const char * -internal_function -category_to_name (category) - int category; -{ - const char *retval; - - switch (category) - { -#ifdef LC_COLLATE - case LC_COLLATE: - retval = "LC_COLLATE"; - break; -#endif -#ifdef LC_CTYPE - case LC_CTYPE: - retval = "LC_CTYPE"; - break; -#endif -#ifdef LC_MONETARY - case LC_MONETARY: - retval = "LC_MONETARY"; - break; -#endif -#ifdef LC_NUMERIC - case LC_NUMERIC: - retval = "LC_NUMERIC"; - break; -#endif -#ifdef LC_TIME - case LC_TIME: - retval = "LC_TIME"; - break; -#endif -#ifdef LC_MESSAGES - case LC_MESSAGES: - retval = "LC_MESSAGES"; - break; -#endif -#ifdef LC_RESPONSE - case LC_RESPONSE: - retval = "LC_RESPONSE"; - break; -#endif -#ifdef LC_ALL - case LC_ALL: - /* This might not make sense but is perhaps better than any other - value. */ - retval = "LC_ALL"; - break; -#endif - default: - /* If you have a better idea for a default value let me know. */ - retval = "LC_XXX"; - } - - return retval; -} - -/* Guess value of current locale from value of the environment variables. */ -static const char * -internal_function -guess_category_value (category, categoryname) - int category; - const char *categoryname; -{ - const char *retval; - - /* The highest priority value is the `LANGUAGE' environment - variable. This is a GNU extension. */ - retval = getenv ("LANGUAGE"); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* `LANGUAGE' is not set. So we have to proceed with the POSIX - methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some - systems this can be done by the `setlocale' function itself. */ -#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL - return setlocale (category, NULL); -#else - /* Setting of LC_ALL overwrites all other. */ - retval = getenv ("LC_ALL"); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* Next comes the name of the desired category. */ - retval = getenv (categoryname); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* Last possibility is the LANG environment variable. */ - retval = getenv ("LANG"); - if (retval != NULL && retval[0] != '\0') - return retval; - - /* We use C as the default domain. POSIX says this is implementation - defined. */ - return "C"; -#endif -} - -/* @@ begin of epilog @@ */ - -/* We don't want libintl.a to depend on any other library. So we - avoid the non-standard function stpcpy. In GNU C Library this - function is available, though. Also allow the symbol HAVE_STPCPY - to be defined. */ -#if !_LIBC && !HAVE_STPCPY -static char * -stpcpy (dest, src) - char *dest; - const char *src; -{ - while ((*dest++ = *src++) != '\0') - /* Do nothing. */ ; - return dest - 1; -} -#endif - - -#ifdef _LIBC -/* If we want to free all resources we have to do some work at - program's end. */ -static void __attribute__ ((unused)) -free_mem (void) -{ - struct binding *runp; - - for (runp = _nl_domain_bindings; runp != NULL; runp = runp->next) - { - free (runp->domainname); - if (runp->dirname != _nl_default_dirname) - /* Yes, this is a pointer comparison. */ - free (runp->dirname); - } - - if (_nl_current_default_domain != _nl_default_default_domain) - /* Yes, again a pointer comparison. */ - free ((char *) _nl_current_default_domain); -} - -text_set_element (__libc_subfreeres, free_mem); -#endif diff --git a/intl/dgettext.c b/intl/dgettext.c index 0510c2b0..c5130411 100644 --- a/intl/dgettext.c +++ b/intl/dgettext.c @@ -1,5 +1,5 @@ -/* Implementation of the dgettext(3) function - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. +/* Implementation of the dgettext(3) function. + Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,14 +19,13 @@ # include #endif -#if defined HAVE_LOCALE_H || defined _LIBC -# include -#endif +#include +#include "gettextP.h" #ifdef _LIBC # include #else -# include "libgettext.h" +# include "libgnuintl.h" #endif /* @@ end of prolog @@ */ diff --git a/intl/explodename.c b/intl/explodename.c index 7f480973..c4ddcc41 100644 --- a/intl/explodename.c +++ b/intl/explodename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. Contributed by Ulrich Drepper , 1995. This program is free software; you can redistribute it and/or modify @@ -19,15 +19,8 @@ # include #endif -#if defined STDC_HEADERS || defined _LIBC -# include -#endif - -#if defined HAVE_STRING_H || defined _LIBC -# include -#else -# include -#endif +#include +#include #include #include "loadinfo.h" diff --git a/intl/finddomain.c b/intl/finddomain.c index 81ea29bf..fdcae623 100644 --- a/intl/finddomain.c +++ b/intl/finddomain.c @@ -1,6 +1,6 @@ /* Handle list of needed message catalogs - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Written by Ulrich Drepper , 1995. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. + Written by Ulrich Drepper , 1995. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,45 +20,20 @@ # include #endif -#include -#include #include #include - -#if defined STDC_HEADERS || defined _LIBC -# include -#else -# ifdef HAVE_MALLOC_H -# include -# else -void free (); -# endif -#endif - -#if defined HAVE_STRING_H || defined _LIBC -# include -#else -# include -# ifndef memcpy -# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) -# endif -#endif -#if !HAVE_STRCHR && !defined _LIBC -# ifndef strchr -# define strchr index -# endif -#endif +#include +#include #if defined HAVE_UNISTD_H || defined _LIBC # include #endif -#include "gettext.h" #include "gettextP.h" #ifdef _LIBC # include #else -# include "libgettext.h" +# include "libgnuintl.h" #endif /* @@ end of prolog @@ */ @@ -71,10 +46,11 @@ static struct loaded_l10nfile *_nl_loaded_domains; established bindings. */ struct loaded_l10nfile * internal_function -_nl_find_domain (dirname, locale, domainname) +_nl_find_domain (dirname, locale, domainname, domainbinding) const char *dirname; char *locale; const char *domainname; + struct binding *domainbinding; { struct loaded_l10nfile *retval; const char *language; @@ -113,7 +89,8 @@ _nl_find_domain (dirname, locale, domainname) 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, NULL, NULL, NULL, domainname, + domainbinding, 0); if (retval != NULL) { /* We know something about this locale. */ @@ -169,7 +146,8 @@ _nl_find_domain (dirname, locale, domainname) retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, strlen (dirname) + 1, mask, language, territory, codeset, normalized_codeset, modifier, special, - sponsor, revision, domainname, 1); + sponsor, revision, domainname, domainbinding, + 1); if (retval == NULL) /* This means we are out of core. */ return NULL; @@ -192,6 +170,10 @@ _nl_find_domain (dirname, locale, domainname) if (alias_value != NULL) free (locale); + /* The space for normalized_codeset is dynamically allocated. Free it. */ + if (mask & XPG_NORM_CODESET) + free ((void *) normalized_codeset); + return retval; } @@ -208,6 +190,7 @@ free_mem (void) if (runp->data != NULL) _nl_unload_domain ((struct loaded_domain *) runp->data); runp = runp->next; + free ((char *) here->filename); free (here); } } diff --git a/intl/gettext.c b/intl/gettext.c index d929f98d..a6402055 100644 --- a/intl/gettext.c +++ b/intl/gettext.c @@ -1,5 +1,5 @@ /* Implementation of gettext(3) function. - Copyright (C) 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,21 +23,14 @@ # define __need_NULL # include #else -# ifdef STDC_HEADERS -# include /* Just for NULL. */ -# else -# ifdef HAVE_STRING_H -# include -# else -# define NULL ((void *) 0) -# endif -# endif +# include /* Just for NULL. */ #endif +#include "gettextP.h" #ifdef _LIBC # include #else -# include "libgettext.h" +# include "libgnuintl.h" #endif /* @@ end of prolog @@ */ @@ -48,10 +41,10 @@ prefix. So we have to make a difference here. */ #ifdef _LIBC # define GETTEXT __gettext -# define DGETTEXT __dgettext +# define DCGETTEXT __dcgettext #else # define GETTEXT gettext__ -# define DGETTEXT dgettext__ +# define DCGETTEXT dcgettext__ #endif /* Look up MSGID in the current default message catalog for the current @@ -61,7 +54,7 @@ char * GETTEXT (msgid) const char *msgid; { - return DGETTEXT (NULL, msgid); + return DCGETTEXT (NULL, msgid, LC_MESSAGES); } #ifdef _LIBC diff --git a/intl/gettext.h b/intl/gettext.h index 3cd23d7d..eb588907 100644 --- a/intl/gettext.h +++ b/intl/gettext.h @@ -1,5 +1,5 @@ -/* Internal header for GNU gettext internationalization functions. - Copyright (C) 1995, 1997 Free Software Foundation, Inc. +/* Description of GNU message catalog format: general file layout. + Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,16 +11,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETTEXT_H #define _GETTEXT_H 1 -#include - #if HAVE_LIMITS_H || _LIBC # include #endif @@ -37,9 +34,8 @@ /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but - doing that would require that the configure script compile and *run* - the resulting executable. Locally running cross-compiled executables - is usually not possible. */ + as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work + when cross-compiling. */ #if __STDC__ # define UINT_MAX_32_BITS 4294967295U diff --git a/intl/gettextP.h b/intl/gettextP.h index 00c52031..c7f46554 100644 --- a/intl/gettextP.h +++ b/intl/gettextP.h @@ -1,6 +1,6 @@ -/* Header describing internals of gettext library - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Written by Ulrich Drepper , 1995. +/* Header describing internals of libintl library. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. + Written by Ulrich Drepper , 1995. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,8 +19,20 @@ #ifndef _GETTEXTP_H #define _GETTEXTP_H +#include /* Get size_t. */ + +#ifdef _LIBC +# include "../iconv/gconv_int.h" +#else +# if HAVE_ICONV +# include +# endif +#endif + #include "loadinfo.h" +#include "gettext.h" /* Get nls_uint32. */ + /* @@ end of prolog @@ */ #ifndef PARAMS @@ -35,6 +47,12 @@ # define internal_function #endif +/* Tell the compiler when a conditional or integer expression is + almost always true or almost always false. */ +#ifndef HAVE_BUILTIN_EXPECT +# define __builtin_expect(expr, val) (expr) +#endif + #ifndef W # define W(flag, data) ((flag) ? SWAP (data) : (data)) #endif @@ -44,8 +62,6 @@ # include # define SWAP(i) bswap_32 (i) #else -static nls_uint32 SWAP PARAMS ((nls_uint32 i)); - static inline nls_uint32 SWAP (i) nls_uint32 i; @@ -55,6 +71,52 @@ SWAP (i) #endif +/* This is the representation of the expressions to determine the + plural form. */ +struct expression +{ + int nargs; /* Number of arguments. */ + enum operator + { + /* Without arguments: */ + var, /* The variable "n". */ + num, /* Decimal number. */ + /* Unary operators: */ + lnot, /* Logical NOT. */ + /* Binary operators: */ + mult, /* Multiplication. */ + divide, /* Division. */ + module, /* Module operation. */ + plus, /* Addition. */ + minus, /* Subtraction. */ + less_than, /* Comparison. */ + greater_than, /* Comparison. */ + less_or_equal, /* Comparison. */ + greater_or_equal, /* Comparison. */ + equal, /* Comparision for equality. */ + not_equal, /* Comparision for inequality. */ + land, /* Logical AND. */ + lor, /* Logical OR. */ + /* Ternary operators: */ + qmop /* Question mark operator. */ + } operation; + union + { + unsigned long int num; /* Number value for `num'. */ + struct expression *args[3]; /* Up to three arguments. */ + } val; +}; + +/* This is the data structure to pass information to the parser and get + the result in a thread-safe way. */ +struct parse_args +{ + const char *cp; + struct expression *res; +}; + + +/* The representation of an opened message catalog. */ struct loaded_domain { const char *data; @@ -66,24 +128,110 @@ struct loaded_domain struct string_desc *trans_tab; nls_uint32 hash_size; nls_uint32 *hash_tab; +#ifdef _LIBC + __gconv_t conv; +#else +# if HAVE_ICONV + iconv_t conv; +# endif +#endif + char **conv_tab; + + struct expression *plural; + unsigned long int nplurals; }; +/* We want to allocate a string at the end of the struct. But ISO C + doesn't allow zero sized arrays. */ +#ifdef __GNUC__ +# define ZERO 0 +#else +# define ZERO 1 +#endif + +/* A set of settings bound to a message domain. Used to store settings + from bindtextdomain() and bind_textdomain_codeset(). */ struct binding { struct binding *next; - char *domainname; char *dirname; + char *codeset; + char domainname[ZERO]; }; +/* 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; + struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname, char *__locale, - const char *__domainname)) + const char *__domainname, + struct binding *__domainbinding)) internal_function; void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain)) internal_function; void _nl_unload_domain PARAMS ((struct loaded_domain *__domain)) internal_function; +#ifdef _LIBC +extern char *__gettext PARAMS ((const char *__msgid)); +extern char *__dgettext PARAMS ((const char *__domainname, + const char *__msgid)); +extern char *__dcgettext PARAMS ((const char *__domainname, + const char *__msgid, int __category)); +extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2, + unsigned long int __n)); +extern char *__dngettext PARAMS ((const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int n)); +extern char *__dcngettext PARAMS ((const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category)); +extern char *__dcigettext PARAMS ((const char *__domainname, + const char *__msgid1, const char *__msgid2, + int __plural, unsigned long int __n, + int __category)); +extern char *__textdomain PARAMS ((const char *__domainname)); +extern char *__bindtextdomain PARAMS ((const char *__domainname, + const char *__dirname)); +extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname, + const char *__codeset)); +#else +extern char *gettext__ PARAMS ((const char *__msgid)); +extern char *dgettext__ PARAMS ((const char *__domainname, + const char *__msgid)); +extern char *dcgettext__ PARAMS ((const char *__domainname, + const char *__msgid, int __category)); +extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2, + unsigned long int __n)); +extern char *dngettext__ PARAMS ((const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n)); +extern char *dcngettext__ PARAMS ((const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category)); +extern char *dcigettext__ PARAMS ((const char *__domainname, + const char *__msgid1, const char *__msgid2, + int __plural, unsigned long int __n, + int __category)); +extern char *textdomain__ PARAMS ((const char *__domainname)); +extern char *bindtextdomain__ PARAMS ((const char *__domainname, + const char *__dirname)); +extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname, + const char *__codeset)); +#endif + +#ifdef _LIBC +extern void __gettext_free_exp PARAMS ((struct expression *exp)) + internal_function; +extern int __gettextparse PARAMS ((void *arg)); +#else +extern void gettext_free_exp__ PARAMS ((struct expression *exp)) + internal_function; +extern int gettextparse__ PARAMS ((void *arg)); +#endif + /* @@ begin of epilog @@ */ #endif /* gettextP.h */ diff --git a/intl/hash-string.h b/intl/hash-string.h index 939e9582..37d4ce1a 100644 --- a/intl/hash-string.h +++ b/intl/hash-string.h @@ -1,5 +1,5 @@ -/* Implements a string hashing function. - Copyright (C) 1995, 1997 Free Software Foundation, Inc. +/* Description of GNU message catalog format: string hashing function. + Copyright (C) 1995, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,10 +11,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* @@ end of prolog @@ */ diff --git a/intl/intl-compat.c b/intl/intl-compat.c index 503efa0f..b8edaa17 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 Software Foundation, Inc. + Copyright (C) 1995, 2000, 2001 Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,24 +20,79 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # include #endif -#include "libgettext.h" +#include "libgnuintl.h" +#include "gettextP.h" /* @@ end of prolog @@ */ +/* This file redirects the gettext functions (without prefix or suffix) to + those defined in the included GNU gettext library (with "__" suffix). + It is compiled into libintl when the included GNU gettext library is + configured --with-included-gettext. + + This redirection works also in the case that the system C library or + the system libintl library contain gettext/textdomain/... functions. + If it didn't, we would need to add preprocessor level redirections to + libgnuintl.h of the following form: + +# define gettext gettext__ +# define dgettext dgettext__ +# define dcgettext dcgettext__ +# define ngettext ngettext__ +# define dngettext dngettext__ +# define dcngettext dcngettext__ +# define textdomain textdomain__ +# define bindtextdomain bindtextdomain__ +# define bind_textdomain_codeset bind_textdomain_codeset__ + + How does this redirection work? There are two cases. + A. When libintl.a is linked into an executable, it works because + functions defined in the executable always override functions in + the shared libraries. + B. When libintl.so is used, it works because + 1. those systems defining gettext/textdomain/... in the C library + (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are + ELF systems and define these symbols as weak, thus explicitly + letting other shared libraries override it. + 2. those systems defining gettext/textdomain/... in a standalone + libintl.so library (namely, Solaris 2.3 and newer) have this + shared library in /usr/lib, and the linker will search /usr/lib + *after* the directory where the GNU gettext library is installed. + + A third case, namely when libintl.a is linked into a shared library + whose name is not libintl.so, is not supported. In this case, on + Solaris, when -lintl precedes the linker option for the shared library + containing GNU gettext, the system's gettext would indeed override + the GNU gettext. Anyone doing this kind of stuff must be clever enough + to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker + command line. */ + #undef gettext #undef dgettext #undef dcgettext +#undef ngettext +#undef dngettext +#undef dcngettext #undef textdomain #undef bindtextdomain +#undef bind_textdomain_codeset char * -bindtextdomain (domainname, dirname) +gettext (msgid) + const char *msgid; +{ + return gettext__ (msgid); +} + + +char * +dgettext (domainname, msgid) const char *domainname; - const char *dirname; + const char *msgid; { - return bindtextdomain__ (domainname, dirname); + return dgettext__ (domainname, msgid); } @@ -52,19 +107,35 @@ dcgettext (domainname, msgid, category) char * -dgettext (domainname, msgid) +ngettext (msgid1, msgid2, n) + const char *msgid1; + const char *msgid2; + unsigned long int n; +{ + return ngettext__ (msgid1, msgid2, n); +} + + +char * +dngettext (domainname, msgid1, msgid2, n) const char *domainname; - const char *msgid; + const char *msgid1; + const char *msgid2; + unsigned long int n; { - return dgettext__ (domainname, msgid); + return dngettext__ (domainname, msgid1, msgid2, n); } char * -gettext (msgid) - const char *msgid; +dcngettext (domainname, msgid1, msgid2, n, category) + const char *domainname; + const char *msgid1; + const char *msgid2; + unsigned long int n; + int category; { - return gettext__ (msgid); + return dcngettext__ (domainname, msgid1, msgid2, n, category); } @@ -74,3 +145,21 @@ textdomain (domainname) { return textdomain__ (domainname); } + + +char * +bindtextdomain (domainname, dirname) + const char *domainname; + const char *dirname; +{ + return bindtextdomain__ (domainname, dirname); +} + + +char * +bind_textdomain_codeset (domainname, codeset) + const char *domainname; + const char *codeset; +{ + return bind_textdomain_codeset__ (domainname, codeset); +} diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 30f5f645..804492d2 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -1,5 +1,4 @@ -/* Handle list of needed message catalogs - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. Contributed by Ulrich Drepper , 1995. This program is free software; you can redistribute it and/or modify @@ -16,22 +15,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Tell glibc's to provide a prototype for stpcpy(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + #ifdef HAVE_CONFIG_H # include #endif - -#if defined HAVE_STRING_H || defined _LIBC -# ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -# endif -# include -#else -# include -# ifndef memcpy -# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) -# endif -#endif +#include #if !HAVE_STRCHR && !defined _LIBC # ifndef strchr # define strchr index @@ -43,10 +38,7 @@ #endif #include #include - -#if defined STDC_HEADERS || defined _LIBC -# include -#endif +#include #include "loadinfo.h" @@ -171,7 +163,7 @@ pop (x) struct loaded_l10nfile * _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, territory, codeset, normalized_codeset, modifier, special, - sponsor, revision, filename, do_allocate) + sponsor, revision, filename, domainbinding, do_allocate) struct loaded_l10nfile **l10nfile_list; const char *dirlist; size_t dirlist_len; @@ -185,6 +177,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, const char *sponsor; const char *revision; const char *filename; + struct binding *domainbinding; int do_allocate; { char *abs_filename; @@ -224,7 +217,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, /* Construct file name. */ memcpy (abs_filename, dirlist, dirlist_len); - __argz_stringify (abs_filename, dirlist_len, ':'); + __argz_stringify (abs_filename, dirlist_len, PATH_SEPARATOR); cp = abs_filename + (dirlist_len - 1); *cp++ = '/'; cp = stpcpy (cp, language); @@ -305,6 +298,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, return NULL; retval->filename = abs_filename; + retval->domainbinding = domainbinding; retval->decided = (__argz_count (dirlist, dirlist_len) != 1 || ((mask & XPG_CODESET) != 0 && (mask & XPG_NORM_CODESET) != 0)); @@ -340,7 +334,8 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt, language, territory, codeset, normalized_codeset, modifier, special, - sponsor, revision, filename, 1); + sponsor, revision, filename, domainbinding, + 1); } retval->successor[entries] = NULL; @@ -349,7 +344,8 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, /* Normalize codeset name. There is no standard for the codeset names. Normalization allows the user to use any of the common - names. */ + names. The return value is dynamically allocated and has to be + freed by the caller. */ const char * _nl_normalize_codeset (codeset, name_len) const char *codeset; diff --git a/intl/libgettext.h b/intl/libgettext.h index 3a92960a..553382ca 100644 --- a/intl/libgettext.h +++ b/intl/libgettext.h @@ -1,5 +1,5 @@ -/* Message catalogs for internationalization. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +/* Convenience header for conditional use of GNU . + Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,168 +15,34 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Because on some systems (e.g. Solaris) we sometimes have to include - the systems libintl.h as well as this file we have more complex - include protection above. But the systems header might perhaps also - define _LIBINTL_H and therefore we have to protect the definition here. */ - -#if !defined _LIBINTL_H || !defined _LIBGETTEXT_H -#ifndef _LIBINTL_H -# define _LIBINTL_H 1 -#endif -#define _LIBGETTEXT_H 1 - -/* We define an additional symbol to signal that we use the GNU - implementation of gettext. */ -#define __USE_GNU_GETTEXT 1 - -#include - -#if HAVE_LOCALE_H -# include -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/* @@ end of prolog @@ */ - -#ifndef PARAMS -# if __STDC__ || defined __cplusplus -# define PARAMS(args) args -# else -# define PARAMS(args) () -# endif -#endif - -#ifndef NULL -# if !defined __cplusplus || defined __GNUC__ -# define NULL ((void *) 0) -# else -# define NULL (0) -# endif -#endif - -#if !HAVE_LC_MESSAGES -/* This value determines the behaviour of the gettext() and dgettext() - function. But some system does not have this defined. Define it - to a default value. */ -# define LC_MESSAGES (-1) -#endif - - -/* Declarations for gettext-using-catgets interface. Derived from - Jim Meyering's libintl.h. */ -struct _msg_ent -{ - const char *_msg; - int _msg_number; -}; - - -#if HAVE_CATGETS -/* These two variables are defined in the automatically by po-to-tbl.sed - generated file `cat-id-tbl.c'. */ -extern const struct _msg_ent _msg_tbl[]; -extern int _msg_tbl_length; -#endif - - -/* For automatical extraction of messages sometimes no real - translation is needed. Instead the string itself is the result. */ -#define gettext_noop(Str) (Str) - -/* 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 PARAMS ((const char *__msgid)); -extern char *gettext__ PARAMS ((const char *__msgid)); - -/* Look up MSGID in the DOMAINNAME message catalog for the current - LC_MESSAGES locale. */ -extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid)); -extern char *dgettext__ PARAMS ((const char *__domainname, - const char *__msgid)); - -/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY - locale. */ -extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid, - int __category)); -extern char *dcgettext__ PARAMS ((const char *__domainname, - const char *__msgid, int __category)); - - -/* 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 PARAMS ((const char *__domainname)); -extern char *textdomain__ PARAMS ((const char *__domainname)); - -/* Specify that the DOMAINNAME message catalog will be found - in DIRNAME rather than in the system locale data base. */ -extern char *bindtextdomain PARAMS ((const char *__domainname, - const char *__dirname)); -extern char *bindtextdomain__ PARAMS ((const char *__domainname, - const char *__dirname)); +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 +/* NLS can be disabled through the configure --disable-nls option. */ #if ENABLE_NLS -/* Solaris 2.3 has the gettext function but dcgettext is missing. - So we omit this optimization for Solaris 2.3. BTW, Solaris 2.4 - has dcgettext. */ -# if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT) - -# define gettext(Msgid) \ - dgettext (NULL, Msgid) - -# define dgettext(Domainname, Msgid) \ - dcgettext (Domainname, Msgid, LC_MESSAGES) - -# if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7 -/* This global variable is defined in loadmsgcat.c. We need a sign, - whether a new catalog was loaded, which can be associated with all - translations. */ -extern int _nl_msg_cat_cntr; - -# define dcgettext(Domainname, Msgid, Category) \ - (__extension__ \ - ({ \ - char *__result; \ - if (__builtin_constant_p (Msgid)) \ - { \ - static char *__translation__; \ - static int __catalog_counter__; \ - if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \ - { \ - __translation__ = \ - dcgettext__ (Domainname, Msgid, Category); \ - __catalog_counter__ = _nl_msg_cat_cntr; \ - } \ - __result = __translation__; \ - } \ - else \ - __result = dcgettext__ (Domainname, Msgid, Category); \ - __result; \ - })) -# endif -# endif +/* Get declarations of GNU message catalog functions. */ +# include #else # define gettext(Msgid) (Msgid) # define dgettext(Domainname, Msgid) (Msgid) # define dcgettext(Domainname, Msgid, Category) (Msgid) -# define textdomain(Domainname) ((char *) Domainname) -# define bindtextdomain(Domainname, Dirname) ((char *) Dirname) +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 ? (char *) (Msgid1) : (char *) (Msgid2)) +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((N) == 1 ? (char *) (Msgid1) : (char *) (Msgid2)) +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((N) == 1 ? (char *) (Msgid1) : (char *) (Msgid2)) +# define textdomain(Domainname) ((char *) (Domainname)) +# define bindtextdomain(Domainname, Dirname) ((char *) (Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) ((char *) (Codeset)) #endif -/* @@ begin of epilog @@ */ - -#ifdef __cplusplus -} -#endif +/* For automatical extraction of messages sometimes no real + translation is needed. Instead the string itself is the result. */ +#define gettext_noop(Str) (Str) -#endif +#endif /* _LIBGETTEXT_H */ diff --git a/intl/loadinfo.h b/intl/loadinfo.h index 1c4524ab..31bf52ac 100644 --- a/intl/loadinfo.h +++ b/intl/loadinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -16,6 +16,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef _LOADINFO_H +#define _LOADINFO_H 1 + #ifndef PARAMS # if __STDC__ # define PARAMS(args) args @@ -24,6 +27,25 @@ # endif #endif +#ifndef internal_function +# define internal_function +#endif + +/* Tell the compiler when a conditional or integer expression is + almost always true or almost always false. */ +#ifndef HAVE_BUILTIN_EXPECT +# define __builtin_expect(expr, val) (expr) +#endif + +/* Separator in PATH like lists of pathnames. */ +#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__ + /* Win32, OS/2, DOS */ +# define PATH_SEPARATOR ';' +#else + /* Unix */ +# define PATH_SEPARATOR ':' +#endif + /* Encoding of locale name parts. */ #define CEN_REVISION 1 #define CEN_SPONSOR 2 @@ -41,6 +63,7 @@ struct loaded_l10nfile { const char *filename; + struct binding *domainbinding; int decided; const void *data; @@ -50,6 +73,10 @@ struct loaded_l10nfile }; +/* Normalize codeset name. There is no standard for the codeset + names. Normalization allows the user to use any of the common + names. The return value is dynamically allocated and has to be + freed by the caller. */ extern const char *_nl_normalize_codeset PARAMS ((const char *codeset, size_t name_len)); @@ -61,11 +88,14 @@ _nl_make_l10nflist PARAMS ((struct loaded_l10nfile **l10nfile_list, const char *normalized_codeset, const char *modifier, const char *special, const char *sponsor, const char *revision, - const char *filename, int do_allocate)); + const char *filename, + struct binding *domainbinding, int do_allocate)); extern const char *_nl_expand_alias PARAMS ((const char *name)); +/* normalized_codeset is dynamically allocated and has to be freed by + the caller. */ extern int _nl_explode_name PARAMS ((char *name, const char **language, const char **modifier, const char **territory, @@ -76,3 +106,10 @@ extern int _nl_explode_name PARAMS ((char *name, const char **language, const char **revision)); extern char *_nl_find_language PARAMS ((const char *name)); + + +extern char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file, + const char *msgid, size_t *lengthp)) + internal_function; + +#endif /* loadinfo.h */ diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 2c6a5650..7ce30892 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -1,5 +1,5 @@ /* Load needed message catalogs. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,22 +15,52 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Tell glibc's to provide a prototype for mempcpy(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + #ifdef HAVE_CONFIG_H # include #endif +#include +#include #include #include #include -#if defined STDC_HEADERS || defined _LIBC -# include +#ifdef __GNUC__ +# define alloca __builtin_alloca +# define HAVE_ALLOCA 1 +#else +# if defined HAVE_ALLOCA_H || defined _LIBC +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca +char *alloca (); +# endif +# endif +# endif #endif +#include +#include + #if defined HAVE_UNISTD_H || defined _LIBC # include #endif +#ifdef _LIBC +# include +# include +#endif + #if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ || (defined _LIBC && defined _POSIX_MAPPED_FILES) # include @@ -43,6 +73,10 @@ #include "gettext.h" #include "gettextP.h" +#ifdef _LIBC +# include "../locale/localeinfo.h" +#endif + /* @@ end of prolog @@ */ #ifdef _LIBC @@ -56,10 +90,113 @@ # define munmap __munmap #endif +/* Names for the libintl functions are a problem. They must not clash + with existing names and they should follow ANSI C. But this source + code is also used in GNU C Library where the names have a __ + prefix. So we have to make a difference here. */ +#ifdef _LIBC +# define PLURAL_PARSE __gettextparse +#else +# define PLURAL_PARSE gettextparse__ +#endif + +/* For those losing systems which don't have `alloca' we have to add + some additional code emulating it. */ +#ifdef HAVE_ALLOCA +# define freea(p) /* nothing */ +#else +# define alloca(n) malloc (n) +# define freea(p) free (p) +#endif + +/* For systems that distinguish between text and binary I/O. + O_BINARY is usually declared in . */ +#if !defined O_BINARY && defined _O_BINARY + /* For MSC-compatible compilers. */ +# define O_BINARY _O_BINARY +# define O_TEXT _O_TEXT +#endif +#ifdef __BEOS__ + /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ +# undef O_BINARY +# undef O_TEXT +#endif +/* On reasonable systems, binary I/O is the default. */ +#ifndef O_BINARY +# define O_BINARY 0 +#endif + /* We need a sign, whether a new catalog was loaded, which can be associated with all translations. This is important if the translations are cached by one of GCC's features. */ -int _nl_msg_cat_cntr = 0; +int _nl_msg_cat_cntr; + +#if defined __GNUC__ \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) + +/* These structs are the constant expression for the germanic plural + form determination. It represents the expression "n != 1". */ +static const struct expression plvar = +{ + .nargs = 0, + .operation = var, +}; +static const struct expression plone = +{ + .nargs = 0, + .operation = num, + .val = + { + .num = 1 + } +}; +static struct expression germanic_plural = +{ + .nargs = 2, + .operation = not_equal, + .val = + { + .args = + { + [0] = (struct expression *) &plvar, + [1] = (struct expression *) &plone + } + } +}; + +# define INIT_GERMANIC_PLURAL() + +#else + +/* For compilers without support for ISO C 99 struct/union initializers: + Initialization at run-time. */ + +static struct expression plvar; +static struct expression plone; +static struct expression germanic_plural; + +static void +init_germanic_plural () +{ + if (plone.val.num == 0) + { + plvar.nargs = 0; + plvar.operation = var; + + plone.nargs = 0; + plone.operation = num; + plone.val.num = 1; + + germanic_plural.nargs = 2; + germanic_plural.operation = not_equal; + germanic_plural.val.args[0] = &plvar; + germanic_plural.val.args[1] = &plone; + } +} + +# define INIT_GERMANIC_PLURAL() init_germanic_plural () + +#endif /* Load the message catalogs specified by FILENAME. If it is no valid @@ -71,10 +208,16 @@ _nl_load_domain (domain_file) { int fd; size_t size; +#ifdef _LIBC + struct stat64 st; +#else struct stat st; +#endif struct mo_file_header *data = (struct mo_file_header *) -1; int use_mmap = 0; struct loaded_domain *domain; + char *nullentry; + size_t nullentrylen; domain_file->decided = 1; domain_file->data = NULL; @@ -87,14 +230,19 @@ _nl_load_domain (domain_file) return; /* Try to open the addressed file. */ - fd = open (domain_file->filename, O_RDONLY); + fd = open (domain_file->filename, O_RDONLY | O_BINARY); if (fd == -1) return; /* We must know about the size of the file. */ - if (fstat (fd, &st) != 0 - || (size = (size_t) st.st_size) != st.st_size - || size < sizeof (struct mo_file_header)) + if ( +#ifdef _LIBC + __builtin_expect (fstat64 (fd, &st) != 0, 0) +#else + __builtin_expect (fstat (fd, &st) != 0, 0) +#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); @@ -107,7 +255,7 @@ _nl_load_domain (domain_file) data = (struct mo_file_header *) mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); - if (data != (struct mo_file_header *) -1) + if (__builtin_expect (data != (struct mo_file_header *) -1, 1)) { /* mmap() call was successful. */ close (fd); @@ -131,12 +279,15 @@ _nl_load_domain (domain_file) do { long int nb = (long int) read (fd, read_ptr, to_read); - if (nb == -1) + if (nb <= 0) { +#ifdef EINTR + if (nb == -1 && errno == EINTR) + continue; +#endif close (fd); return; } - read_ptr += nb; to_read -= nb; } @@ -147,7 +298,8 @@ _nl_load_domain (domain_file) /* Using the magic number we can test whether it really is a message catalog file. */ - if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) + if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED, + 0)) { /* The magic number is wrong: not a message catalog file. */ #ifdef HAVE_MMAP @@ -159,12 +311,11 @@ _nl_load_domain (domain_file) return; } - domain_file->data - = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); - if (domain_file->data == NULL) + domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); + if (domain == NULL) return; + domain_file->data = domain; - domain = (struct loaded_domain *) domain_file->data; domain->data = (char *) data; domain->use_mmap = use_mmap; domain->mmap_size = size; @@ -196,9 +347,137 @@ _nl_load_domain (domain_file) return; } - /* Show that one domain is changed. This might make some cached - translations invalid. */ - ++_nl_msg_cat_cntr; + /* Now 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; +#else +# if HAVE_ICONV + domain->conv = (iconv_t) -1; +# endif +#endif + domain->conv_tab = NULL; + nullentry = _nl_find_msg (domain_file, "", &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 (domain_file->domainbinding != NULL + && domain_file->domainbinding->codeset != NULL) + outcharset = domain_file->domainbinding->codeset; + else + { + outcharset = getenv ("OUTPUT_CHARSET"); + if (outcharset == NULL || outcharset[0] == '\0') + { +# ifdef _LIBC + outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string; +# 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 + domain->conv = iconv_open (outcharset, charset); +# endif +# endif + + freea (charset); + } +#endif /* _LIBC || HAVE_ICONV */ + } + + /* Also look for a plural specification. */ + if (nullentry != NULL) + { + const char *plural; + const char *nplurals; + + plural = strstr (nullentry, "plural="); + nplurals = strstr (nullentry, "nplurals="); + if (plural == NULL || nplurals == NULL) + goto no_plural; + else + { + /* First get the number. */ + char *endp; + unsigned long int n; + struct parse_args args; + + nplurals += 9; + while (*nplurals != '\0' && isspace (*nplurals)) + ++nplurals; +#if defined HAVE_STRTOUL || defined _LIBC + n = strtoul (nplurals, &endp, 10); +#else + for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++) + n = n * 10 + (*endp - '0'); +#endif + domain->nplurals = n; + if (nplurals == endp) + goto no_plural; + + /* Due to the restrictions bison imposes onto the interface of the + scanner function we have to put the input string and the result + passed up from the parser into the same structure which address + is passed down to the parser. */ + plural += 7; + args.cp = plural; + if (PLURAL_PARSE (&args) != 0) + goto no_plural; + domain->plural = args.res; + } + } + else + { + /* By default we are using the Germanic form: singular form only + for `one', the plural form otherwise. Yes, this is also what + English is using since English is a Germanic language. */ + no_plural: + INIT_GERMANIC_PLURAL (); + domain->plural = &germanic_plural; + domain->nplurals = 2; + } } @@ -208,11 +487,20 @@ internal_function _nl_unload_domain (domain) struct loaded_domain *domain; { -#ifdef _POSIX_MAPPED_FILES + if (domain->plural != &germanic_plural) + __gettext_free_exp (domain->plural); + + if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1) + free (domain->conv_tab); + + if (domain->conv != (__gconv_t) -1) + __gconv_close (domain->conv); + +# ifdef _POSIX_MAPPED_FILES if (domain->use_mmap) munmap ((caddr_t) domain->data, domain->mmap_size); else -#endif /* _POSIX_MAPPED_FILES */ +# endif /* _POSIX_MAPPED_FILES */ free ((void *) domain->data); free (domain); diff --git a/intl/localealias.c b/intl/localealias.c index 861020dd..76f19a9a 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -1,6 +1,5 @@ /* Handle aliases for locale names. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Written by Ulrich Drepper , 1995. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,6 +15,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Tell glibc's to provide a prototype for mempcpy(). + This must come before because may include + , and once has been included, it's too late. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + #ifdef HAVE_CONFIG_H # include #endif @@ -41,35 +47,15 @@ char *alloca (); # endif #endif -#if defined STDC_HEADERS || defined _LIBC -# include -#else -char *getenv (); -# ifdef HAVE_MALLOC_H -# include -# else -void free (); -# endif -#endif +#include -#if defined HAVE_STRING_H || defined _LIBC -# ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -# endif -# include -#else -# include -# ifndef memcpy -# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) -# endif -#endif +#include #if !HAVE_STRCHR && !defined _LIBC # ifndef strchr # define strchr index # endif #endif -#include "gettext.h" #include "gettextP.h" /* @@ end of prolog @@ */ @@ -95,40 +81,14 @@ __libc_lock_define_initialized (static, lock); # define internal_function #endif -/* For those loosing systems which don't have `alloca' we have to add +/* For those losing systems which don't have `alloca' we have to add some additional code emulating it. */ #ifdef HAVE_ALLOCA -/* Nothing has to be done. */ -# define ADD_BLOCK(list, address) /* nothing */ -# define FREE_BLOCKS(list) /* nothing */ +# define freea(p) /* nothing */ #else -struct block_list -{ - void *address; - struct block_list *next; -}; -# define ADD_BLOCK(list, addr) \ - do { \ - struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \ - /* If we cannot get a free block we cannot add the new element to \ - the list. */ \ - if (newp != NULL) { \ - newp->address = (addr); \ - newp->next = (list); \ - (list) = newp; \ - } \ - } while (0) -# define FREE_BLOCKS(list) \ - do { \ - while (list != NULL) { \ - struct block_list *old = list; \ - list = list->next; \ - free (old); \ - } \ - } while (0) -# undef alloca -# define alloca(size) (malloc (size)) -#endif /* have alloca */ +# define alloca(n) malloc (n) +# define freea(p) free (p) +#endif #if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED # undef fgets @@ -147,18 +107,18 @@ struct alias_map }; -static char *string_space = NULL; -static size_t string_space_act = 0; -static size_t string_space_max = 0; +static char *string_space; +static size_t string_space_act; +static size_t string_space_max; static struct alias_map *map; -static size_t nmap = 0; -static size_t maxmap = 0; +static size_t nmap; +static size_t maxmap; /* Prototypes for local functions. */ static size_t read_alias_file PARAMS ((const char *fname, int fname_len)) internal_function; -static void extend_alias_table PARAMS ((void)); +static int extend_alias_table PARAMS ((void)); static int alias_compare PARAMS ((const struct alias_map *map1, const struct alias_map *map2)); @@ -204,11 +164,12 @@ _nl_expand_alias (name) { const char *start; - while (locale_alias_path[0] == ':') + while (locale_alias_path[0] == PATH_SEPARATOR) ++locale_alias_path; start = locale_alias_path; - while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':') + while (locale_alias_path[0] != '\0' + && locale_alias_path[0] != PATH_SEPARATOR) ++locale_alias_path; if (start < locale_alias_path) @@ -231,16 +192,12 @@ read_alias_file (fname, fname_len) const char *fname; int fname_len; { -#ifndef HAVE_ALLOCA - struct block_list *block_list = NULL; -#endif FILE *fp; char *full_fname; size_t added; static const char aliasfile[] = "/locale.alias"; full_fname = (char *) alloca (fname_len + sizeof aliasfile); - ADD_BLOCK (block_list, full_fname); #ifdef HAVE_MEMPCPY mempcpy (mempcpy (full_fname, fname, fname_len), aliasfile, sizeof aliasfile); @@ -250,11 +207,9 @@ read_alias_file (fname, fname_len) #endif fp = fopen (full_fname, "r"); + freea (full_fname); if (fp == NULL) - { - FREE_BLOCKS (block_list); - return 0; - } + return 0; added = 0; while (!feof (fp)) @@ -326,7 +281,8 @@ read_alias_file (fname, fname_len) *cp++ = '\0'; if (nmap >= maxmap) - extend_alias_table (); + if (__builtin_expect (extend_alias_table (), 0)) + return added; alias_len = strlen (alias) + 1; value_len = strlen (value) + 1; @@ -339,10 +295,19 @@ read_alias_file (fname, fname_len) ? 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)) { - FREE_BLOCKS (block_list); - return added; + 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; } @@ -369,12 +334,11 @@ read_alias_file (fname, fname_len) qsort (map, nmap, sizeof (struct alias_map), (int (*) PARAMS ((const void *, const void *))) alias_compare); - FREE_BLOCKS (block_list); return added; } -static void +static int extend_alias_table () { size_t new_size; @@ -385,10 +349,11 @@ extend_alias_table () * sizeof (struct alias_map))); if (new_map == NULL) /* Simply don't extend: we don't have any more core. */ - return; + return -1; map = new_map; maxmap = new_size; + return 0; } diff --git a/intl/textdomain.c b/intl/textdomain.c index 88557460..05c2fd76 100644 --- a/intl/textdomain.c +++ b/intl/textdomain.c @@ -1,6 +1,5 @@ /* Implementation of the textdomain(3) function. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Written by Ulrich Drepper , 1995. + Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,23 +19,32 @@ # include #endif -#if defined STDC_HEADERS || defined _LIBC -# include -#endif +#include +#include -#if defined STDC_HEADERS || defined HAVE_STRING_H || defined _LIBC -# include +#ifdef _LIBC +# include #else -# include -# ifndef memcpy -# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) -# endif +# include "libgnuintl.h" #endif +#include "gettextP.h" #ifdef _LIBC -# include +/* We have to handle multi-threaded applications. */ +# include #else -# include "libgettext.h" +/* Provide dummy implementation if this is outside glibc. */ +# define __libc_rwlock_define(CLASS, NAME) +# define __libc_rwlock_wrlock(NAME) +# define __libc_rwlock_unlock(NAME) +#endif + +/* The internal variables in the standalone libintl.a must have different + names than the internal variables in GNU libc, otherwise programs + using libintl.a cannot be linked statically. */ +#if !defined _LIBC +# define _nl_default_default_domain _nl_default_default_domain__ +# define _nl_current_default_domain _nl_current_default_domain__ #endif /* @@ end of prolog @@ */ @@ -61,6 +69,9 @@ extern const char *_nl_current_default_domain; # define TEXTDOMAIN textdomain__ #endif +/* Lock variable to protect the global data in the gettext implementation. */ +__libc_rwlock_define (extern, _nl_state_lock) + /* 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". */ @@ -68,38 +79,60 @@ char * TEXTDOMAIN (domainname) const char *domainname; { - char *old; + char *new_domain; + char *old_domain; /* A NULL pointer requests the current setting. */ if (domainname == NULL) return (char *) _nl_current_default_domain; - old = (char *) _nl_current_default_domain; + __libc_rwlock_wrlock (_nl_state_lock); + + old_domain = (char *) _nl_current_default_domain; /* If domain name is the null string set to default domain "messages". */ if (domainname[0] == '\0' || strcmp (domainname, _nl_default_default_domain) == 0) - _nl_current_default_domain = _nl_default_default_domain; + { + _nl_current_default_domain = _nl_default_default_domain; + new_domain = (char *) _nl_current_default_domain; + } + else if (strcmp (domainname, old_domain) == 0) + /* This can happen and people will use it to signal that some + environment variable changed. */ + new_domain = old_domain; else { /* If the following malloc fails `_nl_current_default_domain' will be NULL. This value will be returned and so signals we are out of core. */ #if defined _LIBC || defined HAVE_STRDUP - _nl_current_default_domain = strdup (domainname); + new_domain = strdup (domainname); #else size_t len = strlen (domainname) + 1; - char *cp = (char *) malloc (len); - if (cp != NULL) - memcpy (cp, domainname, len); - _nl_current_default_domain = cp; + new_domain = (char *) malloc (len); + if (new_domain != NULL) + memcpy (new_domain, domainname, len); #endif + + if (new_domain != NULL) + _nl_current_default_domain = new_domain; + } + + /* We use this possibility to signal a change of the loaded catalogs + since this is most likely the case and there is no other easy we + to do it. Do it only when the call was successful. */ + if (new_domain != NULL) + { + ++_nl_msg_cat_cntr; + + if (old_domain != new_domain && old_domain != _nl_default_default_domain) + free (old_domain); } - if (old != _nl_default_default_domain) - free (old); + __libc_rwlock_unlock (_nl_state_lock); - return (char *) _nl_current_default_domain; + return new_domain; } #ifdef _LIBC