coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] maint: use C99 int size specifiers rather than PRI.MAX defines


From: Pádraig Brady
Subject: [PATCH] maint: use C99 int size specifiers rather than PRI.MAX defines
Date: Wed, 13 Sep 2023 23:11:45 +0100

Following on from commit v9.3-128-gf31229ebd
replace all uses of the PRI.MAX portability defines
with C99 size specifiers %z, %j, and %t.
---
 TODO             |  2 +-
 gl/lib/randint.c |  2 +-
 src/dd.c         | 22 +++++++++++-----------
 src/digest.c     | 18 +++++++++---------
 src/getlimits.c  |  4 ++--
 src/group-list.c |  4 ++--
 src/join.c       |  2 +-
 src/libstdbuf.c  |  3 +--
 src/ls.c         |  6 +++---
 src/nl.c         |  6 +++---
 src/numfmt.c     |  4 ++--
 src/od.c         | 19 +++++++++----------
 src/pinky.c      |  2 +-
 src/pr.c         |  7 +++----
 src/printf.c     |  4 ++--
 src/ptx.c        |  4 ++--
 src/rm.c         |  8 ++++----
 src/stat.c       | 12 ++++++------
 src/stdbuf.c     |  4 ++--
 src/truncate.c   |  8 +++-----
 src/uniq.c       |  2 +-
 src/uptime.c     |  4 ++--
 22 files changed, 71 insertions(+), 76 deletions(-)

diff --git a/TODO b/TODO
index 1c7f71e03..032c930da 100644
--- a/TODO
+++ b/TODO
@@ -18,7 +18,7 @@ document the following in coreutils.texi:
 Suggestion from Paul Eggert:
   More generally, there's not that much use for imaxtostr nowadays,
   since the inttypes module and newer versions of gettext allow things
-  like _("truncating %s at %" PRIdMAX " bytes") to work portably.
+  like _("truncating %s at %jd bytes") to work portably.
   I suspect that (if someone cares to take the time) we can remove
   all instances of imaxtostr and umaxtostr in coreutils and gnulib.
 
diff --git a/gl/lib/randint.c b/gl/lib/randint.c
index ccf268bed..fd5f7c38d 100644
--- a/gl/lib/randint.c
+++ b/gl/lib/randint.c
@@ -41,7 +41,7 @@ main (int argc, char **argv)
   struct randint_source *ints = randint_all_new (name, SIZE_MAX);
 
   for (i = 0; i < n; i++)
-    printf ("%"PRIuMAX"\n", randint_choose (ints, choices));
+    printf ("%ju\n", randint_choose (ints, choices));
 
   return (randint_all_free (ints) == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
 }
diff --git a/src/dd.c b/src/dd.c
index 198d4800c..595b8755b 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -778,16 +778,16 @@ print_xfer_stats (xtime_t progress_time)
   int stats_len
     = (abbreviation_lacks_prefix (si)
        ? fprintf (stderr,
-                  ngettext ("%"PRIdMAX" byte copied, %s, %s",
-                            "%"PRIdMAX" bytes copied, %s, %s",
+                  ngettext ("%jd byte copied, %s, %s",
+                            "%jd bytes copied, %s, %s",
                             select_plural (w_bytes)),
                   w_bytes, delta_s_buf, bytes_per_second)
        : abbreviation_lacks_prefix (iec)
        ? fprintf (stderr,
-                  _("%"PRIdMAX" bytes (%s) copied, %s, %s"),
+                  _("%jd bytes (%s) copied, %s, %s"),
                   w_bytes, si, delta_s_buf, bytes_per_second)
        : fprintf (stderr,
-                  _("%"PRIdMAX" bytes (%s, %s) copied, %s, %s"),
+                  _("%jd bytes (%s, %s) copied, %s, %s"),
                   w_bytes, si, iec, delta_s_buf, bytes_per_second));
 
   if (progress_time)
@@ -821,14 +821,14 @@ print_stats (void)
     }
 
   fprintf (stderr,
-           _("%"PRIdMAX"+%"PRIdMAX" records in\n"
-             "%"PRIdMAX"+%"PRIdMAX" records out\n"),
+           _("%jd+%jd records in\n"
+             "%jd+%jd records out\n"),
            r_full, r_partial, w_full, w_partial);
 
   if (r_truncate != 0)
     fprintf (stderr,
-             ngettext ("%"PRIdMAX" truncated record\n",
-                       "%"PRIdMAX" truncated records\n",
+             ngettext ("%jd truncated record\n",
+                       "%jd truncated records\n",
                        select_plural (r_truncate)),
              r_truncate);
 
@@ -2357,7 +2357,7 @@ dd_copy (void)
             {
               if (iftruncate (STDOUT_FILENO, output_offset) != 0)
                 {
-                  diagnose (errno, _("failed to truncate to %" PRIdMAX " bytes"
+                  diagnose (errno, _("failed to truncate to %jd bytes"
                                      " in output file %s"),
                             (intmax_t) output_offset, quoteaf (output_file));
                   return EXIT_FAILURE;
@@ -2479,7 +2479,7 @@ main (int argc, char **argv)
           && !(conversions_mask & C_NOTRUNC))
         error (EXIT_FAILURE, 0,
                _("offset too large: "
-                 "cannot truncate to a length of seek=%"PRIdMAX""
+                 "cannot truncate to a length of seek=%jd"
                  " (%td-byte) blocks"),
                seek_records, output_blocksize);
 
@@ -2515,7 +2515,7 @@ main (int argc, char **argv)
                 {
                   intmax_t isize = size;
                   diagnose (ftruncate_errno,
-                            _("failed to truncate to %"PRIdMAX" bytes"
+                            _("failed to truncate to %jd bytes"
                               " in output file %s"),
                             isize, quoteaf (output_file));
                   exit_status = EXIT_FAILURE;
diff --git a/src/digest.c b/src/digest.c
index 3d239dabd..b996dde11 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -1052,12 +1052,12 @@ output_file (char const *file, int binary_file, void 
const *digest,
       fputs (DIGEST_TYPE_STRING, stdout);
 # if HASH_ALGO_BLAKE2
       if (digest_length < BLAKE2B_MAX_LEN * 8)
-        printf ("-%"PRIuMAX, digest_length);
+        printf ("-%ju", digest_length);
 # elif HASH_ALGO_CKSUM
       if (cksum_algorithm == blake2b)
         {
           if (digest_length < BLAKE2B_MAX_LEN * 8)
-            printf ("-%"PRIuMAX, digest_length);
+            printf ("-%ju", digest_length);
         }
 # endif
       fputs (" (", stdout);
@@ -1205,7 +1205,7 @@ digest_check (char const *checkfile_name)
           if (warn)
             {
               error (0, 0,
-                     _("%s: %" PRIuMAX
+                     _("%s: %ju"
                        ": improperly formatted %s checksum line"),
                      quotef (checkfile_name), line_number,
                      DIGEST_TYPE_STRING);
@@ -1301,24 +1301,24 @@ digest_check (char const *checkfile_name)
           if (n_misformatted_lines != 0)
             error (0, 0,
                    (ngettext
-                    ("WARNING: %" PRIuMAX " line is improperly formatted",
-                     "WARNING: %" PRIuMAX " lines are improperly formatted",
+                    ("WARNING: %ju line is improperly formatted",
+                     "WARNING: %ju lines are improperly formatted",
                      select_plural (n_misformatted_lines))),
                    n_misformatted_lines);
 
           if (n_open_or_read_failures != 0)
             error (0, 0,
                    (ngettext
-                    ("WARNING: %" PRIuMAX " listed file could not be read",
-                     "WARNING: %" PRIuMAX " listed files could not be read",
+                    ("WARNING: %ju listed file could not be read",
+                     "WARNING: %ju listed files could not be read",
                      select_plural (n_open_or_read_failures))),
                    n_open_or_read_failures);
 
           if (n_mismatched_checksums != 0)
             error (0, 0,
                    (ngettext
-                    ("WARNING: %" PRIuMAX " computed checksum did NOT match",
-                     "WARNING: %" PRIuMAX " computed checksums did NOT match",
+                    ("WARNING: %ju computed checksum did NOT match",
+                     "WARNING: %ju computed checksums did NOT match",
                      select_plural (n_mismatched_checksums))),
                    n_mismatched_checksums);
 
diff --git a/src/getlimits.c b/src/getlimits.c
index 4a9dffecd..5a1ab16e4 100644
--- a/src/getlimits.c
+++ b/src/getlimits.c
@@ -130,12 +130,12 @@ main (int argc, char **argv)
                                    (char const *) nullptr);
 
 #define print_int(TYPE)                                                  \
-  sprintf (limit + 1, "%"PRIuMAX, (uintmax_t) TYPE##_MAX);               \
+  sprintf (limit + 1, "%ju", (uintmax_t) TYPE##_MAX);               \
   printf (#TYPE"_MAX=%s\n", limit + 1);                                  \
   printf (#TYPE"_OFLOW=%s\n", decimal_absval_add_one (limit));           \
   if (TYPE##_MIN)                                                        \
     {                                                                    \
-      sprintf (limit + 1, "%"PRIdMAX, (intmax_t) TYPE##_MIN);            \
+      sprintf (limit + 1, "%jd", (intmax_t) TYPE##_MIN);            \
       printf (#TYPE"_MIN=%s\n", limit + 1);                              \
       printf (#TYPE"_UFLOW=%s\n", decimal_absval_add_one (limit));       \
     }
diff --git a/src/group-list.c b/src/group-list.c
index 523012391..5cdf3639f 100644
--- a/src/group-list.c
+++ b/src/group-list.c
@@ -112,12 +112,12 @@ print_group (gid_t gid, bool use_name)
           if (TYPE_SIGNED (gid_t))
             {
               intmax_t g = gid;
-              error (0, 0, _("cannot find name for group ID %"PRIdMAX), g);
+              error (0, 0, _("cannot find name for group ID %jd"), g);
             }
           else
             {
               uintmax_t g = gid;
-              error (0, 0, _("cannot find name for group ID %"PRIuMAX), g);
+              error (0, 0, _("cannot find name for group ID %ju"), g);
             }
           ok = false;
         }
diff --git a/src/join.c b/src/join.c
index 0bcfa75d6..7eef58c0b 100644
--- a/src/join.c
+++ b/src/join.c
@@ -415,7 +415,7 @@ check_order (const struct line *prev,
 
               error ((check_input_order == CHECK_ORDER_ENABLED
                       ? EXIT_FAILURE : 0),
-                     0, _("%s:%"PRIuMAX": is not sorted: %.*s"),
+                     0, _("%s:%ju: is not sorted: %.*s"),
                      g_names[whatfile - 1], line_no[whatfile - 1],
                      (int) len, current->buf.buffer);
 
diff --git a/src/libstdbuf.c b/src/libstdbuf.c
index 16b65fa2b..e2e2fa953 100644
--- a/src/libstdbuf.c
+++ b/src/libstdbuf.c
@@ -118,8 +118,7 @@ apply_mode (FILE *stream, char const *mode)
              glibc currently ignores the combination of null buffer
              with non zero size, we'll fail here.  */
           fprintf (stderr,
-                   _("failed to allocate a %" PRIuMAX
-                     " byte stdio buffer\n"),
+                   _("failed to allocate a %ju byte stdio buffer\n"),
                    size);
           return;
         }
diff --git a/src/ls.c b/src/ls.c
index 31375cc96..5fe6e2725 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1083,7 +1083,7 @@ dired_dump_obstack (char const *prefix, struct obstack 
*os)
       for (size_t i = 0; i < n_pos; i++)
         {
           intmax_t p = pos[i];
-          printf (" %"PRIdMAX, p);
+          printf (" %jd", p);
         }
       putchar ('\n');
     }
@@ -4245,7 +4245,7 @@ format_user_or_group (char const *name, uintmax_t id, int 
width)
       while (pad--);
     }
   else
-    dired_pos += printf ("%*"PRIuMAX" ", width, id);
+    dired_pos += printf ("%*ju ", width, id);
 }
 
 /* Print the name or id of the user with id U, using a print width of
@@ -4275,7 +4275,7 @@ format_user_or_group_width (char const *name, uintmax_t 
id)
 {
   return (name
           ? mbswidth (name, MBSWIDTH_FLAGS)
-          : snprintf (nullptr, 0, "%"PRIuMAX, id));
+          : snprintf (nullptr, 0, "%ju", id));
 }
 
 /* Return the number of columns that format_user will print,
diff --git a/src/nl.c b/src/nl.c
index e41e695e7..539c53f08 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -44,13 +44,13 @@
    value, and a string separator.  */
 
 /* Right justified, no leading zeroes.  */
-static char const FORMAT_RIGHT_NOLZ[] = "%*" PRIdMAX "%s";
+static char const FORMAT_RIGHT_NOLZ[] = "%*jd%s";
 
 /* Right justified, leading zeroes.  */
-static char const FORMAT_RIGHT_LZ[] = "%0*" PRIdMAX "%s";
+static char const FORMAT_RIGHT_LZ[] = "%0*jd%s";
 
 /* Left justified, no leading zeroes.  */
-static char const FORMAT_LEFT[] = "%-*" PRIdMAX "%s";
+static char const FORMAT_LEFT[] = "%-*jd%s";
 
 /* Default section delimiter characters.  */
 static char DEFAULT_SECTION_DELIMITERS[] = "\\:";
diff --git a/src/numfmt.c b/src/numfmt.c
index a242f0efb..8fd6e77ad 100644
--- a/src/numfmt.c
+++ b/src/numfmt.c
@@ -1189,8 +1189,8 @@ prepare_padded_number (const long double val, size_t 
precision,
         {
           if (precision_used)
             error (conv_exit_code, 0,
-                   _("value/precision too large to be printed: 
'%Lg/%"PRIuMAX"'"
-                     " (consider using --to)"), val, 
(uintmax_t)precision_used);
+                   _("value/precision too large to be printed: '%Lg/%zu'"
+                     " (consider using --to)"), val, precision_used);
           else
             error (conv_exit_code, 0,
                    _("value too large to be printed: '%Lg'"
diff --git a/src/od.c b/src/od.c
index 48ec3d4f0..538175af7 100644
--- a/src/od.c
+++ b/src/od.c
@@ -86,10 +86,10 @@ enum
     FMT_BYTES_ALLOCATED =
            (sizeof "%*.99" + 1
             + MAX (sizeof "ld",
-                   MAX (sizeof PRIdMAX,
-                        MAX (sizeof PRIoMAX,
-                             MAX (sizeof PRIuMAX,
-                                  sizeof PRIxMAX)))))
+                   MAX (sizeof "jd",
+                        MAX (sizeof "jd",
+                             MAX (sizeof "ju",
+                                  sizeof "jx")))))
   };
 
 /* Ensure that our choice for FMT_BYTES_ALLOCATED is reasonable.  */
@@ -709,28 +709,28 @@ decode_one_format (char const *s_orig, char const *s, 
char const **next,
           fmt = SIGNED_DECIMAL;
           field_width = bytes_to_signed_dec_digits[size];
           sprintf (tspec->fmt_string, "%%*%s",
-                   ISPEC_TO_FORMAT (size_spec, "d", "ld", PRIdMAX));
+                   ISPEC_TO_FORMAT (size_spec, "d", "ld", "jd"));
           break;
 
         case 'o':
           fmt = OCTAL;
           sprintf (tspec->fmt_string, "%%*.%d%s",
                    (field_width = bytes_to_oct_digits[size]),
-                   ISPEC_TO_FORMAT (size_spec, "o", "lo", PRIoMAX));
+                   ISPEC_TO_FORMAT (size_spec, "o", "lo", "jo"));
           break;
 
         case 'u':
           fmt = UNSIGNED_DECIMAL;
           field_width = bytes_to_unsigned_dec_digits[size];
           sprintf (tspec->fmt_string, "%%*%s",
-                   ISPEC_TO_FORMAT (size_spec, "u", "lu", PRIuMAX));
+                   ISPEC_TO_FORMAT (size_spec, "u", "lu", "ju"));
           break;
 
         case 'x':
           fmt = HEXADECIMAL;
           sprintf (tspec->fmt_string, "%%*.%d%s",
                    (field_width = bytes_to_hex_digits[size]),
-                   ISPEC_TO_FORMAT (size_spec, "x", "lx", PRIxMAX));
+                   ISPEC_TO_FORMAT (size_spec, "x", "lx", "jx"));
           break;
 
         default:
@@ -1956,8 +1956,7 @@ main (int argc, char **argv)
     }
 
 #ifdef DEBUG
-  printf ("lcm=%d, width_per_block=%"PRIuMAX"\n", l_c_m,
-          (uintmax_t) width_per_block);
+  printf ("lcm=%d, width_per_block=%zu\n", l_c_m, width_per_block);
   for (i = 0; i < n_specs; i++)
     {
       int fields_per_block = bytes_per_block / width_bytes[spec[i].size];
diff --git a/src/pinky.c b/src/pinky.c
index 3427fb12b..db0d2557b 100644
--- a/src/pinky.c
+++ b/src/pinky.c
@@ -165,7 +165,7 @@ idle_string (time_t when)
   else
     {
       intmax_t days = seconds_idle / (24 * 60 * 60);
-      sprintf (buf, "%"PRIdMAX"d", days);
+      sprintf (buf, "%jdd", days);
     }
   return buf;
 }
diff --git a/src/pr.c b/src/pr.c
index 419545c02..57361d629 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -2354,8 +2354,7 @@ skip_to_page (uintmax_t page)
           /* It's very helpful, normally the total number of pages is
              not known in advance.  */
           error (0, 0,
-                 _("starting page number %"PRIuMAX
-                   " exceeds page count %"PRIuMAX),
+                 _("starting page number %ju exceeds page count %ju"),
                  page, n);
           break;
         }
@@ -2384,9 +2383,9 @@ print_header (void)
     error (EXIT_FAILURE, 0, _("page number overflow"));
 
   /* The translator must ensure that formatting the translation of
-     "Page %"PRIuMAX does not generate more than (sizeof page_text - 1)
+     "Page %ju" does not generate more than (sizeof page_text - 1)
      bytes.  */
-  sprintf (page_text, _("Page %"PRIuMAX), page_number);
+  sprintf (page_text, _("Page %ju"), page_number);
   available_width = header_width_available - mbswidth (page_text, 0);
   available_width = MAX (0, available_width);
   lhs_spaces = available_width >> 1;
diff --git a/src/printf.c b/src/printf.c
index 9670d8043..a6f63cb00 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -355,8 +355,8 @@ print_direc (char const *start, size_t length, char 
conversion,
     switch (conversion)
       {
       case 'd': case 'i': case 'o': case 'u': case 'x': case 'X':
-        length_modifier = PRIdMAX;
-        length_modifier_len = sizeof PRIdMAX - 2;
+        length_modifier = "j";
+        length_modifier_len = 1;
         break;
 
       case 'a': case 'e': case 'f': case 'g':
diff --git a/src/ptx.c b/src/ptx.c
index 62b95e86a..3601875ed 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -1111,7 +1111,7 @@ fix_output_parameters (void)
           if (file_index > 0)
             line_ordinal -= file_line_count[file_index - 1];
           char ordinal_string[INT_BUFSIZE_BOUND (intmax_t)];
-          reference_width = sprintf (ordinal_string, "%"PRIdMAX, line_ordinal);
+          reference_width = sprintf (ordinal_string, "%jd", line_ordinal);
           if (input_file_name[file_index])
             reference_width += strlen (input_file_name[file_index]);
           if (reference_width > reference_max_width)
@@ -1427,7 +1427,7 @@ define_all_fields (OCCURS *occurs)
         line_ordinal -= file_line_count[occurs->file_index - 1];
 
       char *file_end = stpcpy (reference.start, file_name);
-      reference.end = file_end + sprintf (file_end, ":%"PRIdMAX, line_ordinal);
+      reference.end = file_end + sprintf (file_end, ":%jd", line_ordinal);
     }
   else if (input_reference)
     {
diff --git a/src/rm.c b/src/rm.c
index ecd7699c3..523f148f5 100644
--- a/src/rm.c
+++ b/src/rm.c
@@ -352,11 +352,11 @@ main (int argc, char **argv)
     {
       fprintf (stderr,
                (x.recursive
-                ? ngettext ("%s: remove %"PRIuMAX" argument recursively? ",
-                            "%s: remove %"PRIuMAX" arguments recursively? ",
+                ? ngettext ("%s: remove %ju argument recursively? ",
+                            "%s: remove %ju arguments recursively? ",
                             select_plural (n_files))
-                : ngettext ("%s: remove %"PRIuMAX" argument? ",
-                            "%s: remove %"PRIuMAX" arguments? ",
+                : ngettext ("%s: remove %ju argument? ",
+                            "%s: remove %ju arguments? ",
                             select_plural (n_files))),
                program_name, n_files);
       if (!yesno ())
diff --git a/src/stat.c b/src/stat.c
index 2705f6522..39acfee70 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -693,25 +693,25 @@ out_string (char *pformat, size_t prefix_len, char const 
*arg)
 static int
 out_int (char *pformat, size_t prefix_len, intmax_t arg)
 {
-  make_format (pformat, prefix_len, "'-+ 0", PRIdMAX);
+  make_format (pformat, prefix_len, "'-+ 0", "jd");
   return printf (pformat, arg);
 }
 static int
 out_uint (char *pformat, size_t prefix_len, uintmax_t arg)
 {
-  make_format (pformat, prefix_len, "'-0", PRIuMAX);
+  make_format (pformat, prefix_len, "'-0", "ju");
   return printf (pformat, arg);
 }
 static void
 out_uint_o (char *pformat, size_t prefix_len, uintmax_t arg)
 {
-  make_format (pformat, prefix_len, "-#0", PRIoMAX);
+  make_format (pformat, prefix_len, "-#0", "jo");
   printf (pformat, arg);
 }
 static void
 out_uint_x (char *pformat, size_t prefix_len, uintmax_t arg)
 {
-  make_format (pformat, prefix_len, "-#0", PRIxMAX);
+  make_format (pformat, prefix_len, "-#0", "jx");
   printf (pformat, arg);
 }
 static int
@@ -1139,8 +1139,8 @@ print_it (char const *format, int fd, char const 
*filename,
   enum
     {
       MAX_ADDITIONAL_BYTES =
-        (MAX (sizeof PRIdMAX,
-              MAX (sizeof PRIoMAX, MAX (sizeof PRIuMAX, sizeof PRIxMAX)))
+        (MAX (sizeof "jd",
+              MAX (sizeof "jo", MAX (sizeof "ju", sizeof "jx")))
          - 1)
     };
   size_t n_alloc = strlen (format) + MAX_ADDITIONAL_BYTES + 1;
diff --git a/src/stdbuf.c b/src/stdbuf.c
index 2a58c365d..1ec23cf8b 100644
--- a/src/stdbuf.c
+++ b/src/stdbuf.c
@@ -287,9 +287,9 @@ set_libstdbuf_options (void)
             ret = asprintf (&var, "%s%c=L", "_STDBUF_",
                             toupper (stdbuf[i].optc));
           else
-            ret = asprintf (&var, "%s%c=%" PRIuMAX, "_STDBUF_",
+            ret = asprintf (&var, "%s%c=%zu", "_STDBUF_",
                             toupper (stdbuf[i].optc),
-                            (uintmax_t) stdbuf[i].size);
+                            stdbuf[i].size);
           if (ret < 0)
             xalloc_die ();
 
diff --git a/src/truncate.c b/src/truncate.c
index d0907e302..4a828e1da 100644
--- a/src/truncate.c
+++ b/src/truncate.c
@@ -120,8 +120,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t 
rsize,
       if (ckd_mul (&ssize, ssize, blksize))
         {
           error (0, 0,
-                 _("overflow in %" PRIdMAX
-                   " * %" PRIdPTR " byte blocks for file %s"),
+                 _("overflow in %jd * %td byte blocks for file %s"),
                  ssize0, blksize, quoteaf (fname));
           return false;
         }
@@ -188,9 +187,8 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t 
rsize,
 
   if (ftruncate (fd, nsize) != 0)
     {
-      intmax_t s = nsize;
-      error (0, errno, _("failed to truncate %s at %"PRIdMAX" bytes"),
-             quoteaf (fname), s);
+      error (0, errno, _("failed to truncate %s at %jd bytes"),
+             quoteaf (fname), (intmax_t) nsize);
       return false;
     }
 
diff --git a/src/uniq.c b/src/uniq.c
index fab04ded8..d294ed665 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -307,7 +307,7 @@ writeline (struct linebuffer const *line,
     return;
 
   if (countmode == count_occurrences)
-    printf ("%7" PRIuMAX " ", linecount + 1);
+    printf ("%7ju ", linecount + 1);
 
   if (fwrite (line->buffer, sizeof (char), line->length, stdout)
       != line->length)
diff --git a/src/uptime.c b/src/uptime.c
index ec7f2f777..01b69d164 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -87,8 +87,8 @@ print_uptime (idx_t n, struct gl_utmp const *utmp_buf)
       int uphours = uptime % 86400 / 3600;
       int upmins = uptime % 86400 % 3600 / 60;
       if (0 < updays)
-        printf (ngettext ("up %"PRIdMAX" day %2d:%02d,  ",
-                          "up %"PRIdMAX" days %2d:%02d,  ",
+        printf (ngettext ("up %jd day %2d:%02d,  ",
+                          "up %jd days %2d:%02d,  ",
                           select_plural (updays)),
                 updays, uphours, upmins);
       else
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]