Only in tar-1.13.25-patched: Makefile Only in tar-1.13.25-patched: config.h Only in tar-1.13.25-patched: config.log Only in tar-1.13.25-patched: config.status Only in tar-1.13.25-patched/doc: Makefile diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/doc/stamp-vti tar-1.13.25-patched/doc/stamp-vti --- tar-1.13.25/doc/stamp-vti Wed Sep 26 23:34:01 2001 +++ tar-1.13.25-patched/doc/stamp-vti Thu Jul 4 21:22:19 2002 @@ -1,4 +1,4 @@ address@hidden UPDATED 26 September 2001 address@hidden UPDATED-MONTH September 2001 address@hidden EDITION 1.13.24 address@hidden VERSION 1.13.24 address@hidden UPDATED 4 July 2002 address@hidden UPDATED-MONTH July 2002 address@hidden EDITION 1.13.25 address@hidden VERSION 1.13.25 diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/doc/tar.texi tar-1.13.25-patched/doc/tar.texi --- tar-1.13.25/doc/tar.texi Wed Sep 26 21:46:09 2001 +++ tar-1.13.25-patched/doc/tar.texi Thu Jul 4 21:40:13 2002 @@ -392,6 +392,11 @@ @set xref-starting-file @xref{Scarce} @set pxref-starting-file @pxref{Scarce} address@hidden op-strip @address@hidden address@hidden ref-strip @ref{Writing} address@hidden xref-strip @xref{Writing} address@hidden pxref-strip @pxref{Writing} + @set op-suffix @address@hidden @set ref-suffix @ref{Backup options} @set xref-suffix @xref{Backup options} @@ -2923,6 +2928,13 @@ files in the archive until it finds one that matches @var{name}. @xref{Scarce}. address@hidden address@hidden + +Strip @var{levels} path components (separated by slashes) from the file name +when extracting (like '@command{patch} --strip'). If the argument @var{levels} is +omitted (or is -1), strip all the path components but the basename. address@hidden + @item address@hidden Alters the suffix @command{tar} uses when backing up files from the default @@ -4144,6 +4156,7 @@ @cindex Modes of extracted files @cindex Writing extracted files to standard output @cindex Standard output, writing extracted files to address@hidden Stripping path compoments @UNREVISED @FIXME{need to mention the brand new option, --backup} @@ -4157,6 +4170,7 @@ * Modification Times:: * Setting Access Permissions:: * Writing to Standard Output:: +* Stripping path components:: * remove files:: @end menu @@ -4343,6 +4357,25 @@ the standard output? is this useful with more that one file? Are pipes the real reason?} address@hidden Stripping path components address@hidden Stripping path components + +If the original archive has been created with an excessive path such as +m/nfs1.niksula/home2/u8/program/duf/src/main.c, you can use address@hidden to strip the unwanted path components. In the above +example, specifying ---strip=3 would result in file name +u8/program/duf/src/main.c, ---strip=1 would give +nfs1.niksula/home2/u8/program/duf/src/main.c and ---strip would give mere +main.c. + address@hidden @kbd address@hidden --strip +Strip @var{levels} path components (separated by slashes) from the file name +when extracting (like '@command{patch} --strip'). If the argument address@hidden omitted (or is -1), strip all the path components but the basename. address@hidden address@hidden table + @node remove files @unnumberedsubsubsec Removing Files Only in tar-1.13.25-patched/doc: tar.texi~ diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/doc/version.texi tar-1.13.25-patched/doc/version.texi --- tar-1.13.25/doc/version.texi Wed Sep 26 23:06:44 2001 +++ tar-1.13.25-patched/doc/version.texi Thu Jul 4 20:55:22 2002 @@ -1,4 +1,4 @@ address@hidden UPDATED 26 September 2001 address@hidden UPDATED-MONTH September 2001 address@hidden EDITION 1.13.24 address@hidden VERSION 1.13.24 address@hidden UPDATED 4 July 2002 address@hidden UPDATED-MONTH July 2002 address@hidden EDITION 1.13.25 address@hidden VERSION 1.13.25 Only in tar-1.13.25-patched/intl: Makefile Only in tar-1.13.25-patched/lib: .deps Only in tar-1.13.25-patched/lib: Makefile Only in tar-1.13.25-patched/lib: libtar.a Only in tar-1.13.25-patched/m4: Makefile Only in tar-1.13.25-patched/po: Makefile Only in tar-1.13.25-patched/po: Makefile.in Only in tar-1.13.25-patched/po: POTFILES Only in tar-1.13.25-patched/scripts: Makefile Only in tar-1.13.25-patched/src: .deps Only in tar-1.13.25-patched/src: Makefile diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/src/common.h tar-1.13.25-patched/src/common.h --- tar-1.13.25/src/common.h Fri Sep 21 03:00:55 2001 +++ tar-1.13.25-patched/src/common.h Thu Jul 4 20:20:06 2002 @@ -165,6 +165,12 @@ /* Boolean value. */ GLOBAL int ignore_failed_read_option; + +/* Strip N leading path components (separated by slash). If -1, strip + everything but the filename. Analogous to patch -p/--strip. + Used with x and t. */ +GLOBAL int strip_slashes_option; + /* Boolean value. */ GLOBAL int ignore_zeros_option; @@ -536,6 +542,8 @@ char const *quote PARAMS ((char const *)); char const *quote_n PARAMS ((int, char const *)); +int strip_slashes PARAMS((char*, int*)); + /* Module names.c. */ extern struct name *gnu_list_name; Only in tar-1.13.25-patched/src: common.h.orig diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/src/extract.c tar-1.13.25-patched/src/extract.c --- tar-1.13.25/src/extract.c Mon Sep 24 21:55:17 2001 +++ tar-1.13.25-patched/src/extract.c Thu Jul 4 21:12:00 2002 @@ -657,6 +657,28 @@ apply_nonancestor_delayed_set_stat (CURRENT_FILE_NAME, 0); + if (strip_slashes_option) + { + char* path = CURRENT_FILE_NAME; + int num_slashes = strip_slashes_option; + skipcrud = strip_slashes(CURRENT_FILE_NAME, &num_slashes); + + /* We are not interested in dirs whose paths were stripped. */ + if (strlen(CURRENT_FILE_NAME) == 0) + return; + + if (num_slashes != strip_slashes_option && strip_slashes_option != -1) + { + WARN ((0, 0, _("%s: ignoring; --strip=%i, but the path only " + "has %i slashes."), + quotearg_colon (path), + strip_slashes_option, num_slashes)); + skip_member (); + return; + } + } + + /* Take a safety backup of a previously existing file. */ if (backup_option && !to_stdout_option) @@ -1120,6 +1142,12 @@ name_length = strlen (CURRENT_FILE_NAME); really_dir: + /* If we are to strip all the leading dirs in the path names, + we should not make empty directories. */ + + if (strip_slashes_option == -1) + break; + /* Remove any redundant trailing "/"s. */ while (FILESYSTEM_PREFIX_LEN (CURRENT_FILE_NAME) < name_length && CURRENT_FILE_NAME[name_length - 1] == '/') Only in tar-1.13.25-patched/src: extract.c.orig Only in tar-1.13.25-patched/src: extract.c.rej Only in tar-1.13.25-patched/src: extract.c~ diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/src/list.c tar-1.13.25-patched/src/list.c --- tar-1.13.25/src/list.c Wed Sep 26 23:05:04 2001 +++ tar-1.13.25-patched/src/list.c Thu Jul 4 20:20:06 2002 @@ -910,6 +910,16 @@ char uintbuf[UINTMAX_STRSIZE_BOUND]; int pad; + char* file_path; + + int num_slashes = strip_slashes_option; + file_path = ¤t_file_name[strip_slashes(current_file_name, + &num_slashes)]; + if (strip_slashes_option != num_slashes && strip_slashes_option != -1) + return; + + if (strlen(file_path) == 0) return; + if (block_number_option) { char buf[UINTMAX_STRSIZE_BOUND]; @@ -920,7 +930,7 @@ if (verbose_option <= 1) { /* Just the fax, mam. */ - fprintf (stdlis, "%s\n", quotearg (current_file_name)); + fprintf (stdlis, "%s\n", quotearg (file_path)); } else { @@ -951,7 +961,7 @@ case AREGTYPE: case LNKTYPE: modes[0] = '-'; - if (current_file_name[strlen (current_file_name) - 1] == '/') + if (file_path[strlen (file_path) - 1] == '/') modes[0] = 'd'; break; case GNUTYPE_DUMPDIR: @@ -1062,7 +1072,7 @@ fprintf (stdlis, "%s %s/%s %*s%s %s", modes, user, group, ugswidth - pad, "", size, time_stamp); - fprintf (stdlis, " %s", quotearg (current_file_name)); + fprintf (stdlis, " %s", quotearg (file_path)); switch (current_header->header.typeflag) { Only in tar-1.13.25-patched/src: list.c.orig Only in tar-1.13.25-patched/src: localedir.h diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/src/misc.c tar-1.13.25-patched/src/misc.c --- tar-1.13.25/src/misc.c Mon Aug 27 02:14:26 2001 +++ tar-1.13.25-patched/src/misc.c Thu Jul 4 20:52:15 2002 @@ -845,3 +845,35 @@ { return quote_n (0, name); } + + +/* Strip strip_count path components from the beginning of the path. If + strip_count == -1 strip everything except the filename itself. Return the + number of chars to skip. Consecutive slashes are treated as one. + strip_count is modified to reflect the the number of slahes actually + stripped. */ +int +strip_slashes (char* path, int* strip_count) +{ + int p; + int result = 0; + int slashes_stripped = 0; + + for (p = 0; + path[p] && (slashes_stripped < *strip_count || *strip_count == -1); + p++) + { + if (ISSLASH(path[p])) + { + /* strip all the consecutive slashes */ + while (ISSLASH(path[p + 1])) + ++p; + + result = p + 1; + slashes_stripped++; + } + } + + *strip_count = slashes_stripped; + return result; +} Only in tar-1.13.25-patched/src: misc.c.orig Only in tar-1.13.25-patched/src: misc.c~ Only in tar-1.13.25-patched/src: rmt Only in tar-1.13.25-patched/src: tar diff -aur --exclude='*.o' --exclude='*cat-id-tbl.c' --exclude='*.pot' --exclude='*.info' tar-1.13.25/src/tar.c tar-1.13.25-patched/src/tar.c --- tar-1.13.25/src/tar.c Fri Sep 21 03:11:27 2001 +++ tar-1.13.25-patched/src/tar.c Thu Jul 4 21:37:02 2002 @@ -146,6 +146,7 @@ PRESERVE_OPTION, RECORD_SIZE_OPTION, RSH_COMMAND_OPTION, + STRIP_OPTION, SUFFIX_OPTION, USE_COMPRESS_PROGRAM_OPTION, VOLNO_FILE_OPTION, @@ -259,6 +260,7 @@ {"show-omitted-dirs", no_argument, &show_omitted_dirs_option, 1}, {"sparse", no_argument, 0, 'S'}, {"starting-file", required_argument, 0, 'K'}, + {"strip", optional_argument, 0, STRIP_OPTION}, {"suffix", required_argument, 0, SUFFIX_OPTION}, {"tape-length", required_argument, 0, 'L'}, {"to-stdout", no_argument, 0, 'O'}, @@ -333,7 +335,12 @@ -G, --incremental handle old GNU-format incremental backup\n\ -g, --listed-incremental=FILE\n\ handle new GNU-format incremental backup\n\ - --ignore-failed-read do not exit with nonzero on unreadable files\n"), + --ignore-failed-read do not exit with nonzero on unreadable files\n\ + --strip=N strip N path components (separated by slashes)\n\ + from the file name when extracting (like\n\ + 'patch --strip'). If the argument N is omitted\n\ + (or is -1), strip all the path components but\n\ + the basename.\n"), stdout); fputs (_("\ \n\ @@ -641,6 +648,12 @@ name_add (optarg); break; + case STRIP_OPTION: + strip_slashes_option = + optarg != NULL && strlen(optarg) ? atoi(optarg) : -1; + if (strip_slashes_option < -1) strip_slashes_option = -1; + break; + case 'd': set_subcommand_option (DIFF_SUBCOMMAND); break; @@ -1228,6 +1241,10 @@ archive_name_cursor++) if (!strcmp (*archive_name_cursor, "-")) request_stdin ("-f"); + if (strip_slashes_option && to_stdout_option) + USAGE_ERROR ((0, 0, + _("-O and --strip are incompatible"))); + break; case CAT_SUBCOMMAND: Only in tar-1.13.25-patched/src: tar.c.orig Only in tar-1.13.25-patched/src: tar.c~ Only in tar-1.13.25-patched: stamp-h Only in tar-1.13.25-patched/tests: .deps Only in tar-1.13.25-patched/tests: Makefile Only in tar-1.13.25-patched/tests: preset