Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/arp Allow -f -, as per PR 10898.



details:   https://anonhg.NetBSD.org/src/rev/94a6cd98a8f8
branches:  trunk
changeset: 755576:94a6cd98a8f8
user:      dholland <dholland%NetBSD.org@localhost>
date:      Thu Jun 10 06:03:20 2010 +0000

description:
Allow -f -, as per PR 10898.

diffstat:

 usr.sbin/arp/arp.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 606c0766dc37 -r 94a6cd98a8f8 usr.sbin/arp/arp.c
--- a/usr.sbin/arp/arp.c        Thu Jun 10 05:24:55 2010 +0000
+++ b/usr.sbin/arp/arp.c        Thu Jun 10 06:03:20 2010 +0000
@@ -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;
 }
 



Home | Main Index | Thread Index | Old Index