On 02/08/2023 00:11, Paul Eggert wrote:
On 2023-08-01 06:28, Pádraig Brady wrote:
perhaps we can now use %j, %t, and %z now?
I hope so, particularly as we haven't seen any issues with Coreutils 9.1
or later.
I haven't run into problems using these printf formats for a while.
Gnulib doc is ambiguous, but suggests it could be an issue on AIX 5.1,
HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.24, mingw, MSVC 14. Of
these, the only platforms that are not obsolete are mingw and MSVC 14,
and Stack Overflow[1] suggests that this is only with older MS-Windows
versions and can be worked around easily on those older versions by
whoever's doing the port.
Diffutils doesn't work on MS-Windows now anyway, as per Bug#64811, so
I'll cc to that bug report to give Gisle Vanem a heads-up about this
other issue.
[1]:
https://stackoverflow.com/questions/44382862/how-to-printf-a-size-t-without-warning-in-mingw-w64-gcc-7-1
Thanks for the info.
I'll apply the following to allow use of all C99 size specs so.
cheers,
Pádraig
From 322530bd433996f8a4f2086c0229facf41c6c709 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Sat, 12 Aug 2023 11:21:50 +0100
Subject: [PATCH] maint: allow use of printf C99 integer size specifiers
Older systems that had issues with these like HPUX and Solaris 8
are no longer supported, or can apply patches to provide support.
Also we've used %td since coreutils 9.1, with no reported issues.
* cfg.mk (sc_prohibit-c99-printf-format): Remove to allow use of
%[jtz] size specifiers, which allows for cleaner code
by avoiding the need to cast to PRI?MAX etc.
---
cfg.mk | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 630251b65..6db0daf71 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -299,17 +299,6 @@ sc_check-I18N-AUTHORS:
'$$(LIBICONV)' 1>&2; exit 1; }; \
done
-# Disallow the C99 printf size specifiers %z and %j as they're not portable.
-# The gnulib printf replacement does support them, however the printf
-# replacement is not currently explicitly depended on by the gnulib error()
-# module for example. Also we use fprintf() in a few places to output simple
-# formats but don't use the gnulib module as it is seen as overkill at present.
-# We'd have to adjust the above gnulib items before disabling this.
-sc_prohibit-c99-printf-format:
- @cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*[jz][udx]' *.c \
- && { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
- || :
-
# Ensure the alternative __attribute (keyword) form isn't used as
# that form is not elided where required. Also ensure that we don't
# directly use attributes already defined by gnulib.
--
2.41.0