Date: Thu, 26 Nov 2015 07:58:22 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291362 - head/tools/regression/lib/libc/resolv Message-ID: <201511260758.tAQ7wMZX017609@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Thu Nov 26 07:58:22 2015 New Revision: 291362 URL: https://svnweb.freebsd.org/changeset/base/291362 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: head/tools/regression/lib/libc/resolv/resolv.c Modified: head/tools/regression/lib/libc/resolv/resolv.c ============================================================================== --- head/tools/regression/lib/libc/resolv/resolv.c Thu Nov 26 07:55:20 2015 (r291361) +++ head/tools/regression/lib/libc/resolv/resolv.c Thu Nov 26 07:58:22 2015 (r291362) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511260758.tAQ7wMZX017609>