From 7752137a6a9d9a042d2c2f00e245b920e41737bc Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 25 Aug 1995 19:23:32 +0000 Subject: Fri Aug 25 12:12:42 1995 Roland McGrath * 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 * 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. --- grp/grpread.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'grp/grpread.c') diff --git a/grp/grpread.c b/grp/grpread.c index b7bac4c..1fed32f 100644 --- a/grp/grpread.c +++ b/grp/grpread.c @@ -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; +} -- cgit v1.1