about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-08-26 02:20:11 +0000
committerUlrich Drepper <drepper@redhat.com>2002-08-26 02:20:11 +0000
commit06a466e7e1d3024b7079d3880dce8593ada9682c (patch)
treea145945cef512285b4388a8ceb1771551d490a24 /locale
parent61ae62f27037d4c38acca2533a06dcd17fbc2ca2 (diff)
downloadglibc-06a466e7e1d3024b7079d3880dce8593ada9682c.tar.gz
glibc-06a466e7e1d3024b7079d3880dce8593ada9682c.tar.xz
glibc-06a466e7e1d3024b7079d3880dce8593ada9682c.zip
Update.
	* locale/programs/locale.c: Don't print aliases for non-existing
	locales for 'locale -a'.
	Patch by Noah Levitt <nlevitt@columbia.edu> [PR libc/4166].

2002-07-19  H.J. Lu  <hjl@gnu.org>

	* sysdeps/unix/sysv/linux/mips/bits/msq.h: New file.

2002-07-16  H.J. Lu  <hjl@gnu.org>

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	sys/personality.h.
	* sysdeps/unix/sysv/linux/sys/personality.h: New file.

2002-08-25  Ulrich Drepper  <drepper@redhat.com>
Diffstat (limited to 'locale')
-rw-r--r--locale/programs/locale.c198
1 files changed, 100 insertions, 98 deletions
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 3377bcc286..8dea09ae1c 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -347,100 +347,13 @@ write_locales (void)
 
 #define PUT(name) tsearch (name, &all_data, \
 			   (int (*) (const void *, const void *)) strcoll)
+#define GET(name) tfind (name, &all_data, \
+			   (int (*) (const void *, const void *)) strcoll)
 
-  /* Now read the locale.alias files.  */
-  if (argz_create_sep (LOCALE_ALIAS_PATH, ':', &alias_path, &alias_path_len))
-    error (1, errno, gettext ("while preparing output"));
-
-  entry = NULL;
-  while ((entry = argz_next (alias_path, alias_path_len, entry)))
-    {
-      static const char aliasfile[] = "/locale.alias";
-      FILE *fp;
-      char full_name[strlen (entry) + sizeof aliasfile];
-
-      stpcpy (stpcpy (full_name, entry), aliasfile);
-      fp = fopen (full_name, "r");
-      if (fp == NULL)
-	/* Ignore non-existing files.  */
-	continue;
-
-      /* No threads present.  */
-      __fsetlocking (fp, FSETLOCKING_BYCALLER);
-
-      while (! feof_unlocked (fp))
-	{
-	  /* It is a reasonable approach to use a fix buffer here
-	     because
-	     a) we are only interested in the first two fields
-	     b) these fields must be usable as file names and so must
-	        not be that long  */
-	  char buf[BUFSIZ];
-	  char *alias;
-	  char *value;
-	  char *cp;
-
-	  if (fgets_unlocked (buf, BUFSIZ, fp) == NULL)
-	    /* EOF reached.  */
-	    break;
-
-	  cp = buf;
-	  /* Ignore leading white space.  */
-	  while (isspace (cp[0]) && cp[0] != '\n')
-	    ++cp;
-
-	  /* A leading '#' signals a comment line.  */
-	  if (cp[0] != '\0' && cp[0] != '#' && cp[0] != '\n')
-	    {
-	      alias = cp++;
-	      while (cp[0] != '\0' && !isspace (cp[0]))
-		++cp;
-	      /* Terminate alias name.  */
-	      if (cp[0] != '\0')
-		*cp++ = '\0';
-
-	      /* Now look for the beginning of the value.  */
-	      while (isspace (cp[0]))
-		++cp;
-
-	      if (cp[0] != '\0')
-		{
-		  value = cp++;
-		  while (cp[0] != '\0' && !isspace (cp[0]))
-		    ++cp;
-		  /* Terminate value.  */
-		  if (cp[0] == '\n')
-		    {
-		      /* This has to be done to make the following
-			 test for the end of line possible.  We are
-			 looking for the terminating '\n' which do not
-			 overwrite here.  */
-		      *cp++ = '\0';
-		      *cp = '\n';
-		    }
-		  else if (cp[0] != '\0')
-		    *cp++ = '\0';
-
-		  /* Add the alias.  */
-		  if (! verbose)
-		    PUT (xstrdup (alias));
-		}
-	    }
-
-	  /* Possibly not the whole line fits into the buffer.
-	     Ignore the rest of the line.  */
-	  while (strchr (cp, '\n') == NULL)
-	    {
-	      cp = buf;
-	      if (fgets_unlocked (buf, BUFSIZ, fp) == NULL)
-		/* Make sure the inner loop will be left.  The outer
-		   loop will exit at the `feof' test.  */
-		*cp = '\n';
-	    }
-	}
-
-      fclose (fp);
-    }
+  /* `POSIX' locale is always available (POSIX.2 4.34.3).  */
+  PUT ("POSIX");
+  /* And so is the "C" locale.  */
+  PUT ("C");
 
   memset (linebuf, '-', sizeof (linebuf) - 1);
   linebuf[sizeof (linebuf) - 1] = '\0';
@@ -570,13 +483,102 @@ write_locales (void)
   if (ndirents > 0)
     free (dirents);
 
-  if (! verbose)
+  /* Now read the locale.alias files.  */
+  if (argz_create_sep (LOCALE_ALIAS_PATH, ':', &alias_path, &alias_path_len))
+    error (1, errno, gettext ("while preparing output"));
+
+  entry = NULL;
+  while ((entry = argz_next (alias_path, alias_path_len, entry)))
     {
-      /* `POSIX' locale is always available (POSIX.2 4.34.3).  */
-      PUT ("POSIX");
-      /* And so is the "C" locale.  */
-      PUT ("C");
+      static const char aliasfile[] = "/locale.alias";
+      FILE *fp;
+      char full_name[strlen (entry) + sizeof aliasfile];
+
+      stpcpy (stpcpy (full_name, entry), aliasfile);
+      fp = fopen (full_name, "r");
+      if (fp == NULL)
+	/* Ignore non-existing files.  */
+	continue;
+
+      /* No threads present.  */
+      __fsetlocking (fp, FSETLOCKING_BYCALLER);
 
+      while (! feof_unlocked (fp))
+	{
+	  /* It is a reasonable approach to use a fix buffer here
+	     because
+	     a) we are only interested in the first two fields
+	     b) these fields must be usable as file names and so must
+	        not be that long  */
+	  char buf[BUFSIZ];
+	  char *alias;
+	  char *value;
+	  char *cp;
+
+	  if (fgets_unlocked (buf, BUFSIZ, fp) == NULL)
+	    /* EOF reached.  */
+	    break;
+
+	  cp = buf;
+	  /* Ignore leading white space.  */
+	  while (isspace (cp[0]) && cp[0] != '\n')
+	    ++cp;
+
+	  /* A leading '#' signals a comment line.  */
+	  if (cp[0] != '\0' && cp[0] != '#' && cp[0] != '\n')
+	    {
+	      alias = cp++;
+	      while (cp[0] != '\0' && !isspace (cp[0]))
+		++cp;
+	      /* Terminate alias name.  */
+	      if (cp[0] != '\0')
+		*cp++ = '\0';
+
+	      /* Now look for the beginning of the value.  */
+	      while (isspace (cp[0]))
+		++cp;
+
+	      if (cp[0] != '\0')
+		{
+		  value = cp++;
+		  while (cp[0] != '\0' && !isspace (cp[0]))
+		    ++cp;
+		  /* Terminate value.  */
+		  if (cp[0] == '\n')
+		    {
+		      /* This has to be done to make the following
+			 test for the end of line possible.  We are
+			 looking for the terminating '\n' which do not
+			 overwrite here.  */
+		      *cp++ = '\0';
+		      *cp = '\n';
+		    }
+		  else if (cp[0] != '\0')
+		    *cp++ = '\0';
+
+		  /* Add the alias.  */
+		  if (! verbose && GET (value) != NULL)
+		    PUT (xstrdup (alias));
+		}
+	    }
+
+	  /* Possibly not the whole line fits into the buffer.
+	     Ignore the rest of the line.  */
+	  while (strchr (cp, '\n') == NULL)
+	    {
+	      cp = buf;
+	      if (fgets_unlocked (buf, BUFSIZ, fp) == NULL)
+		/* Make sure the inner loop will be left.  The outer
+		   loop will exit at the `feof' test.  */
+		*cp = '\n';
+	    }
+	}
+
+      fclose (fp);
+    }
+
+  if (! verbose)
+    {
       twalk (all_data, print_names);
     }
 }