aboutsummaryrefslogtreecommitdiff
path: root/archival/gunzip.c
diff options
context:
space:
mode:
authorRobert Griebl <griebl@gmx.de>2002-05-15 21:57:42 +0000
committerRobert Griebl <griebl@gmx.de>2002-05-15 21:57:42 +0000
commit7ac868460a90e1de4a2f45229f22f1cd07370c05 (patch)
tree270f8530b26b0df5a05abd6102126bbe6b37e65b /archival/gunzip.c
parent081df62b921cf17f1d4c4e0214abfa273c92cfde (diff)
downloadbusybox-7ac868460a90e1de4a2f45229f22f1cd07370c05.tar.gz
gunzip'ing many files to stdout works now
Fixed a missing initialisation and made a for loop more readable.
Diffstat (limited to 'archival/gunzip.c')
-rw-r--r--archival/gunzip.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c
index 032b43c2c..83ed5e84a 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -75,7 +75,7 @@ static int gunzip_file (const char *path, int flags)
{
FILE *in_file, *out_file;
struct stat stat_buf;
- const char *delete_path;
+ const char *delete_path = NULL;
char *out_path = NULL;
if (path == NULL || strcmp (path, "-") == 0) {
@@ -142,8 +142,10 @@ static int gunzip_file (const char *path, int flags)
delete_path = out_path;
}
- fclose(out_file);
- fclose(in_file);
+ if (out_file != stdout)
+ fclose(out_file);
+ if (in_file != stdin)
+ fclose(in_file);
if (delete_path && !(flags & gunzip_test)) {
if (unlink(delete_path) < 0) {
@@ -194,10 +196,11 @@ extern int gunzip_main(int argc, char **argv)
if (optind == argc) {
if (gunzip_file (NULL, flags) < 0)
status = EXIT_FAILURE;
- } else
- for (i = optind; i < argc; i++)
+ } else {
+ for (i = optind; i < argc; i++) {
if (gunzip_file (argv[i], flags) < 0)
status = EXIT_FAILURE;
-
+ }
+ }
return status;
}