aboutsummaryrefslogtreecommitdiff
path: root/grp/getgrgid.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-08-25 19:23:32 +0000
committerRoland McGrath <roland@gnu.org>1995-08-25 19:23:32 +0000
commit7752137a6a9d9a042d2c2f00e245b920e41737bc (patch)
treed0d12093452de95c4c7a609bd14d0094439ad956 /grp/getgrgid.c
parent3cf595e562f955e399d80ea9d053e41d50469e6b (diff)
downloadglibc-7752137a6a9d9a042d2c2f00e245b920e41737bc.zip
glibc-7752137a6a9d9a042d2c2f00e245b920e41737bc.tar.gz
glibc-7752137a6a9d9a042d2c2f00e245b920e41737bc.tar.bz2
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.
Diffstat (limited to 'grp/getgrgid.c')
-rw-r--r--grp/getgrgid.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/grp/getgrgid.c b/grp/getgrgid.c
index 1375f5f..ef3860f 100644
--- a/grp/getgrgid.c
+++ b/grp/getgrgid.c
@@ -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);
}