summaryrefslogtreecommitdiff
path: root/popt
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-07-21 14:20:41 +0000
committerjbj <devnull@localhost>2002-07-21 14:20:41 +0000
commit6eecde7ae6ef5e39945054716e4d69e77378ff8d (patch)
tree774e13afa06fd2cd4c378013bbc07827d3b4c7cf /popt
parent22016eccf09b1b396a3c536afc8c0b9e1afe1c62 (diff)
downloadlibrpm-tizen-6eecde7ae6ef5e39945054716e4d69e77378ff8d.tar.gz
librpm-tizen-6eecde7ae6ef5e39945054716e4d69e77378ff8d.tar.bz2
librpm-tizen-6eecde7ae6ef5e39945054716e4d69e77378ff8d.zip
Update to gettext-0.11.2-3 intl contents.
CVS patchset: 5564 CVS date: 2002/07/21 14:20:41
Diffstat (limited to 'popt')
-rw-r--r--popt/intl/COPYING.LIB-2.0 (renamed from popt/intl/COPYING.LIB)7
-rw-r--r--popt/intl/ChangeLog4
-rw-r--r--popt/intl/Makefile.in58
-rw-r--r--popt/intl/VERSION2
-rw-r--r--popt/intl/bindtextdom.c6
-rwxr-xr-xpopt/intl/config.charset24
-rw-r--r--popt/intl/dcgettext.c3
-rw-r--r--popt/intl/dcigettext.c151
-rw-r--r--popt/intl/dcngettext.c3
-rw-r--r--popt/intl/dgettext.c4
-rw-r--r--popt/intl/dngettext.c4
-rw-r--r--popt/intl/eval-plural.h106
-rw-r--r--popt/intl/gettext.c4
-rw-r--r--popt/intl/gettextP.h69
-rw-r--r--popt/intl/gmo.h100
-rw-r--r--popt/intl/hash-string.h2
-rw-r--r--popt/intl/l10nflist.c26
-rw-r--r--popt/intl/libgnuintl.h60
-rw-r--r--popt/intl/loadinfo.h14
-rw-r--r--popt/intl/loadmsgcat.c144
-rw-r--r--popt/intl/localcharset.c94
-rw-r--r--popt/intl/localealias.c43
-rw-r--r--popt/intl/localename.c694
-rw-r--r--popt/intl/ngettext.c4
-rw-r--r--popt/intl/os2compat.c98
-rw-r--r--popt/intl/os2compat.h46
-rw-r--r--popt/intl/osdep.c24
-rw-r--r--popt/intl/plural-exp.c156
-rw-r--r--popt/intl/plural-exp.h126
-rw-r--r--popt/intl/plural.c58
-rw-r--r--popt/intl/plural.y20
-rw-r--r--popt/intl/textdomain.c8
32 files changed, 1701 insertions, 461 deletions
diff --git a/popt/intl/COPYING.LIB b/popt/intl/COPYING.LIB-2.0
index 92b8903ff..161a3d1d4 100644
--- a/popt/intl/COPYING.LIB
+++ b/popt/intl/COPYING.LIB-2.0
@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -436,7 +436,7 @@ DAMAGES.
END OF TERMS AND CONDITIONS
- How to Apply These Terms to Your New Libraries
+ Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
@@ -464,7 +464,8 @@ convey the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA
Also add information on how to contact you by electronic and paper mail.
diff --git a/popt/intl/ChangeLog b/popt/intl/ChangeLog
index 84e2b37ec..c75d30c22 100644
--- a/popt/intl/ChangeLog
+++ b/popt/intl/ChangeLog
@@ -1,4 +1,4 @@
-2001-09-13 GNU <bug-gnu-utils@gnu.org>
+2002-04-24 GNU <bug-gnu-gettext@gnu.org>
- * Version 0.10.40 released.
+ * Version 0.11.2 released.
diff --git a/popt/intl/Makefile.in b/popt/intl/Makefile.in
index 19ed4a7e0..5b1cf2f26 100644
--- a/popt/intl/Makefile.in
+++ b/popt/intl/Makefile.in
@@ -1,5 +1,5 @@
# Makefile for directory with message catalog handling in GNU NLS Utilities.
-# Copyright (C) 1995-1998, 2000, 2001 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 Library General Public License as published
@@ -52,38 +52,39 @@ YACC = @INTLBISON@ -y -d
YFLAGS = --name-prefix=__gettext
DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
--DLIBDIR=\"$(libdir)\" @DEFS@
+-DLIBDIR=\"$(libdir)\" -DIN_LIBINTL @DEFS@
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
-HEADERS = $(COMHDRS) libgnuintl.h libgettext.h loadinfo.h
-COMHDRS = gettext.h gettextP.h hash-string.h
+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 dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y \
-localcharset.c
+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 dcigettext.$lo dcngettext.$lo dngettext.$lo ngettext.$lo \
-plural.$lo localcharset.$lo
+plural.$lo plural-exp.$lo localcharset.$lo localename.$lo osdep.$lo
GETTOBJS = intl-compat.$lo
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 = COPYING.LIB-2 COPYING.LIB-2.1 libintl.glibc
-DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c
+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=1
+LTV_CURRENT=2
LTV_REVISION=1
LTV_AGE=0
@@ -118,7 +119,7 @@ libintl.a libgnuintl.a: $(OBJECTS)
libintl.la libgnuintl.la: $(OBJECTS)
$(LIBTOOL) --mode=link \
$(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \
- $(OBJECTS) @LIBICONV@ \
+ $(OBJECTS) @LTLIBICONV@ -lc \
-version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
-rpath $(libdir) \
-no-undefined
@@ -152,7 +153,7 @@ install-exec: all
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
- $(mkinstalldirs) $(DESTDIR)$(libdir); \
+ 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 \
@@ -185,7 +186,7 @@ install-data: all
$(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
$(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
$(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \
- dists="COPYING.LIB-2 COPYING.LIB-2.1 $(DISTFILES.common)"; \
+ dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \
for file in $$dists; do \
$(INSTALL_DATA) $(srcdir)/$$file \
$(DESTDIR)$(gettextsrcdir)/$$file; \
@@ -205,6 +206,27 @@ install-data: all
: ; \
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:
@@ -244,7 +266,7 @@ uninstall:
: ; \
fi
if test "$(PACKAGE)" = "gettext"; then \
- for file in VERSION ChangeLog COPYING.LIB-2 COPYING.LIB-2.1 $(DISTFILES.common) $(DISTFILES.generated); do \
+ 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 \
@@ -254,8 +276,11 @@ uninstall:
info dvi:
$(OBJECTS): ../config.h libgnuintl.h
-bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h
-dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h
+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
@@ -300,8 +325,7 @@ dist distdir: Makefile
$(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; \
- ln $$dir/$$file $(distdir) 2> /dev/null \
- || cp -p $$dir/$$file $(distdir); \
+ cp -p $$dir/$$file $(distdir); \
done
Makefile: Makefile.in ../config.status
diff --git a/popt/intl/VERSION b/popt/intl/VERSION
index cb8a01a78..657e73b6b 100644
--- a/popt/intl/VERSION
+++ b/popt/intl/VERSION
@@ -1 +1 @@
-GNU gettext library from gettext-0.10.40
+GNU gettext library from gettext-0.11.2
diff --git a/popt/intl/bindtextdom.c b/popt/intl/bindtextdom.c
index c6a9bd164..a3c233d77 100644
--- a/popt/intl/bindtextdom.c
+++ b/popt/intl/bindtextdom.c
@@ -1,5 +1,5 @@
/* Implementation of the bindtextdomain(3) function
- Copyright (C) 1995-1998, 2000, 2001 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 Library General Public License as published
@@ -63,7 +63,7 @@ extern const char _nl_default_dirname[];
extern struct binding *_nl_domain_bindings;
/* Lock variable to protect the global data in the gettext implementation. */
-__libc_rwlock_define (extern, _nl_state_lock)
+__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
/* Names for the libintl functions are a problem. They must not clash
@@ -85,7 +85,7 @@ __libc_rwlock_define (extern, _nl_state_lock)
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
diff --git a/popt/intl/config.charset b/popt/intl/config.charset
index f4f2611c5..0a1a68db1 100755
--- a/popt/intl/config.charset
+++ b/popt/intl/config.charset
@@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
-# Copyright (C) 2000-2001 Free Software Foundation, Inc.
+# Copyright (C) 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 Library General Public License as published
@@ -235,10 +235,12 @@ case "$os" in
#echo "sun_eu_greek ?" # what is this?
echo "UTF-8 UTF-8"
;;
- freebsd*)
+ freebsd* | os2*)
# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
+ # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
+ # reuse FreeBSD's locale data for OS/2.
echo "C ASCII"
echo "US-ASCII ASCII"
for l in la_LN lt_LN; do
@@ -270,6 +272,20 @@ case "$os" in
echo "ja_JP.Shift_JIS SHIFT_JIS"
echo "ko_KR.EUC EUC-KR"
;;
+ netbsd*)
+ echo "646 ASCII"
+ echo "ISO8859-1 ISO-8859-1"
+ echo "ISO8859-2 ISO-8859-2"
+ echo "ISO8859-4 ISO-8859-4"
+ echo "ISO8859-5 ISO-8859-5"
+ echo "ISO8859-15 ISO-8859-15"
+ echo "eucCN GB2312"
+ echo "eucJP EUC-JP"
+ echo "eucKR EUC-KR"
+ echo "eucTW EUC-TW"
+ echo "BIG5 BIG5"
+ echo "SJIS SHIFT_JIS"
+ ;;
beos*)
# BeOS has a single locale, and it has UTF-8 encoding.
echo "* UTF-8"
@@ -394,8 +410,8 @@ case "$os" in
echo "bg_BG CP866" # not CP855 ??
echo "mk CP866" # not CP855 ??
echo "mk_MK CP866" # not CP855 ??
- echo "ru KOI8-R" # not CP866 ??
- echo "ru_RU KOI8-R" # not CP866 ??
+ echo "ru CP866"
+ echo "ru_RU CP866"
# ISO-8859-6 languages
echo "ar CP864"
echo "ar_AE CP864"
diff --git a/popt/intl/dcgettext.c b/popt/intl/dcgettext.c
index b7c96523d..70ee3bafe 100644
--- a/popt/intl/dcgettext.c
+++ b/popt/intl/dcgettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dcgettext(3) function.
- Copyright (C) 1995-1999, 2000, 2001 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 Library General Public License as published
@@ -54,5 +54,6 @@ DCGETTEXT (domainname, msgid, category)
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
+INTDEF(__dcgettext)
weak_alias (__dcgettext, dcgettext);
#endif
diff --git a/popt/intl/dcigettext.c b/popt/intl/dcigettext.c
index 6acde195f..afbb181f8 100644
--- a/popt/intl/dcigettext.c
+++ b/popt/intl/dcigettext.c
@@ -1,5 +1,5 @@
/* Implementation of the internal dcigettext function.
- Copyright (C) 1995-1999, 2000, 2001 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 Library General Public License as published
@@ -56,13 +56,7 @@ extern int errno;
#include <stddef.h>
#include <stdlib.h>
-
#include <string.h>
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-# define strchr index
-# endif
-#endif
#if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h>
@@ -75,6 +69,7 @@ extern int errno;
#endif
#include "gettextP.h"
+#include "plural-exp.h"
#ifdef _LIBC
# include <libintl.h>
#else
@@ -198,16 +193,6 @@ static void *mempcpy PARAMS ((void *dest, const void *src, size_t n));
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
#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. Neither do SUSV2 and
- ISO C 99. So we can use this feature only on selected systems (e.g.
- those using GNU C Library). */
-#if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
-# define HAVE_LOCALE_NULL
-#endif
-
/* This is the type used for the search tree where known translations
are stored. */
struct known_translation_t
@@ -274,13 +259,18 @@ transcmp (p1, p2)
/* 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";
+const char _nl_default_default_domain[] attribute_hidden = "messages";
/* Value used as the default domain for gettext(3). */
-const char *_nl_current_default_domain = _nl_default_default_domain;
+const char *_nl_current_default_domain attribute_hidden
+ = _nl_default_default_domain;
/* Contains the default location of the message catalogs. */
+#if defined __EMX__
+extern const char _nl_default_dirname[];
+#else
const char _nl_default_dirname[] = LOCALEDIR;
+#endif
/* List with bindings of specific domains created by bindtextdomain()
calls. */
@@ -292,9 +282,6 @@ static char *plural_lookup PARAMS ((struct loaded_l10nfile *domain,
const char *translation,
size_t translation_len))
internal_function;
-static unsigned long int plural_eval PARAMS ((struct expression *pexp,
- unsigned long int n))
- 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))
@@ -362,7 +349,7 @@ typedef unsigned char transmem_block_t;
/* Lock variable to protect the global data in the gettext implementation. */
#ifdef _LIBC
-__libc_rwlock_define_initialized (, _nl_state_lock)
+__libc_rwlock_define_initialized (, _nl_state_lock attribute_hidden)
#endif
/* Checking whether the binaries runs SUID must be done and glibc provides
@@ -395,6 +382,9 @@ static int enable_secure;
}
#endif
+/* Get the function to evaluate the plural expression. */
+#include "eval-plural.h"
+
/* Look up MSGID in the DOMAINNAME message catalog for the current
CATEGORY locale and, if PLURAL is nonzero, search over string
depending on the plural form determined by N. */
@@ -438,6 +428,12 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
if (domainname == NULL)
domainname = _nl_current_default_domain;
+ /* OS/2 specific: backward compatibility with older libintl versions */
+#ifdef LC_MESSAGES_COMPAT
+ if (category == LC_MESSAGES_COMPAT)
+ category = LC_MESSAGES;
+#endif
+
#if defined HAVE_TSEARCH || defined _LIBC
msgid_len = strlen (msgid1) + 1;
@@ -1005,87 +1001,6 @@ plural_lookup (domain, n, translation, translation_len)
}
-/* Function to evaluate the plural expression and return an index value. */
-static unsigned long int
-internal_function
-plural_eval (pexp, n)
- struct expression *pexp;
- unsigned long int n;
-{
- switch (pexp->nargs)
- {
- case 0:
- switch (pexp->operation)
- {
- case var:
- return n;
- case num:
- return pexp->val.num;
- default:
- break;
- }
- /* NOTREACHED */
- break;
- case 1:
- {
- /* pexp->operation must be lnot. */
- unsigned long int arg = plural_eval (pexp->val.args[0], n);
- return ! arg;
- }
- case 2:
- {
- unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
- if (pexp->operation == lor)
- return leftarg || plural_eval (pexp->val.args[1], n);
- else if (pexp->operation == land)
- return leftarg && plural_eval (pexp->val.args[1], n);
- else
- {
- unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
-
- switch (pexp->operation)
- {
- case mult:
- return leftarg * rightarg;
- case divide:
- return leftarg / rightarg;
- case module:
- return leftarg % rightarg;
- case plus:
- return leftarg + rightarg;
- case minus:
- return leftarg - rightarg;
- case less_than:
- return leftarg < rightarg;
- case greater_than:
- return leftarg > rightarg;
- case less_or_equal:
- return leftarg <= rightarg;
- case greater_or_equal:
- return leftarg >= rightarg;
- case equal:
- return leftarg == rightarg;
- case not_equal:
- return leftarg != rightarg;
- default:
- break;
- }
- }
- /* NOTREACHED */
- break;
- }
- case 3:
- {
- /* pexp->operation must be qmop. */
- unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
- return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
- }
- }
- /* NOTREACHED */
- return 0;
-}
-
-
/* Return string representation of locale CATEGORY. */
static const char *
internal_function
@@ -1166,27 +1081,21 @@ guess_category_value (category, categoryname)
/* 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 _LIBC || (defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL)
+#ifdef _LIBC
retval = setlocale (category, NULL);
#else
- /* Setting of LC_ALL overwrites all other. */
- retval = getenv ("LC_ALL");
- if (retval == NULL || retval[0] == '\0')
- {
- /* Next comes the name of the desired category. */
- retval = getenv (categoryname);
- if (retval == NULL || retval[0] == '\0')
- {
- /* Last possibility is the LANG environment variable. */
- retval = getenv ("LANG");
- if (retval == NULL || retval[0] == '\0')
- /* We use C as the default domain. POSIX says this is
- implementation defined. */
- return "C";
- }
- }
+ retval = _nl_locale_name (category, categoryname);
#endif
+ /* Ignore LANGUAGE if the locale is set to "C" because
+ 1. "C" locale usually uses the ASCII encoding, and most international
+ messages use non-ASCII characters. These characters get displayed
+ as question marks (if using glibc's iconv()) or as invalid 8-bit
+ characters (because other iconv()s refuse to convert most non-ASCII
+ characters to ASCII). In any case, the output is ugly.
+ 2. The precise output of some programs in the "C" locale is specified
+ by POSIX and should not depend on environment variables like
+ "LANGUAGE". We allow such programs to use gettext(). */
return language != NULL && strcmp (retval, "C") != 0 ? language : retval;
}
diff --git a/popt/intl/dcngettext.c b/popt/intl/dcngettext.c
index c16af2126..d31ff9bfa 100644
--- a/popt/intl/dcngettext.c
+++ b/popt/intl/dcngettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dcngettext(3) function.
- Copyright (C) 1995-1999, 2000, 2001 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 Library General Public License as published
@@ -56,5 +56,6 @@ DCNGETTEXT (domainname, msgid1, msgid2, n, category)
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
+INTDEF(__dcngettext)
weak_alias (__dcngettext, dcngettext);
#endif
diff --git a/popt/intl/dgettext.c b/popt/intl/dgettext.c
index 3651207a0..17b0442c6 100644
--- a/popt/intl/dgettext.c
+++ b/popt/intl/dgettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dgettext(3) function.
- Copyright (C) 1995-1997, 2000, 2001 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 Library General Public License as published
@@ -37,7 +37,7 @@
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__
diff --git a/popt/intl/dngettext.c b/popt/intl/dngettext.c
index f214e95b4..2b9ff886b 100644
--- a/popt/intl/dngettext.c
+++ b/popt/intl/dngettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dngettext(3) function.
- Copyright (C) 1995-1997, 2000, 2001 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 Library General Public License as published
@@ -37,7 +37,7 @@
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DNGETTEXT __dngettext
-# define DCNGETTEXT __dcngettext
+# define DCNGETTEXT INTUSE(__dcngettext)
#else
# define DNGETTEXT dngettext__
# define DCNGETTEXT dcngettext__
diff --git a/popt/intl/eval-plural.h b/popt/intl/eval-plural.h
new file mode 100644
index 000000000..44f493425
--- /dev/null
+++ b/popt/intl/eval-plural.h
@@ -0,0 +1,106 @@
+/* Plural expression evaluation.
+ Copyright (C) 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 Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef STATIC
+#define STATIC static
+#endif
+
+/* Evaluate the plural expression and return an index value. */
+STATIC unsigned long int plural_eval PARAMS ((struct expression *pexp,
+ unsigned long int n))
+ internal_function;
+
+STATIC
+unsigned long int
+internal_function
+plural_eval (pexp, n)
+ struct expression *pexp;
+ unsigned long int n;
+{
+ switch (pexp->nargs)
+ {
+ case 0:
+ switch (pexp->operation)
+ {
+ case var:
+ return n;
+ case num:
+ return pexp->val.num;
+ default:
+ break;
+ }
+ /* NOTREACHED */
+ break;
+ case 1:
+ {
+ /* pexp->operation must be lnot. */
+ unsigned long int arg = plural_eval (pexp->val.args[0], n);
+ return ! arg;
+ }
+ case 2:
+ {
+ unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
+ if (pexp->operation == lor)
+ return leftarg || plural_eval (pexp->val.args[1], n);
+ else if (pexp->operation == land)
+ return leftarg && plural_eval (pexp->val.args[1], n);
+ else
+ {
+ unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
+
+ switch (pexp->operation)
+ {
+ case mult:
+ return leftarg * rightarg;
+ case divide:
+ return leftarg / rightarg;
+ case module:
+ return leftarg % rightarg;
+ case plus:
+ return leftarg + rightarg;
+ case minus:
+ return leftarg - rightarg;
+ case less_than:
+ return leftarg < rightarg;
+ case greater_than:
+ return leftarg > rightarg;
+ case less_or_equal:
+ return leftarg <= rightarg;
+ case greater_or_equal:
+ return leftarg >= rightarg;
+ case equal:
+ return leftarg == rightarg;
+ case not_equal:
+ return leftarg != rightarg;
+ default:
+ break;
+ }
+ }
+ /* NOTREACHED */
+ break;
+ }
+ case 3:
+ {
+ /* pexp->operation must be qmop. */
+ unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
+ return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
+ }
+ }
+ /* NOTREACHED */
+ return 0;
+}
diff --git a/popt/intl/gettext.c b/popt/intl/gettext.c
index 22a6c2453..e52d8aef3 100644
--- a/popt/intl/gettext.c
+++ b/popt/intl/gettext.c
@@ -1,5 +1,5 @@
/* Implementation of gettext(3) function.
- Copyright (C) 1995, 1997, 2000, 2001 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 Library General Public License as published
@@ -42,7 +42,7 @@
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define GETTEXT __gettext
-# define DCGETTEXT __dcgettext
+# define DCGETTEXT INTUSE(__dcgettext)
#else
# define GETTEXT gettext__
# define DCGETTEXT dcgettext__
diff --git a/popt/intl/gettextP.h b/popt/intl/gettextP.h
index 43de1cd47..4e3a5b252 100644
--- a/popt/intl/gettextP.h
+++ b/popt/intl/gettextP.h
@@ -1,5 +1,5 @@
/* Header describing internals of libintl library.
- Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
This program is free software; you can redistribute it and/or modify it
@@ -32,12 +32,12 @@
#include "loadinfo.h"
-#include "gettext.h" /* Get nls_uint32. */
+#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) ()
@@ -48,6 +48,10 @@
# 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
@@ -72,51 +76,6 @@ SWAP (i)
#endif
-/* This is the representation of the expressions to determine the
- plural form. */
-struct expression
-{
- int nargs; /* Number of arguments. */
- enum operator
- {
- /* Without arguments: */
- var, /* The variable "n". */
- num, /* Decimal number. */
- /* Unary operators: */
- lnot, /* Logical NOT. */
- /* Binary operators: */
- mult, /* Multiplication. */
- divide, /* Division. */
- module, /* Module operation. */
- plus, /* Addition. */
- minus, /* Subtraction. */
- less_than, /* Comparison. */
- greater_than, /* Comparison. */
- less_or_equal, /* Comparison. */
- greater_or_equal, /* Comparison. */
- equal, /* Comparision for equality. */
- not_equal, /* Comparision for inequality. */
- land, /* Logical AND. */
- lor, /* Logical OR. */
- /* Ternary operators: */
- qmop /* Question mark operator. */
- } operation;
- union
- {
- unsigned long int num; /* Number value for `num'. */
- struct expression *args[3]; /* Up to three arguments. */
- } val;
-};
-
-/* This is the data structure to pass information to the parser and get
- the result in a thread-safe way. */
-struct parse_args
-{
- const char *cp;
- struct expression *res;
-};
-
-
/* The representation of an opened message catalog. */
struct loaded_domain
{
@@ -167,6 +126,10 @@ struct binding
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,
@@ -237,16 +200,6 @@ extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname,
const char *__codeset));
#endif
-#ifdef _LIBC
-extern void __gettext_free_exp PARAMS ((struct expression *exp))
- internal_function;
-extern int __gettextparse PARAMS ((void *arg));
-#else
-extern void gettext_free_exp__ PARAMS ((struct expression *exp))
- internal_function;
-extern int gettextparse__ PARAMS ((void *arg));
-#endif
-
/* @@ begin of epilog @@ */
#endif /* gettextP.h */
diff --git a/popt/intl/gmo.h b/popt/intl/gmo.h
new file mode 100644
index 000000000..f05ae470c
--- /dev/null
+++ b/popt/intl/gmo.h
@@ -0,0 +1,100 @@
+/* Description of GNU message catalog format: general file layout.
+ Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _GETTEXT_H
+#define _GETTEXT_H 1
+
+#include <limits.h>
+
+/* @@ end of prolog @@ */
+
+/* The magic number of the GNU message catalog format. */
+#define _MAGIC 0x950412de
+#define _MAGIC_SWAPPED 0xde120495
+
+/* Revision number of the currently used .mo (binary) file format. */
+#define MO_REVISION_NUMBER 0
+
+/* The following contortions are an attempt to use the C preprocessor
+ to determine an unsigned integral type that is 32 bits wide. An
+ alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
+ as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
+ when cross-compiling. */
+
+#if __STDC__
+# define UINT_MAX_32_BITS 4294967295U
+#else
+# define UINT_MAX_32_BITS 0xFFFFFFFF
+#endif
+
+/* If UINT_MAX isn't defined, assume it's a 32-bit type.
+ This should be valid for all systems GNU cares about because
+ that doesn't include 16-bit systems, and only modern systems
+ (that certainly have <limits.h>) have 64+-bit integral types. */
+
+#ifndef UINT_MAX
+# define UINT_MAX UINT_MAX_32_BITS
+#endif
+
+#if UINT_MAX == UINT_MAX_32_BITS
+typedef unsigned nls_uint32;
+#else
+# if USHRT_MAX == UINT_MAX_32_BITS
+typedef unsigned short nls_uint32;
+# else
+# if ULONG_MAX == UINT_MAX_32_BITS
+typedef unsigned long nls_uint32;
+# else
+ /* The following line is intended to throw an error. Using #error is
+ not portable enough. */
+ "Cannot determine unsigned 32-bit data type."
+# endif
+# endif
+#endif
+
+
+/* Header for binary .mo file format. */
+struct mo_file_header
+{
+ /* The magic number. */
+ nls_uint32 magic;
+ /* The revision number of the file format. */
+ nls_uint32 revision;
+ /* The number of strings pairs. */
+ nls_uint32 nstrings;
+ /* Offset of table with start offsets of original strings. */
+ nls_uint32 orig_tab_offset;
+ /* Offset of table with start offsets of translation strings. */
+ nls_uint32 trans_tab_offset;
+ /* Size of hashing table. */
+ nls_uint32 hash_tab_size;
+ /* Offset of first hashing entry. */
+ nls_uint32 hash_tab_offset;
+};
+
+struct string_desc
+{
+ /* Length of addressed string. */
+ nls_uint32 length;
+ /* Offset of string in file. */
+ nls_uint32 offset;
+};
+
+/* @@ begin of epilog @@ */
+
+#endif /* gettext.h */
diff --git a/popt/intl/hash-string.h b/popt/intl/hash-string.h
index ccb7acca6..b267a8778 100644
--- a/popt/intl/hash-string.h
+++ b/popt/intl/hash-string.h
@@ -19,7 +19,7 @@
/* @@ 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) ()
diff --git a/popt/intl/l10nflist.c b/popt/intl/l10nflist.c
index 533e94be8..d861912df 100644
--- a/popt/intl/l10nflist.c
+++ b/popt/intl/l10nflist.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This program is free software; you can redistribute it and/or modify it
@@ -28,11 +28,6 @@
#endif
#include <string.h>
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-# define strchr index
-# endif
-#endif
#if defined _LIBC || defined HAVE_ARGZ_H
# include <argz.h>
@@ -90,6 +85,10 @@ argz_count__ (argz, len)
}
# undef __argz_count
# define __argz_count(argz, len) argz_count__ (argz, len)
+#else
+# ifdef _LIBC
+# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
+# endif
#endif /* !_LIBC && !HAVE___ARGZ_COUNT */
#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
@@ -114,6 +113,11 @@ argz_stringify__ (argz, len, sep)
}
# undef __argz_stringify
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
+#else
+# ifdef _LIBC
+# define __argz_stringify(argz, len, sep) \
+ INTUSE(__argz_stringify) (argz, len, sep)
+# endif
#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
@@ -356,11 +360,11 @@ _nl_normalize_codeset (codeset, name_len)
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;
}
@@ -374,9 +378,9 @@ _nl_normalize_codeset (codeset, name_len)
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';
diff --git a/popt/intl/libgnuintl.h b/popt/intl/libgnuintl.h
index f891deb96..1387e70c7 100644
--- a/popt/intl/libgnuintl.h
+++ b/popt/intl/libgnuintl.h
@@ -1,5 +1,5 @@
/* Message catalogs for internationalization.
- Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1995-1997, 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 Library General Public License as published
@@ -24,10 +24,11 @@
/* The LC_MESSAGES locale category is the category used by the functions
gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
On systems that don't define it, use an arbitrary value instead.
- On Solaris, <locale.h> defines __LOCALE_H then includes <libintl.h> (i.e.
- this file!) and then only defines LC_MESSAGES. To avoid a redefinition
- warning, don't define LC_MESSAGES in this case. */
-#if !defined LC_MESSAGES && !defined __LOCALE_H
+ On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
+ then includes <libintl.h> (i.e. this file!) and then only defines
+ LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
+ in this case. */
+#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
# define LC_MESSAGES 1729
#endif
@@ -42,11 +43,13 @@
# define gettext gettext
#endif
-#ifndef PARAMS
-# if __STDC__ || defined __cplusplus
-# define PARAMS(args) args
+/* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
+ used by programs. Similarly, test __PROTOTYPES, not PROTOTYPES. */
+#ifndef _INTL_PARAMS
+# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
+# define _INTL_PARAMS(args) args
# else
-# define PARAMS(args) ()
+# define _INTL_PARAMS(args) ()
# endif
#endif
@@ -57,49 +60,56 @@ extern "C" {
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
-extern char *gettext PARAMS ((const char *__msgid));
+extern char *gettext _INTL_PARAMS ((const char *__msgid));
/* Look up MSGID in the DOMAINNAME message catalog for the current
LC_MESSAGES locale. */
-extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
+extern char *dgettext _INTL_PARAMS ((const char *__domainname,
+ const char *__msgid));
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
-extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
- int __category));
+extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
+ const char *__msgid,
+ int __category));
/* Similar to `gettext' but select the plural form corresponding to the
number N. */
-extern char *ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
- unsigned long int __n));
+extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
+ const char *__msgid2,
+ unsigned long int __n));
/* Similar to `dgettext' but select the plural form corresponding to the
number N. */
-extern char *dngettext PARAMS ((const char *__domainname, const char *__msgid1,
- const char *__msgid2, unsigned long int __n));
+extern char *dngettext _INTL_PARAMS ((const char *__domainname,
+ const char *__msgid1,
+ const char *__msgid2,
+ unsigned long int __n));
/* Similar to `dcgettext' but select the plural form corresponding to the
number N. */
-extern char *dcngettext PARAMS ((const char *__domainname, const char *__msgid1,
- const char *__msgid2, unsigned long int __n,
- int __category));
+extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
+ const char *__msgid1,
+ const char *__msgid2,
+ unsigned long int __n,
+ int __category));
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
-extern char *textdomain PARAMS ((const char *__domainname));
+extern char *textdomain _INTL_PARAMS ((const char *__domainname));
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
-extern char *bindtextdomain PARAMS ((const char *__domainname,
- const char *__dirname));
+extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
+ const char *__dirname));
/* Specify the character encoding in which the messages from the
DOMAINNAME message catalog will be returned. */
-extern char *bind_textdomain_codeset PARAMS ((const char *__domainname,
- const char *__codeset));
+extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
+ const char *__codeset));
/* Optimized version of the functions above. */
diff --git a/popt/intl/loadinfo.h b/popt/intl/loadinfo.h
index b8612607b..d180962f5 100644
--- a/popt/intl/loadinfo.h
+++ b/popt/intl/loadinfo.h
@@ -20,8 +20,20 @@
#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) ()
diff --git a/popt/intl/loadmsgcat.c b/popt/intl/loadmsgcat.c
index f99ebee3a..76130ed27 100644
--- a/popt/intl/loadmsgcat.c
+++ b/popt/intl/loadmsgcat.c
@@ -71,8 +71,9 @@ char *alloca ();
# undef HAVE_MMAP
#endif
-#include "gettext.h"
+#include "gmo.h"
#include "gettextP.h"
+#include "plural-exp.h"
#ifdef _LIBC
# include "../locale/localeinfo.h"
@@ -91,16 +92,6 @@ char *alloca ();
# define munmap __munmap
#endif
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define PLURAL_PARSE __gettextparse
-#else
-# define PLURAL_PARSE gettextparse__
-#endif
-
/* For those losing systems which don't have `alloca' we have to add
some additional code emulating it. */
#ifdef HAVE_ALLOCA
@@ -132,73 +123,6 @@ char *alloca ();
cached by one of GCC's features. */
int _nl_msg_cat_cntr;
-#if (defined __GNUC__ && !defined __APPLE_CC__) \
- || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
-
-/* These structs are the constant expression for the germanic plural
- form determination. It represents the expression "n != 1". */
-static const struct expression plvar =
-{
- .nargs = 0,
- .operation = var,
-};
-static const struct expression plone =
-{
- .nargs = 0,
- .operation = num,
- .val =
- {
- .num = 1
- }
-};
-static struct expression germanic_plural =
-{
- .nargs = 2,
- .operation = not_equal,
- .val =
- {
- .args =
- {
- [0] = (struct expression *) &plvar,
- [1] = (struct expression *) &plone
- }
- }
-};
-
-# define INIT_GERMANIC_PLURAL()
-
-#else
-
-/* For compilers without support for ISO C 99 struct/union initializers:
- Initialization at run-time. */
-
-static struct expression plvar;
-static struct expression plone;
-static struct expression germanic_plural;
-
-static void
-init_germanic_plural ()
-{
- if (plone.val.num == 0)
- {
- plvar.nargs = 0;
- plvar.operation = var;
-
- plone.nargs = 0;
- plone.operation = num;
- plone.val.num = 1;
-
- germanic_plural.nargs = 2;
- germanic_plural.operation = not_equal;
- germanic_plural.val.args[0] = &plvar;
- germanic_plural.val.args[1] = &plone;
- }
-}
-
-# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
-
-#endif
-
/* Initialize the codeset dependent parts of an opened message catalog.
Return the header entry. */
@@ -271,7 +195,7 @@ _nl_init_domain_conv (domain_file, domain, domainbinding)
outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string;
# else
# if HAVE_ICONV
- extern const char *locale_charset (void);
+ extern const char *locale_charset PARAMS ((void));
outcharset = locale_charset ();
# endif
# endif
@@ -288,8 +212,10 @@ _nl_init_domain_conv (domain_file, domain, domainbinding)
domain->conv = (__gconv_t) -1;
# else
# if HAVE_ICONV
- /* When using GNU libiconv, we want to use transliteration. */
-# if _LIBICONV_VERSION >= 0x0105
+ /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
+ we want to use transliteration. */
+# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
+ || _LIBICONV_VERSION >= 0x0105
len = strlen (outcharset);
{
char *tmp = (char *) alloca (len + 10 + 1);
@@ -299,7 +225,8 @@ _nl_init_domain_conv (domain_file, domain, domainbinding)
}
# endif
domain->conv = iconv_open (outcharset, charset);
-# if _LIBICONV_VERSION >= 0x0105
+# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
+ || _LIBICONV_VERSION >= 0x0105
freea (outcharset);
# endif
# endif
@@ -491,56 +418,7 @@ _nl_load_domain (domain_file, domainbinding)
nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding);
/* Also look for a plural specification. */
- if (nullentry != NULL)
- {
- const char *plural;
- const char *nplurals;
-
- plural = strstr (nullentry, "plural=");
- nplurals = strstr (nullentry, "nplurals=");
- if (plural == NULL || nplurals == NULL)
- goto no_plural;
- else
- {
- /* First get the number. */
- char *endp;
- unsigned long int n;
- struct parse_args args;
-
- nplurals += 9;
- while (*nplurals != '\0' && isspace (*nplurals))
- ++nplurals;
-#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
-#else
- for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
- n = n * 10 + (*endp - '0');
-#endif
- domain->nplurals = n;
- if (nplurals == endp)
- goto no_plural;
-
- /* Due to the restrictions bison imposes onto the interface of the
- scanner function we have to put the input string and the result
- passed up from the parser into the same structure which address
- is passed down to the parser. */
- plural += 7;
- args.cp = plural;
- if (PLURAL_PARSE (&args) != 0)
- goto no_plural;
- domain->plural = args.res;
- }
- }
- else
- {
- /* By default we are using the Germanic form: singular form only
- for `one', the plural form otherwise. Yes, this is also what
- English is using since English is a Germanic language. */
- no_plural:
- INIT_GERMANIC_PLURAL ();
- domain->plural = &germanic_plural;
- domain->nplurals = 2;
- }
+ EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
}
@@ -550,7 +428,7 @@ internal_function
_nl_unload_domain (domain)
struct loaded_domain *domain;
{
- if (domain->plural != &germanic_plural)
+ if (domain->plural != &__gettext_germanic_plural)
__gettext_free_exp (domain->plural);
_nl_free_domain_conv (domain);
diff --git a/popt/intl/localcharset.c b/popt/intl/localcharset.c
index 61f8f3e85..bc5587bf6 100644
--- a/popt/intl/localcharset.c
+++ b/popt/intl/localcharset.c
@@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2001 Free Software Foundation, Inc.
+ Copyright (C) 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 Library General Public License as published
@@ -42,7 +42,12 @@
# define WIN32
#endif
-#ifndef WIN32
+#if defined __EMX__
+/* Assume EMX program runs on OS/2, even if compiled under DOS. */
+# define OS2
+#endif
+
+#if !defined WIN32
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# else
@@ -50,10 +55,19 @@
# include <locale.h>
# endif
# endif
-#else /* WIN32 */
+#elif defined WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
+#if defined OS2
+# define INCL_DOS
+# include <os2.h>
+#endif
+
+#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
+ /* Win32, OS/2, DOS */
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#endif
#ifndef DIRECTORY_SEPARATOR
# define DIRECTORY_SEPARATOR '/'
@@ -63,6 +77,11 @@
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
#endif
+#ifdef HAVE_GETC_UNLOCKED
+# undef getc
+# define getc getc_unlocked
+#endif
+
/* The following static variable is declared 'volatile' to avoid a
possible multithread problem in the function get_charset_aliases. If we
are running in a threaded environment, and if two threads initialize
@@ -86,7 +105,7 @@ get_charset_aliases ()
cp = charset_aliases;
if (cp == NULL)
{
-#ifndef WIN32
+#if !defined WIN32
FILE *fp;
const char *dir = LIBDIR;
const char *base = "charset.alias";
@@ -138,19 +157,19 @@ get_charset_aliases ()
continue;
}
ungetc (c, fp);
- if (fscanf(fp, "%50s %50s", buf1, buf2) < 2)
+ if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
break;
l1 = strlen (buf1);
l2 = strlen (buf2);
if (res_size == 0)
{
res_size = l1 + 1 + l2 + 1;
- res_ptr = malloc (res_size + 1);
+ res_ptr = (char *) malloc (res_size + 1);
}
else
{
res_size += l1 + 1 + l2 + 1;
- res_ptr = realloc (res_ptr, res_size + 1);
+ res_ptr = (char *) realloc (res_ptr, res_size + 1);
}
if (res_ptr == NULL)
{
@@ -174,14 +193,16 @@ get_charset_aliases ()
if (file_name != NULL)
free (file_name);
-#else /* WIN32 */
+#else
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
+# if defined WIN32
cp = "CP936" "\0" "GBK" "\0"
"CP1361" "\0" "JOHAB" "\0";
+# endif
#endif
charset_aliases = cp;
@@ -205,7 +226,7 @@ locale_charset ()
const char *codeset;
const char *aliases;
-#ifndef WIN32
+#if !(defined WIN32 || defined OS2)
# if HAVE_LANGINFO_CODESET
@@ -242,7 +263,7 @@ locale_charset ()
# endif
-#else /* WIN32 */
+#elif defined WIN32
static char buf[2 + 10 + 1];
@@ -250,6 +271,59 @@ locale_charset ()
sprintf (buf, "CP%u", GetACP ());
codeset = buf;
+#elif defined OS2
+
+ const char *locale;
+ static char buf[2 + 10 + 1];
+ ULONG cp[3];
+ ULONG cplen;
+
+ /* Allow user to override the codeset, as set in the operating system,
+ with standard language environment variables. */
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ }
+ if (locale != NULL && locale[0] != '\0')
+ {
+ /* If the locale name contains an encoding after the dot, return it. */
+ const char *dot = strchr (locale, '.');
+
+ if (dot != NULL)
+ {
+ const char *modifier;
+
+ dot++;
+ /* Look for the possible @... trailer and remove it, if any. */
+ modifier = strchr (dot, '@');
+ if (modifier == NULL)
+ return dot;
+ if (modifier - dot < sizeof (buf))
+ {
+ memcpy (buf, dot, modifier - dot);
+ buf [modifier - dot] = '\0';
+ return buf;
+ }
+ }
+
+ /* Resolve through the charset.alias file. */
+ codeset = locale;
+ }
+ else
+ {
+ /* OS/2 has a function returning the locale's codepage as a number. */
+ if (DosQueryCp (sizeof (cp), cp, &cplen))
+ codeset = "";
+ else
+ {
+ sprintf (buf, "CP%u", cp[0]);
+ codeset = buf;
+ }
+ }
+
#endif
if (codeset == NULL)
diff --git a/popt/intl/localealias.c b/popt/intl/localealias.c
index 91e7acc9c..456e41e37 100644
--- a/popt/intl/localealias.c
+++ b/popt/intl/localealias.c
@@ -29,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__
@@ -49,13 +52,7 @@ char *alloca ();
#endif
#include <stdlib.h>
-
#include <string.h>
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-# define strchr index
-# endif
-#endif
#include "gettextP.h"
@@ -71,6 +68,7 @@ char *alloca ();
# 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>
@@ -82,6 +80,15 @@ __libc_lock_define_initialized (static, lock);
# define internal_function
#endif
+/* 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
@@ -128,7 +135,7 @@ const char *
_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;
@@ -137,6 +144,9 @@ _nl_expand_alias (name)
__libc_lock_lock (lock);
#endif
+ if (locale_alias_path == NULL)
+ locale_alias_path = LOCALE_ALIAS_PATH;
+
do
{
struct alias_map item;
@@ -212,8 +222,13 @@ read_alias_file (fname, fname_len)
if (fp == NULL)
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
@@ -225,7 +240,7 @@ read_alias_file (fname, fname_len)
char *value;
char *cp;
- if (fgets (buf, sizeof buf, fp) == NULL)
+ if (FGETS (buf, sizeof buf, fp) == NULL)
/* EOF reached. */
break;
@@ -235,7 +250,7 @@ read_alias_file (fname, fname_len)
{
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;
@@ -244,21 +259,21 @@ read_alias_file (fname, fname_len)
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')
@@ -267,7 +282,7 @@ read_alias_file (fname, fname_len)
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')
diff --git a/popt/intl/localename.c b/popt/intl/localename.c
new file mode 100644
index 000000000..a72419814
--- /dev/null
+++ b/popt/intl/localename.c
@@ -0,0 +1,694 @@
+/* Determine the current selected locale.
+ 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 Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
+/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <locale.h>
+
+#if defined _WIN32 || defined __WIN32__
+# undef WIN32 /* avoid warning on mingw32 */
+# define WIN32
+#endif
+
+#ifdef WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+/* Mingw headers don't have latest language and sublanguage codes. */
+# ifndef LANG_AFRIKAANS
+# define LANG_AFRIKAANS 0x36
+# endif
+# ifndef LANG_ALBANIAN
+# define LANG_ALBANIAN 0x1c
+# endif
+# ifndef LANG_ARABIC
+# define LANG_ARABIC 0x01
+# endif
+# ifndef LANG_ARMENIAN
+# define LANG_ARMENIAN 0x2b
+# endif
+# ifndef LANG_ASSAMESE
+# define LANG_ASSAMESE 0x4d
+# endif
+# ifndef LANG_AZERI
+# define LANG_AZERI 0x2c
+# endif
+# ifndef LANG_BASQUE
+# define LANG_BASQUE 0x2d
+# endif
+# ifndef LANG_BELARUSIAN
+# define LANG_BELARUSIAN 0x23
+# endif
+# ifndef LANG_BENGALI
+# define LANG_BENGALI 0x45
+# endif
+# ifndef LANG_CATALAN
+# define LANG_CATALAN 0x03
+# endif
+# ifndef LANG_ESTONIAN
+# define LANG_ESTONIAN 0x25
+# endif
+# ifndef LANG_FAEROESE
+# define LANG_FAEROESE 0x38
+# endif
+# ifndef LANG_FARSI
+# define LANG_FARSI 0x29
+# endif
+# ifndef LANG_GEORGIAN
+# define LANG_GEORGIAN 0x37
+# endif
+# ifndef LANG_GUJARATI
+# define LANG_GUJARATI 0x47
+# endif
+# ifndef LANG_HEBREW
+# define LANG_HEBREW 0x0d
+# endif
+# ifndef LANG_HINDI
+# define LANG_HINDI 0x39
+# endif
+# ifndef LANG_INDONESIAN
+# define LANG_INDONESIAN 0x21
+# endif
+# ifndef LANG_KANNADA
+# define LANG_KANNADA 0x4b
+# endif
+# ifndef LANG_KASHMIRI
+# define LANG_KASHMIRI 0x60
+# endif
+# ifndef LANG_KAZAK
+# define LANG_KAZAK 0x3f
+# endif
+# ifndef LANG_KONKANI
+# define LANG_KONKANI 0x57
+# endif
+# ifndef LANG_LATVIAN
+# define LANG_LATVIAN 0x26
+# endif
+# ifndef LANG_LITHUANIAN
+# define LANG_LITHUANIAN 0x27
+# endif
+# ifndef LANG_MACEDONIAN
+# define LANG_MACEDONIAN 0x2f
+# endif
+# ifndef LANG_MALAY
+# define LANG_MALAY 0x3e
+# endif
+# ifndef LANG_MALAYALAM
+# define LANG_MALAYALAM 0x4c
+# endif
+# ifndef LANG_MANIPURI
+# define LANG_MANIPURI 0x58
+# endif
+# ifndef LANG_MARATHI
+# define LANG_MARATHI 0x4e
+# endif
+# ifndef LANG_NEPALI
+# define LANG_NEPALI 0x61
+# endif
+# ifndef LANG_ORIYA
+# define LANG_ORIYA 0x48
+# endif
+# ifndef LANG_PUNJABI
+# define LANG_PUNJABI 0x46
+# endif
+# ifndef LANG_SANSKRIT
+# define LANG_SANSKRIT 0x4f
+# endif
+# ifndef LANG_SERBIAN
+# define LANG_SERBIAN 0x1a
+# endif
+# ifndef LANG_SINDHI
+# define LANG_SINDHI 0x59
+# endif
+# ifndef LANG_SLOVAK
+# define LANG_SLOVAK 0x1b
+# endif
+# ifndef LANG_SWAHILI
+# define LANG_SWAHILI 0x41
+# endif
+# ifndef LANG_TAMIL
+# define LANG_TAMIL 0x49
+# endif
+# ifndef LANG_TATAR
+# define LANG_TATAR 0x44
+# endif
+# ifndef LANG_TELUGU
+# define LANG_TELUGU 0x4a
+# endif
+# ifndef LANG_THAI
+# define LANG_THAI 0x1e
+# endif
+# ifndef LANG_UKRAINIAN
+# define LANG_UKRAINIAN 0x22
+# endif
+# ifndef LANG_URDU
+# define LANG_URDU 0x20
+# endif
+# ifndef LANG_UZBEK
+# define LANG_UZBEK 0x43
+# endif
+# ifndef LANG_VIETNAMESE
+# define LANG_VIETNAMESE 0x2a
+# endif
+# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
+# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
+# endif
+# ifndef SUBLANG_ARABIC_IRAQ
+# define SUBLANG_ARABIC_IRAQ 0x02
+# endif
+# ifndef SUBLANG_ARABIC_EGYPT
+# define SUBLANG_ARABIC_EGYPT 0x03
+# endif
+# ifndef SUBLANG_ARABIC_LIBYA
+# define SUBLANG_ARABIC_LIBYA 0x04
+# endif
+# ifndef SUBLANG_ARABIC_ALGERIA
+# define SUBLANG_ARABIC_ALGERIA 0x05
+# endif
+# ifndef SUBLANG_ARABIC_MOROCCO
+# define SUBLANG_ARABIC_MOROCCO 0x06
+# endif
+# ifndef SUBLANG_ARABIC_TUNISIA
+# define SUBLANG_ARABIC_TUNISIA 0x07
+# endif
+# ifndef SUBLANG_ARABIC_OMAN
+# define SUBLANG_ARABIC_OMAN 0x08
+# endif
+# ifndef SUBLANG_ARABIC_YEMEN
+# define SUBLANG_ARABIC_YEMEN 0x09
+# endif
+# ifndef SUBLANG_ARABIC_SYRIA
+# define SUBLANG_ARABIC_SYRIA 0x0a
+# endif
+# ifndef SUBLANG_ARABIC_JORDAN
+# define SUBLANG_ARABIC_JORDAN 0x0b
+# endif
+# ifndef SUBLANG_ARABIC_LEBANON
+# define SUBLANG_ARABIC_LEBANON 0x0c
+# endif
+# ifndef SUBLANG_ARABIC_KUWAIT
+# define SUBLANG_ARABIC_KUWAIT 0x0d
+# endif
+# ifndef SUBLANG_ARABIC_UAE
+# define SUBLANG_ARABIC_UAE 0x0e
+# endif
+# ifndef SUBLANG_ARABIC_BAHRAIN
+# define SUBLANG_ARABIC_BAHRAIN 0x0f
+# endif
+# ifndef SUBLANG_ARABIC_QATAR
+# define SUBLANG_ARABIC_QATAR 0x10
+# endif
+# ifndef SUBLANG_AZERI_LATIN
+# define SUBLANG_AZERI_LATIN 0x01
+# endif
+# ifndef SUBLANG_AZERI_CYRILLIC
+# define SUBLANG_AZERI_CYRILLIC 0x02
+# endif
+# ifndef SUBLANG_CHINESE_MACAU
+# define SUBLANG_CHINESE_MACAU 0x05
+# endif
+# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
+# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
+# endif
+# ifndef SUBLANG_ENGLISH_JAMAICA
+# define SUBLANG_ENGLISH_JAMAICA 0x08
+# endif
+# ifndef SUBLANG_ENGLISH_CARIBBEAN
+# define SUBLANG_ENGLISH_CARIBBEAN 0x09
+# endif
+# ifndef SUBLANG_ENGLISH_BELIZE
+# define SUBLANG_ENGLISH_BELIZE 0x0a
+# endif
+# ifndef SUBLANG_ENGLISH_TRINIDAD
+# define SUBLANG_ENGLISH_TRINIDAD 0x0b
+# endif
+# ifndef SUBLANG_ENGLISH_ZIMBABWE
+# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
+# endif
+# ifndef SUBLANG_ENGLISH_PHILIPPINES
+# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
+# endif
+# ifndef SUBLANG_FRENCH_LUXEMBOURG
+# define SUBLANG_FRENCH_LUXEMBOURG 0x05
+# endif
+# ifndef SUBLANG_FRENCH_MONACO
+# define SUBLANG_FRENCH_MONACO 0x06
+# endif
+# ifndef SUBLANG_GERMAN_LUXEMBOURG
+# define SUBLANG_GERMAN_LUXEMBOURG 0x04
+# endif
+# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
+# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
+# endif
+# ifndef SUBLANG_KASHMIRI_INDIA
+# define SUBLANG_KASHMIRI_INDIA 0x02
+# endif
+# ifndef SUBLANG_MALAY_MALAYSIA
+# define SUBLANG_MALAY_MALAYSIA 0x01
+# endif
+# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
+# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
+# endif
+# ifndef SUBLANG_NEPALI_INDIA
+# define SUBLANG_NEPALI_INDIA 0x02
+# endif
+# ifndef SUBLANG_SERBIAN_LATIN
+# define SUBLANG_SERBIAN_LATIN 0x02
+# endif
+# ifndef SUBLANG_SERBIAN_CYRILLIC
+# define SUBLANG_SERBIAN_CYRILLIC 0x03
+# endif
+# ifndef SUBLANG_SPANISH_GUATEMALA
+# define SUBLANG_SPANISH_GUATEMALA 0x04
+# endif
+# ifndef SUBLANG_SPANISH_COSTA_RICA
+# define SUBLANG_SPANISH_COSTA_RICA 0x05
+# endif
+# ifndef SUBLANG_SPANISH_PANAMA
+# define SUBLANG_SPANISH_PANAMA 0x06
+# endif
+# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
+# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
+# endif
+# ifndef SUBLANG_SPANISH_VENEZUELA
+# define SUBLANG_SPANISH_VENEZUELA 0x08
+# endif
+# ifndef SUBLANG_SPANISH_COLOMBIA
+# define SUBLANG_SPANISH_COLOMBIA 0x09
+# endif
+# ifndef SUBLANG_SPANISH_PERU
+# define SUBLANG_SPANISH_PERU 0x0a
+# endif
+# ifndef SUBLANG_SPANISH_ARGENTINA
+# define SUBLANG_SPANISH_ARGENTINA 0x0b
+# endif
+# ifndef SUBLANG_SPANISH_ECUADOR
+# define SUBLANG_SPANISH_ECUADOR 0x0c
+# endif
+# ifndef SUBLANG_SPANISH_CHILE
+# define SUBLANG_SPANISH_CHILE 0x0d
+# endif
+# ifndef SUBLANG_SPANISH_URUGUAY
+# define SUBLANG_SPANISH_URUGUAY 0x0e
+# endif
+# ifndef SUBLANG_SPANISH_PARAGUAY
+# define SUBLANG_SPANISH_PARAGUAY 0x0f
+# endif
+# ifndef SUBLANG_SPANISH_BOLIVIA
+# define SUBLANG_SPANISH_BOLIVIA 0x10
+# endif
+# ifndef SUBLANG_SPANISH_EL_SALVADOR
+# define SUBLANG_SPANISH_EL_SALVADOR 0x11
+# endif
+# ifndef SUBLANG_SPANISH_HONDURAS
+# define SUBLANG_SPANISH_HONDURAS 0x12
+# endif
+# ifndef SUBLANG_SPANISH_NICARAGUA
+# define SUBLANG_SPANISH_NICARAGUA 0x13
+# endif
+# ifndef SUBLANG_SPANISH_PUERTO_RICO
+# define SUBLANG_SPANISH_PUERTO_RICO 0x14
+# endif
+# ifndef SUBLANG_SWEDISH_FINLAND
+# define SUBLANG_SWEDISH_FINLAND 0x02
+# endif
+# ifndef SUBLANG_URDU_PAKISTAN
+# define SUBLANG_URDU_PAKISTAN 0x01
+# endif
+# ifndef SUBLANG_URDU_INDIA
+# define SUBLANG_URDU_INDIA 0x02
+# endif
+# ifndef SUBLANG_UZBEK_LATIN
+# define SUBLANG_UZBEK_LATIN 0x01
+# endif
+# ifndef SUBLANG_UZBEK_CYRILLIC
+# define SUBLANG_UZBEK_CYRILLIC 0x02
+# endif
+#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. Neither do SUSV2 and
+ ISO C 99. So we can use this feature only on selected systems (e.g.
+ those using GNU C Library). */
+#if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
+# define HAVE_LOCALE_NULL
+#endif
+
+/* Determine the current locale's name, and canonicalize it into XPG syntax
+ language[_territory[.codeset]][@modifier]
+ The codeset part in the result is not reliable; the locale_charset()
+ should be used for codeset information instead.
+ The result must not be freed; it is statically allocated. */
+
+const char *
+_nl_locale_name (category, categoryname)
+ int category;
+ const char *categoryname;
+{
+ const char *retval;
+
+#ifndef WIN32
+
+ /* Use 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
+ retval = setlocale (category, NULL);
+# else
+ /* Setting of LC_ALL overwrites all other. */
+ retval = getenv ("LC_ALL");
+ if (retval == NULL || retval[0] == '\0')
+ {
+ /* Next comes the name of the desired category. */
+ retval = getenv (categoryname);
+ if (retval == NULL || retval[0] == '\0')
+ {
+ /* Last possibility is the LANG environment variable. */
+ retval = getenv ("LANG");
+ if (retval == NULL || retval[0] == '\0')
+ /* We use C as the default domain. POSIX says this is
+ implementation defined. */
+ retval = "C";
+ }
+ }
+# endif
+
+ return retval;
+
+#else /* WIN32 */
+
+ /* Return an XPG style locale name language[_territory][@modifier].
+ Don't even bother determining the codeset; it's not useful in this
+ context, because message catalogs are not specific to a single
+ codeset. */
+
+ LCID lcid;
+ LANGID langid;
+ int primary, sub;
+
+ /* Let the user override the system settings through environment
+ variables, as on POSIX systems. */
+ retval = getenv ("LC_ALL");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+ retval = getenv (categoryname);
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+ retval = getenv ("LANG");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+
+ /* Use native Win32 API locale ID. */
+ lcid = GetThreadLocale ();
+
+ /* Strip off the sorting rules, keep only the language part. */
+ langid = LANGIDFROMLCID (lcid);
+
+ /* Split into language and territory part. */
+ primary = PRIMARYLANGID (langid);
+ sub = SUBLANGID (langid);
+ switch (primary)
+ {
+ case LANG_AFRIKAANS: return "af_ZA";
+ case LANG_ALBANIAN: return "sq_AL";
+ case LANG_ARABIC:
+ switch (sub)
+ {
+ case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
+ case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
+ case SUBLANG_ARABIC_EGYPT: return "ar_EG";
+ case SUBLANG_ARABIC_LIBYA: return "ar_LY";
+ case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
+ case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
+ case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
+ case SUBLANG_ARABIC_OMAN: return "ar_OM";
+ case SUBLANG_ARABIC_YEMEN: return "ar_YE";
+ case SUBLANG_ARABIC_SYRIA: return "ar_SY";
+ case SUBLANG_ARABIC_JORDAN: return "ar_JO";
+ case SUBLANG_ARABIC_LEBANON: return "ar_LB";
+ case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
+ case SUBLANG_ARABIC_UAE: return "ar_AE";
+ case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
+ case SUBLANG_ARABIC_QATAR: return "ar_QA";
+ }
+ return "ar";
+ case LANG_ARMENIAN: return "hy_AM";
+ case LANG_ASSAMESE: return "as_IN";
+ case LANG_AZERI:
+ switch (sub)
+ {
+ /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
+ case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
+ case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
+ }
+ return "az";
+ case LANG_BASQUE:
+ return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
+ case LANG_BELARUSIAN: return "be_BY";
+ case LANG_BENGALI: return "bn_IN";
+ case LANG_BULGARIAN: return "bg_BG";
+ case LANG_CATALAN: return "ca_ES";
+ case LANG_CHINESE:
+ switch (sub)
+ {
+ case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
+ case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
+ case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
+ case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
+ case SUBLANG_CHINESE_MACAU: return "zh_MO";
+ }
+ return "zh";
+ case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN
+ * What used to be called Serbo-Croatian
+ * should really now be two separate
+ * languages because of political reasons.
+ * (Says tml, who knows nothing about Serbian
+ * or Croatian.)
+ * (I can feel those flames coming already.)
+ */
+ switch (sub)
+ {
+ /* FIXME: How to distinguish Croatian and Latin Serbian locales? */
+ case SUBLANG_SERBIAN_LATIN: return "sr_YU";
+ case SUBLANG_SERBIAN_CYRILLIC: return "sr_YU@cyrillic";
+ default: return "hr_HR";
+ }
+ case LANG_CZECH: return "cs_CZ";
+ case LANG_DANISH: return "da_DK";
+ case LANG_DUTCH:
+ switch (sub)
+ {
+ case SUBLANG_DUTCH: return "nl_NL";
+ case SUBLANG_DUTCH_BELGIAN: return "nl_BE";
+ }
+ return "nl";
+ case LANG_ENGLISH:
+ switch (sub)
+ {
+ /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
+ * English was the language spoken in England.
+ * Oh well.
+ */
+ case SUBLANG_ENGLISH_US: return "en_US";
+ case SUBLANG_ENGLISH_UK: return "en_GB";
+ case SUBLANG_ENGLISH_AUS: return "en_AU";
+ case SUBLANG_ENGLISH_CAN: return "en_CA";
+ case SUBLANG_ENGLISH_NZ: return "en_NZ";
+ case SUBLANG_ENGLISH_EIRE: return "en_IE";
+ case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
+ case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
+ case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
+ case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
+ case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
+ case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
+ case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
+ }
+ return "en";
+ case LANG_ESTONIAN: return "et_EE";
+ case LANG_FAEROESE: return "fo_FO";
+ case LANG_FARSI: return "fa_IR";
+ case LANG_FINNISH: return "fi_FI";
+ case LANG_FRENCH:
+ switch (sub)
+ {
+ case SUBLANG_FRENCH: return "fr_FR";
+ case SUBLANG_FRENCH_BELGIAN: return "fr_BE";
+ case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
+ case SUBLANG_FRENCH_SWISS: return "fr_CH";
+ case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
+ case SUBLANG_FRENCH_MONACO: return "fr_MC";
+ }
+ return "fr";
+ case LANG_GEORGIAN: return "ka_GE";
+ case LANG_GERMAN:
+ switch (sub)
+ {
+ case SUBLANG_GERMAN: return "de_DE";
+ case SUBLANG_GERMAN_SWISS: return "de_CH";
+ case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
+ case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
+ case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
+ }
+ return "de";
+ case LANG_GREEK: return "el_GR";
+ case LANG_GUJARATI: return "gu_IN";
+ case LANG_HEBREW: return "he_IL";
+ case LANG_HINDI: return "hi_IN";
+ case LANG_HUNGARIAN: return "hu_HU";
+ case LANG_ICELANDIC: return "is_IS";
+ case LANG_INDONESIAN: return "id_ID";
+ case LANG_ITALIAN:
+ switch (sub)
+ {
+ case SUBLANG_ITALIAN: return "it_IT";
+ case SUBLANG_ITALIAN_SWISS: return "it_CH";
+ }
+ return "it";
+ case LANG_JAPANESE: return "ja_JP";
+ case LANG_KANNADA: return "kn_IN";
+ case LANG_KASHMIRI:
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "ks_PK";
+ case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
+ }
+ return "ks";
+ case LANG_KAZAK: return "kk_KZ";
+ case LANG_KONKANI:
+ /* FIXME: Adjust this when such locales appear on Unix. */
+ return "kok_IN";
+ case LANG_KOREAN: return "ko_KR";
+ case LANG_LATVIAN: return "lv_LV";
+ case LANG_LITHUANIAN: return "lt_LT";
+ case LANG_MACEDONIAN: return "mk_MK";
+ case LANG_MALAY:
+ switch (sub)
+ {
+ case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
+ case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
+ }
+ return "ms";
+ case LANG_MALAYALAM: return "ml_IN";
+ case LANG_MANIPURI:
+ /* FIXME: Adjust this when such locales appear on Unix. */
+ return "mni_IN";
+ case LANG_MARATHI: return "mr_IN";
+ case LANG_NEPALI:
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "ne_NP";
+ case SUBLANG_NEPALI_INDIA: return "ne_IN";
+ }
+ return "ne";
+ case LANG_NORWEGIAN:
+ switch (sub)
+ {
+ case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
+ case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
+ }
+ return "no";
+ case LANG_ORIYA: return "or_IN";
+ case LANG_POLISH: return "pl_PL";
+ case LANG_PORTUGUESE:
+ switch (sub)
+ {
+ case SUBLANG_PORTUGUESE: return "pt_PT";
+ /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
+ Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
+ case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
+ }
+ return "pt";
+ case LANG_PUNJABI: return "pa_IN";
+ case LANG_ROMANIAN: return "ro_RO";
+ case LANG_RUSSIAN:
+ return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA". */
+ case LANG_SANSKRIT: return "sa_IN";
+ case LANG_SINDHI: return "sd";
+ case LANG_SLOVAK: return "sk_SK";
+ case LANG_SLOVENIAN: return "sl_SI";
+ case LANG_SORBIAN:
+ /* FIXME: Adjust this when such locales appear on Unix. */
+ return "wen_DE";
+ case LANG_SPANISH:
+ switch (sub)
+ {
+ case SUBLANG_SPANISH: return "es_ES";
+ case SUBLANG_SPANISH_MEXICAN: return "es_MX";
+ case SUBLANG_SPANISH_MODERN:
+ return "es_ES@modern"; /* not seen on Unix */
+ case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
+ case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
+ case SUBLANG_SPANISH_PANAMA: return "es_PA";
+ case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
+ case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
+ case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
+ case SUBLANG_SPANISH_PERU: return "es_PE";
+ case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
+ case SUBLANG_SPANISH_ECUADOR: return "es_EC";
+ case SUBLANG_SPANISH_CHILE: return "es_CL";
+ case SUBLANG_SPANISH_URUGUAY: return "es_UY";
+ case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
+ case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
+ case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
+ case SUBLANG_SPANISH_HONDURAS: return "es_HN";
+ case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
+ case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
+ }
+ return "es";
+ case LANG_SWAHILI: return "sw";
+ case LANG_SWEDISH:
+ switch (sub)
+ {
+ case SUBLANG_DEFAULT: return "sv_SE";
+ case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
+ }
+ return "sv";
+ case LANG_TAMIL:
+ return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
+ case LANG_TATAR: return "tt";
+ case LANG_TELUGU: return "te_IN";
+ case LANG_THAI: return "th_TH";
+ case LANG_TURKISH: return "tr_TR";
+ case LANG_UKRAINIAN: return "uk_UA";
+ case LANG_URDU:
+ switch (sub)
+ {
+ case SUBLANG_URDU_PAKISTAN: return "ur_PK";
+ case SUBLANG_URDU_INDIA: return "ur_IN";
+ }
+ return "ur";
+ case LANG_UZBEK:
+ switch (sub)
+ {
+ /* FIXME: Adjust this when Uzbek locales appear on Unix. */
+ case SUBLANG_UZBEK_LATIN: return "uz_UZ@latin";
+ case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
+ }
+ return "uz";
+ case LANG_VIETNAMESE: return "vi_VN";
+ default: return "C";
+ }
+
+#endif
+}
diff --git a/popt/intl/ngettext.c b/popt/intl/ngettext.c
index fb3ec5a91..b42ff6a1a 100644
--- a/popt/intl/ngettext.c
+++ b/popt/intl/ngettext.c
@@ -1,5 +1,5 @@
/* Implementation of ngettext(3) function.
- Copyright (C) 1995, 1997, 2000, 2001 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 Library General Public License as published
@@ -44,7 +44,7 @@
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define NGETTEXT __ngettext
-# define DCNGETTEXT __dcngettext
+# define DCNGETTEXT INTUSE(__dcngettext)
#else
# define NGETTEXT ngettext__
# define DCNGETTEXT dcngettext__
diff --git a/popt/intl/os2compat.c b/popt/intl/os2compat.c
new file mode 100644
index 000000000..3ca826666
--- /dev/null
+++ b/popt/intl/os2compat.c
@@ -0,0 +1,98 @@
+/* OS/2 compatibility functions.
+ Copyright (C) 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 Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#define OS2_AWARE
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+
+/* A version of getenv() that works from DLLs */
+extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
+
+char *
+_nl_getenv (const char *name)
+{
+ unsigned char *value;
+ if (DosScanEnv (name, &value))
+ return NULL;
+ else
+ return value;
+}
+
+/* A fixed size buffer. */
+char _nl_default_dirname__[MAXPATHLEN+1];
+
+char *_nlos2_libdir = NULL;
+char *_nlos2_localealiaspath = NULL;
+char *_nlos2_localedir = NULL;
+
+static __attribute__((constructor)) void
+nlos2_initialize ()
+{
+ char *root = getenv ("UNIXROOT");
+ char *gnulocaledir = getenv ("GNULOCALEDIR");
+
+ _nlos2_libdir = gnulocaledir;
+ if (!_nlos2_libdir)
+ {
+ if (root)
+ {
+ size_t sl = strlen (root);
+ _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
+ memcpy (_nlos2_libdir, root, sl);
+ memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
+ }
+ else
+ _nlos2_libdir = LIBDIR;
+ }
+
+ _nlos2_localealiaspath = gnulocaledir;
+ if (!_nlos2_localealiaspath)
+ {
+ if (root)
+ {
+ size_t sl = strlen (root);
+ _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
+ memcpy (_nlos2_localealiaspath, root, sl);
+ memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
+ }
+ else
+ _nlos2_localealiaspath = LOCALE_ALIAS_PATH;
+ }
+
+ _nlos2_localedir = gnulocaledir;
+ if (!_nlos2_localedir)
+ {
+ if (root)
+ {
+ size_t sl = strlen (root);
+ _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
+ memcpy (_nlos2_localedir, root, sl);
+ memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
+ }
+ else
+ _nlos2_localedir = LOCALEDIR;
+ }
+
+ if (strlen (_nlos2_localedir) <= MAXPATHLEN)
+ strcpy (_nl_default_dirname__, _nlos2_localedir);
+}
diff --git a/popt/intl/os2compat.h b/popt/intl/os2compat.h
new file mode 100644
index 000000000..4f74e8c03
--- /dev/null
+++ b/popt/intl/os2compat.h
@@ -0,0 +1,46 @@
+/* OS/2 compatibility defines.
+ This file is intended to be included from config.h
+ Copyright (C) 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 Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* When included from os2compat.h we need all the original definitions */
+#ifndef OS2_AWARE
+
+#undef LIBDIR
+#define LIBDIR _nlos2_libdir
+extern char *_nlos2_libdir;
+
+#undef LOCALEDIR
+#define LOCALEDIR _nlos2_localedir
+extern char *_nlos2_localedir;
+
+#undef LOCALE_ALIAS_PATH
+#define LOCALE_ALIAS_PATH _nlos2_localealiaspath
+extern char *_nlos2_localealiaspath;
+
+#endif
+
+#undef HAVE_STRCASECMP
+#define HAVE_STRCASECMP 1
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+
+/* We have our own getenv() which works even if library is compiled as DLL */
+#define getenv _nl_getenv
+
+/* Older versions of gettext used -1 as the value of LC_MESSAGES */
+#define LC_MESSAGES_COMPAT (-1)
diff --git a/popt/intl/osdep.c b/popt/intl/osdep.c
new file mode 100644
index 000000000..b37259838
--- /dev/null
+++ b/popt/intl/osdep.c
@@ -0,0 +1,24 @@
+/* OS dependent parts of libintl.
+ Copyright (C) 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 Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#if defined __EMX__
+# include "os2compat.c"
+#else
+/* Avoid AIX compiler warning. */
+typedef int dummy;
+#endif
diff --git a/popt/intl/plural-exp.c b/popt/intl/plural-exp.c
new file mode 100644
index 000000000..c937c011a
--- /dev/null
+++ b/popt/intl/plural-exp.c
@@ -0,0 +1,156 @@
+/* Expression parsing for plural form selection.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "plural-exp.h"
+
+#if (defined __GNUC__ && !defined __APPLE_CC__) \
+ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
+
+/* These structs are the constant expression for the germanic plural
+ form determination. It represents the expression "n != 1". */
+static const struct expression plvar =
+{
+ .nargs = 0,
+ .operation = var,
+};
+static const struct expression plone =
+{
+ .nargs = 0,
+ .operation = num,
+ .val =
+ {
+ .num = 1
+ }
+};
+struct expression GERMANIC_PLURAL =
+{
+ .nargs = 2,
+ .operation = not_equal,
+ .val =
+ {
+ .args =
+ {
+ [0] = (struct expression *) &plvar,
+ [1] = (struct expression *) &plone
+ }
+ }
+};
+
+# define INIT_GERMANIC_PLURAL()
+
+#else
+
+/* For compilers without support for ISO C 99 struct/union initializers:
+ Initialization at run-time. */
+
+static struct expression plvar;
+static struct expression plone;
+struct expression GERMANIC_PLURAL;
+
+static void
+init_germanic_plural ()
+{
+ if (plone.val.num == 0)
+ {
+ plvar.nargs = 0;
+ plvar.operation = var;
+
+ plone.nargs = 0;
+ plone.operation = num;
+ plone.val.num = 1;
+
+ GERMANIC_PLURAL.nargs = 2;
+ GERMANIC_PLURAL.operation = not_equal;
+ GERMANIC_PLURAL.val.args[0] = &plvar;
+ GERMANIC_PLURAL.val.args[1] = &plone;
+ }
+}
+
+# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
+
+#endif
+
+void
+internal_function
+EXTRACT_PLURAL_EXPRESSION (nullentry, pluralp, npluralsp)
+ const char *nullentry;
+ struct expression **pluralp;
+ unsigned long int *npluralsp;
+{
+ if (nullentry != NULL)
+ {
+ const char *plural;
+ const char *nplurals;
+
+ plural = strstr (nullentry, "plural=");
+ nplurals = strstr (nullentry, "nplurals=");
+ if (plural == NULL || nplurals == NULL)
+ goto no_plural;
+ else
+ {
+ char *endp;
+ unsigned long int n;
+ struct parse_args args;
+
+ /* First get the number. */
+ nplurals += 9;
+ while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
+ ++nplurals;
+ if (!(*nplurals >= '0' && *nplurals <= '9'))
+ goto no_plural;
+#if defined HAVE_STRTOUL || defined _LIBC
+ n = strtoul (nplurals, &endp, 10);
+#else
+ for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
+ n = n * 10 + (*endp - '0');
+#endif
+ if (nplurals == endp)
+ goto no_plural;
+ *npluralsp = n;
+
+ /* Due to the restrictions bison imposes onto the interface of the
+ scanner function we have to put the input string and the result
+ passed up from the parser into the same structure which address
+ is passed down to the parser. */
+ plural += 7;
+ args.cp = plural;
+ if (PLURAL_PARSE (&args) != 0)
+ goto no_plural;
+ *pluralp = args.res;
+ }
+ }
+ else
+ {
+ /* By default we are using the Germanic form: singular form only
+ for `one', the plural form otherwise. Yes, this is also what
+ English is using since English is a Germanic language. */
+ no_plural:
+ INIT_GERMANIC_PLURAL ();
+ *pluralp = &GERMANIC_PLURAL;
+ *npluralsp = 2;
+ }
+}
diff --git a/popt/intl/plural-exp.h b/popt/intl/plural-exp.h
new file mode 100644
index 000000000..93cdaef57
--- /dev/null
+++ b/popt/intl/plural-exp.h
@@ -0,0 +1,126 @@
+/* Expression parsing and evaluation for plural form selection.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _PLURAL_EXP_H
+#define _PLURAL_EXP_H
+
+#ifndef PARAMS
+# 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
+
+#ifndef attribute_hidden
+# define attribute_hidden
+#endif
+
+
+/* This is the representation of the expressions to determine the
+ plural form. */
+struct expression
+{
+ int nargs; /* Number of arguments. */
+ enum operator
+ {
+ /* Without arguments: */
+ var, /* The variable "n". */
+ num, /* Decimal number. */
+ /* Unary operators: */
+ lnot, /* Logical NOT. */
+ /* Binary operators: */
+ mult, /* Multiplication. */
+ divide, /* Division. */
+ module, /* Modulo operation. */
+ plus, /* Addition. */
+ minus, /* Subtraction. */
+ less_than, /* Comparison. */
+ greater_than, /* Comparison. */
+ less_or_equal, /* Comparison. */
+ greater_or_equal, /* Comparison. */
+ equal, /* Comparison for equality. */
+ not_equal, /* Comparison for inequality. */
+ land, /* Logical AND. */
+ lor, /* Logical OR. */
+ /* Ternary operators: */
+ qmop /* Question mark operator. */
+ } operation;
+ union
+ {
+ unsigned long int num; /* Number value for `num'. */
+ struct expression *args[3]; /* Up to three arguments. */
+ } val;
+};
+
+/* This is the data structure to pass information to the parser and get
+ the result in a thread-safe way. */
+struct parse_args
+{
+ const char *cp;
+ struct expression *res;
+};
+
+
+/* Names for the libintl functions are a problem. This source code is used
+ 1. in the GNU C Library library,
+ 2. in the GNU libintl library,
+ 3. in the GNU gettext tools.
+ The function names in each situation must be different, to allow for
+ binary incompatible changes in 'struct expression'. Furthermore,
+ 1. in the GNU C Library library, the names have a __ prefix,
+ 2.+3. in the GNU libintl library and in the GNU gettext tools, the names
+ must follow ANSI C and not start with __.
+ So we have to distinguish the three cases. */
+#ifdef _LIBC
+# define FREE_EXPRESSION __gettext_free_exp
+# define PLURAL_PARSE __gettextparse
+# define GERMANIC_PLURAL __gettext_germanic_plural
+# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
+#elif defined (IN_LIBINTL)
+# define FREE_EXPRESSION gettext_free_exp__
+# define PLURAL_PARSE gettextparse__
+# define GERMANIC_PLURAL gettext_germanic_plural__
+# define EXTRACT_PLURAL_EXPRESSION gettext_extract_plural__
+#else
+# define FREE_EXPRESSION free_plural_expression
+# define PLURAL_PARSE parse_plural_expression
+# define GERMANIC_PLURAL germanic_plural
+# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
+#endif
+
+extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
+ internal_function;
+extern int PLURAL_PARSE PARAMS ((void *arg));
+extern struct expression GERMANIC_PLURAL attribute_hidden;
+extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
+ struct expression **pluralp,
+ unsigned long int *npluralsp))
+ internal_function;
+
+#if !defined (_LIBC) && !defined (IN_LIBINTL)
+extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
+ unsigned long int n));
+#endif
+
+#endif /* _PLURAL_EXP_H */
diff --git a/popt/intl/plural.c b/popt/intl/plural.c
index 640d43cc5..c9ff63fbd 100644
--- a/popt/intl/plural.c
+++ b/popt/intl/plural.c
@@ -50,30 +50,26 @@
# include <config.h>
#endif
+#include <stddef.h>
#include <stdlib.h>
-#include "gettextP.h"
-
-/* 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 FREE_EXPRESSION __gettext_free_exp
-#else
-# define FREE_EXPRESSION gettext_free_exp__
-# define __gettextparse gettextparse__
+#include "plural-exp.h"
+
+/* The main function generated by the parser is called __gettextparse,
+ but we want it to be called PLURAL_PARSE. */
+#ifndef _LIBC
+# define __gettextparse PLURAL_PARSE
#endif
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
#define YYPARSE_PARAM arg
-#line 53 "plural.y"
+#line 49 "plural.y"
typedef union {
unsigned long int num;
enum operator op;
struct expression *exp;
} YYSTYPE;
-#line 59 "plural.y"
+#line 55 "plural.y"
/* Prototypes for local functions. */
static struct expression *new_exp PARAMS ((int nargs, enum operator op,
@@ -235,8 +231,8 @@ static const short yyrhs[] = { 17,
#if YYDEBUG != 0
static const short yyrline[] = { 0,
- 178, 186, 190, 194, 198, 202, 206, 210, 214, 218,
- 222, 227
+ 174, 182, 186, 190, 194, 198, 202, 206, 210, 214,
+ 218, 223
};
#endif
@@ -303,7 +299,7 @@ static const short yycheck[] = { 1,
#define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
+#line 3 "/usr/local/share/bison.simple"
/* This file comes from bison-1.28. */
/* Skeleton output parser for bison,
@@ -517,7 +513,7 @@ __yy_memcpy (char *to, char *from, unsigned int count)
#endif
#endif
-#line 217 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
+#line 217 "/usr/local/share/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
@@ -846,7 +842,7 @@ yyreduce:
switch (yyn) {
case 1:
-#line 179 "plural.y"
+#line 175 "plural.y"
{
if (yyvsp[0].exp == NULL)
YYABORT;
@@ -854,75 +850,75 @@ case 1:
;
break;}
case 2:
-#line 187 "plural.y"
+#line 183 "plural.y"
{
yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 3:
-#line 191 "plural.y"
+#line 187 "plural.y"
{
yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 4:
-#line 195 "plural.y"
+#line 191 "plural.y"
{
yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 5:
-#line 199 "plural.y"
+#line 195 "plural.y"
{
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 6:
-#line 203 "plural.y"
+#line 199 "plural.y"
{
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 7:
-#line 207 "plural.y"
+#line 203 "plural.y"
{
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 8:
-#line 211 "plural.y"
+#line 207 "plural.y"
{
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
;
break;}
case 9:
-#line 215 "plural.y"
+#line 211 "plural.y"
{
yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
;
break;}
case 10:
-#line 219 "plural.y"
+#line 215 "plural.y"
{
yyval.exp = new_exp_0 (var);
;
break;}
case 11:
-#line 223 "plural.y"
+#line 219 "plural.y"
{
if ((yyval.exp = new_exp_0 (num)) != NULL)
yyval.exp->val.num = yyvsp[0].num;
;
break;}
case 12:
-#line 228 "plural.y"
+#line 224 "plural.y"
{
yyval.exp = yyvsp[-1].exp;
;
break;}
}
/* the action file gets copied in in place of this dollarsign */
-#line 543 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
+#line 543 "/usr/local/share/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1142,7 +1138,7 @@ yyerrhandle:
}
return 1;
}
-#line 233 "plural.y"
+#line 229 "plural.y"
void
diff --git a/popt/intl/plural.y b/popt/intl/plural.y
index be049a6d4..616b7c11a 100644
--- a/popt/intl/plural.y
+++ b/popt/intl/plural.y
@@ -30,25 +30,21 @@
# include <config.h>
#endif
+#include <stddef.h>
#include <stdlib.h>
-#include "gettextP.h"
-
-/* 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 FREE_EXPRESSION __gettext_free_exp
-#else
-# define FREE_EXPRESSION gettext_free_exp__
-# define __gettextparse gettextparse__
+#include "plural-exp.h"
+
+/* The main function generated by the parser is called __gettextparse,
+ but we want it to be called PLURAL_PARSE. */
+#ifndef _LIBC
+# define __gettextparse PLURAL_PARSE
#endif
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
#define YYPARSE_PARAM arg
%}
%pure_parser
-%expect 10
+%expect 7
%union {
unsigned long int num;
diff --git a/popt/intl/textdomain.c b/popt/intl/textdomain.c
index 2e420ad77..8fb4ea085 100644
--- a/popt/intl/textdomain.c
+++ b/popt/intl/textdomain.c
@@ -1,5 +1,5 @@
/* Implementation of the textdomain(3) function.
- Copyright (C) 1995-1998, 2000, 2001 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 Library General Public License as published
@@ -51,10 +51,10 @@
/* @@ 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
@@ -71,7 +71,7 @@ extern const char *_nl_current_default_domain;
#endif
/* Lock variable to protect the global data in the gettext implementation. */
-__libc_rwlock_define (extern, _nl_state_lock)
+__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.