[PATCH] gzip: support long options. +106 bytes
Matheus Izvekov
mizvekov at gmail.com
Tue Jan 5 22:24:51 UTC 2010
>From d6856220eddd8f88b61182886477cf1e6def015f Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Tue, 5 Jan 2010 20:11:03 -0200
Subject: [PATCH] gzip: support long options. +106 bytes
function old new delta
gzip_longopts - 95 +95
gzip_main 189 200 +11
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 106/0) Total: 106 bytes
text data bss dec hex filename
856738 4177 9512 870427 d481b busybox_old
856844 4177 9512 870533 d4885 busybox_unstripped
---
archival/Config.in | 7 +++++++
archival/gzip.c | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/archival/Config.in b/archival/Config.in
index cae7f20..17d5c41 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -165,6 +165,13 @@ config GZIP
gzip is used to compress files.
It's probably the most widely used UNIX compression program.
+config FEATURE_GZIP_LONG_OPTIONS
+ bool "Enable long options"
+ default n
+ depends on GZIP && LONG_OPTS
+ help
+ Enable use of long options, increases size by about 106 Bytes
+
config LZOP
bool "lzop"
default n
diff --git a/archival/gzip.c b/archival/gzip.c
index 7150569..dcfd945 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -2043,6 +2043,23 @@ IF_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
return 0;
}
+#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
+static const char gzip_longopts[] ALIGN1 =
+ "stdout\0" No_argument "c"
+ "to-stdout\0" No_argument "c"
+ "force\0" No_argument "f"
+ "verbose\0" No_argument "v"
+#if ENABLE_GUNZIP
+ "decompress\0" No_argument "d"
+ "uncompress\0" No_argument "d"
+ "test\0" No_argument "t"
+#endif
+ "quiet\0" No_argument "q"
+ "fast\0" No_argument "1"
+ "best\0" No_argument "9"
+ ;
+#endif
+
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
@@ -2066,6 +2083,9 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
{
unsigned opt;
+#if ENABLE_FEATURE_GZIP_LONG_OPTIONS
+ applet_long_options = gzip_longopts;
+#endif
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "q123456789n");
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
--
1.6.6
More information about the busybox
mailing list