]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: don't rely on support for '%j' printf format
authorPádraig Brady <P@draigBrady.com>
Tue, 30 Oct 2012 02:12:23 +0000 (02:12 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 4 Nov 2012 00:49:04 +0000 (00:49 +0000)
* src/factor.c (print_uintmaxes): Replace with PRIuMAX.
* src/join.c (check_order): Likewise.
* cfg.mk (sc_check-j-printf-format): Add a syntax-check rule
to flag new cases of this.

cfg.mk
src/factor.c
src/join.c

diff --git a/cfg.mk b/cfg.mk
index 362b0603a1b83bcbec6a69d8b4b22456aaf206e4..46652b0173edf67165c4921651ac643c657d14b9 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -191,6 +191,16 @@ sc_check-I18N-AUTHORS:
                    '$$(LIBICONV)' 1>&2; exit 1; };                     \
          done
 
+# Ensure %j is not used for intmax_t as it's not universally supported.
+# There are issues on HPUX for example.  But note that %ju was used between
+# coreutils 8.13 (2011-10) and 8.20 (2012-10) without any reported issue,
+# and the particular issue this check is associated with was for %*jx.
+# So we may be able to relax this restriction soon.
+sc_prohibit-j-printf-format:
+       @cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*j[udx]' *.c  \
+         && { echo '$(ME): Use PRI*MAX instead of %j' 1>&2; exit 1; }  \
+         || :
+
 # Look for lines longer than 80 characters, except omit:
 # - program-generated long lines in diff headers,
 # - tests involving long checksum lines, and
index 4c2af981181abd733dced3c3b526466f1aa9ea6e..be5a36cd5f43f5d539193cab84c99eb1a2870ff5 100644 (file)
@@ -2313,7 +2313,7 @@ print_uintmaxes (uintmax_t t1, uintmax_t t0)
   uintmax_t q, r;
 
   if (t1 == 0)
-    printf ("%ju", t0);
+    printf ("%"PRIuMAX, t0);
   else
     {
       /* Use very plain code here since it seems hard to write fast code
index e39ed872582345506cb4ff1edfaea022d2c6d8ac..eb87301c73aeff222965a8f1ecc68a5fb45246ed 100644 (file)
@@ -400,7 +400,7 @@ check_order (const struct line *prev,
 
               error ((check_input_order == CHECK_ORDER_ENABLED
                       ? EXIT_FAILURE : 0),
-                     0, _("%s:%ju: is not sorted: %.*s"),
+                     0, _("%s:%"PRIuMAX": is not sorted: %.*s"),
                      g_names[whatfile - 1], line_no[whatfile - 1],
                      (int) len, current->buf.buffer);