gunzip -c works again
authorGlenn L McGrath <bug1@ihug.co.nz>
Thu, 29 Mar 2001 00:57:20 +0000 (00:57 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Thu, 29 Mar 2001 00:57:20 +0000 (00:57 -0000)
archival/gunzip.c
gunzip.c

index 93f7c351e6f8ad6a60f1d631ecf97992c7a56216..d457b750cae50b2bfe6f7beb747a92762c4a0351 100644 (file)
@@ -1080,32 +1080,31 @@ extern int gunzip_main(int argc, char **argv)
                if (argc != 2) {
                        show_usage();
                }
-               flags |= gunzip_force;
-               flags |= gunzip_to_stdout;
+               flags |= (gunzip_force | gunzip_to_stdout);
        } else
 #endif
-       {
+       if (strcmp(applet_name, "gunzip") == 0) {
                /* workout flags as regular gunzip */
                /* set default flags */
                if (argc == 1) {
                        flags |= (gunzip_from_stdin | gunzip_to_stdout);
-               }
-
-               /* Parse any options */
-               while ((opt = getopt(argc, argv, "ctfh")) != -1) {
-                       switch (opt) {
-                       case 'c':
-                               flags |= gunzip_to_stdout;
-                               break;
-                       case 'f':
-                               flags |= gunzip_force;
-                               break;
-                       case 't':
-                               flags |= gunzip_test;
-                               break;
-                       case 'h':
-                       default:
-                               show_usage(); /* exit's inside usage */
+               } else {
+                       /* Parse any options */
+                       while ((opt = getopt(argc, argv, "ctfh")) != -1) {
+                               switch (opt) {
+                               case 'c':
+                                       flags |= gunzip_to_stdout;
+                                       break;
+                               case 'f':
+                                       flags |= gunzip_force;
+                                       break;
+                               case 't':
+                                       flags |= gunzip_test;
+                                       break;
+                               case 'h':
+                               default:
+                                       show_usage(); /* exit's inside usage */
+                               }
                        }
                }
        }
@@ -1116,7 +1115,6 @@ extern int gunzip_main(int argc, char **argv)
                if ((flags & gunzip_force) == 0) {
                        error_msg_and_die("data not written to terminal. Use -f to force it.");
                }
-               strcpy(if_name, "stdin");
        } else {
                if_name = strdup(argv[optind]);
                /* Open input file */
@@ -1135,8 +1133,6 @@ extern int gunzip_main(int argc, char **argv)
                if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) {
                        error_msg_and_die("data not written to terminal. Use -f to force it.");
                }
-
-               strcpy(of_name, "stdout");
        } else if (flags & gunzip_test) {
                out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
        } else {
index 93f7c351e6f8ad6a60f1d631ecf97992c7a56216..d457b750cae50b2bfe6f7beb747a92762c4a0351 100644 (file)
--- a/gunzip.c
+++ b/gunzip.c
@@ -1080,32 +1080,31 @@ extern int gunzip_main(int argc, char **argv)
                if (argc != 2) {
                        show_usage();
                }
-               flags |= gunzip_force;
-               flags |= gunzip_to_stdout;
+               flags |= (gunzip_force | gunzip_to_stdout);
        } else
 #endif
-       {
+       if (strcmp(applet_name, "gunzip") == 0) {
                /* workout flags as regular gunzip */
                /* set default flags */
                if (argc == 1) {
                        flags |= (gunzip_from_stdin | gunzip_to_stdout);
-               }
-
-               /* Parse any options */
-               while ((opt = getopt(argc, argv, "ctfh")) != -1) {
-                       switch (opt) {
-                       case 'c':
-                               flags |= gunzip_to_stdout;
-                               break;
-                       case 'f':
-                               flags |= gunzip_force;
-                               break;
-                       case 't':
-                               flags |= gunzip_test;
-                               break;
-                       case 'h':
-                       default:
-                               show_usage(); /* exit's inside usage */
+               } else {
+                       /* Parse any options */
+                       while ((opt = getopt(argc, argv, "ctfh")) != -1) {
+                               switch (opt) {
+                               case 'c':
+                                       flags |= gunzip_to_stdout;
+                                       break;
+                               case 'f':
+                                       flags |= gunzip_force;
+                                       break;
+                               case 't':
+                                       flags |= gunzip_test;
+                                       break;
+                               case 'h':
+                               default:
+                                       show_usage(); /* exit's inside usage */
+                               }
                        }
                }
        }
@@ -1116,7 +1115,6 @@ extern int gunzip_main(int argc, char **argv)
                if ((flags & gunzip_force) == 0) {
                        error_msg_and_die("data not written to terminal. Use -f to force it.");
                }
-               strcpy(if_name, "stdin");
        } else {
                if_name = strdup(argv[optind]);
                /* Open input file */
@@ -1135,8 +1133,6 @@ extern int gunzip_main(int argc, char **argv)
                if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) {
                        error_msg_and_die("data not written to terminal. Use -f to force it.");
                }
-
-               strcpy(of_name, "stdout");
        } else if (flags & gunzip_test) {
                out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
        } else {