ifupdown: save some 100+ bytes of code in addstr()
[oweals/busybox.git] / archival / bunzip2.c
index 9810e029010196cad6323f8a39828132a86957db..757001fe463586ec5b8411d9761836b897c5bc98 100644 (file)
 
 int bunzip2_main(int argc, char **argv)
 {
+       USE_DESKTOP(long long) int status;
        char *filename;
-       unsigned long opt;
-       int status, src_fd, dst_fd;
+       unsigned opt;
+       int src_fd, dst_fd;
 
-       opt = bb_getopt_ulflags(argc, argv, "cf");
+       opt = getopt32(argc, argv, "cf");
 
        /* Set input filename and number */
        filename = argv[optind];
@@ -31,12 +32,13 @@ int bunzip2_main(int argc, char **argv)
        }
 
        /* if called as bzcat force the stdout flag */
-       if ((opt & BUNZIP2_OPT_STDOUT) || bb_applet_name[2] == 'c')
+       if ((opt & BUNZIP2_OPT_STDOUT) || applet_name[2] == 'c')
                filename = 0;
 
        /* Check that the input is sane.  */
        if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
-               bb_error_msg_and_die("Compressed data not read from terminal.  Use -f to force it.");
+               bb_error_msg_and_die("compressed data not read from terminal, "
+                               "use -f to force it");
        }
 
        if (filename) {
@@ -45,7 +47,7 @@ int bunzip2_main(int argc, char **argv)
                 * strlen may be less than 4 */
                char *extension = strrchr(filename, '.');
                if (!extension || strcmp(extension, ".bz2") != 0) {
-                       bb_error_msg_and_die("Invalid extension");
+                       bb_error_msg_and_die("invalid extension");
                }
                xstat(filename, &stat_buf);
                *extension = '\0';
@@ -53,10 +55,10 @@ int bunzip2_main(int argc, char **argv)
                                stat_buf.st_mode);
        } else dst_fd = STDOUT_FILENO;
        status = uncompressStream(src_fd, dst_fd);
-       if(filename) {
-               if (!status) filename[strlen(filename)] = '.';
+       if (filename) {
+               if (status >= 0) filename[strlen(filename)] = '.';
                if (unlink(filename) < 0) {
-                       bb_error_msg_and_die("Couldn't remove %s", filename);
+                       bb_error_msg_and_die("cannot remove %s", filename);
                }
        }