pointless whitespace/comment fixes, no code changes
[oweals/busybox.git] / archival / gzip.c
index bda4ae102e5e9a8e736cd958ac8fb7d70e31a686..43804b2e4060fd2a0cd447e501595e6338d0df51 100644 (file)
@@ -40,6 +40,7 @@ aa:      85.1% -- replaced with aa.gz
 */
 
 #include "libbb.h"
+#include "unarchive.h"
 
 
 /* ===========================================================================
@@ -686,7 +687,7 @@ static void check_match(IPos start, IPos match, int length)
        if (verbose > 1) {
                bb_error_msg("\\[%d,%d]", start - match, length);
                do {
-                       putc(G1.window[start++], stderr);
+                       fputc(G1.window[start++], stderr);
                } while (--length != 0);
        }
 }
@@ -2014,7 +2015,7 @@ char* make_new_name_gzip(char *filename)
 }
 
 static
-USE_DESKTOP(long long) int pack_gzip(void)
+USE_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
 {
        struct stat s;
 
@@ -2025,26 +2026,44 @@ USE_DESKTOP(long long) int pack_gzip(void)
        return 0;
 }
 
-int gzip_main(int argc, char **argv);
+/*
+ * Linux kernel build uses gzip -d -n. We accept and ignore it.
+ * Man page says:
+ * -n --no-name
+ * gzip: do not save the original file name and time stamp.
+ * (The original name is always saved if the name had to be truncated.)
+ * gunzip: do not restore the original file name/time even if present
+ * (remove only the gzip suffix from the compressed file name).
+ * This option is the default when decompressing.
+ * -N --name
+ * gzip: always save the original file name and time stamp (this is the default)
+ * gunzip: restore the original file name and time stamp if present.
+ */
+
+int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+#if ENABLE_GUNZIP
 int gzip_main(int argc, char **argv)
+#else
+int gzip_main(int argc UNUSED_PARAM, char **argv)
+#endif
 {
        unsigned opt;
 
        /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
-       opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
-       option_mask32 &= 0x7; /* Clear -d, ignore -q, -0..9 */
-       //if (opt & 0x1) // -c
-       //if (opt & 0x2) // -f
-       //if (opt & 0x4) // -v
+       opt = getopt32(argv, "cfv" USE_GUNZIP("dt") "q123456789n");
 #if ENABLE_GUNZIP /* gunzip_main may not be visible... */
-       if (opt & 0x8) { // -d
+       if (opt & 0x18) // -d and/or -t
                return gunzip_main(argc, argv);
-       }
 #endif
+       option_mask32 &= 0x7; /* ignore -q, -0..9 */
+       //if (opt & 0x1) // -c
+       //if (opt & 0x2) // -f
+       //if (opt & 0x4) // -v
        argv += optind;
 
-       PTR_TO_GLOBALS = xzalloc(sizeof(struct globals) + sizeof(struct globals2))
-                       + sizeof(struct globals);
+       SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+                       + sizeof(struct globals));
+       barrier();
        G2.l_desc.dyn_tree    = G2.dyn_ltree;
        G2.l_desc.static_tree = G2.static_ltree;
        G2.l_desc.extra_bits  = extra_lbits;