aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog90
-rw-r--r--intl/Makefile4
-rw-r--r--intl/bindtextdom.c21
-rw-r--r--intl/dcigettext.c166
-rw-r--r--intl/dgettext.c4
-rw-r--r--intl/dngettext.c4
-rw-r--r--intl/explodename.c11
-rw-r--r--intl/finddomain.c21
-rw-r--r--intl/gettext.c10
-rw-r--r--intl/gettext.h4
-rw-r--r--intl/gettextP.h55
-rw-r--r--intl/l10nflist.c30
-rw-r--r--intl/loadmsgcat.c151
-rw-r--r--intl/localealias.c33
-rw-r--r--intl/ngettext.c10
-rw-r--r--intl/plural-eval.c101
-rw-r--r--intl/plural-exp.c157
-rw-r--r--intl/plural-exp.h118
-rw-r--r--intl/plural.c86
-rw-r--r--intl/plural.y25
-rw-r--r--intl/textdomain.c14
21 files changed, 579 insertions, 536 deletions
diff --git a/ChangeLog b/ChangeLog
index ca18691b56..00084ffab2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,93 @@
+2001-03-04 Bruno Haible <bruno@clisp.org>
+
+ * intl/dcigettext.c (DCIGETTEXT): Increment path_max proportionally.
+
+2001-10-31 Bruno Haible <bruno@clisp.org>
+
+ * intl/plural.y: Include <stddef.h>, needed for NULL with SunOS 4 cc.
+
+2001-03-21 Bruno Haible <bruno@clisp.org>
+
+ * intl/dcigettext.c (_nl_state_lock): Mark as #ifdef _LIBC. AIX 3 xlc
+ chokes on empty macro arguments.
+ * intl/plural.y: Add #pragma for alloca on AIX 3.
+
+2001-11-27 Ulrich Drepper <drepper@redhat.com>
+
+ * intl/dcigettext.c (guess_category_value): Only implement for
+ glibc. Otherwise rely on function _nl_locale_name which isn't
+ present in the glibc sources.
+
+2001-09-24 Bruno Haible <bruno@clisp.org>
+
+ * intl/loadmsgcat.c (_nl_init_domain_conv): Also enable
+ transliteration when building on a glibc system but outside glibc.
+
+2001-09-22 Bruno Haible <bruno@clisp.org>
+
+ * intl/plural-eval.c: New file, extracted from dcigettext.c.
+ * intl/dcigettext.c (plural_eval): Remove function, moved to
+ intl/plural-eval.c.
+ (plural_lookup): Call PLURAL_EVAL instead of plural_eval.
+ Include plural-eval.c.
+
+2001-09-22 Bruno Haible <bruno@clisp.org>
+
+ * intl/plural-exp.c (EXTRACT_PLURAL_EXPRESSION): Reject numbers that
+ don't start with a digit; nplurals must be positive.
+
+2001-09-02 Bruno Haible <bruno@clisp.org>
+
+ * intl/plural-exp.h: New file, extracted from gettextP.h.
+ * intl/plural-exp.c: New file, extracted from loadmsgcat.c.
+ * intl/gettextP.h (struct expression, struct parse_args,
+ __gettext_free_exp, __gettextparse): Move to plural-exp.h.
+ * intl/loadmsgcat.c: Include plural-exp.h.
+ (PLURAL_PARSE): Move macro to plural-exp.h.
+ (plvar, plone, germanic_plural, INIT_GERMANIC_PLURAL): Move to
+ plural-exp.c.
+ (_nl_load_domain): Move plural handling code to plural-exp.c. Call
+ EXTRACT_PLURAL_EXPRESSION.
+ (_nl_unload_domain): Update.
+ * intl/dcigettext.c: Include plural-exp.h.
+ * intl/plural.y: Include plural-exp.h, not gettextP.h.
+ (FREE_EXPRESSION): Move macro to plural-exp.h.
+ * intl/Makefile (routines): Add plural-exp.
+ (distribute): Add plural-exp.h.
+
+2001-07-28 Bruno Haible <bruno@clisp.org>
+
+ * intl/l10nflist.c (_nl_normalize_codeset): Cast isalnum, isalpha,
+ isdigit, tolower argument to 'unsigned char'.
+ * intl/loadmsgcat.c (_nl_load_domain): Cast isspace argument to
+ 'unsigned char'.
+ * intl/localealias.c (read_alias_file): Cast isspace argument to
+ 'unsigned char'.
+
+2001-10-20 Bruno Haible <bruno@clisp.org>
+
+ Assume strchr() exists. (Without it, intl/explodename.c wouldn't link
+ anyway.)
+ * intl/dcigettext.c (strchr): Remove fallback definition; it conflicts
+ with the variable 'index' in plural_lookup.
+ * intl/l10nflist.c (strchr): Likewise.
+ * intl/localealias.c (strchr): Likewise.
+
+ Assume <stddef.h>, <stdlib.h>, <string.h>, <locale.h> exist.
+ * intl/bindtextdom.c: Likewise.
+ * intl/dcigettext.c: Likewise.
+ * intl/dgettext.c: Likewise.
+ * intl/dngettext.c: Likewise.
+ * intl/explodename.c: Likewise.
+ * intl/finddomain.c: Likewise.
+ * intl/gettext.c: Likewise.
+ * intl/l10nflist.c: Likewise.
+ * intl/loadmsgcat.c: Likewise.
+ * intl/localealias.c: Likewise.
+ * intl/ngettext.c: Likewise.
+ * intl/textdomain.c: Likewise.
+ * intl/gettext.h: Assume <limits.h> exists.
+
2001-11-27 Ulrich Drepper <drepper@redhat.com>
* stdio-common/Makefile (tests): Add scanf11.
diff --git a/intl/Makefile b/intl/Makefile
index 61acb309f6..3935e7942b 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -23,9 +23,9 @@ headers = libintl.h
routines = bindtextdom dcgettext dgettext gettext \
dcigettext dcngettext dngettext ngettext \
finddomain loadmsgcat localealias textdomain \
- l10nflist explodename plural
+ l10nflist explodename plural plural-exp
distribute = gettext.h gettextP.h hash-string.h loadinfo.h locale.alias \
- plural.y po2test.sed tst-gettext.sh tst-translit.sh \
+ plural.y plural-exp.h po2test.sed tst-gettext.sh tst-translit.sh \
translit.po tst-gettext2.sh tstlang1.po tstlang2.po tstcodeset.po\
tst-codeset.sh
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index e4830798bc..d051ac9f3a 100644
--- a/intl/bindtextdom.c
+++ b/intl/bindtextdom.c
@@ -21,24 +21,9 @@
# include <config.h>
#endif
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#else
-# ifdef HAVE_MALLOC_H
-# include <malloc.h>
-# else
-void free ();
-# endif
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef memcpy
-# define memcpy(Dst, Src, Num) (bcopy (Src, Dst, Num), (Dst))
-# endif
-#endif
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
#ifdef _LIBC
# include <libintl.h>
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index d5208e41f8..f274de81d8 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -30,11 +30,11 @@
#include <sys/types.h>
-#if defined __GNUC__ && !defined C_ALLOCA
+#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
-# if (defined HAVE_ALLOCA_H || defined _LIBC) && !defined C_ALLOCA
+# if defined HAVE_ALLOCA_H || defined _LIBC
# include <alloca.h>
# else
# ifdef _AIX
@@ -55,42 +55,22 @@ extern int errno;
# define __set_errno(val) errno = (val)
#endif
-#if defined STDC_HEADERS || defined _LIBC
-# include <stddef.h>
-# include <stdlib.h>
-#else
-char *getenv ();
-# ifdef HAVE_MALLOC_H
-# include <malloc.h>
-# else
-void free ();
-# endif
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-# define strchr index
-# endif
-#endif
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
#if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h>
#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
+#include <locale.h>
#if defined HAVE_SYS_PARAM_H || defined _LIBC
# include <sys/param.h>
#endif
#include "gettextP.h"
+#include "plural-exp.h"
#ifdef _LIBC
# include <libintl.h>
#else
@@ -192,16 +172,6 @@ static void *mempcpy PARAMS ((void *dest, const void *src, size_t n));
# define PATH_MAX _POSIX_PATH_MAX
#endif
-/* XPG3 defines the result of `setlocale (category, NULL)' as:
- ``Directs `setlocale()' to query `category' and return the current
- setting of `local'.''
- However it does not specify the exact format. Neither do SUSV2 and
- ISO C 99. So we can use this feature only on selected systems (e.g.
- those using GNU C Library). */
-#ifdef _LIBC
-# define HAVE_LOCALE_NULL
-#endif
-
/* This is the type used for the search tree where known translations
are stored. */
struct known_translation_t
@@ -286,9 +256,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))
@@ -355,7 +322,9 @@ typedef unsigned char transmem_block_t;
#endif
/* Lock variable to protect the global data in the gettext implementation. */
+#ifdef _LIBC
__libc_rwlock_define_initialized (, _nl_state_lock)
+#endif
/* Checking whether the binaries runs SUID must be done and glibc provides
easier methods therefore we make a difference here. */
@@ -375,6 +344,9 @@ static int enable_secure;
}
#endif
+/* Get the function to evaluate the plural expression. */
+#include "plural-eval.c"
+
/* 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. */
@@ -479,16 +451,18 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
path_max = (unsigned int) PATH_MAX;
path_max += 2; /* The getcwd docs say to do this. */
- dirname = (char *) alloca (path_max + dirname_len);
- ADD_BLOCK (block_list, dirname);
-
- __set_errno (0);
- while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE)
+ for (;;)
{
- path_max += PATH_INCR;
dirname = (char *) alloca (path_max + dirname_len);
ADD_BLOCK (block_list, dirname);
+
__set_errno (0);
+ ret = getcwd (dirname, path_max);
+ if (ret != NULL || errno != ERANGE)
+ break;
+
+ path_max += path_max / 2;
+ path_max += PATH_INCR;
}
if (ret == NULL)
@@ -983,87 +957,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
@@ -1144,25 +1037,10 @@ 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
return language != NULL && strcmp (retval, "C") != 0 ? language : retval;
diff --git a/intl/dgettext.c b/intl/dgettext.c
index d0e5ed2b2f..02ca2b1687 100644
--- a/intl/dgettext.c
+++ b/intl/dgettext.c
@@ -21,9 +21,7 @@
# include <config.h>
#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
+#include <locale.h>
#include "gettextP.h"
#ifdef _LIBC
diff --git a/intl/dngettext.c b/intl/dngettext.c
index a620024b6c..14f06c3779 100644
--- a/intl/dngettext.c
+++ b/intl/dngettext.c
@@ -21,9 +21,7 @@
# include <config.h>
#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
-# include <locale.h>
-#endif
+#include <locale.h>
#include "gettextP.h"
#ifdef _LIBC
diff --git a/intl/explodename.c b/intl/explodename.c
index 5561017876..0b17776ec6 100644
--- a/intl/explodename.c
+++ b/intl/explodename.c
@@ -21,15 +21,8 @@
# include <config.h>
#endif
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include "loadinfo.h"
diff --git a/intl/finddomain.c b/intl/finddomain.c
index 7dd18633a9..d487bbdf42 100644
--- a/intl/finddomain.c
+++ b/intl/finddomain.c
@@ -24,25 +24,8 @@
#include <stdio.h>
#include <sys/types.h>
-
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#else
-# ifdef HAVE_MALLOC_H
-# include <malloc.h>
-# else
-void free ();
-# endif
-#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef memcpy
-# define memcpy(Dst, Src, Num) (bcopy (Src, Dst, Num), (Dst))
-# endif
-#endif
+#include <stdlib.h>
+#include <string.h>
#if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h>
diff --git a/intl/gettext.c b/intl/gettext.c
index 4b90f518c7..1f992c8e77 100644
--- a/intl/gettext.c
+++ b/intl/gettext.c
@@ -25,15 +25,7 @@
# define __need_NULL
# include <stddef.h>
#else
-# ifdef STDC_HEADERS
-# include <stdlib.h> /* Just for NULL. */
-# else
-# ifdef HAVE_STRING_H
-# include <string.h>
-# else
-# define NULL ((void *) 0)
-# endif
-# endif
+# include <stdlib.h> /* Just for NULL. */
#endif
#include "gettextP.h"
diff --git a/intl/gettext.h b/intl/gettext.h
index c427d89d17..11a0236daf 100644
--- a/intl/gettext.h
+++ b/intl/gettext.h
@@ -20,9 +20,7 @@
#ifndef _GETTEXT_H
#define _GETTEXT_H 1
-#if HAVE_LIMITS_H || _LIBC
-# include <limits.h>
-#endif
+#include <limits.h>
/* @@ end of prolog @@ */
diff --git a/intl/gettextP.h b/intl/gettextP.h
index 2788964954..98d16954f9 100644
--- a/intl/gettextP.h
+++ b/intl/gettextP.h
@@ -75,51 +75,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
{
@@ -240,16 +195,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/intl/l10nflist.c b/intl/l10nflist.c
index 5e23d394bc..bb5900068c 100644
--- a/intl/l10nflist.c
+++ b/intl/l10nflist.c
@@ -28,30 +28,14 @@
# include <config.h>
#endif
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef memcpy
-# define memcpy(Dst, Src, Num) (bcopy (Src, Dst, Num), (Dst))
-# endif
-#endif
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-# define strchr index
-# endif
-#endif
+#include <string.h>
#if defined _LIBC || defined HAVE_ARGZ_H
# include <argz.h>
#endif
#include <ctype.h>
#include <sys/types.h>
-
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
#include "loadinfo