aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-07 23:22:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-07 23:22:47 +0000
commit6c939e0cb41a366e901063ede1672434886fc9c5 (patch)
treeda4e7e33394cfa4b5ab1217bbe24574cbc842bea
parent36b7e28fa08b27ba43ed7a1618499525635e2612 (diff)
downloadbusybox-6c939e0cb41a366e901063ede1672434886fc9c5.tar.gz
bbunzip: fix comments to match reality
-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,
{
struct stat stat_buf;
USE_DESKTOP(long long) int status;
- char *filename;
- /* NB: new_name is *possibly* malloc'ed! */
+ char *filename, *new_name;
smallint exitcode = 0;
do {
- char *new_name = NULL;
-
+ /* NB: new_name is *maybe* malloc'ed! */
+ new_name = NULL;
filename = *argv; /* can be NULL - 'streaming' bunzip2 */
+
if (filename && LONE_DASH(filename))
filename = NULL;
@@ -73,22 +73,21 @@ int unpack(char **argv,
filename = NULL;
}
- /* Open dst unless -c, "-" or called as bzcat */
+ /* Open dst if we are going to unpack to file */
if (filename) {
new_name = make_new_name(filename);
if (!new_name) {
bb_error_msg("%s: unknown suffix - ignored", filename);
goto err;
}
- /* O_EXCL: "real" bunzip2 doesn't overwrite files too */
- /* TODO: "real" gunzip goes not bail out, but goes
- * to next file */
+ /* O_EXCL: "real" bunzip2 doesn't overwrite files */
+ /* GNU gunzip goes not bail out, but goes to next file */
if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL,
stat_buf.st_mode))
goto err;
}
- /* Check that the input is sane. */
+ /* Check that the input is sane */
if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) {
bb_error_msg_and_die("compressed data not read from terminal, "
"use -f to force it");
@@ -102,14 +101,15 @@ int unpack(char **argv,
char *del = new_name;
if (status >= 0) {
/* TODO: restore user/group/times here? */
- /* delete _old_ file */
+ /* Delete _compressed_ file */
del = filename;
- /* Restore extension (unless tgz -> tar case) */
+ /* restore extension (unless tgz -> tar case) */
if (new_name == filename)
filename[strlen(filename)] = '.';
}
if (unlink(del) < 0)
bb_perror_msg_and_die("cannot remove %s", del);
+
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
/* Extreme bloat for gunzip compat */
if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) {
@@ -117,6 +117,7 @@ int unpack(char **argv,
filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name);
}
#endif
+
free_name:
if (new_name != filename)
free(new_name);
@@ -133,8 +134,8 @@ char* make_new_name_bunzip2(char *filename)
{
char *extension = strrchr(filename, '.');
if (!extension || strcmp(extension, ".bz2") != 0) {
- /* Mimic GNU gunzip ("real" bunzip2 tries to */
- /* unpack file anyway, to file.out) */
+ /* Mimic GNU gunzip - "real" bunzip2 tries to */
+ /* unpack file anyway, to file.out */
return NULL;
}
*extension = '\0';