Fix an obscure option parsing bug.
authorEric Andersen <andersen@codepoet.org>
Sat, 23 Sep 2000 22:36:24 +0000 (22:36 -0000)
committerEric Andersen <andersen@codepoet.org>
Sat, 23 Sep 2000 22:36:24 +0000 (22:36 -0000)
archival/tar.c
tar.c

index ade77a59dd75a242c8b7aa726d07f3880f1b8f9c..6dcda53ef222f775b256b419d79562a354015d2d 100644 (file)
@@ -149,6 +149,7 @@ extern int tar_main(int argc, char **argv)
        int createFlag   = FALSE;
        int verboseFlag  = FALSE;
        int tostdoutFlag = FALSE;
+       int firstOpt = TRUE;
        int stopIt;
                                                                                                                                                   
 
@@ -156,7 +157,9 @@ extern int tar_main(int argc, char **argv)
                usage(tar_usage);
 
        /* do normal option parsing */
-       while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
+       while (--argc > 0 && ((*argv && **(++argv) == '-') || 
+                               (firstOpt==TRUE && strspn(*argv, "-cxt") ))) {
+               firstOpt=FALSE;
                stopIt=FALSE;
                while (stopIt==FALSE && *argv && **argv) {
                        switch (**argv) {
diff --git a/tar.c b/tar.c
index ade77a59dd75a242c8b7aa726d07f3880f1b8f9c..6dcda53ef222f775b256b419d79562a354015d2d 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -149,6 +149,7 @@ extern int tar_main(int argc, char **argv)
        int createFlag   = FALSE;
        int verboseFlag  = FALSE;
        int tostdoutFlag = FALSE;
+       int firstOpt = TRUE;
        int stopIt;
                                                                                                                                                   
 
@@ -156,7 +157,9 @@ extern int tar_main(int argc, char **argv)
                usage(tar_usage);
 
        /* do normal option parsing */
-       while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
+       while (--argc > 0 && ((*argv && **(++argv) == '-') || 
+                               (firstOpt==TRUE && strspn(*argv, "-cxt") ))) {
+               firstOpt=FALSE;
                stopIt=FALSE;
                while (stopIt==FALSE && *argv && **argv) {
                        switch (**argv) {