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_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_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_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
if (opt & OPT_COMPRESS)
get_header_ptr = get_header_tar_Z;
-#if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
if (opt & OPT_NOPRESERVE_TIME)
tar_handle->ah_flags &= ~ARCHIVE_RESTORE_DATE;
-#endif
#if ENABLE_FEATURE_TAR_FROM
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 */
while (excludes) {
llist_t *next = excludes->link;
tar_handle->reject = excludes;
excludes = next;
}
-#endif
+# endif
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
#endif
/* 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) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(*argv, '/');
int flags = O_RDONLY;
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)
bb_error_msg_and_die("empty archive");
signal(SIGCHLD, handle_SIGCHLD);
#endif
- /* create an archive */
+ /* Create an archive */
if (opt & OPT_CREATE) {
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
int zipMode = 0;
token_t tok;
size_t sz = 100;
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;
/* We could zalloc nfile, but then zalloc starts showing in gprof at ~1% */
}
if (idx < 0)
continue;
- if (!(option_mask32 & FLAG(q)) && !((option_mask32 & FLAG(B)) && !nonempty)) {
+ if (!(option_mask32 & (FLAG(q)+FLAG(B))) && !nonempty) {
struct context_vec *cvp = vec;
int lowa = MAX(1, cvp->a - opt_U_context);
int upb = MIN(nlen[0], vec[idx].b + opt_U_context);
if (!anychange) {
/* Print the context/unidiff header first time through */
- printf("--- %s\n", label[0] ?: file[0]);
- printf("+++ %s\n", label[1] ?: file[1]);
+ printf("--- %s\n", label[0] ? label[0] : file[0]);
+ printf("+++ %s\n", label[1] ? label[1] : file[1]);
}
printf("@@ -");
{
const char *p = "-1";
const char *i = "-"; /* compat */
- const char *g; /* unimplemented, default is "0" */
#if ENABLE_LONG_OPTS
static const char patch_longopts[] ALIGN1 =
"strip\0" Required_argument "p"
;
applet_long_options = patch_longopts;
#endif
- opt = getopt32(argv, "p:i:RNg:", &p, &i, &g);
+ opt = getopt32(argv, "p:i:RNg:", &p, &i, NULL);
if (opt & OPT_R)
plus = '-';
patch_level = xatoi(p); /* can be negative! */
"nameserver 10.0.0.1\n"
#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_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] ") \
"[-f TARFILE] [-C DIR] [FILE]..."
#define tar_full_usage "\n\n" \
"or list files from a tar file\n" \
"\nOptions:" \
IF_FEATURE_TAR_CREATE( \
- "\n c Create") \
+ "\n c Create" \
+ ) \
"\n x Extract" \
"\n t List" \
"\nArchive format selection:" \
"\n Z Filter the archive through compress" \
) \
IF_FEATURE_TAR_NOPRESERVE_TIME( \
- "\n m Do not extract files modified time" \
+ "\n m Do not restore mtime" \
) \
"\nFile selection:" \
"\n f Name of TARFILE or \"-\" for stdin" \
"\n O Extract to stdout" \
IF_FEATURE_TAR_FROM( \
+ IF_FEATURE_TAR_LONG_OPTIONS( \
"\n exclude File 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" \
#define tar_example_usage \
#include "libbb.h"
#include "unicode.h"
+/* If it's not a constant... */
+#ifndef unicode_status
uint8_t unicode_status;
+#endif
size_t FAST_FUNC bb_mbstrlen(const char *string)
{