aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-09 20:49:55 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-03-09 20:49:55 +0000
commit6e56bb76612c425314ba9c270725dc853c822196 (patch)
tree14bbc1d2a6a996403bc823be203a2283caf0d95f
parent533cba2f3483a82e4ba18768219faff391759f99 (diff)
downloadbusybox-w32-6e56bb76612c425314ba9c270725dc853c822196.tar.gz
busybox-w32-6e56bb76612c425314ba9c270725dc853c822196.tar.bz2
busybox-w32-6e56bb76612c425314ba9c270725dc853c822196.zip
bbunzip: size optimization: ~90 bytes
git-svn-id: svn://busybox.net/trunk/busybox@18057 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--archival/Kbuild8
-rw-r--r--archival/bbunzip.c35
2 files changed, 21 insertions, 22 deletions
diff --git a/archival/Kbuild b/archival/Kbuild
index 50b90fa93..011feee5f 100644
--- a/archival/Kbuild
+++ b/archival/Kbuild
@@ -8,15 +8,15 @@ libs-y += libunarchive/
8 8
9lib-y:= 9lib-y:=
10lib-$(CONFIG_AR) += ar.o 10lib-$(CONFIG_AR) += ar.o
11lib-$(CONFIG_BUNZIP2) += bbunzip.o ### bunzip2.o 11lib-$(CONFIG_BUNZIP2) += bbunzip.o
12lib-$(CONFIG_UNLZMA) += bbunzip.o ### unlzma.o 12lib-$(CONFIG_UNLZMA) += bbunzip.o
13lib-$(CONFIG_CPIO) += cpio.o 13lib-$(CONFIG_CPIO) += cpio.o
14lib-$(CONFIG_DPKG) += dpkg.o 14lib-$(CONFIG_DPKG) += dpkg.o
15lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o 15lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
16lib-$(CONFIG_GUNZIP) += bbunzip.o ### gunzip.o 16lib-$(CONFIG_GUNZIP) += bbunzip.o
17lib-$(CONFIG_GZIP) += gzip.o 17lib-$(CONFIG_GZIP) += gzip.o
18lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o 18lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
19lib-$(CONFIG_RPM) += rpm.o 19lib-$(CONFIG_RPM) += rpm.o
20lib-$(CONFIG_TAR) += tar.o 20lib-$(CONFIG_TAR) += tar.o
21lib-$(CONFIG_UNCOMPRESS) += bbunzip.o ### uncompress.o 21lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
22lib-$(CONFIG_UNZIP) += unzip.o 22lib-$(CONFIG_UNZIP) += unzip.o
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 3dff946a1..b922fd373 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -127,13 +127,11 @@ int unpack(char **argv,
127 return exitcode; 127 return exitcode;
128} 128}
129 129
130#if ENABLE_BUNZIP2
131
132static 130static
133char* make_new_name_bunzip2(char *filename) 131char* make_new_name_generic(char *filename, const char *expected_ext)
134{ 132{
135 char *extension = strrchr(filename, '.'); 133 char *extension = strrchr(filename, '.');
136 if (!extension || strcmp(extension, ".bz2") != 0) { 134 if (!extension || strcmp(extension + 1, expected_ext) != 0) {
137 /* Mimic GNU gunzip - "real" bunzip2 tries to */ 135 /* Mimic GNU gunzip - "real" bunzip2 tries to */
138 /* unpack file anyway, to file.out */ 136 /* unpack file anyway, to file.out */
139 return NULL; 137 return NULL;
@@ -142,6 +140,14 @@ char* make_new_name_bunzip2(char *filename)
142 return filename; 140 return filename;
143} 141}
144 142
143#if ENABLE_BUNZIP2
144
145static
146char* make_new_name_bunzip2(char *filename)
147{
148 return make_new_name_generic(filename, "bz2");
149}
150
145static 151static
146USE_DESKTOP(long long) int unpack_bunzip2(void) 152USE_DESKTOP(long long) int unpack_bunzip2(void)
147{ 153{
@@ -200,13 +206,14 @@ char* make_new_name_gunzip(char *filename)
200 if (!extension) 206 if (!extension)
201 return NULL; 207 return NULL;
202 208
203 if (strcmp(extension, ".gz") == 0 209 extension++;
210 if (strcmp(extension, "tgz" + 1) == 0
204#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS 211#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
205 || strcmp(extension, ".Z") == 0 212 || strcmp(extension, "Z") == 0
206#endif 213#endif
207 ) { 214 ) {
208 *extension = '\0'; 215 extension[-1] = '\0';
209 } else if(strcmp(extension, ".tgz") == 0) { 216 } else if(strcmp(extension, "tgz") == 0) {
210 filename = xstrdup(filename); 217 filename = xstrdup(filename);
211 extension = strrchr(filename, '.'); 218 extension = strrchr(filename, '.');
212 extension[2] = 'a'; 219 extension[2] = 'a';
@@ -275,11 +282,7 @@ int gunzip_main(int argc, char **argv)
275static 282static
276char* make_new_name_unlzma(char *filename) 283char* make_new_name_unlzma(char *filename)
277{ 284{
278 char *extension = strrchr(filename, '.'); 285 return make_new_name_generic(filename, "lzma");
279 if (!extension || strcmp(extension, ".lzma") != 0)
280 return NULL;
281 *extension = '\0';
282 return filename;
283} 286}
284 287
285static 288static
@@ -315,11 +318,7 @@ int unlzma_main(int argc, char **argv)
315static 318static
316char* make_new_name_uncompress(char *filename) 319char* make_new_name_uncompress(char *filename)
317{ 320{
318 char *extension = strrchr(filename, '.'); 321 return make_new_name_generic(filename, "Z");
319 if (!extension || strcmp(extension, ".Z") != 0)
320 return NULL;
321 *extension = '\0';
322 return filename;
323} 322}
324 323
325static 324static