]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Portability fixes for K&R C compilers, SunOS "make" and others.
authorBruno Haible <bruno@clisp.org>
Mon, 15 Jan 2001 14:59:52 +0000 (14:59 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 15 Jan 2001 14:59:52 +0000 (14:59 +0000)
26 files changed:
intl/ChangeLog
intl/Makefile.in
intl/bindtextdom.c
intl/cat-compat.c
intl/dcigettext.c
intl/explodename.c
intl/finddomain.c
intl/gettext.c
intl/gettextP.h
intl/l10nflist.c
intl/loadmsgcat.c
intl/localcharset.c
intl/localealias.c
intl/ngettext.c
intl/plural.y
intl/textdomain.c
lib/ChangeLog
lib/basename.c
lib/vasprintf.c
po/ChangeLog
po/Makefile.in.in
src/ChangeLog
src/Makefile.am
src/po-lex.c
tests/ChangeLog
tests/plural-1-prg.c

index ed2c64285c2c56d93016d5f1b9264ae727d3156d..18f2b6b3b464f2330e4daf7649184586e6c5f992 100644 (file)
@@ -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,
index fa1f1d9376dce41c5bfaa30d7c5a7886f5f5e9e8..bc1dad774c8a1453fa24c2c7bba54e534ba014be 100644 (file)
@@ -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@
 
index 673a06177a32e4a16743d4529bd148646e218c40..1d5c561c0181d389bbf2f905eaae4da86581aa84 100644 (file)
@@ -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.
index 89aa0aafc0eae5948e927aa34981c960750cb120..2082ad624c2dfa204374aaa8f312878d2478c1f3 100644 (file)
@@ -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
index fd50bd7344ed6b8f8ef275aa8b02189a792cca9d..72bfbfc47b98d9195bffe801141cbd775efdcb57 100644 (file)
 
 #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;
index 6c5569da74ef984387da2edf08a77a9af20b25c8..6253c48f6bbc9538aca225299922429676320b63 100644 (file)
@@ -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] != ',')
index 8e3c38b60e3f7bd09997cee6b0d47c627a12b112..967e24697f8a96d1d3c71637f93bbe9b7bf09928 100644 (file)
@@ -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
index 20643d073bdef04471bc64f9c2b761586f19e5e3..9f2679331a80e9a75359c350139abe3b5c7e3878 100644 (file)
@@ -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
index 8a3320c94f68e445e72114357bf8ea7d8bdf3da4..daba98aba56e33c33b3fa2f9fc4147942505f880 100644 (file)
@@ -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
 #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 @@ */
 
index 2a946e3647bc4f84f72604b2cb5006b231825231..2da1ba2e95d8186d4afb3ae2e34dc64e0fce4b1d 100644 (file)
@@ -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
 
 
 /* @@ 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
@@ -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];
 
index 6324553671e798c6a35fa904121eeaa3bc2874d1..3bbb3543941b5b788af4774b7b61ac8d5c4ea347 100644 (file)
@@ -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
 #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
 
 # 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;
 
index 936d93d84caa2c8d12fa5db130d69d75d2c468a8..12214b79b80d591205100fcd18c937579b57b587 100644 (file)
@@ -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'  */
index 2227d9bffe9241134ee8ee981da01fd90967c745..cdda88aeb363ea396df836418a39059bdef7b726 100644 (file)
@@ -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;
 }
 
index 8ae565d8fbc4b73ad160ab1043b5d76a04f0fd7b..aeb8db7092248cee49ed88ad985ab93d10e3627d 100644 (file)
@@ -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
index d33bb9644769168afc932c5ba51707b284c87372..77a27230794ec064eed518bf3c9c54de5addfe20 100644 (file)
@@ -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"
 
 %{
 /* 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.  */
 }
index 302554d2f21a099313e9b01e5851866c0479b913..55bb55015a7d655457733c33efeb2c42f59ec5c6 100644 (file)
@@ -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
 # 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>
index 13af1249b8fb0877c781f9dc590f9f15dd0dc6a4..474adce616c60a0f885b87944532b96ffb1f60f2 100644 (file)
@@ -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.
index db7d65874e8fc19ed5fba40fd0f91e8db633f1ab..11f55425239e6a311c9eed93b042f8f978fa0ec1 100644 (file)
@@ -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;
index 5f35951423824f9c9292b3632fc58272d9d20bd1..becc34a3c65603ee0af1936b9fbaa49aa0083cad 100644 (file)
@@ -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':
index 14d683d6b7fe55c07907e5fefba6929726d25e9c..f1e54d01c64fcdabcca4cd2cd10d2a50cd506d50 100644 (file)
@@ -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.
index c34b98f3029e96b0e79c6beb948d4d0b10831a58..166e133eaa5067a3bb08d32cb53bed3f8ee2413e 100644 (file)
@@ -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`; \
index d061b04bee3fc2b1f5abde2f89d8acc3e3335338..1e81e11ae43d52920f0ded2332228b609cffe40d 100644 (file)
@@ -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.
index 2cdf0932810212eff8e7ce9bbc8e7ef3a97456c7..3ad74f50b41b03ab5d469c31f50c0d544f4c0bf9 100644 (file)
@@ -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
index a3474b9eb529aca431536374719f671b4ff94753..83f0cdd18a5c3e3ead9fa7031bbf633ddfa94e7c 100644 (file)
@@ -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;
 
index c6ff0aaa87dcc43543235db6407bafb5ad78e820..4ec18c29b4fb890e0ef8206c89a7032c625de9ee 100644 (file)
@@ -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.
index 5bfbafe81757843e6edddd1f513dbcf726c224aa..38e8f5b237c3ab40846a426c94b9a612ce4cc8f7 100644 (file)
@@ -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>