aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-07 23:22:47 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-07 23:22:47 +0000
commit0e2270ac33a9b6c87044d4d2f66945195be39907 (patch)
treeda4e7e33394cfa4b5ab1217bbe24574cbc842bea
parent7db358cb69247b35b6e9cb12d5c48a8fa4aa9eca (diff)
downloadbusybox-w32-0e2270ac33a9b6c87044d4d2f66945195be39907.tar.gz
busybox-w32-0e2270ac33a9b6c87044d4d2f66945195be39907.tar.bz2
busybox-w32-0e2270ac33a9b6c87044d4d2f66945195be39907.zip
bbunzip: fix comments to match reality
git-svn-id: svn://busybox.net/trunk/busybox@18031 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--archival/bbunzip.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 7ec8f4f0a..3dff946a1 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -42,14 +42,14 @@ int unpack(char **argv,
42{ 42{
43 struct stat stat_buf; 43 struct stat stat_buf;
44 USE_DESKTOP(long long) int status; 44 USE_DESKTOP(long long) int status;
45 char *filename; 45 char *filename, *new_name;
46 /* NB: new_name is *possibly* malloc'ed! */
47 smallint exitcode = 0; 46 smallint exitcode = 0;
48 47
49 do { 48 do {
50 char *new_name = NULL; 49 /* NB: new_name is *maybe* malloc'ed! */
51 50 new_name = NULL;
52 filename = *argv; /* can be NULL - 'streaming' bunzip2 */ 51 filename = *argv; /* can be NULL - 'streaming' bunzip2 */
52
53 if (filename && LONE_DASH(filename)) 53 if (filename && LONE_DASH(filename))
54 filename = NULL; 54 filename = NULL;
55 55
@@ -73,22 +73,21 @@ int unpack(char **argv,
73 filename = NULL; 73 filename = NULL;
74 } 74 }
75 75
76 /* Open dst unless -c, "-" or called as bzcat */ 76 /* Open dst if we are going to unpack to file */
77 if (filename) { 77 if (filename) {
78 new_name = make_new_name(filename); 78 new_name = make_new_name(filename);
79 if (!new_name) { 79 if (!new_name) {
80 bb_error_msg("%s: unknown suffix - ignored", filename); 80 bb_error_msg("%s: unknown suffix - ignored", filename);
81 goto err; 81 goto err;
82 } 82 }
83 /* O_EXCL: "real" bunzip2 doesn't overwrite files too */ 83 /* O_EXCL: "real" bunzip2 doesn't overwrite files */
84 /* TODO: "real" gunzip goes not bail out, but goes 84 /* GNU gunzip goes not bail out, but goes to next file */
85 * to next file */
86 if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL, 85 if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL,
87 stat_buf.st_mode)) 86 stat_buf.st_mode))
88 goto err; 87 goto err;
89 } 88 }
90 89
91 /* Check that the input is sane. */ 90 /* Check that the input is sane */
92 if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) { 91 if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) {
93 bb_error_msg_and_die("compressed data not read from terminal, " 92 bb_error_msg_and_die("compressed data not read from terminal, "
94 "use -f to force it"); 93 "use -f to force it");
@@ -102,14 +101,15 @@ int unpack(char **argv,
102 char *del = new_name; 101 char *del = new_name;
103 if (status >= 0) { 102 if (status >= 0) {
104 /* TODO: restore user/group/times here? */ 103 /* TODO: restore user/group/times here? */
105 /* delete _old_ file */ 104 /* Delete _compressed_ file */
106 del = filename; 105 del = filename;
107 /* Restore extension (unless tgz -> tar case) */ 106 /* restore extension (unless tgz -> tar case) */
108 if (new_name == filename) 107 if (new_name == filename)
109 filename[strlen(filename)] = '.'; 108 filename[strlen(filename)] = '.';
110 } 109 }
111 if (unlink(del) < 0) 110 if (unlink(del) < 0)
112 bb_perror_msg_and_die("cannot remove %s", del); 111 bb_perror_msg_and_die("cannot remove %s", del);
112
113#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */ 113#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
114 /* Extreme bloat for gunzip compat */ 114 /* Extreme bloat for gunzip compat */
115 if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) { 115 if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) {
@@ -117,6 +117,7 @@ int unpack(char **argv,
117 filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name); 117 filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name);
118 } 118 }
119#endif 119#endif
120
120 free_name: 121 free_name:
121 if (new_name != filename) 122 if (new_name != filename)
122 free(new_name); 123 free(new_name);
@@ -133,8 +134,8 @@ char* make_new_name_bunzip2(char *filename)
133{ 134{
134 char *extension = strrchr(filename, '.'); 135 char *extension = strrchr(filename, '.');
135 if (!extension || strcmp(extension, ".bz2") != 0) { 136 if (!extension || strcmp(extension, ".bz2") != 0) {
136 /* Mimic GNU gunzip ("real" bunzip2 tries to */ 137 /* Mimic GNU gunzip - "real" bunzip2 tries to */
137 /* unpack file anyway, to file.out) */ 138 /* unpack file anyway, to file.out */
138 return NULL; 139 return NULL;
139 } 140 }
140 *extension = '\0'; 141 *extension = '\0';