]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Use intmax_t, not size_t, for input line numbers
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 12 Aug 2024 23:18:16 +0000 (16:18 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 15 Aug 2024 06:25:46 +0000 (23:25 -0700)
This works better on platforms where SIZE_MAX < OFF_MAX.
* src/common.h (struct common locus):
* src/names.c (struct name_elt):
Use intmax_t for line numbers.  All uses changed.

src/common.h
src/names.c
src/tar.c

index 361a62eba3aed1d36cef059e5154f1a23e8dd158..8fdd88dc91c67f4232d9c6cd1cd61fd08f820b20 100644 (file)
@@ -853,7 +853,7 @@ struct option_locus
 {
   enum option_source source;  /* Option origin */
   char const *name;           /* File or variable name */
-  size_t line;                /* Number of input line if source is OPTS_FILE */
+  intmax_t line;              /* Number of input line if source is OPTS_FILE */
   struct option_locus *prev;  /* Previous occurrence of the option of same
                                 class */
 };
index 143fbef7c736c509e007d7fc75c170339ec14cdb..bdb7519fb073c7be4a6f0679e4e0ff5a8e619648 100644 (file)
@@ -206,8 +206,8 @@ names_parse_opt (int key, char *arg, struct argp_state *state)
        struct tar_args *args = state->input;
        if (args->loc->source == OPTS_FILE)
          {
-           error (0, 0, _("%s:%lu: unrecognized option"), args->loc->name,
-                  (unsigned long) args->loc->line);
+           error (0, 0, _("%s:%jd: unrecognized option"), args->loc->name,
+                  args->loc->line);
            set_exit_status (TAREXIT_FAILURE);
          }
        return ARGP_ERR_UNKNOWN;
@@ -651,7 +651,7 @@ struct name_elt        /* A name_array element. */
     struct             /* File, if type == NELT_FILE */
     {
       const char *name;/* File name */
-      size_t line;     /* Input line number */
+      intmax_t line;   /* Input line number */
       int term;        /* File name terminator in the list */
       bool verbatim;   /* Verbatim handling of file names: no white-space
                          trimming, no option processing */
index 79b713a89a837c6681e7021faba0de210d099f8d..d69f12b9fc5410658ea189caf6f52fa7290a6957 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -2224,8 +2224,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
 
     case ARGP_KEY_ERROR:
       if (args->loc->source == OPTS_FILE)
-       error (0, 0, _("%s:%lu: location of the error"), args->loc->name,
-              (unsigned long) args->loc->line);
+       error (0, 0, _("%s:%jd: location of the error"), args->loc->name,
+              args->loc->line);
       else if (args->loc->source == OPTS_ENVIRON)
        error (0, 0, _("error parsing %s"), args->loc->name);
       exit (EX_USAGE);