svn commit: r291361 - user/ngie/more-tests2/tools/regression/lib/libc/resolv
Garrett Cooper
ngie at FreeBSD.org
Thu Nov 26 07:55:21 UTC 2015
Author: ngie
Date: Thu Nov 26 07:55:20 2015
New Revision: 291361
URL: https://svnweb.freebsd.org/changeset/base/291361
Log:
r291359 was incorrect. Skip over tokens that start with `#' as fgetln can
return more than one '\n' delimited line in a buffer
Handle empty lines too, just in case
MFC after: 3 days
X-MFC with: r291359
Modified:
user/ngie/more-tests2/tools/regression/lib/libc/resolv/resolv.c
Modified: user/ngie/more-tests2/tools/regression/lib/libc/resolv/resolv.c
==============================================================================
--- user/ngie/more-tests2/tools/regression/lib/libc/resolv/resolv.c Thu Nov 26 07:06:20 2015 (r291360)
+++ user/ngie/more-tests2/tools/regression/lib/libc/resolv/resolv.c Thu Nov 26 07:55:20 2015 (r291361)
@@ -87,13 +87,14 @@ load(const char *fname)
if ((fp = fopen(fname, "r")) == NULL)
err(1, "Cannot open `%s'", fname);
while ((line = fgetln(fp, &len)) != NULL) {
- if (line[0] == '#')
- continue;
char c = line[len];
char *ptr;
line[len] = '\0';
- for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS))
+ for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) {
+ if (ptr == '\0' || ptr[0] == '#')
+ continue;
sl_add(hosts, strdup(ptr));
+ }
line[len] = c;
}
More information about the svn-src-user
mailing list