X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=3ef9c8f7a48c7c36c78c2ea6e626b3810f745c39;hb=84a55f12e5880196623d4193bf1d7f5141e6b0d5;hp=a639974f49b1b55ef3fb8190c01b5e501a11eca2;hpb=a7e9b6a17b2c111f4afa5ae35e3a206483366693;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index a639974..3ef9c8f 100644 --- a/src/tar.c +++ b/src/tar.c @@ -614,23 +614,18 @@ static struct argp_option options[] = { {"no-auto-compress", NO_AUTO_COMPRESS_OPTION, 0, 0, N_("do not use archive suffix to determine the compression program"), GRID+1 }, - {"bzip2", 'j', 0, 0, - N_("filter the archive through bzip2"), GRID+1 }, - {"gzip", 'z', 0, 0, - N_("filter the archive through gzip"), GRID+1 }, + {"use-compress-program", 'I', N_("PROG"), 0, + N_("filter through PROG (must accept -d)"), GRID+1 }, + /* Note: docstrings for the options below are generated by tar_help_filter */ + {"bzip2", 'j', 0, 0, NULL, GRID+1 }, + {"gzip", 'z', 0, 0, NULL, GRID+1 }, {"gunzip", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, {"ungzip", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, - {"compress", 'Z', 0, 0, - N_("filter the archive through compress"), GRID+1 }, + {"compress", 'Z', 0, 0, NULL, GRID+1 }, {"uncompress", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, - {"lzma", LZMA_OPTION, 0, 0, - N_("filter the archive through lzma"), GRID+1 }, - {"lzop", LZOP_OPTION, 0, 0, - N_("filter the archive through lzop"), GRID+8 }, - {"xz", 'J', 0, 0, - N_("filter the archive through xz"), GRID+8 }, - {"use-compress-program", 'I', N_("PROG"), 0, - N_("filter through PROG (must accept -d)"), GRID+1 }, + {"lzma", LZMA_OPTION, 0, 0, NULL, GRID+1 }, + {"lzop", LZOP_OPTION, 0, 0, NULL, GRID+1 }, + {"xz", 'J', 0, 0, NULL, GRID+1 }, #undef GRID #define GRID 100 @@ -903,9 +898,7 @@ add_exclude_array (char const * const * fv) static char * format_default_settings (void) { - char *s; - - asprintf (&s, + return xasprintf ( "--format=%s -f%s -b%d --quoting-style=%s --rmt-command=%s" #ifdef REMOTE_SHELL " --rsh-command=%s" @@ -919,7 +912,6 @@ format_default_settings (void) REMOTE_SHELL #endif ); - return s; } @@ -1260,22 +1252,47 @@ tar_help_filter (int key, const char *text, void *input) struct obstack stk; char *s; - if (key != ARGP_KEY_HELP_EXTRA) - return (char*) text; + switch (key) + { + default: + s = (char*) text; + break; + + case 'j': + s = xasprintf (_("filter the archive through %s"), BZIP2_PROGRAM); + break; + + case 'z': + s = xasprintf (_("filter the archive through %s"), GZIP_PROGRAM); + break; + + case 'Z': + s = xasprintf (_("filter the archive through %s"), COMPRESS_PROGRAM); + break; - obstack_init (&stk); - s = _("Valid arguments for the --quoting-style option are:"); - obstack_grow (&stk, s, strlen (s)); - obstack_grow (&stk, "\n\n", 2); - tar_list_quoting_styles (&stk, " "); - s = _("\n*This* tar defaults to:\n"); - obstack_grow (&stk, s, strlen (s)); - s = format_default_settings (); - obstack_grow (&stk, s, strlen (s)); - obstack_1grow (&stk, '\n'); - obstack_1grow (&stk, 0); - s = xstrdup (obstack_finish (&stk)); - obstack_free (&stk, NULL); + case LZMA_OPTION: + s = xasprintf (_("filter the archive through %s"), LZMA_PROGRAM); + break; + + case 'J': + s = xasprintf (_("filter the archive through %s"), XZ_PROGRAM); + break; + + case ARGP_KEY_HELP_EXTRA: + obstack_init (&stk); + s = _("Valid arguments for the --quoting-style option are:"); + obstack_grow (&stk, s, strlen (s)); + obstack_grow (&stk, "\n\n", 2); + tar_list_quoting_styles (&stk, " "); + s = _("\n*This* tar defaults to:\n"); + obstack_grow (&stk, s, strlen (s)); + s = format_default_settings (); + obstack_grow (&stk, s, strlen (s)); + obstack_1grow (&stk, '\n'); + obstack_1grow (&stk, 0); + s = xstrdup (obstack_finish (&stk)); + obstack_free (&stk, NULL); + } return s; } @@ -1441,11 +1458,11 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'j': - set_use_compress_program_option ("bzip2"); + set_use_compress_program_option (BZIP2_PROGRAM); break; case 'J': - set_use_compress_program_option ("xz"); + set_use_compress_program_option (XZ_PROGRAM); break; case 'k': @@ -1489,11 +1506,11 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case LZMA_OPTION: - set_use_compress_program_option ("lzma"); + set_use_compress_program_option (LZMA_PROGRAM); break; case LZOP_OPTION: - set_use_compress_program_option ("lzop"); + set_use_compress_program_option (LZOP_PROGRAM); break; case 'm': @@ -1651,11 +1668,11 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'z': - set_use_compress_program_option ("gzip"); + set_use_compress_program_option (GZIP_PROGRAM); break; case 'Z': - set_use_compress_program_option ("compress"); + set_use_compress_program_option (COMPRESS_PROGRAM); break; case ANCHORED_OPTION: