diff options
Diffstat (limited to 'gshadow/fgetsgent_r.c')
-rw-r--r-- | gshadow/fgetsgent_r.c | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c index a7a1860c76..218206b4ac 100644 --- a/gshadow/fgetsgent_r.c +++ b/gshadow/fgetsgent_r.c @@ -36,40 +36,11 @@ int __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen, struct sgrp **result) { - char *p; - - _IO_flockfile (stream); - do - { - buffer[buflen - 1] = '\xff'; - p = fgets_unlocked (buffer, buflen, stream); - if (p == NULL && feof_unlocked (stream)) - { - _IO_funlockfile (stream); - *result = NULL; - __set_errno (ENOENT); - return errno; - } - if (p == NULL || buffer[buflen - 1] != '\xff') - { - _IO_funlockfile (stream); - *result = NULL; - __set_errno (ERANGE); - return errno; - } - - /* Skip leading blanks. */ - while (isspace (*p)) - ++p; - } while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */ - /* Parse the line. If it is invalid, loop to - get the next line of the file to parse. */ - || ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen, - &errno)); - - _IO_funlockfile (stream); - - *result = resbuf; - return 0; + int ret = __nss_fgetent_r (stream, resbuf, buffer, buflen, parse_line); + if (ret == 0) + *result = resbuf; + else + *result = NULL; + return ret; } weak_alias (__fgetsgent_r, fgetsgent_r) |