*: small code shrinks and compile fix for unicode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
0d478334b3
commit
94ca6943bc
@ -770,8 +770,8 @@ enum {
|
|||||||
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
|
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
|
||||||
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
|
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
|
||||||
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
|
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
|
||||||
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
|
|
||||||
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
|
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
|
||||||
|
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
|
||||||
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
|
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
|
||||||
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
|
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
|
||||||
OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite
|
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)
|
|||||||
if (opt & OPT_COMPRESS)
|
if (opt & OPT_COMPRESS)
|
||||||
get_header_ptr = get_header_tar_Z;
|
get_header_ptr = get_header_tar_Z;
|
||||||
|
|
||||||
#if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
|
|
||||||
if (opt & OPT_NOPRESERVE_TIME)
|
if (opt & OPT_NOPRESERVE_TIME)
|
||||||
tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE;
|
tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLE_FEATURE_TAR_FROM
|
#if ENABLE_FEATURE_TAR_FROM
|
||||||
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
|
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
|
||||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
# if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||||
/* Append excludes to reject */
|
/* Append excludes to reject */
|
||||||
while (excludes) {
|
while (excludes) {
|
||||||
llist_t *next = excludes->link;
|
llist_t *next = excludes->link;
|
||||||
@ -966,12 +964,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
tar_handle->reject = excludes;
|
tar_handle->reject = excludes;
|
||||||
excludes = next;
|
excludes = next;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Setup an array of filenames to work with */
|
/* Setup an array of filenames to work with */
|
||||||
/* TODO: This is the same as in ar, separate function ? */
|
/* TODO: This is the same as in ar, make a separate function? */
|
||||||
while (*argv) {
|
while (*argv) {
|
||||||
/* kill trailing '/' unless the string is just "/" */
|
/* kill trailing '/' unless the string is just "/" */
|
||||||
char *cp = last_char_is(*argv, '/');
|
char *cp = last_char_is(*argv, '/');
|
||||||
@ -990,7 +988,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
int flags = O_RDONLY;
|
int flags = O_RDONLY;
|
||||||
|
|
||||||
if (opt & OPT_CREATE) {
|
if (opt & OPT_CREATE) {
|
||||||
/* Make sure there is at least one file to tar up. */
|
/* Make sure there is at least one file to tar up */
|
||||||
if (tar_handle->accept == NULL)
|
if (tar_handle->accept == NULL)
|
||||||
bb_error_msg_and_die("empty archive");
|
bb_error_msg_and_die("empty archive");
|
||||||
|
|
||||||
@ -1022,7 +1020,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
signal(SIGCHLD, handle_SIGCHLD);
|
signal(SIGCHLD, handle_SIGCHLD);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* create an archive */
|
/* Create an archive */
|
||||||
if (opt & OPT_CREATE) {
|
if (opt & OPT_CREATE) {
|
||||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||||
int zipMode = 0;
|
int zipMode = 0;
|
||||||
|
@ -432,7 +432,8 @@ static NOINLINE int *create_J(FILE_and_pos_t ft[2], int nlen[2], off_t *ix[2])
|
|||||||
token_t tok;
|
token_t tok;
|
||||||
size_t sz = 100;
|
size_t sz = 100;
|
||||||
nfile[i] = xmalloc((sz + 3) * sizeof(nfile[i][0]));
|
nfile[i] = xmalloc((sz + 3) * sizeof(nfile[i][0]));
|
||||||
fseeko(ft[i].ft_fp, 0, SEEK_SET); /* ft gets here without the correct position */
|
/* ft gets here without the correct position, cant use seek_ft */
|
||||||
|
fseeko(ft[i].ft_fp, 0, SEEK_SET);
|
||||||
|
|
||||||
nlen[i] = 0;
|
nlen[i] = 0;
|
||||||
/* We could zalloc nfile, but then zalloc starts showing in gprof at ~1% */
|
/* 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])
|
|||||||
}
|
}
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
continue;
|
continue;
|
||||||
if (!(option_mask32 & FLAG(q)) && !((option_mask32 & FLAG(B)) && !nonempty)) {
|
if (!(option_mask32 & (FLAG(q)+FLAG(B))) && !nonempty) {
|
||||||
struct context_vec *cvp = vec;
|
struct context_vec *cvp = vec;
|
||||||
int lowa = MAX(1, cvp->a - opt_U_context);
|
int lowa = MAX(1, cvp->a - opt_U_context);
|
||||||
int upb = MIN(nlen[0], vec[idx].b + opt_U_context);
|
int upb = MIN(nlen[0], vec[idx].b + opt_U_context);
|
||||||
@ -634,8 +635,8 @@ static bool diff(FILE* fp[2], char *file[2])
|
|||||||
|
|
||||||
if (!anychange) {
|
if (!anychange) {
|
||||||
/* Print the context/unidiff header first time through */
|
/* Print the context/unidiff header first time through */
|
||||||
printf("--- %s\n", label[0] ?: file[0]);
|
printf("--- %s\n", label[0] ? label[0] : file[0]);
|
||||||
printf("+++ %s\n", label[1] ?: file[1]);
|
printf("+++ %s\n", label[1] ? label[1] : file[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("@@ -");
|
printf("@@ -");
|
||||||
|
@ -85,7 +85,6 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
{
|
{
|
||||||
const char *p = "-1";
|
const char *p = "-1";
|
||||||
const char *i = "-"; /* compat */
|
const char *i = "-"; /* compat */
|
||||||
const char *g; /* unimplemented, default is "0" */
|
|
||||||
#if ENABLE_LONG_OPTS
|
#if ENABLE_LONG_OPTS
|
||||||
static const char patch_longopts[] ALIGN1 =
|
static const char patch_longopts[] ALIGN1 =
|
||||||
"strip\0" Required_argument "p"
|
"strip\0" Required_argument "p"
|
||||||
@ -97,7 +96,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
;
|
;
|
||||||
applet_long_options = patch_longopts;
|
applet_long_options = patch_longopts;
|
||||||
#endif
|
#endif
|
||||||
opt = getopt32(argv, "p:i:RNg:", &p, &i, &g);
|
opt = getopt32(argv, "p:i:RNg:", &p, &i, NULL);
|
||||||
if (opt & OPT_R)
|
if (opt & OPT_R)
|
||||||
plus = '-';
|
plus = '-';
|
||||||
patch_level = xatoi(p); /* can be negative! */
|
patch_level = xatoi(p); /* can be negative! */
|
||||||
|
@ -4406,9 +4406,9 @@
|
|||||||
"nameserver 10.0.0.1\n"
|
"nameserver 10.0.0.1\n"
|
||||||
|
|
||||||
#define tar_trivial_usage \
|
#define tar_trivial_usage \
|
||||||
"-[" IF_FEATURE_TAR_CREATE("c") IF_FEATURE_SEAMLESS_GZ("z") \
|
"-[" IF_FEATURE_TAR_CREATE("c") "xt" IF_FEATURE_SEAMLESS_GZ("z") \
|
||||||
IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \
|
IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a") \
|
||||||
IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "xtvO] " \
|
IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "vO] " \
|
||||||
IF_FEATURE_TAR_FROM("[-X FILE] ") \
|
IF_FEATURE_TAR_FROM("[-X FILE] ") \
|
||||||
"[-f TARFILE] [-C DIR] [FILE]..."
|
"[-f TARFILE] [-C DIR] [FILE]..."
|
||||||
#define tar_full_usage "\n\n" \
|
#define tar_full_usage "\n\n" \
|
||||||
@ -4417,7 +4417,8 @@
|
|||||||
"or list files from a tar file\n" \
|
"or list files from a tar file\n" \
|
||||||
"\nOptions:" \
|
"\nOptions:" \
|
||||||
IF_FEATURE_TAR_CREATE( \
|
IF_FEATURE_TAR_CREATE( \
|
||||||
"\n c Create") \
|
"\n c Create" \
|
||||||
|
) \
|
||||||
"\n x Extract" \
|
"\n x Extract" \
|
||||||
"\n t List" \
|
"\n t List" \
|
||||||
"\nArchive format selection:" \
|
"\nArchive format selection:" \
|
||||||
@ -4434,16 +4435,18 @@
|
|||||||
"\n Z Filter the archive through compress" \
|
"\n Z Filter the archive through compress" \
|
||||||
) \
|
) \
|
||||||
IF_FEATURE_TAR_NOPRESERVE_TIME( \
|
IF_FEATURE_TAR_NOPRESERVE_TIME( \
|
||||||
"\n m Do not extract files modified time" \
|
"\n m Do not restore mtime" \
|
||||||
) \
|
) \
|
||||||
"\nFile selection:" \
|
"\nFile selection:" \
|
||||||
"\n f Name of TARFILE or \"-\" for stdin" \
|
"\n f Name of TARFILE or \"-\" for stdin" \
|
||||||
"\n O Extract to stdout" \
|
"\n O Extract to stdout" \
|
||||||
IF_FEATURE_TAR_FROM( \
|
IF_FEATURE_TAR_FROM( \
|
||||||
|
IF_FEATURE_TAR_LONG_OPTIONS( \
|
||||||
"\n exclude File to exclude" \
|
"\n exclude File to exclude" \
|
||||||
|
) \
|
||||||
"\n X File with names to exclude" \
|
"\n X File with names to exclude" \
|
||||||
) \
|
) \
|
||||||
"\n C Change to directory DIR before operation" \
|
"\n C Change to DIR before operation" \
|
||||||
"\n v Verbose" \
|
"\n v Verbose" \
|
||||||
|
|
||||||
#define tar_example_usage \
|
#define tar_example_usage \
|
||||||
|
@ -9,7 +9,10 @@
|
|||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#include "unicode.h"
|
#include "unicode.h"
|
||||||
|
|
||||||
|
/* If it's not a constant... */
|
||||||
|
#ifndef unicode_status
|
||||||
uint8_t unicode_status;
|
uint8_t unicode_status;
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t FAST_FUNC bb_mbstrlen(const char *string)
|
size_t FAST_FUNC bb_mbstrlen(const char *string)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user