Blame packages/m/mpfr/tests-tsprintf.patch

Bernhard M. Wiedemann 514c2a
From 5172494c09718ffcb7ef1f19b3b211e3bce8781a Mon Sep 17 00:00:00 2001
Bernhard M. Wiedemann 514c2a
From: Vincent Lefevre <vincent@vinc17.net>
Bernhard M. Wiedemann 514c2a
Date: Tue, 10 Jan 2023 17:05:17 +0100
Bernhard M. Wiedemann 514c2a
Subject: [PATCH] [tests/tsprintf.c] Modified a buggy test of the thousands
Bernhard M. Wiedemann 514c2a
 separator.
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
The test
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
  check_vsprintf ("+01,234,567  :", "%0+ -'13.10Pd:", (mpfr_prec_t) 1234567);
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
is based on the output from glibc up to 2.36, which is incorrect:
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
  https://sourceware.org/bugzilla/show_bug.cgi?id=23432
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
The GNU C Library has apparently been partially fixed in its Git
Bernhard M. Wiedemann 514c2a
repository for the future 2.37, since a tsprintf failure has been
Bernhard M. Wiedemann 514c2a
reported (this is a bug in this test, not in the MPFR library):
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
  https://sympa.inria.fr/sympa/arc/mpfr/2023-01/msg00001.html
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
So, modified the test to avoid the particular case of leading zeros
Bernhard M. Wiedemann 514c2a
due to the precision field larger than the number of digits. This
Bernhard M. Wiedemann 514c2a
case has already been tested without the thousands separator (where
Bernhard M. Wiedemann 514c2a
there are no issues with the C libraries), so that we do not miss
Bernhard M. Wiedemann 514c2a
much testing. Added a comment explaining the issue and a possible
Bernhard M. Wiedemann 514c2a
solution for future testing of this particular case (if need be).
Bernhard M. Wiedemann 514c2a
---
Bernhard M. Wiedemann 514c2a
 tests/tsprintf.c | 12 +++++++++++-
Bernhard M. Wiedemann 514c2a
 1 file changed, 11 insertions(+), 1 deletion(-)
Bernhard M. Wiedemann 514c2a
Bernhard M. Wiedemann 514c2a
diff --git a/tests/tsprintf.c b/tests/tsprintf.c
Bernhard M. Wiedemann 514c2a
index c68b2ba71..c0182503b 100644
Bernhard M. Wiedemann 514c2a
--- a/tests/tsprintf.c
Bernhard M. Wiedemann 514c2a
+++ b/tests/tsprintf.c
Bernhard M. Wiedemann 514c2a
@@ -1719,7 +1719,17 @@ test_locale (void)
Bernhard M. Wiedemann 514c2a
   check_sprintf ("000000001,000", "%'013.4Rg", x);
Bernhard M. Wiedemann 514c2a
 
Bernhard M. Wiedemann 514c2a
 #ifdef PRINTF_GROUPFLAG
Bernhard M. Wiedemann 514c2a
-  check_vsprintf ("+01,234,567  :", "%0+ -'13.10Pd:", (mpfr_prec_t) 1234567);
Bernhard M. Wiedemann 514c2a
+  /* Do not test the thousands separator with a precision field larger
Bernhard M. Wiedemann 514c2a
+     than the number of digits (thus needing leading zeros), such as
Bernhard M. Wiedemann 514c2a
+     "%0+ -'13.10Pd:" (used up to MPFR 4.2.0), since the GNU libc is
Bernhard M. Wiedemann 514c2a
+     buggy: https://sourceware.org/bugzilla/show_bug.cgi?id=23432
Bernhard M. Wiedemann 514c2a
+     We don't know about the other implementations.
Bernhard M. Wiedemann 514c2a
+     If we wanted to check that and avoid a failure of the test because of
Bernhard M. Wiedemann 514c2a
+     a buggy C library (while MPFR would be consistent with the C library),
Bernhard M. Wiedemann 514c2a
+     we could compare the MPFR output with both the correct output and the
Bernhard M. Wiedemann 514c2a
+     output from the C library (possibly buggy). But to do that in a clean
Bernhard M. Wiedemann 514c2a
+     way, this would require a change in the check_vsprintf() call. */
Bernhard M. Wiedemann 514c2a
+  check_vsprintf ("+1,234,567   :", "%0+ -'13Pd:", (mpfr_prec_t) 1234567);
Bernhard M. Wiedemann 514c2a
 #endif
Bernhard M. Wiedemann 514c2a
 
Bernhard M. Wiedemann 514c2a
   mpfr_clear (x);
Bernhard M. Wiedemann 514c2a
-- 
Bernhard M. Wiedemann 514c2a
2.39.1
Bernhard M. Wiedemann 514c2a