Fri Aug 25 12:12:42 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
authorRoland McGrath <roland@gnu.org>
Fri, 25 Aug 1995 19:23:32 +0000 (19:23 +0000)
committerRoland McGrath <roland@gnu.org>
Fri, 25 Aug 1995 19:23:32 +0000 (19:23 +0000)
* sysdeps/mach/hurd/mmap.c: Fix inverted test of MAP_FIXED.

* stdio/vfscanf.c (number): Allow field width to inhibit first
digit after base detection.

* stdio/vfprintf.c (vfprintf: %s): Never search past the limit
specified by the precision.

* grp/grpread.c (__grpscan): New function.
* grp/grp.h (__grpscan): Declare it.
* grp/getgrgid.c: Use __grpscan.
* grp/getgrnam.c: Likewise.
* pwd/pwdread.c (__pwdscan): New function.
* pwd/pwd.h (__pwdscan): Declare it.
* pwd/getpwnam.c: Use __pwdscan.
* pwd/getpwuid.c: Likewise.

Thu Aug 24 16:29:40 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>

* sysdeps/mach/hurd/mmap.c: Treat (FLAGS & MAP_TYPE) == 0 like
MAP_FILE.

* hurd/thread-cancel.c: Return EINTR when called on self.
* sysdeps/i386/elf/start.S (data_start): Define as weak alias for
__data_start.

15 files changed:
ChangeLog
grp/getgrgid.c
grp/getgrnam.c
grp/grp.h
grp/grpread.c
hurd/thread-cancel.c
pwd/getpwnam.c
pwd/getpwuid.c
pwd/pwd.h
pwd/pwdread.c
stdio/vfprintf.c
stdio/vfscanf.c
sysdeps/i386/elf/start.S
sysdeps/mach/hurd/mmap.c
utime.h

index a05ebf2..036a121 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+Fri Aug 25 12:12:42 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
+
+       * sysdeps/mach/hurd/mmap.c: Fix inverted test of MAP_FIXED.
+
+       * stdio/vfscanf.c (number): Allow field width to inhibit first
+       digit after base detection.
+
+       * stdio/vfprintf.c (vfprintf: %s): Never search past the limit
+       specified by the precision.
+
+       * grp/grpread.c (__grpscan): New function.
+       * grp/grp.h (__grpscan): Declare it.
+       * grp/getgrgid.c: Use __grpscan.
+       * grp/getgrnam.c: Likewise.
+       * pwd/pwdread.c (__pwdscan): New function.
+       * pwd/pwd.h (__pwdscan): Declare it.
+       * pwd/getpwnam.c: Use __pwdscan.
+       * pwd/getpwuid.c: Likewise.
+
+Thu Aug 24 16:29:40 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
+
+       * sysdeps/mach/hurd/mmap.c: Treat (FLAGS & MAP_TYPE) == 0 like
+       MAP_FILE.
+
+       * hurd/thread-cancel.c: Return EINTR when called on self.
+       * sysdeps/i386/elf/start.S (data_start): Define as weak alias for
+       __data_start.
+
 Tue Aug 22 16:49:12 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>
 
        * inet/netdb.h: Moved to resolv.
index 1375f5f..ef3860f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995 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
@@ -24,27 +24,13 @@ Cambridge, MA 02139, USA.  */
 
 /* Search for an entry with a matching group ID.  */
 struct group *
-DEFUN(getgrgid, (gid), register gid_t gid)
+DEFUN(getgrgid, (gid), gid_t gid)
 {
-  static PTR info = NULL;
-  register FILE *stream;
-  register struct group *g;
-
-  if (info == NULL)
+  int match (struct group *p)
     {
-      info = __grpalloc();
-      if (info == NULL)
-       return NULL;
+      return p->gr_gid == gid;
     }
+  static void *info;
 
-  stream = __grpopen();
-  if (stream == NULL)
-    return NULL;
-
-  while ((g = __grpread(stream, info)) != NULL)
-    if (g->gr_gid == (gid_t) gid)
-      break;
-
-  (void) fclose(stream);
-  return g;
+  return __grpscan (&info, &match);
 }
index 1f88ea3..8416770 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995 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
@@ -24,27 +24,13 @@ Cambridge, MA 02139, USA.  */
 
 /* Search for an entry with a matching name.  */
 struct group *
-DEFUN(getgrnam, (name), register CONST char *name)
+DEFUN(getgrnam, (name), const char *name)
 {
-  static PTR info = NULL;
-  register FILE *stream;
-  register struct group *g;
-
-  if (info == NULL)
+  int match (struct group *p)
     {
-      info = __grpalloc();
-      if (info == NULL)
-       return NULL;
+      return ! strcmp (name, p->gr_name);
     }
+  static void *info;
 
-  stream = __grpopen();
-  if (stream == NULL)
-    return NULL;
-
-  while ((g = __grpread(stream, info)) != NULL)
-    if (!strcmp(g->gr_name, name))
-      break;
-
-  (void) fclose(stream);
-  return g;
+  return __grpscan (&info, &match);
 }
index 2562671..722e00f 100644 (file)
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995 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
@@ -55,6 +55,11 @@ extern struct group *__grpread __P ((FILE * __stream, __ptr_t __g));
 
 /* Return a chunk of memory containing pre-initialized data for __grpread.  */
 extern __ptr_t __grpalloc __P ((void));
+
+/* Scan the group file, filling in G, until SELECTOR returns nonzero for an
+   entry.  Return the `struct group' of G if successful, NULL on failure.  */
+extern struct group *__grpscan __P ((__ptr_t *__p,
+                                    int (*__selector) (struct group *)));
 #endif
 
 
index b7bac4c..1fed32f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995 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
@@ -133,3 +133,34 @@ DEFUN(__grpread, (stream, g), FILE *stream AND PTR CONST g)
 
   return &info->g;
 }
+
+
+struct group *
+__grpscan (void **info, int (*selector) (struct group *))
+{
+  FILE *stream;
+  struct group *p;
+
+  if (*info == NULL)
+    {
+      *info = __grpalloc ();
+      if (info == NULL)
+       return NULL;
+    }
+
+  stream = __grpopen ();
+  if (stream == NULL)
+    return NULL;
+
+  p = NULL;
+  while (! feof (stream))
+    {
+      p = __grpread (stream, *info);
+      if (p && (*selector) (p))
+       break;
+      p = NULL;
+    }
+
+  (void) fclose (stream);
+  return p;
+}
index 7fb8cd2..8182845 100644 (file)
@@ -42,6 +42,8 @@ hurd_thread_cancel (thread_t thread)
 
   if (! ss)
     return EINVAL;
+  if (ss == _hurd_self_sigstate ())
+    return EINTR;              /* Bozo.  */
 
   __spin_lock (&ss->lock);
   assert (! ss->critical_section);
index 1e7ea5c..bac8b6b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995 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
@@ -24,27 +24,13 @@ Cambridge, MA 02139, USA.  */
 
 /* Search for an entry with a matching name.  */
 struct passwd *
-DEFUN(getpwnam, (name), register CONST char *name)
+DEFUN(getpwnam, (name), const char *name)
 {
-  static PTR info = NULL;
-  register FILE *stream;
-  register struct passwd *p;
-
-  if (info == NULL)
+  int match (struct passwd *p)
     {
-      info = __pwdalloc();
-      if (info == NULL)
-       return(NULL);
+      return ! strcmp (name, p->pw_name);
     }
+  static void *info;
 
-  stream = __pwdopen();
-  if (stream == NULL)
-    return(NULL);
-
-  while ((p = __pwdread(stream, info)) != NULL)
-    if (!strcmp(p->pw_name, name))
-      break;
-
-  (void) fclose(stream);
-  return(p);
+  return __pwdscan (&info, &match);
 }
index 30e4032..5093488 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995 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
@@ -24,27 +24,13 @@ Cambridge, MA 02139, USA.  */
 
 /* Search for an entry with a matching uid.  */
 struct passwd *
-DEFUN(getpwuid, (uid), register uid_t uid)
+DEFUN(getpwuid, (uid), uid_t uid)
 {
-  static PTR info;
-  register FILE *stream;
-  register struct passwd *p;
-
-  if (info == NULL)
+  int match (struct passwd *p)
     {
-      info = __pwdalloc();
-      if (info == NULL)
-       return(NULL);
+      return p->pw_uid == uid;
     }
+  static void *info;
 
-  stream = __pwdopen();
-  if (stream == NULL)
-    return(NULL);
-
-  while ((p = __pwdread(stream, info)) != NULL)
-    if (p->pw_uid == uid)
-      break;
-
-  (void) fclose(stream);
-  return(p);
+  return __pwdscan (&info, &match);
 }
index c72c37d..dd7d837 100644 (file)
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995 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
@@ -58,6 +58,12 @@ extern struct passwd *__pwdread __P ((FILE * __stream, __ptr_t __p));
 
 /* Return a chunk of memory containing pre-initialized data for __pwdread.  */
 extern __ptr_t __pwdalloc __P ((void));
+
+/* Scan the password file, filling in P, until SELECTOR returns nonzero for
+   an entry.  Return the `struct passwd' of P if successful, NULL on
+   failure.  */
+extern struct passwd *__pwdscan __P ((__ptr_t *__p,
+                                     int (*__selector) (struct passwd *)));
 #endif
 
 
index 0ce27d7..1203236 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995 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
@@ -114,3 +114,34 @@ DEFUN(__pwdread, (stream, p), FILE *stream AND PTR CONST p)
 
   return &info->p;
 }
+
+
+struct passwd *
+__pwdscan (void **info, int (*selector) (struct passwd *))
+{
+  FILE *stream;
+  struct passwd *p;
+
+  if (*info == NULL)
+    {
+      *info = __pwdalloc ();
+      if (info == NULL)
+       return NULL;
+    }
+
+  stream = __pwdopen ();
+  if (stream == NULL)
+    return NULL;
+
+  p = NULL;
+  while (! feof (stream))
+    {
+      p = __pwdread (stream, *info);
+      if (p && (*selector) (p))
+       break;
+      p = NULL;
+    }
+
+  (void) fclose (stream);
+  return p;
+}
index 1246229..06aa0a0 100644 (file)
@@ -533,21 +533,16 @@ vfprintf (s, format, ap)
                }
               else if (specs[cnt].info.prec != -1)
                {
+                 /* Search for the end of the string, but don't search
+                     past the length specified by the precision.  */
                  const char *end = memchr (str, '\0', specs[cnt].info.prec);
                  if (end)
                    len = end - str;
                  else
-                   len = strlen (str);
-               }
-             else
-               {
-                 len = strlen (str);
-
-                 if (specs[cnt].info.prec != -1
-                     && (size_t) specs[cnt].info.prec < len)
-                   /* Limit the length to the precision.  */
                    len = specs[cnt].info.prec;
                }
+             else
+               len = strlen (str);
 
               specs[cnt].info.width -= len;
 
index 6eacc2b..a778346 100644 (file)
@@ -422,7 +422,7 @@ DEFUN(__vfscanf, (s, format, arg),
            base = 10;
 
          /* Read the number into WORK.  */
-         do
+         while (width != 0 && c != EOF)
            {
              if (base == 16 ? !isxdigit(c) :
                  (!isdigit(c) || c - '0' >= base))
@@ -430,11 +430,12 @@ DEFUN(__vfscanf, (s, format, arg),
              *w++ = c;
              if (width > 0)
                --width;
-           } while (inchar() != EOF && width != 0);
+             (void) inchar ();
+           }
 
          if (w == work ||
              (w - work == 1 && (work[0] == '+' || work[0] == '-')))
-           /* There was on number.  */
+           /* There was no number.  */
            conv_error();
 
          /* Convert the number.  */
index 67d7916..c5796e8 100644 (file)
@@ -90,3 +90,5 @@ nofini:
        .globl __data_start
 __data_start:
        .long 0
+       .weak data_start
+       data_start = __data_start
index 0fb1a08..9793077 100644 (file)
@@ -57,6 +57,7 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
       break;
 
     case MAP_FILE:
+    case 0:                    /* Allow, e.g., just MAP_SHARED.  */
       {
        mach_port_t robj, wobj;
        if (err = HURD_DPORT_USE (fd, __io_map (port, &robj, &wobj)))
@@ -91,7 +92,7 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
   mapaddr = (vm_address_t) addr;
   err = __vm_map (__mach_task_self (),
                  &mapaddr, (vm_size_t) len, (vm_address_t) 0,
-                 flags & MAP_FIXED,
+                 ! (flags & MAP_FIXED),
                  memobj, (vm_offset_t) offset,
                  flags & (MAP_COPY|MAP_PRIVATE),
                  vmprot, VM_PROT_ALL,
diff --git a/utime.h b/utime.h
index e9dfbea..6dadc53 100644 (file)
--- a/utime.h
+++ b/utime.h
@@ -1 +1 @@
-#include <posix/utime.h>
+#include <io/utime.h>