summaryrefslogtreecommitdiffstats
path: root/usr.sbin/arp/arp.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2002-12-27 10:09:04 +0000
committerru <ru@FreeBSD.org>2002-12-27 10:09:04 +0000
commit357cc16da89629ae10de734ddf1a73fc627152a2 (patch)
tree9c148e7f80a3cf231569c819f405aa7fd75ddaee /usr.sbin/arp/arp.c
parentafd8ad09d78e1fa25f2cec6f0227b7fe0cc17bf3 (diff)
downloadFreeBSD-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/arp/arp.c')
-rw-r--r--usr.sbin/arp/arp.c10
1 files changed, 8 insertions, 2 deletions
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);
OpenPOWER on IntegriCloud