Discussion:
[PATCH] printf.m4: fix a bug in detecting printf %j support
(too old to reply)
Jim Meyering
2016-10-20 16:43:24 UTC
Permalink
Raw Message
Zev Weiss noticed that on a system with inadequate uintmax_t support,
printf.m4's gl_PRINTF_SIZES_C99 might nonetheless declare "yes".
This fixes it to handle that corner case.

printf.m4: fix a bug in detecting printf %j support
* m4/printf.m4 (gl_PRINTF_SIZES_C99): Fail any system for which
uintmax_t is defined in neither stdint.h nor inttypes.h.
Before, this macro might have mistakenly set
gl_cv_func_printf_sizes_c99=yes on such a system.
Spotted by Zev Weiss.
---
ChangeLog | 9 +++++++++
m4/printf.m4 | 2 ++
2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a1a314b..48b1d1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-10-20 Jim Meyering <***@fb.com>
+
+ printf.m4: fix a bug in detecting printf %j support
+ * m4/printf.m4 (gl_PRINTF_SIZES_C99): Fail any system for which
+ uintmax_t is defined in neither stdint.h nor inttypes.h.
+ Before, this macro might have mistakenly set
+ gl_cv_func_printf_sizes_c99=yes on such a system.
+ Spotted by Zev Weiss.
+
2016-10-19 Paul Eggert <***@cs.ucla.edu>

sched: substitute HAVE_SYS_CDEFS_H too
diff --git a/m4/printf.m4 b/m4/printf.m4
index e495e0c..c7a14b2 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -38,6 +38,8 @@ int main ()
if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
|| strcmp (buf, "12345671 33") != 0)
result |= 1;
+#else
+ result |= 1;
#endif
buf[0] = '\0';
if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
--
2.8.0-rc2
Bruno Haible
2016-10-20 19:51:17 UTC
Permalink
Raw Message
Post by Jim Meyering
diff --git a/m4/printf.m4 b/m4/printf.m4
index e495e0c..c7a14b2 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -38,6 +38,8 @@ int main ()
if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
|| strcmp (buf, "12345671 33") != 0)
result |= 1;
+#else
+ result |= 1;
#endif
buf[0] = '\0';
if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
Looks good: Yes, in this case, *printf is not buggy, but we need to replace it
anyway, for the sake of the gnulib-defined 'uintmax_t'.

Thanks to both of you.

Bruno

Loading...