summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2001-01-15 14:59:52 +0000
committerBruno Haible <bruno@clisp.org>2001-01-15 14:59:52 +0000
commite0560b43903ad644e19cff68c3b744a39d891613 (patch)
tree06626d434c05c2100b54330c3c6b6ff82926b803
parent4d48f86a3ab0114dce08c731553f90727f7dde03 (diff)
downloadexternal_gettext-e0560b43903ad644e19cff68c3b744a39d891613.zip
external_gettext-e0560b43903ad644e19cff68c3b744a39d891613.tar.gz
external_gettext-e0560b43903ad644e19cff68c3b744a39d891613.tar.bz2
Portability fixes for K&R C compilers, SunOS "make" and others.
-rw-r--r--intl/ChangeLog41
-rw-r--r--intl/Makefile.in7
-rw-r--r--intl/bindtextdom.c12
-rw-r--r--intl/cat-compat.c9
-rw-r--r--intl/dcigettext.c13
-rw-r--r--intl/explodename.c7
-rw-r--r--intl/finddomain.c4
-rw-r--r--intl/gettext.c4
-rw-r--r--intl/gettextP.h11
-rw-r--r--intl/l10nflist.c11
-rw-r--r--intl/loadmsgcat.c41
-rw-r--r--intl/localcharset.c5
-rw-r--r--intl/localealias.c61
-rw-r--r--intl/ngettext.c4
-rw-r--r--intl/plural.y130
-rw-r--r--intl/textdomain.c6
-rw-r--r--lib/ChangeLog7
-rw-r--r--lib/basename.c6
-rw-r--r--lib/vasprintf.c13
-rw-r--r--po/ChangeLog4
-rw-r--r--po/Makefile.in.in4
-rw-r--r--src/ChangeLog9
-rw-r--r--src/Makefile.am6
-rw-r--r--src/po-lex.c4
-rw-r--r--tests/ChangeLog5
-rw-r--r--tests/plural-1-prg.c6
26 files changed, 287 insertions, 143 deletions
diff --git a/intl/ChangeLog b/intl/ChangeLog
index ed2c642..18f2b6b 100644
--- a/intl/ChangeLog
+++ b/intl/ChangeLog
@@ -1,3 +1,44 @@
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * Makefile.in (INCLUDES): Remove reference to $(top_srcdir)/lib.
+ (.SUFFIXES): Put .c before .y, so that Solaris "make" uses the .c.o
+ rule, not the builtin .y.o rule.
+ (.y.c): Use $< instead of $^. $^ is not supported by SUSV2 "make"
+ specification. Remove $*.h explicitly: we don't need plural.h.
+ * gettextP.h: Include <stddef.h>.
+ (__gettext_free_exp, __gettextparse): Convert prototype to K&R C
+ syntax.
+ * bindtextdom.c (offsetof): Provide fallback for platforms that lack
+ it, like SunOS4.
+ (set_binding_values): Convert prototype to K&R C syntax.
+ * cat-compat.c: Include stdlib.h, string.h whenever possible.
+ * dcigettext.c: Ignore the value of C_ALLOCA, because libintl.a
+ must not depend on external .o files.
+ (offsetof): Provide fallback for platforms that lack it, like SunOS4.
+ (transcmp): Convert to K&R C syntax.
+ * explodename.c Include stdlib.h whenever possible.
+ (_nl_find_language): Convert to K&R C syntax.
+ * finddomain.c: Include stdlib.h whenever possible.
+ * l10nflist.c Include stdlib.h whenever possible.
+ (tolower): Conditional macro.
+ (_nl_normalize_codeset): Use tolower, not _tolower.
+ * loadmsgcat.c: Include stdlib.h whenever possible.
+ Include headers needed for alloca().
+ (freea): New macro.
+ (_nl_load_domain): Add fallback code for platforms lacking strtoul,
+ like SunOS4. Add fallback code for platforms lacking alloca.
+ * localealias.c: Include stdlib.h whenever possible.
+ (ADD_BLOCK, FREE_BLOCK): Remove macros.
+ (freea): New macro.
+ (read_alias_file): Simplify fallback code for platforms lacking alloca.
+ * plural.y (new_exp_0, new_exp_2, new_exp_3): New functions.
+ (new_exp): Remove function.
+ (__gettext_free_exp, yylex, yyerror): Convert to K&R C syntax.
+ * textdomain.c: Include stdlib.h whenever possible.
+ * gettext.c: Likewise.
+ * ngettext.c: Likewise.
+ * localcharset.c (volatile): Define to empty if not using ANSI C.
+
2001-01-01 Bruno Haible <haible@clisp.cons.org>
* Makefile.in (mostlyclean): Remove intlh.inst, charset.alias,
diff --git a/intl/Makefile.in b/intl/Makefile.in
index fa1f1d9..bc1dad7 100644
--- a/intl/Makefile.in
+++ b/intl/Makefile.in
@@ -82,20 +82,21 @@ LTV_REVISION=0
LTV_AGE=0
.SUFFIXES:
-.SUFFIXES: .y .c .o .lo .sin .sed
+.SUFFIXES: .c .y .o .lo .sin .sed
.c.o:
$(COMPILE) $<
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) $<
.y.c:
- $(YACC) $(YFLAGS) --output $@ $^
+ $(YACC) $(YFLAGS) --output $@ $<
+ rm -f $*.h
.sin.sed:
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@
mv t-$@ $@
-INCLUDES = -I.. -I. -I$(top_srcdir)/intl -I$(top_srcdir)/lib
+INCLUDES = -I.. -I. -I$(top_srcdir)/intl
all: all-@USE_INCLUDED_LIBINTL@
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index 673a061..1d5c561 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.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -67,6 +67,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. */
@@ -95,8 +100,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.
diff --git a/intl/cat-compat.c b/intl/cat-compat.c
index 89aa0aa..2082ad6 100644
--- a/intl/cat-compat.c
+++ b/intl/cat-compat.c
@@ -1,5 +1,5 @@
/* Compatibility code for gettext-using-catgets interface.
- Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,9 +21,8 @@
#include <stdio.h>
-#ifdef STDC_HEADERS
+#ifdef HAVE_STDLIB_H
# include <stdlib.h>
-# include <string.h>
#else
char *getenv ();
# ifdef HAVE_MALLOC_H
@@ -31,6 +30,10 @@ char *getenv ();
# endif
#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+
#ifdef HAVE_NL_TYPES_H
# include <nl_types.h>
#endif
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index fd50bd7..72bfbfc 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -28,11 +28,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
@@ -130,6 +130,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
@@ -235,7 +240,9 @@ static void *root;
/* Function to compare two entries in the table of known translations. */
static int
-transcmp (const void *p1, const void *p2)
+transcmp (p1, p2)
+ const void *p1;
+ const void *p2;
{
struct known_translation_t *s1 = (struct known_translation_t *) p1;
struct known_translation_t *s2 = (struct known_translation_t *) p2;
diff --git a/intl/explodename.c b/intl/explodename.c
index 6c5569d..6253c48 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.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
# include <config.h>
#endif
-#if defined STDC_HEADERS || defined _LIBC
+#if defined HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#endif
@@ -44,7 +44,8 @@
/* @@ end of prolog @@ */
char *
-_nl_find_language (const char *name)
+_nl_find_language (name)
+ const char *name;
{
while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
&& name[0] != '+' && name[0] != ',')
diff --git a/intl/finddomain.c b/intl/finddomain.c
index 8e3c38b..967e246 100644
--- a/intl/finddomain.c
+++ b/intl/finddomain.c
@@ -1,5 +1,5 @@
/* Handle list of needed message catalogs
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@gnu.org>, 1995.
This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <sys/types.h>
-#if defined STDC_HEADERS || defined _LIBC
+#if defined HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#else
# ifdef HAVE_MALLOC_H
diff --git a/intl/gettext.c b/intl/gettext.c
index 20643d0..9f26793 100644
--- a/intl/gettext.c
+++ b/intl/gettext.c
@@ -1,5 +1,5 @@
/* Implementation of gettext(3) function.
- Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
# define __need_NULL
# include <stddef.h>
#else
-# ifdef STDC_HEADERS
+# ifdef HAVE_STDLIB_H
# include <stdlib.h> /* Just for NULL. */
# else
# ifdef HAVE_STRING_H
diff --git a/intl/gettextP.h b/intl/gettextP.h
index 8a3320c..daba98a 100644
--- a/intl/gettextP.h
+++ b/intl/gettextP.h
@@ -1,5 +1,5 @@
/* Header describing internals of gettext library
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
This program is free software; you can redistribute it and/or modify
@@ -19,6 +19,10 @@
#ifndef _GETTEXTP_H
#define _GETTEXTP_H
+#if defined HAVE_STDDEF_H || defined _LIBC
+# include <stddef.h> /* Get size_t. */
+#endif
+
#ifdef _LIBC
# include "../iconv/gconv_int.h"
#else
@@ -191,8 +195,9 @@ extern char *dcigettext__ PARAMS ((const char *domainname, const char *msgid1,
#endif
extern int __gettextdebug;
-extern void __gettext_free_exp (struct expression *exp) internal_function;
-extern int __gettextparse (void *arg);
+extern void __gettext_free_exp PARAMS ((struct expression *exp))
+ internal_function;
+extern int __gettextparse PARAMS ((void *arg));
/* @@ begin of epilog @@ */
diff --git a/intl/l10nflist.c b/intl/l10nflist.c
index 2a946e3..2da1ba2 100644
--- a/intl/l10nflist.c
+++ b/intl/l10nflist.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1999, 2000, 2001 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
@@ -47,7 +47,7 @@
#include <ctype.h>
#include <sys/types.h>
-#if defined STDC_HEADERS || defined _LIBC
+#if defined HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#endif
@@ -65,6 +65,11 @@
/* @@ end of prolog @@ */
#ifdef _LIBC
+/* Use more efficient version of <ctype.h> function. */
+# define tolower _tolower
+#endif
+
+#ifdef _LIBC
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
@@ -388,7 +393,7 @@ _nl_normalize_codeset (codeset, name_len)
for (cnt = 0; cnt < name_len; ++cnt)
if (isalpha (codeset[cnt]))
- *wp++ = _tolower (codeset[cnt]);
+ *wp++ = tolower (codeset[cnt]);
else if (isdigit (codeset[cnt]))
*wp++ = codeset[cnt];
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 6324553..3bbb354 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -1,5 +1,5 @@
/* Load needed message catalogs.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,7 +32,24 @@
#include <sys/types.h>
#include <sys/stat.h>
-#if defined STDC_HEADERS || defined _LIBC
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+# define HAVE_ALLOCA 1
+#else
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+#if defined HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#endif
@@ -79,6 +96,15 @@
# define munmap __munmap
#endif
+/* For those losing systems which don't have `alloca' we have to add
+ some additional code emulating it. */
+#ifdef HAVE_ALLOCA
+# define freea(p) /* nothing */
+#else
+# define alloca(n) malloc (n)
+# define freea(p) free (p)
+#endif
+
/* We need a sign, whether a new catalog was loaded, which can be associated
with all translations. This is important if the translations are
cached by one of GCC's features. */
@@ -370,6 +396,8 @@ _nl_load_domain (domain_file)
domain->conv = iconv_open (outcharset, charset);
# endif
# endif
+
+ freea (charset);
}
#endif /* _LIBC || HAVE_ICONV */
}
@@ -388,12 +416,19 @@ _nl_load_domain (domain_file)
{
/* First get the number. */
char *endp;
+ unsigned long int n;
struct parse_args args;
nplurals += 9;
while (*nplurals != '\0' && isspace (*nplurals))
++nplurals;
- domain->nplurals = strtoul (nplurals, &endp, 10);
+#ifdef HAVE_STRTOUL
+ 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;
diff --git a/intl/localcharset.c b/intl/localcharset.c
index 936d93d..12214b7 100644
--- a/intl/localcharset.c
+++ b/intl/localcharset.c
@@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -69,6 +69,9 @@
'charset_aliases' simultaneously, both will produce the same value,
and everything will be ok if the two assignments to 'charset_aliases'
are atomic. But I don't know what will happen if the two assignments mix. */
+#if __STDC__ != 1
+# define volatile /* empty */
+#endif
/* Pointer to the contents of the charset.alias file, if it has already been
read, else NULL. Its format is:
ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
diff --git a/intl/localealias.c b/intl/localealias.c
index 2227d9b..cdda88a 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -1,5 +1,5 @@
/* Handle aliases for locale names.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ char *alloca ();
# endif
#endif
-#if defined STDC_HEADERS || defined _LIBC
+#if defined HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#else
char *getenv ();
@@ -98,40 +98,14 @@ __libc_lock_define_initialized (static, lock);
# define internal_function
#endif
-/* For those loosing systems which don't have `alloca' we have to add
+/* For those losing systems which don't have `alloca' we have to add
some additional code emulating it. */
#ifdef HAVE_ALLOCA
-/* Nothing has to be done. */
-# define ADD_BLOCK(list, address) /* nothing */
-# define FREE_BLOCKS(list) /* nothing */
+# define freea(p) /* nothing */
#else
-struct block_list
-{
- void *address;
- struct block_list *next;
-};
-# define ADD_BLOCK(list, addr) \
- do { \
- struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \
- /* If we cannot get a free block we cannot add the new element to \
- the list. */ \
- if (newp != NULL) { \
- newp->address = (addr); \
- newp->next = (list); \
- (list) = newp; \
- } \
- } while (0)
-# define FREE_BLOCKS(list) \
- do { \
- while (list != NULL) { \
- struct block_list *old = list; \
- list = list->next; \
- free (old); \
- } \
- } while (0)
-# undef alloca
-# define alloca(size) (malloc (size))
-#endif /* have alloca */
+# define alloca(n) malloc (n)
+# define freea(p) free (p)
+#endif
#if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED
# undef fgets
@@ -234,16 +208,12 @@ read_alias_file (fname, fname_len)
const char *fname;
int fname_len;
{
-#ifndef HAVE_ALLOCA
- struct block_list *block_list = NULL;
-#endif
FILE *fp;
char *full_fname;
size_t added;
static const char aliasfile[] = "/locale.alias";
full_fname = (char *) alloca (fname_len + sizeof aliasfile);
- ADD_BLOCK (block_list, full_fname);
#ifdef HAVE_MEMPCPY
mempcpy (mempcpy (full_fname, fname, fname_len),
aliasfile, sizeof aliasfile);
@@ -253,11 +223,9 @@ read_alias_file (fname, fname_len)
#endif
fp = fopen (full_fname, "r");
+ freea (full_fname);
if (fp == NULL)
- {
- FREE_BLOCKS (block_list);
- return 0;
- }
+ return 0;
added = 0;
while (!feof (fp))
@@ -330,10 +298,7 @@ read_alias_file (fname, fname_len)
if (nmap >= maxmap)
if (__builtin_expect (extend_alias_table (), 0))
- {
- FREE_BLOCKS (block_list);
- return added;
- }
+ return added;
alias_len = strlen (alias) + 1;
value_len = strlen (value) + 1;
@@ -346,10 +311,7 @@ read_alias_file (fname, fname_len)
? alias_len + value_len : 1024));
char *new_pool = (char *) realloc (string_space, new_size);
if (new_pool == NULL)
- {
- FREE_BLOCKS (block_list);
- return added;
- }
+ return added;
if (__builtin_expect (string_space != new_pool, 0))
{
@@ -388,7 +350,6 @@ read_alias_file (fname, fname_len)
qsort (map, nmap, sizeof (struct alias_map),
(int (*) PARAMS ((const void *, const void *))) alias_compare);
- FREE_BLOCKS (block_list);
return added;
}
diff --git a/intl/ngettext.c b/intl/ngettext.c
index 8ae565d..aeb8db7 100644
--- a/intl/ngettext.c
+++ b/intl/ngettext.c
@@ -1,5 +1,5 @@
/* Implementation of ngettext(3) function.
- Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
# define __need_NULL
# include <stddef.h>
#else
-# ifdef STDC_HEADERS
+# ifdef HAVE_STDLIB_H
# include <stdlib.h> /* Just for NULL. */
# else
# ifdef HAVE_STRING_H
diff --git a/intl/plural.y b/intl/plural.y
index d33bb96..77a2723 100644
--- a/intl/plural.y
+++ b/intl/plural.y
@@ -1,6 +1,6 @@
%{
/* Expression parsing for plural form selection.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ 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
@@ -21,7 +21,6 @@
# include <config.h>
#endif
-#include <stdarg.h>
#include <stdlib.h>
#include "gettext.h"
#include "gettextP.h"
@@ -39,9 +38,16 @@
%{
/* Prototypes for local functions. */
-static struct expression *new_exp (enum operator op, int n, ...);
-static int yylex (YYSTYPE *lval, const char **pexp);
-static void yyerror (const char *str);
+static struct expression *new_exp_0 PARAMS ((enum operator op));
+static struct expression *new_exp_2 PARAMS ((enum operator op,
+ struct expression *left,
+ struct expression *right));
+static struct expression *new_exp_3 PARAMS ((enum operator op,
+ struct expression *bexp,
+ struct expression *tbranch,
+ struct expression *fbranch));
+static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
+static void yyerror PARAMS ((const char *str));
%}
%left '?'
@@ -63,62 +69,62 @@ start: exp
exp: exp '?' exp ':' exp
{
- if (($$ = new_exp (qmop, 3, $1, $3, $5)) == NULL)
+ if (($$ = new_exp_3 (qmop, $1, $3, $5)) == NULL)
YYABORT
}
| exp '|' exp
{
- if (($$ = new_exp (lor, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (lor, $1, $3)) == NULL)
YYABORT
}
| exp '&' exp
{
- if (($$ = new_exp (land, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (land, $1, $3)) == NULL)
YYABORT
}
| exp '=' exp
{
- if (($$ = new_exp (equal, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (equal, $1, $3)) == NULL)
YYABORT
}
| exp '!' exp
{
- if (($$ = new_exp (not_equal, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (not_equal, $1, $3)) == NULL)
YYABORT
}
| exp '+' exp
{
- if (($$ = new_exp (plus, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (plus, $1, $3)) == NULL)
YYABORT
}
| exp '-' exp
{
- if (($$ = new_exp (minus, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (minus, $1, $3)) == NULL)
YYABORT
}
| exp '*' exp
{
- if (($$ = new_exp (mult, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (mult, $1, $3)) == NULL)
YYABORT
}
| exp '/' exp
{
- if (($$ = new_exp (divide, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (divide, $1, $3)) == NULL)
YYABORT
}
| exp '%' exp
{
- if (($$ = new_exp (module, 2, $1, $3)) == NULL)
+ if (($$ = new_exp_2 (module, $1, $3)) == NULL)
YYABORT
}
| 'n'
{
- if (($$ = new_exp (var, 0)) == NULL)
+ if (($$ = new_exp_0 (var)) == NULL)
YYABORT
}
| NUMBER
{
- if (($$ = new_exp (num, 0)) == NULL)
+ if (($$ = new_exp_0 (num)) == NULL)
YYABORT;
$$->val.num = $1
}
@@ -131,45 +137,76 @@ exp: exp '?' exp ':' exp
%%
static struct expression *
-new_exp (enum operator op, int n, ...)
+new_exp_0 (op)
+ enum operator op;
{
- struct expression *newp = (struct expression *) calloc (1, sizeof (*newp));
- va_list va;
+ struct expression *newp = (struct expression *) malloc (sizeof (*newp));
- va_start (va, n);
+ if (newp != NULL)
+ newp->operation = op;
- if (newp == NULL)
- while (n-- > 0)
- __gettext_free_exp (va_arg (va, struct expression *));
- else
+ return newp;
+}
+
+static struct expression *
+new_exp_2 (op, left, right)
+ enum operator op;
+ struct expression *left;
+ struct expression *right;
+{
+ struct expression *newp = NULL;
+
+ if (left != NULL && right != NULL)
+ newp = (struct expression *) malloc (sizeof (*newp));
+
+ if (newp != NULL)
{
newp->operation = op;
- if (n > 0)
- {
- newp->val.args3.bexp = va_arg (va, struct expression *);
- newp->val.args3.tbranch = va_arg (va, struct expression *);
-
- if (n > 2)
- newp->val.args3.fbranch = va_arg (va, struct expression *);
-
- if (newp->val.args3.bexp == NULL
- || newp->val.args3.tbranch == NULL
- || (n > 2 && newp->val.args3.fbranch == NULL))
- {
- __gettext_free_exp (newp);
- newp = NULL;
- }
- }
+ newp->val.args2.left = left;
+ newp->val.args2.right = right;
+ }
+ else
+ {
+ __gettext_free_exp (left);
+ __gettext_free_exp (right);
}
- va_end (va);
+ return newp;
+}
+
+static struct expression *
+new_exp_3 (op, bexp, tbranch, fbranch)
+ enum operator op;
+ struct expression *bexp;
+ struct expression *tbranch;
+ struct expression *fbranch;
+{
+ struct expression *newp = NULL;
+
+ if (bexp != NULL && tbranch != NULL && fbranch != NULL)
+ newp = (struct expression *) malloc (sizeof (*newp));
+
+ if (newp != NULL)
+ {
+ newp->operation = op;
+ newp->val.args3.bexp = bexp;
+ newp->val.args3.tbranch = tbranch;
+ newp->val.args3.fbranch = fbranch;
+ }
+ else
+ {
+ __gettext_free_exp (bexp);
+ __gettext_free_exp (tbranch);
+ __gettext_free_exp (fbranch);
+ }
return newp;
}
void
internal_function
-__gettext_free_exp (struct expression *exp)
+__gettext_free_exp (exp)
+ struct expression *exp;
{
if (exp == NULL)
return;
@@ -203,7 +240,9 @@ __gettext_free_exp (struct expression *exp)
static int
-yylex (YYSTYPE *lval, const char **pexp)
+yylex (lval, pexp)
+ YYSTYPE *lval;
+ const char **pexp;
{
const char *exp = *pexp;
int result;
@@ -298,7 +337,8 @@ yylex (YYSTYPE *lval, const char **pexp)
static void
-yyerror (const char *str)
+yyerror (str)
+ const char *str;
{
/* Do nothing. We don't print error messages here. */
}
diff --git a/intl/textdomain.c b/intl/textdomain.c
index 302554d..55bb550 100644
--- a/intl/textdomain.c
+++ b/intl/textdomain.c
@@ -1,5 +1,5 @@
/* Implementation of the textdomain(3) function.
- Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,11 +19,11 @@
# include <config.h>
#endif
-#if defined STDC_HEADERS || defined _LIBC
+#if defined HAVE_STDLIB_H || defined _LIBC
# include <stdlib.h>
#endif
-#if defined STDC_HEADERS || defined HAVE_STRING_H || defined _LIBC
+#if defined HAVE_STRING_H || defined _LIBC
# include <string.h>
#else
# include <strings.h>
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 13af124..474adce 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,10 @@
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * basename.c: Include <stdio.h>, needed by assert on SunOS4.
+ (basename): Convert to K&R C syntax.
+ * vasprintf.c (int_vasprintf): Don't use fabs, it needs -lm on some
+ platforms.
+
2000-12-31 Bruno Haible <haible@clisp.cons.org>
* hash.c (insert_entry): Use obstack_copy instead of obstack_copy0.
diff --git a/lib/basename.c b/lib/basename.c
index db7d658..11f5542 100644
--- a/lib/basename.c
+++ b/lib/basename.c
@@ -1,5 +1,5 @@
/* Return the name-within-directory of a file name.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
@@ -23,6 +23,7 @@
# include <config.h>
#endif
+#include <stdio.h>
#include <assert.h>
#ifndef FILESYSTEM_PREFIX_LEN
@@ -45,7 +46,8 @@
If NAME is all slashes, be sure to return `/'. */
char *
-basename (char const *name)
+basename (name)
+ char const *name;
{
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
int all_slashes = 1;
diff --git a/lib/vasprintf.c b/lib/vasprintf.c
index 5f35951..becc34a 100644
--- a/lib/vasprintf.c
+++ b/lib/vasprintf.c
@@ -1,6 +1,6 @@
/* Like vsprintf but provides a pointer to malloc'd storage, which must
be freed by the caller.
- Copyright (C) 1994, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -97,10 +97,13 @@ int_vasprintf (result, format, args)
(void) va_arg (ap, int);
break;
case 'f':
- if (fabs (va_arg (ap, double)) >= 1.0)
- /* Since an ieee double can have an exponent of 307, we'll
- make the buffer wide enough to cover the gross case. */
- total_width += 307;
+ {
+ double arg = va_arg (ap, double);
+ if (arg >= 1.0 || arg <= -1.0)
+ /* Since an ieee double can have an exponent of 307, we'll
+ make the buffer wide enough to cover the gross case. */
+ total_width += 307;
+ }
break;
case 'e':
case 'E':
diff --git a/po/ChangeLog b/po/ChangeLog
index 14d683d..f1e54d0 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,7 @@
+2001-01-04 Bruno Haible <haible@clisp.cons.org>
+
+ * Makefile.in.in (install-data-yes): Fix syntax error with "@".
+
2000-12-31 Bruno Haible <haible@clisp.cons.org>
* da.po: Change charset from ISO-Latin-1 to ISO-8859-1.
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index c34b98f..166e133 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -1,5 +1,5 @@
# Makefile for program source directory in GNU NLS utilities package.
-# Copyright (C) 1995, 1996, 1997, 2000 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+# Copyright (C) 1995-1997, 2000, 2001 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
@@ -111,7 +111,7 @@ install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
- $(mkinstalldirs) $(DESTDIR)$(datadir); \
+ $(mkinstalldirs) $(DESTDIR)$(datadir)
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
diff --git a/src/ChangeLog b/src/ChangeLog
index d061b04..1e81e11 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2001-01-05 Bruno Haible <haible@clisp.cons.org>
+
+ * Makefile.am (po-gram-gen.h): Don't use $^, not supported by the
+ SUSV2 "make" specification.
+ (LDADD): Add @INTLLIBS@. Needed on Solaris without
+ --with-included-gettext.
+ * po-lex.c (gram_max_allowed_errors): Change type to
+ 'unsigned int'.
+
2001-01-01 Bruno Haible <haible@clisp.cons.org>
Implement plural form handling.
diff --git a/src/Makefile.am b/src/Makefile.am
index 2cdf093..3ad74f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
## Makefile for program src directory in GNU NLS utilities package.
-## Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+## Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ l = @l@
INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/lib -I../intl \
-I$(top_srcdir)/intl
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
-LDADD = ../lib/libnlsut.a ../intl/libintl.$la
+LDADD = ../lib/libnlsut.a @INTLLIBS@ ../intl/libintl.$la
SED = sed
YACC = @YACC@ -d
@@ -57,7 +57,7 @@ BUILT_SOURCES = po-gram-gen.c po-hash-gen.c po-gram-gen.h po-hash-gen.h
po-lex.o: po-gram-gen2.h
po-gram-gen2.h: po-gram-gen.h
- $(SED) 's/[yY][yY]/po_gram_/g' $^ > $@-tmp
+ $(SED) 's/[yY][yY]/po_gram_/g' $(srcdir)/po-gram-gen.h > $@-tmp
mv $@-tmp $@
DISTCLEANFILES = po-gram-gen2.h
diff --git a/src/po-lex.c b/src/po-lex.c
index a3474b9..83f0cdd 100644
--- a/src/po-lex.c
+++ b/src/po-lex.c
@@ -1,5 +1,5 @@
/* GNU gettext - internationalization aids
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
@@ -58,7 +58,7 @@
static FILE *fp;
lex_pos_ty gram_pos;
-size_t gram_max_allowed_errors = 20;
+unsigned int gram_max_allowed_errors = 20;
static int pass_comments = 0;
static int pass_obsolete_entries = 0;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index c6ff0aa..4ec18c2 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2001-01-04 Bruno Haible <haible@clisp.cons.org>
+
+ * plural-1-prg.c: Include config.h. Needed for C compilers lacking
+ "const", like SunOS4 cc.
+
2001-01-01 Bruno Haible <haible@clisp.cons.org>
Implement plural form handling.
diff --git a/tests/plural-1-prg.c b/tests/plural-1-prg.c
index 5bfbafe..38e8f5b 100644
--- a/tests/plural-1-prg.c
+++ b/tests/plural-1-prg.c
@@ -1,3 +1,9 @@
+/* Test program, used by the plural-1 test. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>