summary refs log tree commit diff
path: root/intl
diff options
context:
space:
mode:
Diffstat (limited to 'intl')
-rw-r--r--intl/Makefile6
-rw-r--r--intl/dcgettext.c41
-rw-r--r--intl/finddomain.c26
-rw-r--r--intl/gettextP.h21
-rw-r--r--intl/hash-string.h26
-rw-r--r--intl/libintl.h34
-rw-r--r--intl/localealias.c20
7 files changed, 99 insertions, 75 deletions
diff --git a/intl/Makefile b/intl/Makefile
index adc4d01e61..0354b427b3 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -31,9 +31,9 @@ CPPFLAGS += -D'GNULOCALEDIR="$(localedir)"' \
 
 ifdef gettext-srcdir
 
-%:: $(gettext-srcdir)/intl/%.glibc; $(copysrc)
-%:: $(gettext-srcdir)/intl/%.c; $(copysrc)
-%:: $(gettext-srcdir)/intl/%.h; $(copysrc)
+%.h:: $(gettext-srcdir)/intl/%.glibc; $(copysrc)
+%.c:: $(gettext-srcdir)/intl/%.c; $(copysrc)
+%.h:: $(gettext-srcdir)/intl/%.h; $(copysrc)
 
 define copysrc
 cp -f $< $@.new
diff --git a/intl/dcgettext.c b/intl/dcgettext.c
index 09e0443494..7562f69ab4 100644
--- a/intl/dcgettext.c
+++ b/intl/dcgettext.c
@@ -1,5 +1,5 @@
-/* dcgettext.c -- implemenatation of the dcgettext(3) function
-   Copyright (C) 1995 Software Foundation, Inc.
+/* dcgettext.c -- implementation of the dcgettext(3) function
+   Copyright (C) 1995 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
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #ifdef __GNUC__
 # define alloca __builtin_alloca
 #else
-# ifdef HAVE_ALLOCA_H || defined _LIBC
+# if defined HAVE_ALLOCA_H || defined _LIBC
 #  include <alloca.h>
 # else
 #  ifdef _AIX
@@ -151,10 +151,11 @@ const char _nl_default_dirname[] = GNULOCALEDIR;
 struct binding *_nl_domain_bindings;
 
 /* Prototypes for local functions.  */
-static char *find_msg __P ((struct loaded_domain *domain, const char *msgid));
-static const char *category_to_name __P((int category));
-static const char *guess_category_value __P((int category,
-					     const char *categoryname));
+static char *find_msg PARAMS ((struct loaded_domain *domain,
+			       const char *msgid));
+static const char *category_to_name PARAMS ((int category));
+static const char *guess_category_value PARAMS ((int category,
+						 const char *categoryname));
 
 
 /* Names for the libintl functions are a problem.  They must not clash
@@ -182,6 +183,7 @@ DCGETTEXT (domainname, msgid, category)
   char *dirname, *xdomainname;
   char *single_locale;
   char *retval;
+  int saved_errno = errno;
 
   /* If no real MSGID is given return NULL.  */
   if (msgid == NULL)
@@ -233,9 +235,12 @@ DCGETTEXT (domainname, msgid, category)
 	}
 
       if (ret == NULL)
-	/* We cannot get the current working directory.  Don't signal an
-	   error but simply return the default string.  */
-	return (char *) msgid;
+	{
+	  /* We cannot get the current working directory.  Don't signal an
+	     error but simply return the default string.  */
+	  errno = saved_errno;
+	  return (char *) msgid;
+	}
 
       /* We don't want libintl.a to depend on any other library.  So
 	 we avoid the non-standard function stpcpy.  In GNU C Library
@@ -302,7 +307,10 @@ DCGETTEXT (domainname, msgid, category)
 	 domain.  Return the MSGID.  */
       if (strcmp (single_locale, "C") == 0
 	  || strcmp (single_locale, "POSIX") == 0)
-	return (char *) msgid;
+	{
+	  errno = saved_errno;
+	  return (char *) msgid;
+	}
 
 
       /* Find structure describing the message catalog matching the
@@ -317,7 +325,7 @@ DCGETTEXT (domainname, msgid, category)
 	    {
 	      int cnt;
 
-	      for (cnt = 0; domain->successor[cnt] != NULL; --cnt)
+	      for (cnt = 0; domain->successor[cnt] != NULL; ++cnt)
 		{
 		  retval = find_msg (domain->successor[cnt], msgid);
 
@@ -327,7 +335,10 @@ DCGETTEXT (domainname, msgid, category)
 	    }
 
 	  if (retval != NULL)
-	    return retval;
+	    {
+	      errno = saved_errno;
+	      return retval;
+	    }
 	}
     }
   /* NOTREACHED */
@@ -375,8 +386,8 @@ find_msg (domain, msgid)
 
       while (1)
 	{
-	  if (idx >= W (domain->must_swap, domain->hash_size) - incr)
-	    idx -= W (domain->must_swap, domain->hash_size) - incr;
+	  if (idx >= domain->hash_size - incr)
+	    idx -= domain->hash_size - incr;
 	  else
 	    idx += incr;
 
diff --git a/intl/finddomain.c b/intl/finddomain.c
index 007a87e075..07c5f44799 100644
--- a/intl/finddomain.c
+++ b/intl/finddomain.c
@@ -1,5 +1,5 @@
 /* finddomain.c -- handle list of needed message catalogs
-   Copyright (C) 1995 Software Foundation, Inc.
+   Copyright (C) 1995 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
 This program is free software; you can redistribute it and/or modify
@@ -83,21 +83,21 @@ void free ();
 static struct loaded_domain *_nl_loaded_domains;
 
 /* Prototypes for local functions.  */
-static struct loaded_domain *make_entry_rec __P ((const char *dirname,
-						  int mask,
-						  const char *language,
-						  const char *territory,
-						  const char *codeset,
-						  const char *modifier,
-						  const char *special,
-						  const char *sponsor,
-						  const char *revision,
-						  const char *domainname,
-						  int do_allocate));
+static struct loaded_domain *make_entry_rec PARAMS ((const char *dirname,
+						     int mask,
+						     const char *language,
+						     const char *territory,
+						     const char *codeset,
+						     const char *modifier,
+						     const char *special,
+						     const char *sponsor,
+						     const char *revision,
+						     const char *domainname,
+						     int do_allocate));
 
 /* Substitution for systems lacking this function in their C library.  */
 #if !_LIBC && !HAVE_STPCPY
-static char *stpcpy __P ((char *dest, const char *src));
+static char *stpcpy PARAMS ((char *dest, const char *src));
 #endif
 
 
diff --git a/intl/gettextP.h b/intl/gettextP.h
index 12031c605b..7c74f6c9ab 100644
--- a/intl/gettextP.h
+++ b/intl/gettextP.h
@@ -1,5 +1,5 @@
 /* gettextP.h -- header describing internals of gettext library
-   Copyright (C) 1995 Software Foundation, Inc.
+   Copyright (C) 1995 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
@@ -20,11 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* @@ end of prolog @@ */
 
-#ifndef __P
+#ifndef PARAMS
 # if __STDC__
-#  define __P(args) args
+#  define PARAMS(args) args
 # else
-#  define __P(args) ()
+#  define PARAMS(args) ()
 # endif
 #endif
 
@@ -32,6 +32,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 # define W(flag, data) ((flag) ? SWAP (data) : (data))
 #endif
 
+
+static nls_uint32 SWAP PARAMS ((nls_uint32 i));
+
 static inline nls_uint32
 SWAP (i)
      nls_uint32 i;
@@ -64,12 +67,12 @@ struct binding
   char *dirname;
 };
 
-struct loaded_domain *_nl_find_domain __P ((const char *__dirname,
-					    char *__locale,
-					    const char *__domainname));
-void _nl_load_domain __P ((struct loaded_domain *__domain));
+struct loaded_domain *_nl_find_domain PARAMS ((const char *__dirname,
+					       char *__locale,
+					       const char *__domainname));
+void _nl_load_domain PARAMS ((struct loaded_domain *__domain));
 
-const char *_nl_expand_alias __P ((const char *__name));
+const char *_nl_expand_alias PARAMS ((const char *__name));
 
 /* @@ begin of epilog @@ */
 
diff --git a/intl/hash-string.h b/intl/hash-string.h
index e846b507ac..ef1f448d86 100644
--- a/intl/hash-string.h
+++ b/intl/hash-string.h
@@ -1,5 +1,5 @@
 /* hash-string - Implements a string hashing function.
-   Copyright (C) 1995 Software Foundation, Inc.
+   Copyright (C) 1995 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,22 +21,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* @@ end of prolog @@ */
 
-#ifndef BITSPERBYTE
-# define BITSPERBYTE 8
+#ifndef PARAMS
+# if __STDC__
+#  define PARAMS(Args) Args
+# else
+#  define PARAMS(Args) ()
+# endif
 #endif
 
-#ifndef LONGBITS
-# define LONGBITS (sizeof (long) * BITSPERBYTE)
-#endif	/* LONGBITS  */
+/* We assume to have `unsigned long int' value with at least 32 bits.  */
+#define HASHWORDBITS 32
+
 
 /* Defines the so called `hashpjw' function by P.J. Weinberger
    [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
-   1986, 1987 Bell Telephone Laboratories, Inc.]  */ 
+   1986, 1987 Bell Telephone Laboratories, Inc.]  */
+static unsigned long hash_string PARAMS ((const char *__str_param));
+
 static inline unsigned long
 hash_string (str_param)
      const char *str_param;
 {
-  unsigned long hval, g;
+  unsigned long int hval, g;
   const char *str = str_param;
 
   /* Compute the hash value for the given string.  */
@@ -45,10 +51,10 @@ hash_string (str_param)
     {
       hval <<= 4;
       hval += (unsigned long) *str++;
-      g = hval & ((unsigned long) 0xf << (LONGBITS - 4));
+      g = hval & ((unsigned long) 0xf << (HASHWORDBITS - 4));
       if (g != 0)
 	{
-	  hval ^= g >> (LONGBITS - 8);
+	  hval ^= g >> (HASHWORDBITS - 8);
 	  hval ^= g;
 	}
     }
diff --git a/intl/libintl.h b/intl/libintl.h
index f9a150d3df..8e5b8f9e69 100644
--- a/intl/libintl.h
+++ b/intl/libintl.h
@@ -37,34 +37,36 @@ __BEGIN_DECLS
 /* Look up MSGID in the current default message catalog for the current
    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
    text).  */
-extern char *gettext __P ((const char *__msgid));
-extern char *__gettext __P ((const char *__msgid));
+extern char *gettext __P ((__const char *__msgid));
+extern char *__gettext __P ((__const char *__msgid));
 
 /* Look up MSGID in the DOMAINNAME message catalog for the current
    LC_MESSAGES locale.  */
-extern char *dgettext __P ((const char *__domainname, const char *__msgid));
-extern char *__dgettext __P ((const char *__domainname, const char *__msgid));
+extern char *dgettext __P ((__const char *__domainname,
+			    __const char *__msgid));
+extern char *__dgettext __P ((__const char *__domainname,
+			      __const char *__msgid));
 
 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
    locale.  */
-extern char *dcgettext __P ((const char *__domainname, const char *__msgid,
-			     int __category));
-extern char *__dcgettext __P ((const char *__domainname, const char *__msgid,
-			       int __category));
+extern char *dcgettext __P ((__const char *__domainname,
+			     __const char *__msgid, int __category));
+extern char *__dcgettext __P ((__const char *__domainname,
+			       __const char *__msgid, int __category));
 
 
 /* Set the current default message catalog to DOMAINNAME.
    If DOMAINNAME is null, return the current default.
    If DOMAINNAME is "", reset to the default of "messages".  */
-extern char *textdomain __P ((const char *__domainname));
-extern char *__textdomain __P ((const char *__domainname));
+extern char *textdomain __P ((__const char *__domainname));
+extern char *__textdomain __P ((__const char *__domainname));
 
 /* Specify that the DOMAINNAME message catalog will be found
    in DIRNAME rather than in the system locale data base.  */
-extern char *bindtextdomain __P ((const char *__domainname,
-				  const char *__dirname));
-extern char *__bindtextdomain __P ((const char *__domainname,
-				    const char *__dirname));
+extern char *bindtextdomain __P ((__const char *__domainname,
+				  __const char *__dirname));
+extern char *__bindtextdomain __P ((__const char *__domainname,
+				    __const char *__dirname));
 
 
 /* Optimized version of the function above.  */
@@ -73,9 +75,9 @@ extern char *__bindtextdomain __P ((const char *__domainname,
    `__builtin_constant_p' predicate in dcgettext would always return
    false.  */
 
-# define gettext (msgid) dgettext (NULL, msgid)
+# define gettext(msgid) dgettext (NULL, msgid)
 
-# define dgettext (domainname, msgid)					      \
+# define dgettext(domainname, msgid)					      \
   dcgettext (domainname, msgid, LC_MESSAGES)
 
 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
diff --git a/intl/localealias.c b/intl/localealias.c
index 47f2cbffa8..02fa8a7b86 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -1,5 +1,5 @@
 /* localealias.c -- handle aliases for locale names
-   Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996 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
@@ -86,10 +86,10 @@ static size_t maxmap = 0;
 
 
 /* Prototypes for local functions.  */
-static size_t read_alias_file __P ((const char *fname, int fname_len));
-static void extend_alias_table __P ((void));
-static int alias_compare __P ((const struct alias_map *map1,
-			       const struct alias_map *map2));
+static size_t read_alias_file PARAMS ((const char *fname, int fname_len));
+static void extend_alias_table PARAMS ((void));
+static int alias_compare PARAMS ((const struct alias_map *map1,
+				  const struct alias_map *map2));
 
 
 const char *
@@ -109,9 +109,9 @@ _nl_expand_alias (name)
       if (nmap > 0)
 	retval = (struct alias_map *) bsearch (&item, map, nmap,
 					       sizeof (struct alias_map),
-					       (int (*) (const void *,
-							 const void *))
-						 alias_compare);
+					       (int (*) PARAMS ((const void *,
+								 const void *))
+						) alias_compare);
       else
 	retval = NULL;
 
@@ -257,7 +257,7 @@ read_alias_file (fname, fname_len)
 
   if (added > 0)
     qsort (map, nmap, sizeof (struct alias_map),
-	   (int (*) (const void *, const void *)) alias_compare);
+	   (int (*) PARAMS ((const void *, const void *))) alias_compare);
 
   return added;
 }
@@ -309,6 +309,8 @@ alias_compare (map1, map2)
       c2 = isupper (*p2) ? tolower (*p2) : *p2;
       if (c1 == '\0')
 	break;
+      ++p1;
+      ++p2;
     }
   while (c1 == c2);