diff options
author | ru <ru@FreeBSD.org> | 2002-12-27 10:09:04 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2002-12-27 10:09:04 +0000 |
commit | 357cc16da89629ae10de734ddf1a73fc627152a2 (patch) | |
tree | 9c148e7f80a3cf231569c819f405aa7fd75ddaee /usr.sbin | |
parent | afd8ad09d78e1fa25f2cec6f0227b7fe0cc17bf3 (diff) | |
download | FreeBSD-src-357cc16da89629ae10de734ddf1a73fc627152a2.zip FreeBSD-src-357cc16da89629ae10de734ddf1a73fc627152a2.tar.gz |
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
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/arp/arp.8 | 4 | ||||
-rw-r--r-- | usr.sbin/arp/arp.c | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/arp/arp.8 b/usr.sbin/arp/arp.8 index 802243d..89aa7a5 100644 --- a/usr.sbin/arp/arp.8 +++ b/usr.sbin/arp/arp.8 @@ -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 , diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 493d9e8..b052762 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -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); |