Module Name:    src
Committed By:   dholland
Date:           Thu Jun 10 06:03:20 UTC 2010

Modified Files:
        src/usr.sbin/arp: arp.c

Log Message:
Allow -f -, as per PR 10898.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/arp/arp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/arp/arp.c
diff -u src/usr.sbin/arp/arp.c:1.48 src/usr.sbin/arp/arp.c:1.49
--- src/usr.sbin/arp/arp.c:1.48	Thu Apr  2 21:02:06 2009
+++ src/usr.sbin/arp/arp.c	Thu Jun 10 06:03:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: arp.c,v 1.48 2009/04/02 21:02:06 christos Exp $ */
+/*	$NetBSD: arp.c,v 1.49 2010/06/10 06:03:20 dholland Exp $ */
 
 /*
  * Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)arp.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: arp.c,v 1.48 2009/04/02 21:02:06 christos Exp $");
+__RCSID("$NetBSD: arp.c,v 1.49 2010/06/10 06:03:20 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -195,8 +195,14 @@
 	int i, retval;
 	FILE *fp;
 
-	if ((fp = fopen(name, "r")) == NULL)
-		err(1, "cannot open %s", name);
+	if (!strcmp(name, "-")) {
+		fp = stdin;
+	} else {
+		fp = fopen(name, "r");
+		if (fp == NULL) {
+			err(1, "Cannot open %s", name);
+		}
+	}
 	retval = 0;
 	for (; (line = fparseln(fp, NULL, NULL, NULL, 0)) != NULL; free(line)) {
 		char **ap, *inputstring;
@@ -216,7 +222,8 @@
 		if (set(i, argv))
 			retval = 1;
 	}
-	(void)fclose(fp);
+	if (fp != stdin)
+		(void)fclose(fp);
 	return retval;
 }
 

Reply via email to