summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--locale/programs/locale.c198
-rw-r--r--sysdeps/unix/sysv/linux/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/msq.h74
4 files changed, 191 insertions, 99 deletions
diff --git a/ChangeLog b/ChangeLog
index a5972e105b..879d4420e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,22 @@
 
 2002-08-25  Ulrich Drepper  <drepper@redhat.com>
 
+	* 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>
+
 	* elf/tst-tlsmod1.c (in_dso): Make sure the TLS variable access is
 	not moved ahead of the fputs call.
 	* elf/tst-tlsmod2.c (in_dso): Likewise.
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);
     }
 }
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 9a2bbc492e..cc37196526 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -20,7 +20,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
 		  sys/kd.h sys/soundcard.h sys/vt.h \
 		  sys/quota.h sys/fsuid.h \
 		  scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
-		  sys/ultrasound.h sys/raw.h
+		  sys/ultrasound.h sys/raw.h sys/personality.h
 
 install-others += $(inst_includedir)/bits/syscall.h
 
diff --git a/sysdeps/unix/sysv/linux/mips/bits/msq.h b/sysdeps/unix/sysv/linux/mips/bits/msq.h
new file mode 100644
index 0000000000..c2c1dd2e85
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/bits/msq.h
@@ -0,0 +1,74 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _SYS_MSG_H
+# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+#ifdef __USE_GNU
+# define MSG_EXCEPT	020000	/* recv any msg except of specified type */
+#endif
+
+/* Types used in the structure definition.  */
+typedef unsigned long int msgqnum_t;
+typedef unsigned long int msglen_t;
+
+
+/* Structure of record for one message inside the kernel.
+   The type `struct msg' is opaque.  */
+struct msqid_ds
+{
+  struct ipc_perm msg_perm;	/* structure describing operation permission */
+  __time_t msg_stime;		/* time of last msgsnd command */
+  __time_t msg_rtime;		/* time of last msgrcv command */
+  __time_t msg_ctime;		/* time of last change */
+  unsigned long int __msg_cbytes; /* current number of bytes on queue */
+  msgqnum_t msg_qnum;		/* number of messages currently on queue */
+  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
+  __pid_t msg_lspid;		/* pid of last msgsnd() */
+  __pid_t msg_lrpid;		/* pid of last msgrcv() */
+  unsigned long int __unused1;
+  unsigned long int __unused2;
+};
+
+#ifdef __USE_MISC
+
+# define msg_cbytes	__msg_cbytes
+
+/* ipcs ctl commands */
+# define MSG_STAT 11
+# define MSG_INFO 12
+
+/* buffer for msgctl calls IPC_INFO, MSG_INFO */
+struct msginfo
+  {
+    int msgpool;
+    int msgmap;
+    int msgmax;
+    int msgmnb;
+    int msgmni;
+    int msgssz;
+    int msgtql;
+    unsigned short int msgseg;
+  };
+
+#endif /* __USE_MISC */