svn commit: trunk/busybox/archival

vda at busybox.net vda at busybox.net
Wed Mar 7 23:22:47 UTC 2007


Author: vda
Date: 2007-03-07 15:22:47 -0800 (Wed, 07 Mar 2007)
New Revision: 18031

Log:
bbunzip: fix comments to match reality


Modified:
   trunk/busybox/archival/bbunzip.c


Changeset:
Modified: trunk/busybox/archival/bbunzip.c
===================================================================
--- trunk/busybox/archival/bbunzip.c	2007-03-07 23:08:26 UTC (rev 18030)
+++ trunk/busybox/archival/bbunzip.c	2007-03-07 23:22:47 UTC (rev 18031)
@@ -42,14 +42,14 @@
 {
 	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 */
 
-		filename = *argv; /* can be NULL - 'streaming' bunzip2 */
 		if (filename && LONE_DASH(filename))
 			filename = NULL;
 
@@ -73,22 +73,21 @@
 			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 @@
 			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 @@
 					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 *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';




More information about the busybox-cvs mailing list