gunzip -c works again

This commit is contained in:
Glenn L McGrath 2001-03-29 00:57:20 +00:00
parent ae8ad35590
commit ed7a776538
2 changed files with 38 additions and 46 deletions

View File

@ -1080,17 +1080,15 @@ extern int gunzip_main(int argc, char **argv)
if (argc != 2) { if (argc != 2) {
show_usage(); show_usage();
} }
flags |= gunzip_force; flags |= (gunzip_force | gunzip_to_stdout);
flags |= gunzip_to_stdout;
} else } else
#endif #endif
{ if (strcmp(applet_name, "gunzip") == 0) {
/* workout flags as regular gunzip */ /* workout flags as regular gunzip */
/* set default flags */ /* set default flags */
if (argc == 1) { if (argc == 1) {
flags |= (gunzip_from_stdin | gunzip_to_stdout); flags |= (gunzip_from_stdin | gunzip_to_stdout);
} } else {
/* Parse any options */ /* Parse any options */
while ((opt = getopt(argc, argv, "ctfh")) != -1) { while ((opt = getopt(argc, argv, "ctfh")) != -1) {
switch (opt) { switch (opt) {
@ -1109,6 +1107,7 @@ extern int gunzip_main(int argc, char **argv)
} }
} }
} }
}
/* Set input filename and number */ /* Set input filename and number */
if (flags & gunzip_from_stdin) { if (flags & gunzip_from_stdin) {
@ -1116,7 +1115,6 @@ extern int gunzip_main(int argc, char **argv)
if ((flags & gunzip_force) == 0) { if ((flags & gunzip_force) == 0) {
error_msg_and_die("data not written to terminal. Use -f to force it."); error_msg_and_die("data not written to terminal. Use -f to force it.");
} }
strcpy(if_name, "stdin");
} else { } else {
if_name = strdup(argv[optind]); if_name = strdup(argv[optind]);
/* Open input file */ /* Open input file */
@ -1135,8 +1133,6 @@ extern int gunzip_main(int argc, char **argv)
if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) { if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) {
error_msg_and_die("data not written to terminal. Use -f to force it."); error_msg_and_die("data not written to terminal. Use -f to force it.");
} }
strcpy(of_name, "stdout");
} else if (flags & gunzip_test) { } else if (flags & gunzip_test) {
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */ out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
} else { } else {

View File

@ -1080,17 +1080,15 @@ extern int gunzip_main(int argc, char **argv)
if (argc != 2) { if (argc != 2) {
show_usage(); show_usage();
} }
flags |= gunzip_force; flags |= (gunzip_force | gunzip_to_stdout);
flags |= gunzip_to_stdout;
} else } else
#endif #endif
{ if (strcmp(applet_name, "gunzip") == 0) {
/* workout flags as regular gunzip */ /* workout flags as regular gunzip */
/* set default flags */ /* set default flags */
if (argc == 1) { if (argc == 1) {
flags |= (gunzip_from_stdin | gunzip_to_stdout); flags |= (gunzip_from_stdin | gunzip_to_stdout);
} } else {
/* Parse any options */ /* Parse any options */
while ((opt = getopt(argc, argv, "ctfh")) != -1) { while ((opt = getopt(argc, argv, "ctfh")) != -1) {
switch (opt) { switch (opt) {
@ -1109,6 +1107,7 @@ extern int gunzip_main(int argc, char **argv)
} }
} }
} }
}
/* Set input filename and number */ /* Set input filename and number */
if (flags & gunzip_from_stdin) { if (flags & gunzip_from_stdin) {
@ -1116,7 +1115,6 @@ extern int gunzip_main(int argc, char **argv)
if ((flags & gunzip_force) == 0) { if ((flags & gunzip_force) == 0) {
error_msg_and_die("data not written to terminal. Use -f to force it."); error_msg_and_die("data not written to terminal. Use -f to force it.");
} }
strcpy(if_name, "stdin");
} else { } else {
if_name = strdup(argv[optind]); if_name = strdup(argv[optind]);
/* Open input file */ /* Open input file */
@ -1135,8 +1133,6 @@ extern int gunzip_main(int argc, char **argv)
if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) { if (isatty(fileno(out_file)) && ((flags & gunzip_force) == 0)) {
error_msg_and_die("data not written to terminal. Use -f to force it."); error_msg_and_die("data not written to terminal. Use -f to force it.");
} }
strcpy(of_name, "stdout");
} else if (flags & gunzip_test) { } else if (flags & gunzip_test) {
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */ out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
} else { } else {