POLA dictates that in the file designated with the -f option

argument, leading whitespace and empty lines be ignored, and
the `#' character marks the rest of the line as a comment.

PR:		bin/45958
MFC after:	3 days
This commit is contained in:
Ruslan Ermilov 2002-12-27 10:09:04 +00:00
parent 975512a907
commit 44acbc1adc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108314
2 changed files with 12 additions and 2 deletions

View File

@ -163,6 +163,10 @@ in the file should be of the form
.Ed
.Pp
with argument meanings as given above.
Leading whitespace and empty lines are ignored.
A
.Ql #
character will mark the rest of the line as a comment.
.El
.Sh SEE ALSO
.Xr inet 3 ,

View File

@ -72,6 +72,7 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <netdb.h>
@ -219,7 +220,7 @@ file(char *name)
{
FILE *fp;
int i, retval;
char line[100], arg[5][50], *args[5];
char line[100], arg[5][50], *args[5], *s;
if ((fp = fopen(name, "r")) == NULL)
errx(1, "cannot open %s", name);
@ -230,7 +231,12 @@ file(char *name)
args[4] = &arg[4][0];
retval = 0;
while(fgets(line, 100, fp) != NULL) {
i = sscanf(line, "%49s %49s %49s %49s %49s", arg[0], arg[1],
if ((s = strchr(line, '#')) != NULL)
*s = '\0';
for (s = line; isblank(*s); s++);
if (*s == '\0')
continue;
i = sscanf(s, "%49s %49s %49s %49s %49s", arg[0], arg[1],
arg[2], arg[3], arg[4]);
if (i < 2) {
warnx("bad line: %s", line);