|
|
76b6d9 |
commit 8b915921fbf4d32bf68fc3d637413cf96236b3fd
|
|
|
76b6d9 |
Author: Andreas Schwab <schwab@suse.de>
|
|
|
76b6d9 |
Date: Mon Aug 29 15:05:40 2022 +0200
|
|
|
76b6d9 |
|
|
|
76b6d9 |
Add test for bug 29530
|
|
|
76b6d9 |
|
|
|
76b6d9 |
This tests for a bug that was introduced in commit edc1686af0 ("vfprintf:
|
|
|
76b6d9 |
Reuse work_buffer in group_number") and fixed as a side effect of commit
|
|
|
76b6d9 |
6caddd34bd ("Remove most vfprintf width/precision-dependent allocations
|
|
|
76b6d9 |
(bug 14231, bug 26211).").
|
|
|
76b6d9 |
|
|
|
76b6d9 |
(cherry picked from commit ca6466e8be32369a658035d69542d47603e58a99)
|
|
|
76b6d9 |
|
|
|
76b6d9 |
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
|
|
|
76b6d9 |
index d76b47bd5f932f69..ac61093660ef9063 100644
|
|
|
76b6d9 |
--- a/stdio-common/Makefile
|
|
|
76b6d9 |
+++ b/stdio-common/Makefile
|
|
|
76b6d9 |
@@ -64,7 +64,9 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
|
|
|
76b6d9 |
tst-scanf-round \
|
|
|
76b6d9 |
tst-renameat2 \
|
|
|
76b6d9 |
tst-printf-bz25691 \
|
|
|
76b6d9 |
- tst-vfprintf-width-prec-alloc
|
|
|
76b6d9 |
+ tst-vfprintf-width-prec-alloc \
|
|
|
76b6d9 |
+ tst-grouping2 \
|
|
|
76b6d9 |
+ # tests
|
|
|
76b6d9 |
|
|
|
76b6d9 |
test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
|
|
|
76b6d9 |
|
|
|
76b6d9 |
@@ -91,6 +93,7 @@ $(objpfx)bug14.out: $(gen-locales)
|
|
|
76b6d9 |
$(objpfx)scanf13.out: $(gen-locales)
|
|
|
76b6d9 |
$(objpfx)test-vfprintf.out: $(gen-locales)
|
|
|
76b6d9 |
$(objpfx)tst-grouping.out: $(gen-locales)
|
|
|
76b6d9 |
+$(objpfx)tst-grouping2.out: $(gen-locales)
|
|
|
76b6d9 |
$(objpfx)tst-sprintf.out: $(gen-locales)
|
|
|
76b6d9 |
$(objpfx)tst-sscanf.out: $(gen-locales)
|
|
|
76b6d9 |
$(objpfx)tst-swprintf.out: $(gen-locales)
|
|
|
76b6d9 |
diff --git a/stdio-common/tst-grouping2.c b/stdio-common/tst-grouping2.c
|
|
|
76b6d9 |
new file mode 100644
|
|
|
76b6d9 |
index 0000000000000000..3024c942a60e51bf
|
|
|
76b6d9 |
--- /dev/null
|
|
|
76b6d9 |
+++ b/stdio-common/tst-grouping2.c
|
|
|
76b6d9 |
@@ -0,0 +1,39 @@
|
|
|
76b6d9 |
+/* Test printf with grouping and large width (bug 29530)
|
|
|
76b6d9 |
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
76b6d9 |
+ This file is part of the GNU C Library.
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
76b6d9 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
76b6d9 |
+ License as published by the Free Software Foundation; either
|
|
|
76b6d9 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
76b6d9 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
76b6d9 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
76b6d9 |
+ Lesser General Public License for more details.
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
76b6d9 |
+ License along with the GNU C Library; if not, see
|
|
|
76b6d9 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+#include <locale.h>
|
|
|
76b6d9 |
+#include <stdio.h>
|
|
|
76b6d9 |
+#include <support/check.h>
|
|
|
76b6d9 |
+#include <support/support.h>
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+static int
|
|
|
76b6d9 |
+do_test (void)
|
|
|
76b6d9 |
+{
|
|
|
76b6d9 |
+ const int field_width = 1000;
|
|
|
76b6d9 |
+ char buf[field_width + 1];
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+ xsetlocale (LC_NUMERIC, "de_DE.UTF-8");
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+ /* This used to crash in group_number. */
|
|
|
76b6d9 |
+ TEST_COMPARE (sprintf (buf, "%'*d", field_width, 1000), field_width);
|
|
|
76b6d9 |
+ TEST_COMPARE_STRING (buf + field_width - 6, " 1.000");
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+ return 0;
|
|
|
76b6d9 |
+}
|
|
|
76b6d9 |
+
|
|
|
76b6d9 |
+#include <support/test-driver.c>
|