Fix spelling errors.
[oweals/busybox.git] / tar.c
diff --git a/tar.c b/tar.c
index e205763dbfc4108c403a7804ed6dbd4027d0f3f1..7d440f451c7c51ac426751100e8bc0c3a9976cd5 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -60,8 +60,9 @@ static const char tar_usage[] =
 #if defined BB_FEATURE_TAR_EXCLUDE
        "[--exclude File] "
 #endif
-       "[-f tarFile] [FILE] ...\n\n"
-       "Create, extract, or list files from a tar file.  Note that\n"
+       "[-f tarFile] [FILE] ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+       "\nCreate, extract, or list files from a tar file.  Note that\n"
        "this version of tar treats hard links as separate files.\n\n"
        "Main operation mode:\n"
 #ifdef BB_FEATURE_TAR_CREATE
@@ -77,6 +78,7 @@ static const char tar_usage[] =
 #endif
        "\nInformative output:\n"
        "\tv\t\tverbosely list files processed\n"
+#endif
        ;
 
 /* Tar file constants  */
@@ -171,7 +173,7 @@ extern int tar_main(int argc, char **argv)
 #if defined BB_FEATURE_TAR_EXCLUDE
        int excludeListSize=0;
 #endif
-       const char *tarName=NULL;
+       const char *tarName="-";
        int listFlag     = FALSE;
        int extractFlag  = FALSE;
        int createFlag   = FALSE;
@@ -183,15 +185,15 @@ extern int tar_main(int argc, char **argv)
                usage(tar_usage);
 
        /* Parse any options */
-       while (--argc > 0 && (**(++argv) != '\0')) {
+       while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
                stopIt=FALSE;
-               while (stopIt==FALSE && *(++(*argv))) {
+               while (stopIt==FALSE && *argv && **argv) {
                        switch (**argv) {
                                case 'f':
                                        if (--argc == 0) {
                                                fatalError( "Option requires an argument: No file specified\n");
                                        }
-                                       if (tarName != NULL)
+                                       if (*tarName != '-')
                                                fatalError( "Only one 'f' option allowed\n");
                                        tarName = *(++argv);
                                        if (tarName == NULL)
@@ -250,6 +252,7 @@ extern int tar_main(int argc, char **argv)
                                        fatalError( "Unknown tar flag '%c'\n" 
                                                        "Try `tar --help' for more information\n", **argv);
                        }
+                       ++(*argv);
                }
        }
 
@@ -263,7 +266,8 @@ extern int tar_main(int argc, char **argv)
 #else
                exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
 #endif
-       } else {
+       }
+       if (listFlag == TRUE || extractFlag == TRUE) {
                exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
        }