pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/intl ChangeLog,1.1,1.2 Makefile.in,1.1,1.


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/intl ChangeLog,1.1,1.2 Makefile.in,1.1,1.2 VERSION,1.1,1.2 bindtextdom.c,1.1,1.2 dcgettext.c,1.1,1.2 dgettext.c,1.1,1.2 explodename.c,1.1,1.2 finddomain.c,1.1,1.2 gettext.c,1.1,1.2 gettextP.h,1.1,1.2 hash-string.h,1.1,1.2 intl-compat.c,1.1,1.2 l10nflist.c,1.1,1.2 loadinfo.h,1.1,1.2 loadmsgcat.c,1.1,1.2 localealias.c,1.1,1.2 textdomain.c,1.1,1.2
Date: 10 Apr 2003 21:34:18 -0000

Update of /var/lib/cvs/Games/Pingus/intl
In directory dark:/tmp/cvs-serv12187

Modified Files:
        ChangeLog Makefile.in VERSION bindtextdom.c dcgettext.c 
        dgettext.c explodename.c finddomain.c gettext.c gettextP.h 
        hash-string.h intl-compat.c l10nflist.c loadinfo.h 
        loadmsgcat.c localealias.c textdomain.c 
Log Message:
new libintl

Index: ChangeLog
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/ChangeLog,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ChangeLog   12 Oct 2000 19:26:16 -0000      1.1
+++ ChangeLog   10 Apr 2003 21:34:16 -0000      1.2
@@ -1,1086 +1,4 @@
-1998-04-29  Ulrich Drepper  <address@hidden>
-
-       * 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.
-
[...1057 lines suppressed...]
-
-       * 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  <address@hidden>
-
-       * tupdate.perl.in: Complete rewrite for new .po file format.
+2002-08-06  GNU  <address@hidden>
 
-Sun Jul  2 02:06:50 1995  Ulrich Drepper  <address@hidden>
+       * Version 0.11.5 released.
 
-       * 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.

Index: Makefile.in
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.in 12 Oct 2000 19:26:16 -0000      1.1
+++ Makefile.in 10 Apr 2003 21:34:16 -0000      1.2
@@ -1,19 +1,20 @@
 # 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-2002 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
-# the Free Software Foundation; either version 2, or (at your option)
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Library General Public License as published
+# by the Free Software Foundation; either version 2, or (at your option)
 # any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
 #
-# You should have received a copy of the GNU 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.
+# You should have received a copy of the GNU Library General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
 
 PACKAGE = @PACKAGE@
 VERSION = @VERSION@
@@ -28,75 +29,107 @@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 transform = @program_transform_name@
-libdir = $(exec_prefix)/lib
-includedir = $(prefix)/include
-datadir = $(prefix)/@DATADIRNAME@
+libdir = @libdir@
+includedir = @includedir@
+datadir = @datadir@
 localedir = $(datadir)/locale
-gnulocaledir = $(prefix)/share/locale
-gettextsrcdir = @datadir@/gettext/intl
-aliaspath = $(localedir):.
+gettextsrcdir = $(datadir)/gettext/intl
+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)\" -DIN_LIBINTL @DEFS@
 CPPFLAGS = @CPPFLAGS@
 CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
 
 COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
 
-HEADERS = $(COMHDRS) libgettext.h loadinfo.h
-COMHDRS = gettext.h gettextP.h hash-string.h
-SOURCES = $(COMSRCS) intl-compat.c cat-compat.c
+HEADERS = $(COMHDRS) libgnuintl.h loadinfo.h
+COMHDRS = gmo.h gettextP.h hash-string.h plural-exp.h eval-plural.h os2compat.h
+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 \
+plural-exp.c localcharset.c localename.c osdep.c os2compat.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 plural-exp.$lo localcharset.$lo localename.$lo osdep.$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 = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc
+DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \
+COPYING.LIB-2 gettext.h libgettext.h plural-eval.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=4
+LTV_REVISION=0
+LTV_AGE=2
 
 .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: address@hidden@
+.sin.sed:
+       sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@
+       mv t-$@ $@
 
-all-yes: libintl.$la intlh.inst
-all-no:
+INCLUDES = -I.. -I. -I$(top_srcdir)/intl
 
-libintl.a: $(OBJECTS)
+all: address@hidden@
+all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
+all-no: address@hidden@
+all-no-yes: libgnuintl.$la
+all-no-no:
+
+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) @LTLIBICONV@ -lc \
+         -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,59 +137,150 @@
 # 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); \
+         $(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 \
+         test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \
+         temp=$(DESTDIR)$(libdir)/t-charset.alias; \
+         dest=$(DESTDIR)$(libdir)/charset.alias; \
+         if test -f $(DESTDIR)$(libdir)/charset.alias; then \
+           orig=$(DESTDIR)$(libdir)/charset.alias; \
+           sed -f ref-add.sed $$orig > $$temp; \
+           $(INSTALL_DATA) $$temp $$dest; \
+           rm -f $$temp; \
          else \
-           $(top_srcdir)/mkinstalldirs $(libdir) $(includedir); \
+           if test @GLIBC21@ = no; then \
+             orig=charset.alias; \
+             sed -f ref-add.sed $$orig > $$temp; \
+             $(INSTALL_DATA) $$temp $$dest; \
+             rm -f $$temp; \
+           fi; \
          fi; \
-         $(INSTALL_DATA) intlh.inst $(includedir)/libintl.h; \
-         $(INSTALL_DATA) libintl.a $(libdir)/libintl.a; \
+         $(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; \
-         dists="$(DISTFILES.common)"; \
+         $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
+         $(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
+         $(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \
+         dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \
          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.generated)"; \
+         for file in $$dists; do \
+           if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+           $(INSTALL_DATA) $$dir/$$file \
+                           $(DESTDIR)$(gettextsrcdir)/$$file; \
+         done; \
+         dists="$(DISTFILES.obsolete)"; \
+         for file in $$dists; do \
+           rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
          done; \
        else \
          : ; \
        fi
 
+install-strip: install
+
+installdirs:
+       if test "$(PACKAGE)" = "gettext" \
+          && test '@INTLOBJS@' = '$(GETTOBJS)'; then \
+         $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
+       else \
+         : ; \
+       fi
+       if test '@USE_INCLUDED_LIBINTL@' = yes; then \
+         test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \
+         $(mkinstalldirs) $(DESTDIR)$(localedir); \
+       else \
+         : ; \
+       fi
+       if test "$(PACKAGE)" = "gettext"; then \
+         $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
+       else \
+         : ; \
+       fi
+
 # Define this as empty until I found a useful application.
 installcheck:
 
 uninstall:
+       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 \
-         dists="$(DISTFILES.common)"; \
-         for file in $$dists; do \
-           rm -f $(gettextsrcdir)/$$file; \
-         done \
+         for file in VERSION ChangeLog COPYING.LIB-2.0 COPYING.LIB-2.1 
$(DISTFILES.common) $(DISTFILES.generated); do \
+           rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
+         done; \
        else \
          : ; \
        fi
 
 info dvi:
 
-$(OBJECTS): ../config.h libgettext.h
-bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h
-dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h
+$(OBJECTS): ../config.h libgnuintl.h
+bindtextdom.$lo dcgettext.$lo dcigettext.$lo dcngettext.$lo dgettext.$lo 
dngettext.$lo finddomain.$lo gettext.$lo intl-compat.$lo loadmsgcat.$lo 
localealias.$lo ngettext.$lo textdomain.$lo: gettextP.h gmo.h loadinfo.h
+dcigettext.$lo: hash-string.h
+explodename.$lo l10nflist.$lo: loadinfo.h
+dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: plural-exp.h
+dcigettext.$lo: eval-plural.h
 
 tags: TAGS
 
@@ -170,12 +294,19 @@
 
 
 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
+       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;"
@@ -185,33 +316,21 @@
 # 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 \
-         ln $(srcdir)/$$file $(distdir) 2> /dev/null \
-           || cp -p $(srcdir)/$$file $(distdir); \
+       $(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \
+       for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) 
$$additional; do \
+         if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+         cp -p $$dir/$$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.
address@hidden@intlh.inst: intlh.inst.in ../config.status
address@hidden@ cd .. \
address@hidden@ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
address@hidden@   $(SHELL) ./config.status
address@hidden@.PHONY: intlh.inst
address@hidden@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.

Index: VERSION
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/VERSION,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- VERSION     12 Oct 2000 19:26:16 -0000      1.1
+++ VERSION     10 Apr 2003 21:34:16 -0000      1.2
@@ -1 +1 @@
-GNU gettext library from gettext-0.10.35
+GNU gettext library from gettext-0.11.5

Index: bindtextdom.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/bindtextdom.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- bindtextdom.c       12 Oct 2000 19:26:16 -0000      1.1
+++ bindtextdom.c       10 Apr 2003 21:34:16 -0000      1.2
@@ -1,50 +1,58 @@
 /* Implementation of the bindtextdomain(3) function
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000, 2001, 2002 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#else
-# ifdef HAVE_MALLOC_H
-#  include <malloc.h>
-# else
-void free ();
-# endif
-#endif
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
 
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
+#ifdef _LIBC
+# include <libintl.h>
 #else
-# include <strings.h>
-# ifndef memcpy
-#  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
-# endif
+# include "libgnuintl.h"
 #endif
+#include "gettextP.h"
 
 #ifdef _LIBC
-# include <libintl.h>
+/* We have to handle multi-threaded applications.  */
+# include <bits/libc-lock.h>
 #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 libintl_nl_default_dirname
+# define _nl_domain_bindings libintl_nl_domain_bindings
+#endif
+
+/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>.  */
+#ifndef offsetof
+# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
 #endif
-#include "gettext.h"
-#include "gettextP.h"
 
 /* @@ end of prolog @@ */
 
@@ -54,6 +62,9 @@
 /* List with bindings of specific domains.  */
 extern struct binding *_nl_domain_bindings;
 
+/* Lock variable to protect the global data in the gettext implementation.  */
+__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
+
 
 /* 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 +72,48 @@
    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 BINDTEXTDOMAIN libintl_bindtextdomain
+# define BIND_TEXTDOMAIN_CODESET libintl_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 +129,173 @@
        }
     }
 
-  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;
+                     binding->codeset_cntr++;
+                     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 (new_binding == NULL)
-       return NULL;
+      if (__builtin_expect (new_binding == NULL, 0))
+       goto failed;
+
+      memcpy (new_binding->domainname, domainname, len);
 
+      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;
+
+      new_binding->codeset_cntr = 0;
+
+      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;
+             new_binding->codeset_cntr++;
+           }
+         *codesetp = codeset;
+         new_binding->codeset = (char *) codeset;
        }
+      else
+       new_binding->codeset = NULL;
 
       /* Now enqueue it.  */
       if (_nl_domain_bindings == NULL
@@ -191,13 +315,55 @@
          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

Index: dcgettext.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/dcgettext.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dcgettext.c 12 Oct 2000 19:26:16 -0000      1.1
+++ dcgettext.c 10 Apr 2003 21:34:16 -0000      1.2
@@ -1,238 +1,44 @@
 /* Implementation of the dcgettext(3) function.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000, 2001, 2002 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#include <sys/types.h>
-
-#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 <alloca.h>
-# else
-#  ifdef _AIX
- #pragma alloca
-#  else
-#   ifndef alloca
-char *alloca ();
-#   endif
-#  endif
-# endif
-#endif
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-#ifndef __set_errno
-# define __set_errno(val) errno = (val)
-#endif
-
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#else
-char *getenv ();
-# ifdef HAVE_MALLOC_H
-#  include <malloc.h>
-# else
-void free ();
-# endif
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# ifndef _GNU_SOURCE
-#  define _GNU_SOURCE  1
-# endif
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-#  define strchr index
-# endif
-#endif
-
-#if defined HAVE_UNISTD_H || defined _LIBC
-# include <unistd.h>
-#endif
-
-#include "gettext.h"
 #include "gettextP.h"
 #ifdef _LIBC
 # include <libintl.h>
 #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 <limits.h>
-#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 <sys/param.h>
-#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 DCGETTEXT libintl_dcgettext
+# define DCIGETTEXT libintl_dcigettext
 #endif
 
 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
@@ -243,413 +49,11 @@
      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.  */
+INTDEF(__dcgettext)
 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

Index: dgettext.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/dgettext.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dgettext.c  12 Oct 2000 19:26:16 -0000      1.1
+++ dgettext.c  10 Apr 2003 21:34:16 -0000      1.2
@@ -1,32 +1,32 @@
-/* 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, 2002 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
+#include <locale.h>
 
+#include "gettextP.h"
 #ifdef _LIBC
 # include <libintl.h>
 #else
-# include "libgettext.h"
+# include "libgnuintl.h"
 #endif
 
 /* @@ end of prolog @@ */
@@ -37,10 +37,10 @@
    prefix.  So we have to make a difference here.  */
 #ifdef _LIBC
 # define DGETTEXT __dgettext
-# define DCGETTEXT __dcgettext
+# define DCGETTEXT INTUSE(__dcgettext)
 #else
-# define DGETTEXT dgettext__
-# define DCGETTEXT dcgettext__
+# define DGETTEXT libintl_dgettext
+# define DCGETTEXT libintl_dcgettext
 #endif
 
 /* Look up MSGID in the DOMAINNAME message catalog of the current

Index: explodename.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/explodename.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- explodename.c       12 Oct 2000 19:26:16 -0000      1.1
+++ explodename.c       10 Apr 2003 21:34:16 -0000      1.2
@@ -1,33 +1,27 @@
-/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
    Contributed by Ulrich Drepper <address@hidden>, 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 
 #include "loadinfo.h"

Index: finddomain.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/finddomain.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- finddomain.c        12 Oct 2000 19:26:16 -0000      1.1
+++ finddomain.c        10 Apr 2003 21:34:16 -0000      1.2
@@ -1,64 +1,40 @@
 /* Handle list of needed message catalogs
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
-   Written by Ulrich Drepper <address@hidden>, 1995.
+   Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+   Written by Ulrich Drepper <address@hidden>, 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#include <ctype.h>
-#include <errno.h>
 #include <stdio.h>
 #include <sys/types.h>
-
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#else
-# ifdef HAVE_MALLOC_H
-#  include <malloc.h>
-# else
-void free ();
-# endif
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-# 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 <stdlib.h>
+#include <string.h>
 
 #if defined HAVE_UNISTD_H || defined _LIBC
 # include <unistd.h>
 #endif
 
-#include "gettext.h"
 #include "gettextP.h"
 #ifdef _LIBC
 # include <libintl.h>
 #else
-# include "libgettext.h"
+# include "libgnuintl.h"
 #endif
 
 /* @@ end of prolog @@ */
@@ -71,10 +47,11 @@
    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;
@@ -120,7 +97,7 @@
       int cnt;
 
       if (retval->decided == 0)
-       _nl_load_domain (retval);
+       _nl_load_domain (retval, domainbinding);
 
       if (retval->data != NULL)
        return retval;
@@ -128,7 +105,7 @@
       for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
        {
          if (retval->successor[cnt]->decided == 0)
-           _nl_load_domain (retval->successor[cnt]);
+           _nl_load_domain (retval->successor[cnt], domainbinding);
 
          if (retval->successor[cnt]->data != NULL)
            break;
@@ -175,14 +152,14 @@
     return NULL;
 
   if (retval->decided == 0)
-    _nl_load_domain (retval);
+    _nl_load_domain (retval, domainbinding);
   if (retval->data == NULL)
     {
       int cnt;
       for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
        {
          if (retval->successor[cnt]->decided == 0)
-           _nl_load_domain (retval->successor[cnt]);
+           _nl_load_domain (retval->successor[cnt], domainbinding);
          if (retval->successor[cnt]->data != NULL)
            break;
        }
@@ -192,6 +169,10 @@
   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 +189,7 @@
       if (runp->data != NULL)
        _nl_unload_domain ((struct loaded_domain *) runp->data);
       runp = runp->next;
+      free ((char *) here->filename);
       free (here);
     }
 }

Index: gettext.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/gettext.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gettext.c   12 Oct 2000 19:26:16 -0000      1.1
+++ gettext.c   10 Apr 2003 21:34:16 -0000      1.2
@@ -1,19 +1,20 @@
 /* Implementation of gettext(3) function.
-   Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 2000, 2001, 2002 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -23,21 +24,14 @@
 # define __need_NULL
 # include <stddef.h>
 #else
-# ifdef STDC_HEADERS
-#  include <stdlib.h>          /* Just for NULL.  */
-# else
-#  ifdef HAVE_STRING_H
-#   include <string.h>
-#  else
-#   define NULL ((void *) 0)
-#  endif
-# endif
+# include <stdlib.h>           /* Just for NULL.  */
 #endif
 
+#include "gettextP.h"
 #ifdef _LIBC
 # include <libintl.h>
 #else
-# include "libgettext.h"
+# include "libgnuintl.h"
 #endif
 
 /* @@ end of prolog @@ */
@@ -48,10 +42,10 @@
    prefix.  So we have to make a difference here.  */
 #ifdef _LIBC
 # define GETTEXT __gettext
-# define DGETTEXT __dgettext
+# define DCGETTEXT INTUSE(__dcgettext)
 #else
-# define GETTEXT gettext__
-# define DGETTEXT dgettext__
+# define GETTEXT libintl_gettext
+# define DCGETTEXT libintl_dcgettext
 #endif
 
 /* Look up MSGID in the current default message catalog for the current
@@ -61,7 +55,7 @@
 GETTEXT (msgid)
      const char *msgid;
 {
-  return DGETTEXT (NULL, msgid);
+  return DCGETTEXT (NULL, msgid, LC_MESSAGES);
 }
 
 #ifdef _LIBC

Index: gettextP.h
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/gettextP.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gettextP.h  12 Oct 2000 19:26:16 -0000      1.1
+++ gettextP.h  10 Apr 2003 21:34:16 -0000      1.2
@@ -1,30 +1,43 @@
-/* Header describing internals of gettext library
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
-   Written by Ulrich Drepper <address@hidden>, 1995.
+/* Header describing internals of libintl library.
+   Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc.
+   Written by Ulrich Drepper <address@hidden>, 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifndef _GETTEXTP_H
 #define _GETTEXTP_H
 
+#include <stddef.h>            /* Get size_t.  */
+
+#ifdef _LIBC
+# include "../iconv/gconv_int.h"
+#else
+# if HAVE_ICONV
+#  include <iconv.h>
+# endif
+#endif
+
 #include "loadinfo.h"
 
+#include "gmo.h"               /* Get nls_uint32.  */
+
 /* @@ end of prolog @@ */
 
 #ifndef PARAMS
-# if __STDC__
+# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus 
|| __PROTOTYPES
 #  define PARAMS(args) args
 # else
 #  define PARAMS(args) ()
@@ -35,6 +48,16 @@
 # define internal_function
 #endif
 
+#ifndef attribute_hidden
+# define attribute_hidden
+#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 +67,6 @@
 # include <byteswap.h>
 # 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,34 +76,166 @@
 #endif
 
 
+/* In-memory representation of system dependent string.  */
+struct sysdep_string_desc
+{
+  /* Length of addressed string, including the trailing NUL.  */
+  size_t length;
+  /* Pointer to addressed string.  */
+  const char *pointer;
+};
+
+/* The representation of an opened message catalog.  */
 struct loaded_domain
 {
+  /* Pointer to memory containing the .mo file.  */
   const char *data;
+  /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed.  */
   int use_mmap;
+  /* Size of mmap()ed memory.  */
   size_t mmap_size;
+  /* 1 if the .mo file uses a different endianness than this machine.  */
   int must_swap;
+  /* Pointer to additional malloc()ed memory.  */
+  void *malloced;
+
+  /* Number of static strings pairs.  */
   nls_uint32 nstrings;
-  struct string_desc *orig_tab;
-  struct string_desc *trans_tab;
+  /* Pointer to descriptors of original strings in the file.  */
+  const struct string_desc *orig_tab;
+  /* Pointer to descriptors of translated strings in the file.  */
+  const struct string_desc *trans_tab;
+
+  /* Number of system dependent strings pairs.  */
+  nls_uint32 n_sysdep_strings;
+  /* Pointer to descriptors of original sysdep strings.  */
+  const struct sysdep_string_desc *orig_sysdep_tab;
+  /* Pointer to descriptors of translated sysdep strings.  */
+  const struct sysdep_string_desc *trans_sysdep_tab;
+
+  /* Size of hash table.  */
   nls_uint32 hash_size;
-  nls_uint32 *hash_tab;
+  /* Pointer to hash table.  */
+  const nls_uint32 *hash_tab;
+  /* 1 if the hash table uses a different endianness than this machine.  */
+  int must_swap_hash_tab;
+
+  int codeset_cntr;
+#ifdef _LIBC
+  __gconv_t conv;
+#else
+# if HAVE_ICONV
+  iconv_t conv;
+# endif
+#endif
+  char **conv_tab;
+
+  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;
+  int codeset_cntr;    /* Incremented each time codeset changes.  */
+  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;
+
+#ifndef _LIBC
+const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
+#endif
+
 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))
+void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
+                             struct binding *__domainbinding))
      internal_function;
 void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
      internal_function;
+const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile 
*__domain_file,
+                                         struct loaded_domain *__domain,
+                                         struct binding *__domainbinding))
+     internal_function;
+void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
+     internal_function;
+
+char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
+                           struct binding *domainbinding,
+                           const char *msgid, size_t *lengthp))
+     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 *libintl_gettext PARAMS ((const char *__msgid));
+extern char *libintl_dgettext PARAMS ((const char *__domainname,
+                                      const char *__msgid));
+extern char *libintl_dcgettext PARAMS ((const char *__domainname,
+                                       const char *__msgid, int __category));
+extern char *libintl_ngettext PARAMS ((const char *__msgid1,
+                                      const char *__msgid2,
+                                      unsigned long int __n));
+extern char *libintl_dngettext PARAMS ((const char *__domainname,
+                                       const char *__msgid1,
+                                       const char *__msgid2,
+                                       unsigned long int __n));
+extern char *libintl_dcngettext PARAMS ((const char *__domainname,
+                                        const char *__msgid1,
+                                        const char *__msgid2,
+                                        unsigned long int __n,
+                                        int __category));
+extern char *libintl_dcigettext PARAMS ((const char *__domainname,
+                                        const char *__msgid1,
+                                        const char *__msgid2,
+                                        int __plural, unsigned long int __n,
+                                        int __category));
+extern char *libintl_textdomain PARAMS ((const char *__domainname));
+extern char *libintl_bindtextdomain PARAMS ((const char *__domainname,
+                                            const char *__dirname));
+extern char *libintl_bind_textdomain_codeset PARAMS ((const char *__domainname,
+                                                     const char *__codeset));
+#endif
 
 /* @@ begin of epilog @@ */
 

Index: hash-string.h
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/hash-string.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hash-string.h       12 Oct 2000 19:26:16 -0000      1.1
+++ hash-string.h       10 Apr 2003 21:34:16 -0000      1.2
@@ -1,25 +1,25 @@
-/* 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
    You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   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 @@ */
 
 #ifndef PARAMS
-# if __STDC__
+# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus 
|| __PROTOTYPES
 #  define PARAMS(Args) Args
 # else
 #  define PARAMS(Args) ()

Index: intl-compat.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/intl-compat.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- intl-compat.c       12 Oct 2000 19:26:16 -0000      1.1
+++ intl-compat.c       10 Apr 2003 21:34:16 -0000      1.2
@@ -1,43 +1,64 @@
 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
    Library.
-   Copyright (C) 1995 Software Foundation, Inc.
+   Copyright (C) 1995, 2000-2002 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
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
+   any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#include "libgettext.h"
+#define _INTL_REDIRECT_MACROS
+#include "libgnuintl.h"
+#include "gettextP.h"
 
 /* @@ end of prolog @@ */
 
+/* This file redirects the gettext functions (without prefix) to those
+   defined in the included GNU libintl library (with "libintl_" prefix).
+   It is compiled into libintl in order to make the AM_GNU_GETTEXT test
+   of gettext <= 0.11.2 work with the libintl library >= 0.11.3 which
+   has the redirections primarily in the <libintl.h> include file.  */
+
 
 #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 libintl_gettext (msgid);
+}
+
+
+char *
+dgettext (domainname, msgid)
      const char *domainname;
-     const char *dirname;
+     const char *msgid;
 {
-  return bindtextdomain__ (domainname, dirname);
+  return libintl_dgettext (domainname, msgid);
 }
 
 
@@ -47,24 +68,40 @@
      const char *msgid;
      int category;
 {
-  return dcgettext__ (domainname, msgid, category);
+  return libintl_dcgettext (domainname, msgid, category);
 }
 
 
 char *
-dgettext (domainname, msgid)
+ngettext (msgid1, msgid2, n)
+     const char *msgid1;
+     const char *msgid2;
+     unsigned long int n;
+{
+  return libintl_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 libintl_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 libintl_dcngettext (domainname, msgid1, msgid2, n, category);
 }
 
 
@@ -72,5 +109,23 @@
 textdomain (domainname)
      const char *domainname;
 {
-  return textdomain__ (domainname);
+  return libintl_textdomain (domainname);
+}
+
+
+char *
+bindtextdomain (domainname, dirname)
+     const char *domainname;
+     const char *dirname;
+{
+  return libintl_bindtextdomain (domainname, dirname);
+}
+
+
+char *
+bind_textdomain_codeset (domainname, codeset)
+     const char *domainname;
+     const char *codeset;
+{
+  return libintl_bind_textdomain_codeset (domainname, codeset);
 }

Index: l10nflist.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/l10nflist.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- l10nflist.c 12 Oct 2000 19:26:16 -0000      1.1
+++ l10nflist.c 10 Apr 2003 21:34:16 -0000      1.2
@@ -1,52 +1,40 @@
-/* Handle list of needed message catalogs
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Ulrich Drepper <address@hidden>, 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
+
+/* Tell glibc's <string.h> to provide a prototype for stpcpy().
+   This must come before <config.h> because <config.h> may include
+   <features.h>, and once <features.h> has been included, it's too late.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE   1
+#endif
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-
-#if defined HAVE_STRING_H || defined _LIBC
-# ifndef _GNU_SOURCE
-#  define _GNU_SOURCE  1
-# endif
-# include <string.h>
-#else
-# include <strings.h>
-# 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 <string.h>
 
 #if defined _LIBC || defined HAVE_ARGZ_H
 # include <argz.h>
 #endif
 #include <ctype.h>
 #include <sys/types.h>
-
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
 
 #include "loadinfo.h"
 
@@ -74,6 +62,24 @@
 # endif
 #endif
 
+/* Pathname support.
+   ISSLASH(C)           tests whether C is a directory separator character.
+   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
+                        it may be concatenated to a directory pathname.
+ */
+#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
+  /* Win32, OS/2, DOS */
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+# define HAS_DEVICE(P) \
+    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
+     && (P)[1] == ':')
+# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
+#else
+  /* Unix */
+# define ISSLASH(C) ((C) == '/')
+# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
+#endif
+
 /* Define function which are usually not available.  */
 
 #if !defined _LIBC && !defined HAVE___ARGZ_COUNT
@@ -97,6 +103,10 @@
 }
 # undef __argz_count
 # define __argz_count(argz, len) argz_count__ (argz, len)
+#else
+# ifdef _LIBC
+#  define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
+# endif
 #endif /* !_LIBC && !HAVE___ARGZ_COUNT */
 
 #if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
@@ -121,6 +131,11 @@
 }
 # undef __argz_stringify
 # define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
+#else
+# ifdef _LIBC
+#  define __argz_stringify(argz, len, sep) \
+  INTUSE(__argz_stringify) (argz, len, sep)
+# endif
 #endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
 
 #if !defined _LIBC && !defined HAVE___ARGZ_NEXT
@@ -188,12 +203,18 @@
      int do_allocate;
 {
   char *abs_filename;
-  struct loaded_l10nfile *last = NULL;
+  struct loaded_l10nfile **lastp;
   struct loaded_l10nfile *retval;
   char *cp;
+  size_t dirlist_count;
   size_t entries;
   int cnt;
 
+  /* If LANGUAGE contains an absolute directory specification, we ignore
+     DIRLIST.  */
+  if (IS_ABSOLUTE_PATH (language))
+    dirlist_len = 0;
+
   /* Allocate room for the full file name.  */
   abs_filename = (char *) malloc (dirlist_len
                                  + strlen (language)
@@ -211,7 +232,7 @@
                                  + (((mask & CEN_SPONSOR) != 0
                                      || (mask & CEN_REVISION) != 0)
                                     ? (1 + ((mask & CEN_SPONSOR) != 0
-                                            ? strlen (sponsor) + 1 : 0)
+                                            ? strlen (sponsor) : 0)
                                        + ((mask & CEN_REVISION) != 0
                                           ? strlen (revision) + 1 : 0)) : 0)
                                  + 1 + strlen (filename) + 1);
@@ -219,14 +240,16 @@
   if (abs_filename == NULL)
     return NULL;
 
-  retval = NULL;
-  last = NULL;
-
   /* Construct file name.  */
-  memcpy (abs_filename, dirlist, dirlist_len);
-  __argz_stringify (abs_filename, dirlist_len, ':');
-  cp = abs_filename + (dirlist_len - 1);
-  *cp++ = '/';
+  cp = abs_filename;
+  if (dirlist_len > 0)
+    {
+      memcpy (cp, dirlist, dirlist_len);
+      __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
+      cp += dirlist_len;
+      cp[-1] = '/';
+    }
+
   cp = stpcpy (cp, language);
 
   if ((mask & TERRITORY) != 0)
@@ -273,7 +296,7 @@
 
   /* Look in list of already loaded domains whether it is already
      available.  */
-  last = NULL;
+  lastp = l10nfile_list;
   for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
     if (retval->filename != NULL)
       {
@@ -288,7 +311,7 @@
            break;
          }
 
-       last = retval;
+       lastp = &retval->next;
       }
 
   if (retval != NULL || do_allocate == 0)
@@ -297,48 +320,66 @@
       return retval;
     }
 
-  retval = (struct loaded_l10nfile *)
-    malloc (sizeof (*retval) + (__argz_count (dirlist, dirlist_len)
-                               * (1 << pop (mask))
-                               * sizeof (struct loaded_l10nfile *)));
+  dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
+
+  /* Allocate a new loaded_l10nfile.  */
+  retval =
+    (struct loaded_l10nfile *)
+    malloc (sizeof (*retval)
+           + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
+              * sizeof (struct loaded_l10nfile *)));
   if (retval == NULL)
     return NULL;
 
   retval->filename = abs_filename;
-  retval->decided = (__argz_count (dirlist, dirlist_len) != 1
+
+  /* We set retval->data to NULL here; it is filled in later.
+     Setting retval->decided to 1 here means that retval does not
+     correspond to a real file (dirlist_count > 1) or is not worth
+     looking up (if an unnormalized codeset was specified).  */
+  retval->decided = (dirlist_count > 1
                     || ((mask & XPG_CODESET) != 0
                         && (mask & XPG_NORM_CODESET) != 0));
   retval->data = NULL;
 
-  if (last == NULL)
-    {
-      retval->next = *l10nfile_list;
-      *l10nfile_list = retval;
-    }
-  else
-    {
-      retval->next = last->next;
-      last->next = retval;
-    }
+  retval->next = *lastp;
+  *lastp = retval;
 
   entries = 0;
-  /* If the DIRLIST is a real list the RETVAL entry corresponds not to
-     a real file.  So we have to use the DIRLIST separation mechanism
-     of the inner loop.  */
-  cnt = __argz_count (dirlist, dirlist_len) == 1 ? mask - 1 : mask;
-  for (; cnt >= 0; --cnt)
+  /* Recurse to fill the inheritance list of RETVAL.
+     If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL
+     entry does not correspond to a real file; retval->filename contains
+     colons.  In this case we loop across all elements of DIRLIST and
+     across all bit patterns dominated by MASK.
+     If the DIRLIST is a single directory or entirely redundant (i.e.
+     DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
+     MASK, excluding MASK itself.
+     In either case, we loop down from MASK to 0.  This has the effect
+     that the extra bits in the locale name are dropped in this order:
+     first the modifier, then the territory, then the codeset, then the
+     normalized_codeset.  */
+  for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
     if ((cnt & ~mask) == 0
        && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
        && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
       {
-       /* Iterate over all elements of the DIRLIST.  */
-       char *dir = NULL;
+       if (dirlist_count > 1)
+         {
+           /* Iterate over all elements of the DIRLIST.  */
+           char *dir = NULL;
 
-       while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
-              != NULL)
+           while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
+                  != NULL)
+             retval->successor[entries++]
+               = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
+                                     cnt, language, territory, codeset,
+                                     normalized_codeset, modifier, special,
+                                     sponsor, revision, filename, 1);
+         }
+       else
          retval->successor[entries++]
-           = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt,
-                                 language, territory, codeset,
+           = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
+                                 cnt, language, territory, codeset,
                                  normalized_codeset, modifier, special,
                                  sponsor, revision, filename, 1);
       }
@@ -349,7 +390,8 @@
 
 /* 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;
@@ -362,11 +404,11 @@
   size_t cnt;
 
   for (cnt = 0; cnt < name_len; ++cnt)
-    if (isalnum (codeset[cnt]))
+    if (isalnum ((unsigned char) codeset[cnt]))
       {
        ++len;
 
-       if (isalpha (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
          only_digit = 0;
       }
 
@@ -380,9 +422,9 @@
        wp = retval;
 
       for (cnt = 0; cnt < name_len; ++cnt)
-       if (isalpha (codeset[cnt]))
-         *wp++ = tolower (codeset[cnt]);
-       else if (isdigit (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
+         *wp++ = tolower ((unsigned char) codeset[cnt]);
+       else if (isdigit ((unsigned char) codeset[cnt]))
          *wp++ = codeset[cnt];
 
       *wp = '\0';

Index: loadinfo.h
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/loadinfo.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- loadinfo.h  12 Oct 2000 19:26:16 -0000      1.1
+++ loadinfo.h  10 Apr 2003 21:34:16 -0000      1.2
@@ -1,29 +1,64 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2000-2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <address@hidden>, 1996.
 
-   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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
+
+#ifndef _LOADINFO_H
+#define _LOADINFO_H    1
+
+/* Declarations of locale dependent catalog lookup functions.
+   Implemented in
+
+     localealias.c    Possibly replace a locale name by another.
+     explodename.c    Split a locale name into its various fields.
+     l10nflist.c      Generate a list of filenames of possible message 
catalogs.
+     finddomain.c     Find and open the relevant message catalogs.
+
+   The main function _nl_find_domain() in finddomain.c is declared
+   in gettextP.h.
+ */
 
 #ifndef PARAMS
-# if __STDC__
+# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus 
|| __PROTOTYPES
 #  define PARAMS(args) args
 # else
 #  define PARAMS(args) ()
 # 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
@@ -50,9 +85,27 @@
 };
 
 
+/* 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));
 
+/* Lookup a locale dependent file.
+   *L10NFILE_LIST denotes a pool of lookup results of locale dependent
+   files of the same kind, sorted in decreasing order of ->filename.
+   DIRLIST and DIRLIST_LEN are an argz list of directories in which to
+   look, containing at least one directory (i.e. DIRLIST_LEN > 0).
+   MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER,
+   SPECIAL, SPONSOR, REVISION are the pieces of the locale name, as
+   produced by _nl_explode_name().  FILENAME is the filename suffix.
+   The return value is the lookup result, either found in *L10NFILE_LIST,
+   or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL.
+   If the return value is non-NULL, it is added to *L10NFILE_LIST, and
+   its ->next field denotes the chaining inside *L10NFILE_LIST, and
+   furthermore its ->successor[] field contains a list of other lookup
+   results from which this lookup result inherits.  */
 extern struct loaded_l10nfile *
 _nl_make_l10nflist PARAMS ((struct loaded_l10nfile **l10nfile_list,
                            const char *dirlist, size_t dirlist_len, int mask,
@@ -63,9 +116,29 @@
                            const char *sponsor, const char *revision,
                            const char *filename, int do_allocate));
 
-
+/* Lookup the real locale name for a locale alias NAME, or NULL if
+   NAME is not a locale alias (but possibly a real locale name).
+   The return value is statically allocated and must not be freed.  */
 extern const char *_nl_expand_alias PARAMS ((const char *name));
 
+/* Split a locale name NAME into its pieces: language, modifier,
+   territory, codeset, special, sponsor, revision.
+   NAME gets destructively modified: NUL bytes are inserted here and
+   there.  *LANGUAGE gets assigned NAME.  Each of *MODIFIER, *TERRITORY,
+   *CODESET, *SPECIAL, *SPONSOR, *REVISION gets assigned either a
+   pointer into the old NAME string, or NULL.  *NORMALIZED_CODESET
+   gets assigned the expanded *CODESET, if it is different from *CODESET;
+   this one is dynamically allocated and has to be freed by the caller.
+   The return value is a bitmask, where each bit corresponds to one
+   filled-in value:
+     XPG_MODIFIER, CEN_AUDIENCE  for *MODIFIER,
+     TERRITORY                   for *TERRITORY,
+     XPG_CODESET                 for *CODESET,
+     XPG_NORM_CODESET            for *NORMALIZED_CODESET,
+     CEN_SPECIAL                 for *SPECIAL,
+     CEN_SPONSOR                 for *SPONSOR,
+     CEN_REVISION                for *REVISION.
+ */
 extern int _nl_explode_name PARAMS ((char *name, const char **language,
                                     const char **modifier,
                                     const char **territory,
@@ -75,4 +148,9 @@
                                     const char **sponsor,
                                     const char **revision));
 
+/* Split a locale name NAME into a leading language part and all the
+   rest.  Return a pointer to the first character after the language,
+   i.e. to the first byte of the rest.  */
 extern char *_nl_find_language PARAMS ((const char *name));
+
+#endif /* loadinfo.h */

Index: loadmsgcat.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/loadmsgcat.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- loadmsgcat.c        12 Oct 2000 19:26:16 -0000      1.1
+++ loadmsgcat.c        10 Apr 2003 21:34:16 -0000      1.2
@@ -1,36 +1,67 @@
 /* Load needed message catalogs.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999, 2000-2002 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
[...1275 lines suppressed...]
      struct loaded_domain *domain;
 {
-#ifdef _POSIX_MAPPED_FILES
+  if (domain->plural != &__gettext_germanic_plural)
+    __gettext_free_exp (domain->plural);
+
+  _nl_free_domain_conv (domain);
+
+  if (domain->malloced)
+    free (domain->malloced);
+
+# 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);

Index: localealias.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/localealias.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- localealias.c       12 Oct 2000 19:26:16 -0000      1.1
+++ localealias.c       10 Apr 2003 21:34:16 -0000      1.2
@@ -1,20 +1,27 @@
 /* Handle aliases for locale names.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
-   Written by Ulrich Drepper <address@hidden>, 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
+
+/* Tell glibc's <string.h> to provide a prototype for mempcpy().
+   This must come before <config.h> because <config.h> may include
+   <features.h>, and once <features.h> has been included, it's too late.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE    1
+#endif
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -22,6 +29,9 @@
 
 #include <ctype.h>
 #include <stdio.h>
+#if defined _LIBC || defined HAVE___FSETLOCKING
+# include <stdio_ext.h>
+#endif
 #include <sys/types.h>
 
 #ifdef __GNUC__
@@ -41,35 +51,9 @@
 # endif
 #endif
 
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#else
-char *getenv ();
-# ifdef HAVE_MALLOC_H
-#  include <malloc.h>
-# else
-void free ();
-# endif
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# ifndef _GNU_SOURCE
-#  define _GNU_SOURCE  1
-# endif
-# include <string.h>
-#else
-# include <strings.h>
-# 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 <stdlib.h>
+#include <string.h>
 
-#include "gettext.h"
 #include "gettextP.h"
 
 /* @@ end of prolog @@ */
@@ -84,6 +68,7 @@
 #  define mempcpy __mempcpy
 # endif
 # define HAVE_MEMPCPY  1
+# define HAVE___FSETLOCKING    1
 
 /* We need locking here since we can be called from different places.  */
 # include <bits/libc-lock.h>
@@ -95,40 +80,23 @@
 # define internal_function
 #endif
 
-/* For those loosing systems which don't have `alloca' we have to add
+/* Some optimizations for glibc.  */
+#ifdef _LIBC
+# define FEOF(fp)              feof_unlocked (fp)
+# define FGETS(buf, n, fp)     fgets_unlocked (buf, n, fp)
+#else
+# define FEOF(fp)              feof (fp)
+# define FGETS(buf, n, fp)     fgets (buf, n, fp)
+#endif
+
+/* 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 +115,18 @@
 };
 
 
-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));
 
@@ -167,7 +135,7 @@
 _nl_expand_alias (name)
     const char *name;
 {
-  static const char *locale_alias_path = LOCALE_ALIAS_PATH;
+  static const char *locale_alias_path;
   struct alias_map *retval;
   const char *result = NULL;
   size_t added;
@@ -176,6 +144,9 @@
   __libc_lock_lock (lock);
 #endif
 
+  if (locale_alias_path == NULL)
+    locale_alias_path = LOCALE_ALIAS_PATH;
+
   do
     {
       struct alias_map item;
@@ -204,11 +175,12 @@
        {
          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 +203,12 @@
      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,14 +218,17 @@
 #endif
 
   fp = fopen (full_fname, "r");
+  freea (full_fname);
   if (fp == NULL)
-    {
-      FREE_BLOCKS (block_list);
-      return 0;
-    }
+    return 0;
+
+#ifdef HAVE___FSETLOCKING
+  /* No threads present.  */
+  __fsetlocking (fp, FSETLOCKING_BYCALLER);
+#endif
 
   added = 0;
-  while (!feof (fp))
+  while (!FEOF (fp))
     {
       /* It is a reasonable approach to use a fix buffer here because
         a) we are only interested in the first two fields
@@ -269,7 +240,7 @@
       char *value;
       char *cp;
 
-      if (fgets (buf, sizeof buf, fp) == NULL)
+      if (FGETS (buf, sizeof buf, fp) == NULL)
        /* EOF reached.  */
        break;
 
@@ -279,7 +250,7 @@
        {
          char altbuf[BUFSIZ];
          do
-           if (fgets (altbuf, sizeof altbuf, fp) == NULL)
+           if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
              /* Make sure the inner loop will be left.  The outer loop
                 will exit at the `feof' test.  */
              break;
@@ -288,21 +259,21 @@
 
       cp = buf;
       /* Ignore leading white space.  */
-      while (isspace (cp[0]))
+      while (isspace ((unsigned char) cp[0]))
        ++cp;
 
       /* A leading '#' signals a comment line.  */
       if (cp[0] != '\0' && cp[0] != '#')
        {
          alias = cp++;
-         while (cp[0] != '\0' && !isspace (cp[0]))
+         while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
            ++cp;
          /* Terminate alias name.  */
          if (cp[0] != '\0')
            *cp++ = '\0';
 
          /* Now look for the beginning of the value.  */
-         while (isspace (cp[0]))
+         while (isspace ((unsigned char) cp[0]))
            ++cp;
 
          if (cp[0] != '\0')
@@ -311,7 +282,7 @@
              size_t value_len;
 
              value = cp++;
-             while (cp[0] != '\0' && !isspace (cp[0]))
+             while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
                ++cp;
              /* Terminate value.  */
              if (cp[0] == '\n')
@@ -326,7 +297,8 @@
                *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 +311,19 @@
                                        ? 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 +350,11 @@
     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 +365,11 @@
                                                * 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;
 }
 
 

Index: textdomain.c
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/intl/textdomain.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- textdomain.c        12 Oct 2000 19:26:16 -0000      1.1
+++ textdomain.c        10 Apr 2003 21:34:16 -0000      1.2
@@ -1,51 +1,60 @@
 /* Implementation of the textdomain(3) function.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
-   Written by Ulrich Drepper <address@hidden>, 1995.
+   Copyright (C) 1995-1998, 2000, 2001, 2002 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
-   the Free Software Foundation; either version 2, or (at your option)
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published
+   by the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-   You should have received a copy of the GNU 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
 
-#if defined STDC_HEADERS || defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
+#ifdef _LIBC
+# include <libintl.h>
 #else
-# include <strings.h>
-# ifndef memcpy
-#  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
-# endif
+# include "libgnuintl.h"
 #endif
+#include "gettextP.h"
 
 #ifdef _LIBC
-# include <libintl.h>
+/* We have to handle multi-threaded applications.  */
+# include <bits/libc-lock.h>
 #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 libintl_nl_default_default_domain
+# define _nl_current_default_domain libintl_nl_current_default_domain
 #endif
 
 /* @@ end of prolog @@ */
 
 /* Name of the default text domain.  */
-extern const char _nl_default_default_domain[];
+extern const char _nl_default_default_domain[] attribute_hidden;
 
 /* Default text domain in which entries for gettext(3) are to be found.  */
-extern const char *_nl_current_default_domain;
+extern const char *_nl_current_default_domain attribute_hidden;
 
 
 /* Names for the libintl functions are a problem.  They must not clash
@@ -58,9 +67,12 @@
 #  define strdup(str) __strdup (str)
 # endif
 #else
-# define TEXTDOMAIN textdomain__
+# define TEXTDOMAIN libintl_textdomain
 #endif
 
+/* Lock variable to protect the global data in the gettext implementation.  */
+__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
+
 /* 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 +80,60 @@
 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;
     }
 
-  if (old != _nl_default_default_domain)
-    free (old);
+  /* 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;
 
-  return (char *) _nl_current_default_domain;
+      if (old_domain != new_domain && old_domain != _nl_default_default_domain)
+       free (old_domain);
+    }
+
+  __libc_rwlock_unlock (_nl_state_lock);
+
+  return new_domain;
 }
 
 #ifdef _LIBC





reply via email to

[Prev in Thread] Current Thread [Next in Thread]