]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Modernize use of Gnulib, paxutils
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 27 Jul 2024 04:55:31 +0000 (21:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 27 Jul 2024 04:56:20 +0000 (21:56 -0700)
* 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".

configure.ac
gnulib.modules
lib/.gitignore
lib/Makefile.am
lib/wordsplit.c
src/buffer.c
src/compare.c
src/create.c
src/delete.c
src/extract.c
src/system.c

index 6b052f24d2654741d94d2457f5b89602c1b2fb34..af6f691806f14383481ba847d0addec621cf8618 100644 (file)
@@ -34,19 +34,7 @@ AC_PROG_YACC
 gl_EARLY
 AC_CHECK_TOOLS([AR], [ar])
 
-AC_SYS_LARGEFILE
-
-AC_CHECK_HEADERS_ONCE(fcntl.h linux/fd.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/mtio.h sys/time.h sys/tprintf.h sys/tape.h \
-  unistd.h locale.h)
-
-AC_CHECK_HEADERS([sys/buf.h], [], [],
-[#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif])
+AC_CHECK_HEADERS_ONCE([linux/fd.h sys/mtio.h])
 
 AC_HEADER_MAJOR
 
@@ -234,13 +222,7 @@ fi
 
 TAR_HEADERS_ATTR_XATTR_H
 
-AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
-
-AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
-AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
-AC_CHECK_DECLS([time],,, [#include <time.h>])
-
-AC_REPLACE_FUNCS(waitpid)
+AC_CHECK_FUNCS_ONCE([fchmod fchown fsync mkfifo waitpid])
 
 AC_ARG_VAR([RSH], [Configure absolute path to default remote shell binary])
 AC_CACHE_CHECK(for remote shell, tar_cv_path_RSH,
@@ -264,9 +246,7 @@ AC_CACHE_CHECK(for remote shell, tar_cv_path_RSH,
       fi
     done
   fi])
-if test $tar_cv_path_RSH = no; then
-  AC_CHECK_HEADERS(netdb.h)
-else
+if test $tar_cv_path_RSH != "no"; then
   AC_DEFINE_UNQUOTED(REMOTE_SHELL, "$tar_cv_path_RSH",
     [Define to the full path of your rsh, if any.])
 fi
@@ -360,7 +340,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE,
 
 # Iconv
 AM_ICONV
-AC_CHECK_HEADERS(iconv.h)
+AC_CHECK_HEADERS_ONCE([iconv.h])
 AC_CHECK_TYPE(iconv_t,:,
               AC_DEFINE(iconv_t, int,
                         [Conversion descriptor type]),
index 48c0e4cb0bb85358cc7369f6ecee239fc245ed53..0e6cec61558fb035486dcfbbe0a68dcfca8ec353 100644 (file)
@@ -63,6 +63,7 @@ human
 idx
 inttostr
 inttypes
+largefile
 lchown
 linkat
 localcharset
index b1a5f8659f38cc3fc4c4ee75d6e657a6bcd89d4e..1d0adc1530ca8af6de864ff2a9b457b15c0c3b7a 100644 (file)
@@ -6,5 +6,4 @@ paxnames.c
 rmt-command.h
 rmt.h
 rtapelib.c
-system-ioctl.h
 system.h
index 4f104b4125082ecad18ae2acacc4197e91b1e736..5df1ffb07b1493bc876bcc076af4cef82b682f83 100644 (file)
@@ -33,7 +33,6 @@ noinst_HEADERS = \
  paxlib.h\
  rmt.h\
  system.h\
- system-ioctl.h\
  wordsplit.h\
  xattr-at.h
 
@@ -41,7 +40,7 @@ libtar_a_SOURCES = \
   paxerror.c paxexit-status.c paxlib.h paxnames.c \
   rtapelib.c \
   rmt.h \
-  system.h system-ioctl.h \
+  system.h \
   wordsplit.c\
   xattr-at.c
 
index 82dfa9d09823a1b150404a49be296d325ffb8399..604f02c73852b5d52782d0e41f7761e66f0cc10e 100644 (file)
@@ -193,7 +193,7 @@ wordsplit_init0 (struct wordsplit *wsp)
   wsp->ws_errno = 0;
 }
 
-char wordsplit_c_escape_tab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v";
+static char wordsplit_c_escape_tab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v";
 
 static int
 wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
@@ -2513,7 +2513,7 @@ wordsplit_get_words (struct wordsplit *ws, size_t *wordc, char ***wordv)
   return 0;
 }
 
-const char *_wordsplit_errstr[] = {
+static char const *const wordsplit_errstr[] = {
   N_("no error"),
   N_("missing closing quote"),
   N_("memory exhausted"),
@@ -2524,16 +2524,15 @@ const char *_wordsplit_errstr[] = {
   N_("unbalanced parenthesis"),
   N_("globbing error")
 };
-int _wordsplit_nerrs =
-  sizeof (_wordsplit_errstr) / sizeof (_wordsplit_errstr[0]);
+enum { wordsplit_nerrs = sizeof wordsplit_errstr / sizeof *wordsplit_errstr };
 
 const char *
 wordsplit_strerror (struct wordsplit *ws)
 {
   if (ws->ws_errno == WRDSE_USERERR)
     return ws->ws_usererr;
-  if (ws->ws_errno < _wordsplit_nerrs)
-    return _wordsplit_errstr[ws->ws_errno];
+  if (ws->ws_errno < wordsplit_nerrs)
+    return wordsplit_errstr[ws->ws_errno];
   return N_("unknown error");
 }
 
index 9da6747a6cf28a147eb4e882728fbf36eb566daa..5358a0b080b9ffd60cbb9743b01d4e3bb19ecf9e 100644 (file)
@@ -52,10 +52,14 @@ static int record_index;
 /* FIXME: The following variables should ideally be static to this
    module.  However, this cannot be done yet.  The cleanup continues!  */
 
+extern union block *record_start;
 union block *record_start;      /* start of record of archive */
+extern union block *record_end;
 union block *record_end;        /* last+1 block of archive record */
+extern union block *current_block;
 union block *current_block;     /* current block of archive */
 enum access_mode access_mode;   /* how do we handle the archive */
+extern off_t records_read;
 off_t records_read;             /* number of records read from this archive */
 off_t records_written;          /* likewise, for records written */
 extern off_t records_skipped;   /* number of records skipped at the start
index d99fba35f145d55d421f629edcce1a4c3aba155a..d08220a2061baba22815d3e436969796c4e273c3 100644 (file)
    Written by John Gilmore, on 1987-04-30.  */
 
 #include <system.h>
-#include <system-ioctl.h>
 
 #if HAVE_LINUX_FD_H
 # include <linux/fd.h>
 #endif
 
+#if HAVE_SYS_MTIO_H
+# include <sys/ioctl.h>
+# include <sys/mtio.h>
+#endif
+
 #include "common.h"
 #include <quotearg.h>
 #include <rmt.h>
@@ -267,7 +271,6 @@ diff_link (void)
                                      current_stat_info.link_name));
 }
 
-#ifdef HAVE_READLINK
 static void
 diff_symlink (void)
 {
@@ -293,7 +296,6 @@ diff_symlink (void)
   if (linkbuf != buf)
     free (linkbuf);
 }
-#endif
 
 static void
 diff_special (void)
@@ -496,11 +498,9 @@ diff_archive (void)
       diff_link ();
       break;
 
-#ifdef HAVE_READLINK
     case SYMTYPE:
       diff_symlink ();
       break;
-#endif
 
     case CHRTYPE:
     case BLKTYPE:
index bcb4a394aa403fc06ffb0fbf57239740963bbc24..344bd6d347a409b217214333176097ab16d8c0fc 100644 (file)
@@ -1870,7 +1870,6 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p)
 
       return allocated;
     }
-#ifdef HAVE_READLINK
   else if (S_ISLNK (st->stat.st_mode))
     {
       st->link_name = areadlinkat_with_size (parentfd, name, st->stat.st_size);
@@ -1905,7 +1904,6 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p)
       file_count_links (st);
       return allocated;
     }
-#endif
   else if (S_ISCHR (st->stat.st_mode))
     {
       type = CHRTYPE;
index 8303415fa9f020c1a4bd6bd68293d3f942c9252c..221a1dfb85825d0cf1bcfe13bc6377437a822085 100644 (file)
@@ -37,6 +37,7 @@ extern off_t records_read;
 
 /* The number of records skipped at the start of the archive, when
    passing over members that are not deleted.  */
+extern off_t records_skipped;
 off_t records_skipped;
 
 /* Move archive descriptor by COUNT records worth.  If COUNT is
index 41f8418fb50556a03eff0bfb88dff36baeb2975c..5952bce29aaa595b6381a67d5467d5382b4450bb 100644 (file)
@@ -1587,7 +1587,6 @@ extract_link (char *file_name, MAYBE_UNUSED int typeflag)
 static int
 extract_symlink (char *file_name, MAYBE_UNUSED int typeflag)
 {
-#ifdef HAVE_SYMLINK
   bool interdir_made = false;
 
   if (! absolute_names_option
@@ -1605,6 +1604,19 @@ extract_symlink (char *file_name, MAYBE_UNUSED int typeflag)
        return 0;
 
       case RECOVER_NO:
+       if (!implemented (errno))
+         {
+           static bool warned;
+           if (!warned)
+             {
+               warned = true;
+               WARNOPT (WARN_SYMLINK_CAST,
+                        (0, 0,
+                         _("Attempting extraction of symbolic links"
+                           " as hard links")));
+             }
+           return extract_link (file_name, typeflag);
+         }
        symlink_error (current_stat_info.link_name, file_name);
        return -1;
       }
@@ -1612,19 +1624,6 @@ extract_symlink (char *file_name, MAYBE_UNUSED int typeflag)
   set_stat (file_name, &current_stat_info, -1, 0, 0,
            SYMTYPE, false, AT_SYMLINK_NOFOLLOW);
   return 0;
-
-#else
-  static int warned_once;
-
-  if (!warned_once)
-    {
-      warned_once = 1;
-      WARNOPT (WARN_SYMLINK_CAST,
-              (0, 0,
-               _("Attempting extraction of symbolic links as hard links")));
-    }
-  return extract_link (file_name, typeflag);
-#endif
 }
 
 #if S_IFCHR || S_IFBLK
index eae0a17aad85062d5b8776fa82e63997642e298e..8da1083306bc0f4f17d5b17924a7a082bc3ecb5e 100644 (file)
    with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <system.h>
-#include <system-ioctl.h>
+
+#if HAVE_SYS_MTIO_H
+# include <sys/ioctl.h>
+# include <sys/mtio.h>
+#endif
 
 #include "common.h"
 #include <priv-set.h>
@@ -69,7 +73,7 @@ mtioseek (bool count_files, off_t count)
   return false;
 }
 
-#if MSDOS
+#if !HAVE_WAITPID /* MingW, MSVC 14.  */
 
 bool
 sys_get_archive_stat (void)