]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Support >UINT_MAX lines in map files
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 13 Aug 2024 00:47:26 +0000 (17:47 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 15 Aug 2024 06:25:46 +0000 (23:25 -0700)
* src/map.c (parse_id, map_read): Prefer intmax_t to unsigned
for line numbers.

src/map.c

index 1ff5d077418a0f0500fc3e84cc3f2c7da4953e54..499c3fb38416ca9569c93dffd47b1256274b8e32 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -48,7 +48,7 @@ map_compare (void const *entry1, void const *entry2)
 static bool
 parse_id (uintmax_t *retval,
          char const *arg, char const *what, uintmax_t maxval,
-         char const *file, unsigned line)
+         char const *file, intmax_t line)
 {
   char *p;
   bool overflow;
@@ -56,12 +56,12 @@ parse_id (uintmax_t *retval,
 
   if ((p == arg) | *p)
     {
-      error (0, 0, _("%s:%u: invalid %s: %s"),  file, line, what, arg);
+      error (0, 0, _("%s:%jd: invalid %s: %s"),  file, line, what, arg);
       return false;
     }
   if (overflow)
     {
-      error (0, 0, _("%s:%u: %s out of range: %s"), file, line, what, arg);
+      error (0, 0, _("%s:%jd: %s out of range: %s"), file, line, what, arg);
       return false;
     }
   return true;
@@ -78,7 +78,7 @@ map_read (Hash_table **ptab, char const *file,
   ssize_t n;
   struct wordsplit ws;
   int wsopt;
-  unsigned line;
+  intmax_t line;
   int err = 0;
 
   fp = fopen (file, "r");
@@ -98,14 +98,14 @@ map_read (Hash_table **ptab, char const *file,
 
       ++line;
       if (wordsplit (buf, &ws, wsopt))
-       FATAL_ERROR ((0, 0, _("%s:%u: cannot split line: %s"),
+       FATAL_ERROR ((0, 0, _("%s:%jd: cannot split line: %s"),
                      file, line, wordsplit_strerror (&ws)));
       wsopt |= WRDSF_REUSE;
       if (ws.ws_wordc == 0)
        continue;
       if (ws.ws_wordc != 2)
        {
-         error (0, 0, _("%s:%u: malformed line"), file, line);
+         error (0, 0, _("%s:%jd: malformed line"), file, line);
          err = 1;
          continue;
        }
@@ -123,7 +123,7 @@ map_read (Hash_table **ptab, char const *file,
          orig_id = name_to_id (ws.ws_wordv[0]);
          if (orig_id == UINTMAX_MAX)
            {
-             error (0, 0, _("%s:%u: can't obtain %s of %s"),
+             error (0, 0, _("%s:%jd: can't obtain %s of %s"),
                     file, line, what, ws.ws_wordv[0]);
              err = 1;
              continue;
@@ -156,7 +156,7 @@ map_read (Hash_table **ptab, char const *file,
          new_id = name_to_id (ws.ws_wordv[1]);
          if (new_id == UINTMAX_MAX)
            {
-             error (0, 0, _("%s:%u: can't obtain %s of %s"),
+             error (0, 0, _("%s:%jd: can't obtain %s of %s"),
                     file, line, what, ws.ws_wordv[1]);
              err = 1;
              continue;