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.
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);
}
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)
}
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);
{
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;
&& !(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);
{
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;
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);
if (warn)
{
error (0, 0,
- _("%s: %" PRIuMAX
+ _("%s: %ju"
": improperly formatted %s checksum line"),
quotef (checkfile_name), line_number,
DIGEST_TYPE_STRING);
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);
(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)); \
}
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;
}
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);
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;
}
for (size_t i = 0; i < n_pos; i++)
{
intmax_t p = pos[i];
- printf (" %"PRIdMAX, p);
+ printf (" %jd", p);
}
putchar ('\n');
}
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
{
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,
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[] = "\\:";
{
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'"
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. */
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:
}
#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];
else
{
intmax_t days = seconds_idle / (24 * 60 * 60);
- sprintf (buf, "%"PRIdMAX"d", days);
+ sprintf (buf, "%jdd", days);
}
return buf;
}
/* 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;
}
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;
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':
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)
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)
{
{
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 ())
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
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;
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 ();
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;
}
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;
}
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)
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