tar: code shrink

function                                             old     new   delta
packed_usage                                       31863   31853     -10
tar_main                                            1013    1002     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-21)             Total: -21 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-11-13 01:56:51 +01:00
parent 931cf64ae7
commit a07fead823

View File

@ -751,7 +751,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
#endif #endif
//usage:#define tar_trivial_usage //usage:#define tar_trivial_usage
//usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt" //usage: IF_FEATURE_TAR_CREATE("c|") "x|t [-"
//usage: IF_FEATURE_SEAMLESS_Z("Z") //usage: IF_FEATURE_SEAMLESS_Z("Z")
//usage: IF_FEATURE_SEAMLESS_GZ("z") //usage: IF_FEATURE_SEAMLESS_GZ("z")
//usage: IF_FEATURE_SEAMLESS_XZ("J") //usage: IF_FEATURE_SEAMLESS_XZ("J")
@ -773,34 +773,34 @@ static llist_t *append_file_list_to_list(llist_t *list)
//usage: ) //usage: )
//usage: "\n x Extract" //usage: "\n x Extract"
//usage: "\n t List" //usage: "\n t List"
//usage: "\n f FILE Name of TARFILE ('-' for stdin/out)" //usage: "\n -f FILE Name of TARFILE ('-' for stdin/out)"
//usage: "\n C DIR Change to DIR before operation" //usage: "\n -C DIR Change to DIR before operation"
//usage: "\n v Verbose" //usage: "\n -v Verbose"
//usage: IF_FEATURE_SEAMLESS_Z( //usage: IF_FEATURE_SEAMLESS_Z(
//usage: "\n Z (De)compress using compress" //usage: "\n -Z (De)compress using compress"
//usage: ) //usage: )
//usage: IF_FEATURE_SEAMLESS_GZ( //usage: IF_FEATURE_SEAMLESS_GZ(
//usage: "\n z (De)compress using gzip" //usage: "\n -z (De)compress using gzip"
//usage: ) //usage: )
//usage: IF_FEATURE_SEAMLESS_XZ( //usage: IF_FEATURE_SEAMLESS_XZ(
//usage: "\n J (De)compress using xz" //usage: "\n -J (De)compress using xz"
//usage: ) //usage: )
//usage: IF_FEATURE_SEAMLESS_BZ2( //usage: IF_FEATURE_SEAMLESS_BZ2(
//usage: "\n j (De)compress using bzip2" //usage: "\n -j (De)compress using bzip2"
//usage: ) //usage: )
//usage: IF_FEATURE_SEAMLESS_LZMA( //usage: IF_FEATURE_SEAMLESS_LZMA(
//usage: "\n a (De)compress using lzma" //usage: "\n -a (De)compress using lzma"
//usage: ) //usage: )
//usage: "\n O Extract to stdout" //usage: "\n -O Extract to stdout"
//usage: IF_FEATURE_TAR_CREATE( //usage: IF_FEATURE_TAR_CREATE(
//usage: "\n h Follow symlinks" //usage: "\n -h Follow symlinks"
//usage: ) //usage: )
//usage: IF_FEATURE_TAR_NOPRESERVE_TIME( //usage: IF_FEATURE_TAR_NOPRESERVE_TIME(
//usage: "\n m Don't restore mtime" //usage: "\n -m Don't restore mtime"
//usage: ) //usage: )
//usage: IF_FEATURE_TAR_FROM( //usage: IF_FEATURE_TAR_FROM(
//usage: "\n T FILE File with names to include" //usage: "\n -T FILE File with names to include"
//usage: "\n X FILE File with glob patterns to exclude" //usage: "\n -X FILE File with glob patterns to exclude"
//usage: IF_FEATURE_TAR_LONG_OPTIONS( //usage: IF_FEATURE_TAR_LONG_OPTIONS(
//usage: "\n --exclude PATTERN Glob pattern to exclude" //usage: "\n --exclude PATTERN Glob pattern to exclude"
//usage: ) //usage: )
@ -967,11 +967,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
puts("tar (busybox) " BB_VER); puts("tar (busybox) " BB_VER);
return 0; return 0;
} }
if (argv[1] && argv[1][0] != '-') { #endif
if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0') {
/* Compat: /* Compat:
* 1st argument without dash handles options with parameters * 1st argument without dash handles options with parameters
* differently from dashed one: it takes *next argv[i]* * differently from dashed one: it takes *next argv[i]*
* as paramenter even if there are more chars in 1st argument: * as parameter even if there are more chars in 1st argument:
* "tar fx TARFILE" - "x" is not taken as f's param * "tar fx TARFILE" - "x" is not taken as f's param
* but is interpreted as -x option * but is interpreted as -x option
* "tar -xf TARFILE" - dashed equivalent of the above * "tar -xf TARFILE" - dashed equivalent of the above
@ -991,11 +992,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
} }
*f = 'f'; *f = 'f';
} }
} /* Prepend '-' to the first argument */
#endif
/* Prepend '-' to the first argument if required */
if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0')
argv[1] = xasprintf("-%s", argv[1]); argv[1] = xasprintf("-%s", argv[1]);
}
opt = GETOPT32(argv, "^" opt = GETOPT32(argv, "^"
"txC:f:Oopvk" "txC:f:Oopvk"
IF_FEATURE_TAR_CREATE( "ch" ) IF_FEATURE_TAR_CREATE( "ch" )