aboutsummaryrefslogtreecommitdiff
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
parent081df62b921cf17f1d4c4e0214abfa273c92cfde (diff)
downloadbusybox-w32-7ac868460a90e1de4a2f45229f22f1cd07370c05.tar.gz
busybox-w32-7ac868460a90e1de4a2f45229f22f1cd07370c05.tar.bz2
busybox-w32-7ac868460a90e1de4a2f45229f22f1cd07370c05.zip
gunzip'ing many files to stdout works now
Fixed a missing initialisation and made a for loop more readable.
-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)
75{ 75{
76 FILE *in_file, *out_file; 76 FILE *in_file, *out_file;
77 struct stat stat_buf; 77 struct stat stat_buf;
78 const char *delete_path; 78 const char *delete_path = NULL;
79 char *out_path = NULL; 79 char *out_path = NULL;
80 80
81 if (path == NULL || strcmp (path, "-") == 0) { 81 if (path == NULL || strcmp (path, "-") == 0) {
@@ -142,8 +142,10 @@ static int gunzip_file (const char *path, int flags)
142 delete_path = out_path; 142 delete_path = out_path;
143 } 143 }
144 144
145 fclose(out_file); 145 if (out_file != stdout)
146 fclose(in_file); 146 fclose(out_file);
147 if (in_file != stdin)
148 fclose(in_file);
147 149
148 if (delete_path && !(flags & gunzip_test)) { 150 if (delete_path && !(flags & gunzip_test)) {
149 if (unlink(delete_path) < 0) { 151 if (unlink(delete_path) < 0) {
@@ -194,10 +196,11 @@ extern int gunzip_main(int argc, char **argv)
194 if (optind == argc) { 196 if (optind == argc) {
195 if (gunzip_file (NULL, flags) < 0) 197 if (gunzip_file (NULL, flags) < 0)
196 status = EXIT_FAILURE; 198 status = EXIT_FAILURE;
197 } else 199 } else {
198 for (i = optind; i < argc; i++) 200 for (i = optind; i < argc; i++) {
199 if (gunzip_file (argv[i], flags) < 0) 201 if (gunzip_file (argv[i], flags) < 0)
200 status = EXIT_FAILURE; 202 status = EXIT_FAILURE;
201 203 }
204 }
202 return status; 205 return status;
203} 206}