aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog130
-rw-r--r--intl/Makefile2
-rw-r--r--intl/bindtextdom.c17
-rw-r--r--intl/dcgettext.c5
-rw-r--r--intl/dcigettext.c158
-rw-r--r--intl/dcngettext.c5
-rw-r--r--intl/dgettext.c5
-rw-r--r--intl/dngettext.c5
-rw-r--r--intl/explodename.c5
-rw-r--r--intl/finddomain.c5
-rw-r--r--intl/gettext.c7
-rw-r--r--intl/gettext.h9
-rw-r--r--intl/gettextP.h126
-rw-r--r--intl/l10nflist.c4
-rw-r--r--intl/loadmsgcat.c78
-rw-r--r--intl/localealias.c60
-rw-r--r--intl/ngettext.c5
-rw-r--r--intl/plural.c443
-rw-r--r--intl/plural.y328
-rw-r--r--intl/textdomain.c5
20 files changed, 901 insertions, 501 deletions
diff --git a/ChangeLog b/ChangeLog
index 99e55f7837..4d054b0894 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,133 @@
+2001-03-17 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/loadmsgcat.c (_nl_load_domain) [!_LIBC]: Use fstat, not fstat64.
+
+2001-03-17 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/gettextP.h (struct expression): Add operators lnot, less_than,
+ greater_than, less_or_equal, greater_or_equal. Replace args2/args3
+ union by a 'nargs' counter and an 'args[]' array.
+ * intl/plural.y: Don't include stdarg.h.
+ (new_exp): Take an array of arguments instead of varargs.
+ (new_exp_0, new_exp_1, new_exp_2, new_exp_3): New functions.
+ ('?' ':'): Make right-associative.
+ (EQUOP2): New token, replaces '=' and '!'.
+ (CMPOP2): New token.
+ (ADDOP2): New token, replaces '+' and '-'.
+ (MULOP2): New token, replaces '*', '/' and '%'.
+ ('!'): New token.
+ (exp): Add rules for CMPOP2 and '!'. Don't call YYABORT.
+ (start): Call YYABORT here.
+ (FREE_EXPRESSION): Update.
+ (yylex): Don't skip "\\n". Recognize comparison and '!' operators.
+ Update for new token symbols.
+ * intl/loadmsgcat.c (plvar, plone, germanic_plural,
+ init_germanic_plural): Update.
+ * intl/dcigettext.c (_nl_find_msg): Optimize for space.
+ (plural_eval): Recognize comparison and '!' operators. Optimize for
+ space.
+
+2001-03-10 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/loadmsgcat.c (_nl_load_domain): locale_charset() doesn't return
+ NULL any more.
+
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/loadmsgcat.c: Include headers needed for alloca().
+ (freea): New macro.
+ (_nl_load_domain): Add fallback code for platforms lacking alloca.
+ * intl/localealias.c: (ADD_BLOCK, FREE_BLOCK): Remove macros.
+ (freea): New macro.
+ (read_alias_file): Simplify fallback code for platforms lacking
+ alloca.
+
+2001-01-07 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/gettextP.h (__gettextdebug): Remove declaration.
+ (__gettext_free_exp, __gettextparse): Convert prototype to K&R C
+ syntax.
+ (gettext_free_exp__, gettextparse__): New non-libc declarations.
+ * intl/plural.y [!_LIBC]: Define gettextparse__, gettext_free_exp__,
+ not __gettextparse, __gettext_free_exp.
+ * intl/loadmsgcat.c [!_LIBC]: Use gettextparse__, not __gettextparse.
+
+2001-02-24 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/dcigettext.c: Update comment about HAVE_LOCALE_NULL.
+
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/loadmsgcat.c (_nl_load_domain): Add fallback code for platforms
+ lacking strtoul, like SunOS4.
+
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/l10nflist.c (_nl_normalize_codeset): Use tolower, not _tolower.
+
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/bindtextdom.c (set_binding_values): Convert prototype to K&R C
+ syntax.
+ * intl/dcigettext.c (transcmp): Convert to K&R C syntax.
+ * intl/explodename.c (_nl_find_language): Convert to K&R C syntax.
+ * intl/plural.y (__gettext_free_exp, yylex, yyerror): Convert to K&R C
+ syntax.
+
+2001-01-07 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/gettextP.h (gettext__, dgettext__, dcgettext__, textdomain__,
+ bindtextdomain__, bind_textdomain_codeset__): New declarations, from
+ old libgettext.h.
+ * intl/bindtextdom.c: Include libgnuintl.h instead of libgettext.h.
+ * intl/dcgettext.c: Likewise.
+ * intl/dcigettext.c: Likewise.
+ * intl/dcngettext.c: Likewise.
+ * intl/dngettext.c: Likewise.
+ * intl/finddomain.c: Likewise.
+ * intl/ngettext.c: Likewise.
+ * intl/textdomain.c: Likewise.
+ * intl/dgettext.c: Include libgnuintl.h instead of libgettext.h.
+ Include gettextP.h.
+ * intl/gettext.c: Likewise. Don't include locale.h.
+
+2001-03-17 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/gettextP.h (ZERO): New macro.
+ (struct binding): Always use ZERO.
+ * intl/bindtextdom.c (offsetof): Provide fallback for platforms that
+ lack it, like SunOS4.
+ (set_binding_values): Use offsetof, not sizeof.
+ * intl/dcigettext.c (offsetof): Provide fallback for platforms that
+ lack it, like SunOS4.
+ (ZERO): Remove macro.
+ (struct transmem_list): Use ZERO.
+ (DCIGETTEXT): Use offsetof, not sizeof.
+
+2001-03-17 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/gettextP.h: Include <stddef.h>. Include gettext.h, for
+ nls_uint32.
+ * intl/bindtextdom.c: Don't include gettext.h.
+ * intl/dcgettext.c: Likewise.
+ * intl/dcigettext.c: Likewise.
+ * intl/dcngettext.c: Likewise.
+ * intl/dngettext.c: Likewise.
+ * intl/finddomain.c: Likewise.
+ * intl/localealias.c: Likewise.
+ * intl/ngettext.c: Likewise.
+ * intl/plural.y: Likewise.
+ * intl/textdomain.c: Likewise.
+
+2001-03-17 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/gettext.h: Don't include <stdio.h>.
+
+2001-03-17 Bruno Haible <haible@clisp.cons.org>
+
+ * intl/Makefile (CPPFLAGS): Set LOCALEDIR instead of GNULOCALEDIR.
+ * intl/dcigettext.c (_nl_default_dirname): Initialize with LOCALEDIR.
+
2001-03-19 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/i386/i686/tempname.c: New file.
diff --git a/intl/Makefile b/intl/Makefile
index 29cf14ec8b..fc428c60fe 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -81,7 +81,7 @@ CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\"
$(objpfx)tst-translit.out: $(objpfx)tst-gettext.out
-CPPFLAGS += -D'GNULOCALEDIR="$(msgcatdir)"' \
+CPPFLAGS += -D'LOCALEDIR="$(msgcatdir)"' \
-D'LOCALE_ALIAS_PATH="$(msgcatdir)"'
BISONFLAGS = --yacc --name-prefix=__gettext --output
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index 45000a6b58..1b22bfc648 100644
--- a/intl/bindtextdom.c
+++ b/intl/bindtextdom.c
@@ -1,5 +1,5 @@
/* Implementation of the bindtextdomain(3) function
- Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -42,9 +42,8 @@ void free ();
#ifdef _LIBC
# include <libintl.h>
#else
-# include "libgettext.h"
+# include "libgnuintl.h"
#endif
-#include "gettext.h"
#include "gettextP.h"
#ifdef _LIBC
@@ -65,6 +64,11 @@ void free ();
# define _nl_domain_bindings _nl_domain_bindings__
#endif
+/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */
+#ifndef offsetof
+# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
+#endif
+
/* @@ end of prolog @@ */
/* Contains the default location of the message catalogs. */
@@ -93,8 +97,9 @@ __libc_rwlock_define (extern, _nl_state_lock)
#endif
/* Prototypes for local functions. */
-static void set_binding_values (const char *domainname, const char **dirnamep,
- const char **codesetp);
+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.
@@ -234,7 +239,7 @@ set_binding_values (domainname, dirnamep, codesetp)
/* We have to create a new binding. */
size_t len = strlen (domainname) + 1;
struct binding *new_binding =
- (struct binding *) malloc (sizeof (*new_binding) + len);
+ (struct binding *) malloc (offsetof (struct binding, domainname) + len);
if (__builtin_expect (new_binding == NULL, 0))
goto failed;
diff --git a/intl/dcgettext.c b/intl/dcgettext.c
index 8115d5c54e..145de63e8b 100644
--- a/intl/dcgettext.c
+++ b/intl/dcgettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dcgettext(3) function.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -20,12 +20,11 @@
# include <config.h>
#endif
-#include "gettext.h"
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
-# include "libgettext.h"
+# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index 75aa03a45f..cd3392128b 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -89,12 +89,11 @@ void free ();
# include <sys/param.h>
#endif
-#include "gettext.h"
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
-# include "libgettext.h"
+# include "libgnuintl.h"
#endif
#include "hash-string.h"
@@ -129,6 +128,11 @@ void free ();
# define _nl_domain_bindings _nl_domain_bindings__
#endif
+/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */
+#ifndef offsetof
+# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
+#endif
+
/* @@ end of prolog @@ */
#ifdef _LIBC
@@ -190,21 +194,13 @@ static void *mempcpy PARAMS ((void *dest, const void *src, size_t n));
/* XPG3 defines the result of `setlocale (category, NULL)' as:
``Directs `setlocale()' to query `category' and return the current
setting of `local'.''
- However it does not specify the exact format. And even worse: POSIX
- defines this not at all. So we can use this feature only on selected
- system (e.g. those using GNU C Library). */
+ 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
-/* We want to allocate a string at the end of the struct. gcc makes
- this easy. */
-#ifdef __GNUC__
-# define ZERO 0
-#else
-# define ZERO 1
-#endif
-
/* This is the type used for the search tree where known translations
are stored. */
struct known_translation_t
@@ -241,8 +237,11 @@ static void *root;
# endif
/* Function to compare two entries in the table of known translations. */
+static int transcmp PARAMS ((const void *p1, const void *p2));
static int
-transcmp (const void *p1, const void *p2)
+transcmp (p1, p2)
+ const void *p1;
+ const void *p2;
{
const struct known_translation_t *s1;
const struct known_translation_t *s2;
@@ -274,7 +273,7 @@ const char _nl_default_default_domain[] = "messages";
const char *_nl_current_default_domain = _nl_default_default_domain;
/* Contains the default location of the message catalogs. */
-const char _nl_default_dirname[] = GNULOCALEDIR;
+const char _nl_default_dirname[] = LOCALEDIR;
/* List with bindings of specific domains created by bindtextdomain()
calls. */
@@ -336,7 +335,7 @@ struct block_list
typedef struct transmem_list
{
struct transmem_list *next;
- char data[0];
+ char data[ZERO];
} transmem_block_t;
static struct transmem_list *transmem_list;
#else
@@ -423,8 +422,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
/* Try to find the translation among those which we found at
some time. */
- search =
- (struct known_translation_t *) alloca (sizeof (*search) + msgid_len);
+ search = (struct known_translation_t *)
+ alloca (offsetof (struct known_translation_t, msgid) + msgid_len);
memcpy (search->msgid, msgid1, msgid_len);
search->domainname = (char *) domainname;
search->category = category;
@@ -607,8 +606,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
struct known_translation_t *newp;
newp = (struct known_translation_t *)
- malloc (sizeof (*newp) + msgid_len
- + domainname_len + 1 - ZERO);
+ malloc (offsetof (struct known_translation_t, msgid)
+ + msgid_len + domainname_len + 1);
if (newp != NULL)
{
newp->domainname =
@@ -679,14 +678,15 @@ _nl_find_msg (domain_file, msgid, lengthp)
nls_uint32 hash_val = hash_string (msgid);
nls_uint32 idx = hash_val % domain->hash_size;
nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2));
- nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]);
-
- if (nstr == 0)
- /* Hash table entry is empty. */
- return NULL;
while (1)
{
+ nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]);
+
+ if (nstr == 0)
+ /* Hash table entry is empty. */
+ return NULL;
+
/* Compare msgid with the original string at index nstr-1.
We compare the lengths with >=, not ==, because plural entries
are represented by strings with an embedded NUL. */
@@ -704,11 +704,6 @@ _nl_find_msg (domain_file, msgid, lengthp)
idx -= domain->hash_size - incr;
else
idx += incr;
-
- nstr = W (domain->must_swap, domain->hash_tab[idx]);
- if (nstr == 0)
- /* Hash table entry is empty. */
- return NULL;
}
/* NOTREACHED */
}
@@ -980,43 +975,74 @@ plural_eval (pexp, n)
struct expression *pexp;
unsigned long int n;
{
- switch (pexp->operation)
+ switch (pexp->nargs)
{
- case var:
- return n;
- case num:
- return pexp->val.num;
- case mult:
- return (plural_eval (pexp->val.args2.left, n)
- * plural_eval (pexp->val.args2.right, n));
- case divide:
- return (plural_eval (pexp->val.args2.left, n)
- / plural_eval (pexp->val.args2.right, n));
- case module:
- return (plural_eval (pexp->val.args2.left, n)
- % plural_eval (pexp->val.args2.right, n));
- case plus:
- return (plural_eval (pexp->val.args2.left, n)
- + plural_eval (pexp->val.args2.right, n));
- case minus:
- return (plural_eval (pexp->val.args2.left, n)
- - plural_eval (pexp->val.args2.right, n));
- case equal:
- return (plural_eval (pexp->val.args2.left, n)
- == plural_eval (pexp->val.args2.right, n));
- case not_equal:
- return (plural_eval (pexp->val.args2.left, n)
- != plural_eval (pexp->val.args2.right, n));
- case land:
- return (plural_eval (pexp->val.args2.left, n)
- && plural_eval (pexp->val.args2.right, n));
- case lor:
- return (plural_eval (pexp->val.args2.left, n)
- || plural_eval (pexp->val.args2.right, n));
- case qmop:
- return (plural_eval (pexp->val.args3.bexp, n)
- ? plural_eval (pexp->val.args3.tbranch, n)
- : plural_eval (pexp->val.args3.fbranch, n));
+ 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/intl/dcngettext.c b/intl/dcngettext.c
index d10f4a6363..0064a7dde5 100644
--- a/intl/dcngettext.c
+++ b/intl/dcngettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dcngettext(3) function.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -20,12 +20,11 @@
# include <config.h>
#endif
-#include "gettext.h"
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
-# include "libgettext.h"
+# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
diff --git a/intl/dgettext.c b/intl/dgettext.c
index 85770d2bc7..a847706bcf 100644
--- a/intl/dgettext.c
+++ b/intl/dgettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dgettext(3) function.
- Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -24,10 +24,11 @@
# include <locale.h>
#endif
+#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
-# include "libgettext.h"
+# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
diff --git a/intl/dngettext.c b/intl/dngettext.c
index 050144641c..a5e8c7ba34 100644
--- a/intl/dngettext.c
+++ b/intl/dngettext.c
@@ -1,5 +1,5 @@
/* Implementation of the dngettext(3) function.
- Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -24,12 +24,11 @@
# include <locale.h>
#endif
-#include "gettext.h"
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
-# include "libgettext.h"
+# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
diff --git a/intl/explodename.c b/intl/explodename.c
index f89c7c93f9..e62128d12e 100644
--- a/intl/explodename.c
+++ b/intl/explodename.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
Contrib