about summary refs log tree commit diff
path: root/locale/programs
diff options
context:
space:
mode:
Diffstat (limited to 'locale/programs')
-rw-r--r--locale/programs/3level.h3
-rw-r--r--locale/programs/ld-collate.c83
-rw-r--r--locale/programs/locfile.c60
-rw-r--r--locale/programs/locfile.h66
4 files changed, 123 insertions, 89 deletions
diff --git a/locale/programs/3level.h b/locale/programs/3level.h
index f4d641d67c..ef4ba2bbc0 100644
--- a/locale/programs/3level.h
+++ b/locale/programs/3level.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2001 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Bruno Haible <haible@clisp.cons.org>, 2000.
 
@@ -80,6 +80,7 @@ CONCAT(TABLE,_init) (struct TABLE *t)
 
 /* Retrieve an entry.  */
 static inline ELEMENT
+__attribute ((always_inline))
 CONCAT(TABLE,_get) (struct TABLE *t, uint32_t wc)
 {
   uint32_t index1 = wc >> (t->q + t->p);
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 9d2bca437a..6d0d03c235 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
 
@@ -42,6 +42,7 @@
 #define obstack_chunk_free free
 
 static inline void
+__attribute ((always_inline))
 obstack_int32_grow (struct obstack *obstack, int32_t data)
 {
   if (sizeof (int32_t) == sizeof (int))
@@ -51,6 +52,7 @@ obstack_int32_grow (struct obstack *obstack, int32_t data)
 }
 
 static inline void
+__attribute ((always_inline))
 obstack_int32_grow_fast (struct obstack *obstack, int32_t data)
 {
   if (sizeof (int32_t) == sizeof (int))
@@ -249,6 +251,7 @@ static uint32_t nrules;
 
 /* We need UTF-8 encoding of numbers.  */
 static inline int
+__attribute ((always_inline))
 utf8_encode (char *buf, int val)
 {
   int retval;
@@ -606,10 +609,10 @@ static struct element_t *
 find_element (struct linereader *ldfile, struct locale_collate_t *collate,
 	      const char *str, size_t len)
 {
-  struct element_t *result = NULL;
+  void *result = NULL;
 
   /* Search for the entries among the collation sequences already define.  */
-  if (find_entry (&collate->seq_table, str, len, (void **) &result) != 0)
+  if (find_entry (&collate->seq_table, str, len, &result) != 0)
     {
       /* Nope, not define yet.  So we see whether it is a
          collation symbol.  */
@@ -625,8 +628,7 @@ find_element (struct linereader *ldfile, struct locale_collate_t *collate,
 	    result = sym->order = new_element (collate, NULL, 0, NULL,
 					       NULL, 0, 0);
 	}
-      else if (find_entry (&collate->elem_table, str, len,
-			   (void **) &result) != 0)
+      else if (find_entry (&collate->elem_table, str, len, &result) != 0)
 	{
 	  /* It's also no collation element.  So it is a character
 	     element defined later.  */
@@ -636,7 +638,7 @@ find_element (struct linereader *ldfile, struct locale_collate_t *collate,
 	}
     }
 
-  return result;
+  return (struct element_t *) result;
 }
 
 
@@ -944,8 +946,8 @@ insert_value (struct linereader *ldfile, const char *symstr, size_t symlen,
     {
       /* It's no character, so look through the collation elements and
 	 symbol list.  */
-      if (find_entry (&collate->elem_table, symstr, symlen,
-			   (void **) &elem) != 0)
+      void *ptr = elem;
+      if (find_entry (&collate->elem_table, symstr, symlen, &ptr) != 0)
 	{
 	  void *result;
 	  struct symbol_t *sym = NULL;
@@ -976,12 +978,15 @@ insert_value (struct linereader *ldfile, const char *symstr, size_t symlen,
 		insert_entry (&collate->seq_table, symstr, symlen, elem);
 	    }
 	}
+      else
+	/* Copy the result back.  */
+	elem = ptr;
     }
   else
     {
       /* Otherwise the symbols stands for a character.  */
-      if (find_entry (&collate->seq_table, symstr, symlen,
-		      (void **) &elem) != 0)
+      void *ptr = elem;
+      if (find_entry (&collate->seq_table, symstr, symlen, &ptr) != 0)
 	{
 	  uint32_t wcs[2] = { wc, 0 };
 
@@ -998,6 +1003,9 @@ insert_value (struct linereader *ldfile, const char *symstr, size_t symlen,
 	}
       else
 	{
+	  /* Copy the result back.  */
+	  elem = ptr;
+
 	  /* Maybe the character was used before the definition.  In this case
 	     we have to insert the byte sequences now.  */
 	  if (elem->mbs == NULL && seq != NULL)
@@ -1169,8 +1177,9 @@ sequence is not lower than that of the last character"), "LC_COLLATE");
 		  /* Now we are ready to insert the new value in the
 		     sequence.  Find out whether the element is
 		     already known.  */
+		  void *ptr;
 		  if (find_entry (&collate->seq_table, seq->name, namelen,
-				  (void **) &elem) != 0)
+				  &ptr) != 0)
 		    {
 		      uint32_t wcs[2] = { seq->ucs4, 0 };
 
@@ -1186,6 +1195,9 @@ sequence is not lower than that of the last character"), "LC_COLLATE");
 			/* This cannot happen.  */
 			assert (! "Internal error");
 		    }
+		  else
+		    /* Copy the result.  */
+		    elem = ptr;
 
 		  /* Test whether this element is not already in the list.  */
 		  if (elem->next != NULL || (collate->cursor != NULL
@@ -1324,9 +1336,12 @@ order for `%.*s' already defined at %s:%Zu"),
 	      sprintf (buf + preflen, base == 10 ? "%ld" : "%lX", from);
 
 	      /* Look whether this name is already defined.  */
-	      if (find_entry (&collate->seq_table, buf, symlen,
-			      (void **) &elem) == 0)
+	      void *ptr;
+	      if (find_entry (&collate->seq_table, buf, symlen, &ptr) == 0)
 		{
+		  /* Copy back the result.  */
+		  elem = ptr;
+
 		  if (elem->next != NULL || (collate->cursor != NULL
 					     && elem->next == collate->cursor))
 		    {
@@ -3009,7 +3024,7 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
 	      size_t newname_len = arg->val.str.lenmb;
 	      const char *symname;
 	      size_t symname_len;
-	      struct symbol_t *symval;
+	      void *symval;	/* Actually struct symbol_t*  */
 
 	      arg = lr_token (ldfile, charmap, result, repertoire, verbose);
 	      if (arg->tok != tok_bsymbol)
@@ -3045,7 +3060,7 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
 
 	      /* See whether the symbol name is already defined.  */
 	      if (find_entry (&collate->sym_table, symname, symname_len,
-			      (void **) &symval) != 0)
+			      &symval) != 0)
 		{
 		  lr_error (ldfile, _("\
 %s: unknown symbol `%s' in equivalent definition"),
@@ -3294,6 +3309,7 @@ error while adding equivalent collating symbol"));
 	      size_t lenmb;
 	      struct element_t *insp;
 	      int no_error = 1;
+	      void *ptr;
 
 	      if (arg->tok == tok_bsymbol)
 		{
@@ -3307,18 +3323,20 @@ error while adding equivalent collating symbol"));
 		  lenmb = 9;
 		}
 
-	      if (find_entry (&collate->seq_table, startmb, lenmb,
-			      (void **) &insp) == 0)
+	      if (find_entry (&collate->seq_table, startmb, lenmb, &ptr) == 0)
 		/* Yes, the symbol exists.  Simply point the cursor
 		   to it.  */
-		collate->cursor = insp;
+		collate->cursor = (struct element_t *) ptr;
 	      else
 		{
 		  struct symbol_t *symbp;
+		  void *ptr;
 
 		  if (find_entry (&collate->sym_table, startmb, lenmb,
-				  (void **) &symbp) == 0)
+				  &ptr) == 0)
 		    {
+		      symbp = ptr;
+
 		      if (symbp->order->last != NULL
 			  || symbp->order->next != NULL)
 			collate->cursor = symbp->order;
@@ -3334,8 +3352,10 @@ error while adding equivalent collating symbol"));
 			}
 		    }
 		  else if (find_entry (&collate->elem_table, startmb, lenmb,
-				       (void **) &insp) == 0)
+				       &ptr) == 0)
 		    {
+		      insp = (struct element_t *) ptr;
+
 		      if (insp->last != NULL || insp->next != NULL)
 			collate->cursor = insp;
 		      else
@@ -3517,10 +3537,12 @@ error while adding equivalent collating symbol"));
                  collation symbols since these are purely abstract
                  values and don't need directions associated.  */
 	      struct element_t *seqp;
+	      void *ptr;
 
-	      if (find_entry (&collate->seq_table, symstr, symlen,
-			      (void **) &seqp) == 0)
+	      if (find_entry (&collate->seq_table, symstr, symlen, &ptr) == 0)
 		{
+		  seqp = ptr;
+
 		  /* It's already defined.  First check whether this
 		     is really a collating symbol.  */
 		  if (seqp->is_character)
@@ -3561,8 +3583,9 @@ error while adding equivalent collating symbol"));
 	    {
 	      /* It is possible that we already have this collation sequence.
 		 In this case we move the entry.  */
-	      struct element_t *seqp;
+	      struct element_t *seqp = NULL;
 	      void *sym;
+	      void *ptr;
 
 	      /* If the symbol after which we have to insert was not found
 		 ignore all entries.  */
@@ -3572,17 +3595,19 @@ error while adding equivalent collating symbol"));
 		  break;
 		}
 
-	      if (find_entry (&collate->seq_table, symstr, symlen,
-			      (void **) &seqp) == 0)
-		goto move_entry;
+	      if (find_entry (&collate->seq_table, symstr, symlen, &ptr) == 0)
+		{
+		  seqp = (struct element_t *) ptr;
+		  goto move_entry;
+		}
 
 	      if (find_entry (&collate->sym_table, symstr, symlen, &sym) == 0
 		  && (seqp = ((struct symbol_t *) sym)->order) != NULL)
 		goto move_entry;
 
-	      if (find_entry (&collate->elem_table, symstr, symlen,
-			      (void **) &seqp) == 0
-		  && (seqp->last != NULL || seqp->next != NULL
+	      if (find_entry (&collate->elem_table, symstr, symlen, &ptr) == 0
+		  && (seqp = (struct element_t *) ptr,
+		      seqp->last != NULL || seqp->next != NULL
 		      || (collate->start != NULL && seqp == collate->start)))
 		{
 		move_entry:
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
index 1e8e434ee1..2eeed96141 100644
--- a/locale/programs/locfile.c
+++ b/locale/programs/locfile.c
@@ -764,3 +764,63 @@ cannot create output file `%s' for category `%s'"), fname, category));
 
   free (fname);
 }
+
+
+/* General handling of `copy'.  */
+void
+handle_copy (struct linereader *ldfile, const struct charmap_t *charmap,
+	     const char *repertoire_name, struct localedef_t *result,
+	     enum token_t token, int locale, const char *locale_name,
+	     int ignore_content)
+{
+  struct token *now;
+  int warned = 0;
+
+  now = lr_token (ldfile, charmap, result, NULL, verbose);
+  if (now->tok != tok_string)
+    lr_error (ldfile, _("expect string argument for `copy'"));
+  else if (!ignore_content)
+    {
+      if (now->val.str.startmb == NULL)
+	lr_error (ldfile, _("\
+locale name should consist only of portable characters"));
+      else
+	{
+	  (void) add_to_readlist (locale, now->val.str.startmb,
+				  repertoire_name, 1, NULL);
+	  result->copy_name[locale] = now->val.str.startmb;
+	}
+    }
+
+  lr_ignore_rest (ldfile, now->tok == tok_string);
+
+  /* The rest of the line must be empty and the next keyword must be
+     `END xxx'.  */
+  while ((now = lr_token (ldfile, charmap, result, NULL, verbose))->tok
+	 != tok_end && now->tok != tok_eof)
+    {
+      if (warned == 0)
+	{
+	  lr_error (ldfile, _("\
+no other keyword shall be specified when `copy' is used"));
+	  warned = 1;
+	}
+
+      lr_ignore_rest (ldfile, 0);
+    }
+
+  if (now->tok != tok_eof)
+    {
+      /* Handle `END xxx'.  */
+      now = lr_token (ldfile, charmap, result, NULL, verbose);
+
+      if (now->tok != token)
+	lr_error (ldfile, _("\
+`%1$s' definition does not end with `END %1$s'"), locale_name);
+
+      lr_ignore_rest (ldfile, now->tok == token);
+    }
+  else
+    /* When we come here we reached the end of the file.  */
+    lr_error (ldfile, _("%s: premature end of file"), locale_name);
+}
diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h
index 2e96c62ec7..db34f462e3 100644
--- a/locale/programs/locfile.h
+++ b/locale/programs/locfile.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
 
@@ -45,64 +45,12 @@ struct locale_file
 
 
 /* General handling of `copy'.  */
-static inline void
-handle_copy (struct linereader *ldfile, const struct charmap_t *charmap,
-	     const char *repertoire_name, struct localedef_t *result,
-	     enum token_t token, int locale, const char *locale_name,
-	     int ignore_content)
-{
-  struct token *now;
-  int warned = 0;
-
-  now = lr_token (ldfile, charmap, result, NULL, verbose);
-  if (now->tok != tok_string)
-    lr_error (ldfile, _("expect string argument for `copy'"));
-  else if (!ignore_content)
-    {
-      if (now->val.str.startmb == NULL)
-	lr_error (ldfile, _("\
-locale name should consist only of portable characters"));
-      else
-	{
-	  (void) add_to_readlist (locale, now->val.str.startmb,
-				  repertoire_name, 1, NULL);
-	  result->copy_name[locale] = now->val.str.startmb;
-	}
-    }
-
-  lr_ignore_rest (ldfile, now->tok == tok_string);
-
-  /* The rest of the line must be empty and the next keyword must be
-     `END xxx'.  */
-  while ((now = lr_token (ldfile, charmap, result, NULL, verbose))->tok
-	 != tok_end && now->tok != tok_eof)
-    {
-      if (warned == 0)
-	{
-	  lr_error (ldfile, _("\
-no other keyword shall be specified when `copy' is used"));
-	  warned = 1;
-	}
-
-      lr_ignore_rest (ldfile, 0);
-    }
-
-  if (now->tok != tok_eof)
-    {
-      /* Handle `END xxx'.  */
-      now = lr_token (ldfile, charmap, result, NULL, verbose);
-
-      if (now->tok != token)
-	lr_error (ldfile, _("\
-`%1$s' definition does not end with `END %1$s'"), locale_name);
-
-      lr_ignore_rest (ldfile, now->tok == token);
-    }
-  else
-    /* When we come here we reached the end of the file.  */
-    lr_error (ldfile, _("%s: premature end of file"), locale_name);
-}
-
+extern void handle_copy (struct linereader *ldfile,
+			 const struct charmap_t *charmap,
+			 const char *repertoire_name,
+			 struct localedef_t *result, enum token_t token,
+			 int locale, const char *locale_name,
+			 int ignore_content);
 
 /* Found in locfile.c.  */
 extern int locfile_read (struct localedef_t *result,