diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-20 02:51:09 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-20 02:51:09 +0100 |
commit | 94ca6943bc5266b0f3e6fc180814e184d7502442 (patch) | |
tree | 5034cffc64f6679c4478eabb6a37100c57cbc9cd | |
parent | 0d478334b3e6f644f26518c31117b25134a2678a (diff) | |
download | busybox-w32-94ca6943bc5266b0f3e6fc180814e184d7502442.tar.gz busybox-w32-94ca6943bc5266b0f3e6fc180814e184d7502442.tar.bz2 busybox-w32-94ca6943bc5266b0f3e6fc180814e184d7502442.zip |
*: small code shrinks and compile fix for unicode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/tar.c | 14 | ||||
-rw-r--r-- | editors/diff.c | 9 | ||||
-rw-r--r-- | editors/patch.c | 3 | ||||
-rw-r--r-- | include/usage.h | 13 | ||||
-rw-r--r-- | libbb/unicode.c | 3 |
5 files changed, 23 insertions, 19 deletions
diff --git a/archival/tar.c b/archival/tar.c index f16b4d671..3a940128b 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -770,8 +770,8 @@ enum { | |||
770 | OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T | 770 | OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T |
771 | OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X | 771 | OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X |
772 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z | 772 | OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z |
773 | OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m | ||
774 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z | 773 | OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z |
774 | OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m | ||
775 | OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner | 775 | OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner |
776 | OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions | 776 | OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions |
777 | OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite | 777 | OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite |
@@ -951,14 +951,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
951 | if (opt & OPT_COMPRESS) | 951 | if (opt & OPT_COMPRESS) |
952 | get_header_ptr = get_header_tar_Z; | 952 | get_header_ptr = get_header_tar_Z; |
953 | 953 | ||
954 | #if ENABLE_FEATURE_TAR_NOPRESERVE_TIME | ||
955 | if (opt & OPT_NOPRESERVE_TIME) | 954 | if (opt & OPT_NOPRESERVE_TIME) |
956 | tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE; | 955 | tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE; |
957 | #endif | ||
958 | 956 | ||
959 | #if ENABLE_FEATURE_TAR_FROM | 957 | #if ENABLE_FEATURE_TAR_FROM |
960 | tar_handle->reject = append_file_list_to_list(tar_handle->reject); | 958 | tar_handle->reject = append_file_list_to_list(tar_handle->reject); |
961 | #if ENABLE_FEATURE_TAR_LONG_OPTIONS | 959 | # if ENABLE_FEATURE_TAR_LONG_OPTIONS |
962 | /* Append excludes to reject */ | 960 | /* Append excludes to reject */ |
963 | while (excludes) { | 961 | while (excludes) { |
964 | llist_t *next = excludes->link; | 962 | llist_t *next = excludes->link; |
@@ -966,12 +964,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
966 | tar_handle->reject = excludes; | 964 | tar_handle->reject = excludes; |
967 | excludes = next; | 965 | excludes = next; |
968 | } | 966 | } |
969 | #endif | 967 | # endif |
970 | tar_handle->accept = append_file_list_to_list(tar_handle->accept); | 968 | tar_handle->accept = append_file_list_to_list(tar_handle->accept); |
971 | #endif | 969 | #endif |
972 | 970 | ||
973 | /* Setup an array of filenames to work with */ | 971 | /* Setup an array of filenames to work with */ |
974 | /* TODO: This is the same as in ar, separate function ? */ | 972 | /* TODO: This is the same as in ar, make a separate function? */ |
975 | while (*argv) { | 973 | while (*argv) { |
976 | /* kill trailing '/' unless the string is just "/" */ | 974 | /* kill trailing '/' unless the string is just "/" */ |
977 | char *cp = last_char_is(*argv, '/'); | 975 | char *cp = last_char_is(*argv, '/'); |
@@ -990,7 +988,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
990 | int flags = O_RDONLY; | 988 | int flags = O_RDONLY; |
991 | 989 | ||
992 | if (opt & OPT_CREATE) { | 990 | if (opt & OPT_CREATE) { |
993 | /* Make sure there is at least one file to tar up. */ | 991 | /* Make sure there is at least one file to tar up */ |
994 | if (tar_handle->accept == NULL) | 992 | if (tar_handle->accept == NULL) |
995 | bb_error_msg_and_die("empty archive"); | 993 | bb_error_msg_and_die("empty archive"); |
996 | 994 | ||
@@ -1022,7 +1020,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) | |||
1022 | signal(SIGCHLD, handle_SIGCHLD); | 1020 | signal(SIGCHLD, handle_SIGCHLD); |
1023 | #endif | 1021 | #endif |
1024 | 1022 | ||
1025 | /* create an archive */ | 1023 | /* Create an archive */ |
1026 | if (opt & OPT_CREATE) { | 1024 | if (opt & OPT_CREATE) { |
1027 | #if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 | 1025 | #if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 |
1028 | int zipMode = 0; | 1026 | int zipMode = 0; |
diff --git a/editors/diff.c b/editors/diff.c index 91109821e..2e3a455f7 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -432,7 +432,8 @@ static NOINLINE int *create_J(FILE_and_pos_t ft[2], int nlen[2], off_t *ix[2]) | |||
432 | token_t tok; | 432 | token_t tok; |
433 | size_t sz = 100; | 433 | size_t sz = 100; |
434 | nfile[i] = xmalloc((sz + 3) * sizeof(nfile[i][0])); | 434 | nfile[i] = xmalloc((sz + 3) * sizeof(nfile[i][0])); |
435 | fseeko(ft[i].ft_fp, 0, SEEK_SET); /* ft gets here without the correct position */ | 435 | /* ft gets here without the correct position, cant use seek_ft */ |
436 | fseeko(ft[i].ft_fp, 0, SEEK_SET); | ||
436 | 437 | ||
437 | nlen[i] = 0; | 438 | nlen[i] = 0; |
438 | /* We could zalloc nfile, but then zalloc starts showing in gprof at ~1% */ | 439 | /* We could zalloc nfile, but then zalloc starts showing in gprof at ~1% */ |
@@ -625,7 +626,7 @@ static bool diff(FILE* fp[2], char *file[2]) | |||
625 | } | 626 | } |
626 | if (idx < 0) | 627 | if (idx < 0) |
627 | continue; | 628 | continue; |
628 | if (!(option_mask32 & FLAG(q)) && !((option_mask32 & FLAG(B)) && !nonempty)) { | 629 | if (!(option_mask32 & (FLAG(q)+FLAG(B))) && !nonempty) { |
629 | struct context_vec *cvp = vec; | 630 | struct context_vec *cvp = vec; |
630 | int lowa = MAX(1, cvp->a - opt_U_context); | 631 | int lowa = MAX(1, cvp->a - opt_U_context); |
631 | int upb = MIN(nlen[0], vec[idx].b + opt_U_context); | 632 | int upb = MIN(nlen[0], vec[idx].b + opt_U_context); |
@@ -634,8 +635,8 @@ static bool diff(FILE* fp[2], char *file[2]) | |||
634 | 635 | ||
635 | if (!anychange) { | 636 | if (!anychange) { |
636 | /* Print the context/unidiff header first time through */ | 637 | /* Print the context/unidiff header first time through */ |
637 | printf("--- %s\n", label[0] ?: file[0]); | 638 | printf("--- %s\n", label[0] ? label[0] : file[0]); |
638 | printf("+++ %s\n", label[1] ?: file[1]); | 639 | printf("+++ %s\n", label[1] ? label[1] : file[1]); |
639 | } | 640 | } |
640 | 641 | ||
641 | printf("@@ -"); | 642 | printf("@@ -"); |
diff --git a/editors/patch.c b/editors/patch.c index ab3af3ce7..b36980fed 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -85,7 +85,6 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
85 | { | 85 | { |
86 | const char *p = "-1"; | 86 | const char *p = "-1"; |
87 | const char *i = "-"; /* compat */ | 87 | const char *i = "-"; /* compat */ |
88 | const char *g; /* unimplemented, default is "0" */ | ||
89 | #if ENABLE_LONG_OPTS | 88 | #if ENABLE_LONG_OPTS |
90 | static const char patch_longopts[] ALIGN1 = | 89 | static const char patch_longopts[] ALIGN1 = |
91 | "strip\0" Required_argument "p" | 90 | "strip\0" Required_argument "p" |
@@ -97,7 +96,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
97 | ; | 96 | ; |
98 | applet_long_options = patch_longopts; | 97 | applet_long_options = patch_longopts; |
99 | #endif | 98 | #endif |
100 | opt = getopt32(argv, "p:i:RNg:", &p, &i, &g); | 99 | opt = getopt32(argv, "p:i:RNg:", &p, &i, NULL); |
101 | if (opt & OPT_R) | 100 | if (opt & OPT_R) |
102 | plus = '-'; | 101 | plus = '-'; |
103 | patch_level = xatoi(p); /* can be negative! */ | 102 | patch_level = xatoi(p); /* can be negative! */ |
diff --git a/include/usage.h b/include/usage.h index 77b7b99bd..44cc83422 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -4406,9 +4406,9 @@ | |||
4406 | "nameserver 10.0.0.1\n" | 4406 | "nameserver 10.0.0.1\n" |
4407 | 4407 | ||
4408 | #define tar_trivial_usage \ | 4408 | #define tar_trivial_usage \ |
4409 | "-[" IF_FEATURE_TAR_CREATE("c") IF_FEATURE_SEAMLESS_GZ("z") \ | 4409 | "-[" IF_FEATURE_TAR_CREATE("c") "xt" IF_FEATURE_SEAMLESS_GZ("z") \ |
4410 | IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \ | 4410 | IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \ |
4411 | IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "xtvO] " \ | 4411 | IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "vO] " \ |
4412 | IF_FEATURE_TAR_FROM("[-X FILE] ") \ | 4412 | IF_FEATURE_TAR_FROM("[-X FILE] ") \ |
4413 | "[-f TARFILE] [-C DIR] [FILE]..." | 4413 | "[-f TARFILE] [-C DIR] [FILE]..." |
4414 | #define tar_full_usage "\n\n" \ | 4414 | #define tar_full_usage "\n\n" \ |
@@ -4417,7 +4417,8 @@ | |||
4417 | "or list files from a tar file\n" \ | 4417 | "or list files from a tar file\n" \ |
4418 | "\nOptions:" \ | 4418 | "\nOptions:" \ |
4419 | IF_FEATURE_TAR_CREATE( \ | 4419 | IF_FEATURE_TAR_CREATE( \ |
4420 | "\n c Create") \ | 4420 | "\n c Create" \ |
4421 | ) \ | ||
4421 | "\n x Extract" \ | 4422 | "\n x Extract" \ |
4422 | "\n t List" \ | 4423 | "\n t List" \ |
4423 | "\nArchive format selection:" \ | 4424 | "\nArchive format selection:" \ |
@@ -4434,16 +4435,18 @@ | |||
4434 | "\n Z Filter the archive through compress" \ | 4435 | "\n Z Filter the archive through compress" \ |
4435 | ) \ | 4436 | ) \ |
4436 | IF_FEATURE_TAR_NOPRESERVE_TIME( \ | 4437 | IF_FEATURE_TAR_NOPRESERVE_TIME( \ |
4437 | "\n m Do not extract files modified time" \ | 4438 | "\n m Do not restore mtime" \ |
4438 | ) \ | 4439 | ) \ |
4439 | "\nFile selection:" \ | 4440 | "\nFile selection:" \ |
4440 | "\n f Name of TARFILE or \"-\" for stdin" \ | 4441 | "\n f Name of TARFILE or \"-\" for stdin" \ |
4441 | "\n O Extract to stdout" \ | 4442 | "\n O Extract to stdout" \ |
4442 | IF_FEATURE_TAR_FROM( \ | 4443 | IF_FEATURE_TAR_FROM( \ |
4444 | IF_FEATURE_TAR_LONG_OPTIONS( \ | ||
4443 | "\n exclude File to exclude" \ | 4445 | "\n exclude File to exclude" \ |
4446 | ) \ | ||
4444 | "\n X File with names to exclude" \ | 4447 | "\n X File with names to exclude" \ |
4445 | ) \ | 4448 | ) \ |
4446 | "\n C Change to directory DIR before operation" \ | 4449 | "\n C Change to DIR before operation" \ |
4447 | "\n v Verbose" \ | 4450 | "\n v Verbose" \ |
4448 | 4451 | ||
4449 | #define tar_example_usage \ | 4452 | #define tar_example_usage \ |
diff --git a/libbb/unicode.c b/libbb/unicode.c index 9d316df04..80042957c 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c | |||
@@ -9,7 +9,10 @@ | |||
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | #include "unicode.h" | 10 | #include "unicode.h" |
11 | 11 | ||
12 | /* If it's not a constant... */ | ||
13 | #ifndef unicode_status | ||
12 | uint8_t unicode_status; | 14 | uint8_t unicode_status; |
15 | #endif | ||
13 | 16 | ||
14 | size_t FAST_FUNC bb_mbstrlen(const char *string) | 17 | size_t FAST_FUNC bb_mbstrlen(const char *string) |
15 | { | 18 | { |