Source-Changes-HG archive

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

[src/trunk]: src/bin/pax Accept -X -



details:   https://anonhg.NetBSD.org/src/rev/c797a7b9c091
branches:  trunk
changeset: 770953:c797a7b9c091
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 03 21:59:45 2011 +0000

description:
Accept -X -

diffstat:

 bin/pax/tar.c |  24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diffs (51 lines):

diff -r af80eacebef5 -r c797a7b9c091 bin/pax/tar.c
--- a/bin/pax/tar.c     Thu Nov 03 20:46:41 2011 +0000
+++ b/bin/pax/tar.c     Thu Nov 03 21:59:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tar.c,v 1.67 2009/02/14 08:10:06 lukem Exp $   */
+/*     $NetBSD: tar.c,v 1.68 2011/11/03 21:59:45 christos Exp $        */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)tar.c      8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: tar.c,v 1.67 2009/02/14 08:10:06 lukem Exp $");
+__RCSID("$NetBSD: tar.c,v 1.68 2011/11/03 21:59:45 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -1386,11 +1386,15 @@
        int lineno = 0;
        size_t len;
 
-       fp = fopen(path, "r");
-       if (fp == NULL) {
-               tty_warn(1, "cannot open %s: %s", path,
-                   strerror(errno));
-               return -1;
+       if (path[0] == '-' && path[1] == '\0')
+               fp = stdin;
+       else {
+               fp = fopen(path, "r");
+               if (fp == NULL) {
+                       tty_warn(1, "cannot open %s: %s", path,
+                           strerror(errno));
+                       return -1;
+               }
        }
 
        while ((line = fgetln(fp, &len))) {
@@ -1400,7 +1404,9 @@
                            lineno, path);
                }
                if (tar_gnutar_exclude_one(line, len))
-                       return (-1);
+                       return -1;
        }
-       return (0);
+       if (fp != stdin)
+               fclose(fp);
+       return 0;
 }



Home | Main Index | Thread Index | Old Index