3353 Commits

Author SHA1 Message Date
Paul Eggert
afd073399a maint: remove GLOBAL as per GCC 14
* src/common.h (GLOBAL): Remove this macro, and all its uses.
It collides with GCC 14 and -Wmissing-variable-declarations.
Change all uses of GLOBAL to use extern instead,
and declare the variables in their respective .c files.
Move .c file’s extern declarations here, so that they
appear only once and are checked against definitions.
* src/names.c (unconsumed_option_tail): Now static.
2024-07-26 23:44:03 -07:00
Paul Eggert
9f1c32c18b Modernize use of Gnulib, paxutils
* configure.ac: Omit stuff no longer needed now that Gnulib or
paxlib does it, or the code no longer needs the configure-time checks.
Do not use AC_SYS_LARGEFILE (Gnulib largefile does this) or check
for fcntl.h, memory.h, net/errno.h, sgtty.h, string.h,
sys/param.h, sys/device.h, sys/gentape.h, sys/inet.h,
sys/io/trioctl.h, sys/time.h, sys/tprintf.h, sys/tape.h, unistd.h,
locale.h, netdb.h; these are all now standard, or old ways of getting
at magtapes are no longer needed and we now have only sys/mtio.h.
Do not check for lstat, readlink, symlink, and check only for
waitpid’s existence rather than attempting to replace it.
Do not check for decls of getgrgid, getpwuid, or time.
Check just once for iconv.h.
* gnulib.modules: Add largefile.
* lib/.gitignore, lib/Makefile.am (noinst_HEADERS, libtar_a_SOURCES):
Remove system-ioctl.h, which is no longer in paxlib.
All includes now changed to just check HAVE_SYS_MTIO_H directly.
* lib/wordsplit.c (wordsplit_c_escape_tab, wordsplit_errstr)
(wordsplit_nerrs):
Now static or an enum, and without any leading "_" in the name.
* src/buffer.c (record_start, record_end, current_block, records_read):
* src/delete.c (records_skipped): Add extern decl to pacify GCC.
* src/compare.c, src/create.c, src/extract.c: Omit uses of
HAVE_READLINK and HAVE_SYMLINK since we now let Gnulib deal with
platforms lacking readlinkat and symlinkat.
* src/system.c: Use "#if !HAVE_WAITPID" instead of "#if MSDOS".
2024-07-26 21:56:20 -07:00
Paul Eggert
4e0deb7416 build: update gnulib and paxutils submodules to latest 2024-07-26 21:56:20 -07:00
Paul Eggert
3d2c735b7c maint: higher-precision checkpoint timestamps
* src/checkpoint.c (format_checkpoint_string):
Use current_timespec to get nanosecond resolution.
This also frees us from the necessity of including <sys/time.h>
to use gettimeofday, which is removed in POSIX.1-2024.
2024-07-24 10:04:16 -07:00
Paul Eggert
bd066ac0a5 build: update gnulib and paxutils submodules to latest 2024-07-24 10:04:16 -07:00
Paul Eggert
b96cabb1ea Sync bootstrap from Gnulib 2024-07-24 10:04:16 -07:00
Paul Eggert
42d1143dd5 Sync bootstrap from Gnulib 2024-07-15 14:59:33 -07:00
Paul Eggert
2b9e2cc947 maint: adjust to Gnulib -Wsystem-headers change
* configure.ac: Do not suppress -Wsystem-headers, as
Gnulib no longer enables it.
2024-07-15 14:59:33 -07:00
Paul Eggert
1752231f9e build: update gnulib submodule to latest 2024-07-15 14:59:33 -07:00
Sergey Poznyakoff
5f2cda027d Various formatting fixes 2024-06-07 00:05:00 +03:00
Sergey Poznyakoff
1e6ce98e3a Fix spurious diagnostic during extraction of . with --keep-newer-files
Bug reported in https://savannah.gnu.org/bugs/?65838.

Bug introduced by 79d1ac38c1.

* src/extract.c (make_directories): Restore second argument.  This
reverts the change made in 79d1ac38c1.
(maybe_recoverable, rename_directory): Update calls to make_directories.
* tests/extrac27.at: New file.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Likewise.
2024-06-05 18:19:10 +03:00
Paul Eggert
883f2e6dca tar: fix current_block confusion
Problem reported by Robert Morris in:
https://lists.gnu.org/r/bug-tar/2024-03/msg00001.html
* src/delete.c (flush_file): Simply return at EOF,
so that current_block continues to point to end of input.
2024-03-03 13:28:23 -08:00
Paul Eggert
628c49250a tar: fix unlikely overflow
* src/delete.c (flush_file): Fix arithmetic overflow if
TYPE_MAXIMUM (off_t) - BLOCKSIZE < current_stat_info.stat.st_size.
2024-03-03 13:28:23 -08:00
Paul Eggert
21318f3856 tar: improve diagnostic for truncated archive
* src/buffer.c (seek_archive): If EOF has been read, don’t attempt
to seek past it.  This replaces a bogus "rmtlseek not stopped at a
record boundary" message with a better "Unexpected EOF in archive"
when I run ‘tar tvf gtar13c.tar’ using the gtar13.tar file here:
https://lists.gnu.org/r/bug-tar/2024-03/msg00001.html
2024-03-03 13:28:23 -08:00
Sergey Poznyakoff
fac2b4c11a Avoid gcc 13 "unused parameter" warnings 2024-01-16 14:28:19 +02:00
Sergey Poznyakoff
6ba24c31c6 Recognize suffixes .z (gzip) and .tzo (lzop) 2024-01-15 22:52:27 +02:00
Sergey Poznyakoff
7b65ae35ab Fix description of the CACHEDIR.TAG file. 2024-01-15 22:30:22 +02:00
Sergey Poznyakoff
f622c07108 Fix --exclude-ignore option.
This fixes https://savannah.gnu.org/bugs/?64387.

* src/exclist.c (info_attach_exclist): Always use file->flags.
(exclude_vcs_ignores): Pass flags from struct vcs_ignore_file
to excfile_add.

* tests/exclude19.at: New test.
* tests/exclude20.at: New test.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Add new tests.
2024-01-15 21:24:34 +02:00
Sergey Poznyakoff
d763055edd Fix missing space in the manual 2024-01-15 20:21:26 +02:00
Sergey Poznyakoff
b4d1fa77b6 When given -c -a, issue a warning if no compressor is associated with the suffix.
* src/suffix.c (find_compression_suffix): Always return stripped
archive name length in the last argument.  Return 0 if there is no
suffix.
(find_compression_program): Remove.
(set_compression_program_by_suffix): Take third argument, controlling
whether to issue a warning if no suitable compression program is found
for the suffix.
* src/common.h (set_compression_program_by_suffix): Change prototype.
* src/buffer.c, src/tar.c: All uses of set_compression_program_by_suffix
changed.
2024-01-15 00:00:02 +02:00
Paul Eggert
66eaa2f821 Port EOF detection test to macOS
* tests/delete06.at: Don’t assume the diagnostic is
“Value too large for defined data type”, as strerror
uses a different wording on macOS 12.6.
2024-01-01 19:12:10 -08:00
Paul Eggert
24a2fcfd83 Skip test on macOS 12.6
* tests/xform04.at: Skip test on macOS 12.6, which is behind the times
and doesn’t think that ⱥ (U+2C65 LATIN SMALL LETTER A WITH STROKE) is
printable.
2024-01-01 19:12:10 -08:00
Paul Eggert
835b0c7dee Port --numeric-owner basic tests to macOS
* tests/numeric.at: If chown fails, skip the test.
This is needed on macOS 12.6 if the user has group
ID 4294967295 (nogroup), which chown rejects.
2024-01-01 19:12:10 -08:00
Paul Eggert
c6f0ad5117 Update copyright years
UPDATE_COPYRIGHT_USE_INTERVALS=1 \
gnulib/build-aux/update-copyright \
  $(git ls-files | sed -e '/^gnulib$/d
			   /^paxutils$/d
			   /^COPYING$/d
			   /\/fdl.texi$/d')
sed -i '2000,${
    /^Copyright @copyright/d
    s/^[0-9]*--\(2024 Free Software Foundation, Inc.\)/Copyright (C) \1/
  }' doc/tar.texi
2024-01-01 19:08:46 -08:00
Paul Eggert
f0098df0b3 doc: fix date in example
* doc/tar.texi: Fix copyright date in example.
2024-01-01 19:08:46 -08:00
Paul Eggert
3a27df1d69 build: update gnulib submodule to latest 2024-01-01 19:08:46 -08:00
Paul Eggert
c1e277476c Support multi-byte --transform='...\L...' etc
Support upcasing and downcasing in multi-byte locales.
* gnulib.modules: Add c32rtomb, c32tolower, c32toupper,
mbrtoc32-regular.
* src/transform.c: Do not include ctype.h.  Include mcel.h.
(stk, stk_init): Move up.
(run_case_conv): Return void, not char *.  Append result to
stk directly; this avoids the need for a separate allocation.
All callers changed.  Do not assume a single-byte locale.
* tests/xform04.at: New test.
* tests/Makefile.am (TESTSUITE_AT):
* tests/testsuite.at: Add it.
2023-09-12 23:23:41 -05:00
Paul Eggert
783321ff1b Simplify wordsplit_string_unquote_copy
* lib/wordsplit.c (wordsplit_string_unquote_copy): Simplify.
2023-09-12 23:23:41 -05:00
Paul Eggert
01f986b921 Parse in a more locale-independent way
update submodules to latest
* gnulib.modules: Add c-ctype.
* lib/wordsplit.c, src/buffer.c, src/exclist.c, src/incremen.c:
* src/list.c, src/misc.c, src/names.c, src/sparse.c, src/tar.c:
* src/xheader.c:
Include c-ctype.h, and use its API rather than ctype.h’s.
This is more likely to work when oddball locales are used.
* src/transform.c: Include ctype.h, since this module still uses
tolower and toupper (this is probably wrong - should be multi-byte).
2023-09-12 23:23:41 -05:00
Paul Eggert
05fcfaafb6 Use single is_octal_digit function
* src/list.c (ISOCTAL): Remove.
(is_octal_digit): New static function.
All uses of ISOCTAL and ISODIGIT replaced with is_octal_digit.
2023-09-12 23:23:40 -05:00
Paul Eggert
e35fe3a77c maint: fix THANKS misspellings
* THANKS: Fix recently-introduced misspellings.
2023-09-11 09:32:18 -05:00
Paul Eggert
78d4ccd755 Fix pointer bug in drop_volume_label_suffix
Problem reported by Marc Espie in:
https://lists.gnu.org/r/bug-tar/2023-09/msg00003.html
* src/buffer.c (drop_volume_label_suffix):
Redo to not compute a pointer before the start of a buffer,
as this is not portable.
2023-09-11 01:17:29 -05:00
Paul Eggert
9599d193b8 quote unknown header keywords in diagnostics
* src/xheader.c (decx): Quote unknown header in warning, as it may
contain control characters.  Problem reported by Wicher Minnaard.
2023-09-11 01:17:29 -05:00
Paul Eggert
e1bba5e7dd Prefer mcel to mbuiter
Prefer the lighter-weight mcel implementation to the heavier-weight
mbuiter that GNU tar does not need.
* bootstrap.conf (avoided_gnulib_modules): Avoid mbuiter, mbuiterf.
* gnulib.modules: Add mcel-prefer.
2023-09-10 10:12:20 -07:00
Paul Eggert
f2613580c7 build: update gnulib submodule to latest 2023-09-10 10:12:20 -07:00
Markus Mayer
1cdad4cc28 .gitmodules: switch to HTTPS
HTTPS is not only encrypted but also better suited for corporate
firewalls. Let's use it to clone submodules.
Copyright-paperwork-exempt: yes
2023-09-07 14:33:37 -07:00
Sergey Poznyakoff
ecdef6677b docs: replace references to fileutils with coreutils.
GNU fileutils is decommissioned and superseded by coreutils.
This fixes Savannah bug #64495.
2023-08-22 23:55:09 +03:00
Sergey Poznyakoff
5114218025 Fix Savane bug #64581
This reverts commit 4f3824743f.
2023-08-22 18:34:20 +03:00
Paul Eggert
a9a8990fb3 Bump extrac26 timeout
* tests/extrac26.at: Increase timeout from 15 to 60 s.
On my old machine it took 15 s.
2023-08-21 13:42:14 -07:00
Paul Eggert
12b58a69aa Simplify recently-added hash code
* src/extract.c (delay_set_stat): Simplify hash lookup;
no need to initialize members other than file_name.
Avoid assignment in ‘if’ when it’s easy.
(extract_finish): Do not bother to free when we are about to exit.
2023-08-21 13:42:14 -07:00
Benjamin Woodruff
a5afb36765 Fix O(n^2) time bug in --delay-directory-restore
delayed_set_stat avoids inserting duplicate entries into
delayed_set_stat_head. It was doing this by scanning the entire
list.

Normally this list is small, but if --delay-directory-restore is
used (including automatically for incremental archives), this list
grows with the total number of directories in the archive.

The entire scan takes O(n) time. Extracting an archive with n
directories could therefore take O(n^2) time.

The included test uses AT_SKIP_LARGE_FILES, allowing it to optionally be
skipped. It may execute slowly on certain filesystems or disks, as it
creates thousands of directories.

There are still potentially problematic O(n) scans in
find_direct_ancestor and remove_delayed_set_stat, which this patch does
not attempt to fix.

* NEWS: Update.
* src/extract.c (delayed_set_stat_table): Create a table for O(1)
lookups of entries in the delayed_set_stat_head list. The list
remains, as tracking insertion order is important.
(dl_hash, dl_compare): New hash table helper functions.
(delay_set_stat): Create the hash table, replace the O(n) list scan
with a hash_lookup, insert new entries into the hash table.
(remove_delayed_set_stat): Also remove entry from hash table.
(apply_nonancestor_delayed_set_stat): Also remove entry from hash
table.
(extract_finish): Free the (empty) hash table.
* tests/extrac26.at: New file.
* tests/Makefile.am (TESTSUITE_AT): Include extrac26.at.
* tests/testsuite.at: Include extrac26.at.
2023-08-21 13:42:14 -07:00
Paul Eggert
bfee1d44a3 Pacify gcc -Wanalyzer-fd-use-without-check
* src/system.c (sys_exec_setmtime_script):
Treat fds with more care.
2023-08-21 13:42:14 -07:00
Paul Eggert
8131ca7b26 build: update gnulib submodule to latest 2023-08-21 13:42:14 -07:00
Sergey Poznyakoff
d437ecf75d Revert "Fix savannah bug #63567"
Commit e89c7a45eb broke deletion from archives. The reported number
of bytes read is rounded to the nearest record anyway, revert the
commit and document the fact.

Reported by Ed Santiago. See
https://bugzilla.redhat.com/show_bug.cgi?id=2230127

* doc/tar.texi: Document the fact that --totals rounds up the
number of bytes reads to the nearest record.
* src/buffer.c: Revert changes.
* tests/delete06.at: Fix expected status code and stderr.
2023-08-15 11:34:21 +03:00
Paul Eggert
8e5483577d Stop using alloca
* gnulib.modules: Remove alloca.
* src/create.c (dump_file0): Return address of any allocated
storage.  Caller changed to free it.  Use xmalloc instead
of alloca, to obtain this storage.
* src/list.c (from_header): Use quote_mem instead of quote,
removing the need to use alloca.
2023-08-02 09:02:33 -07:00
Sergey Poznyakoff
9a30bb2674 New option: --set-mtime-command
* NEWS: Document new option.
* src/common.h (COMMAND_MTIME): New constant.
* src/create.c (set_mtime_command)
(set_mtime_format): New globals.
(sys_exec_setmtime_script): New prototype.
* src/system.c (start_header): Handle COMMAND_MTIME.
* src/tar.c (sys_exec_setmtime_script): New function.
2023-08-01 15:45:14 +03:00
Paul Eggert
eb30aa7801 * doc/tar.texi: Fix minor reproducibility typos. 2023-07-25 09:45:46 -07:00
Paul Eggert
68636f0bcb Improve reproducibility recipe
* doc/tar.texi (Reproducibility): Improve index.
Improve and add comments to recipe.  In the recipe,
don’t worry about file names beginning with ‘-’ for simplicity;
don’t use touch -c as it exits with status 0 even when it
does not work; and set directory timestamps too.
2023-07-25 09:43:57 -07:00
Sergey Poznyakoff
8ed95e92ef * doc/tar.texi: Define reproducibility. 2023-07-25 09:43:57 -07:00
Paul Eggert
d1ca333391 New doc about reproducible archives
* doc/tar.texi (Reproducibility): New section.
Spruce some other sections related to timestamps etc.
2023-07-24 14:46:53 -07:00