diff options
Diffstat (limited to 'stdio-common')
112 files changed, 790 insertions, 605 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 3709222..8da1646 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -260,8 +260,10 @@ tests := \ tllformat \ tst-bz11319 \ tst-bz11319-fortify2 \ + tst-bz12701-c \ tst-cookie \ tst-dprintf-length \ + tst-fclose-devzero \ tst-fclose-offset \ tst-fdopen \ tst-fdopen2 \ @@ -758,6 +760,30 @@ CFLAGS-tst-scanf-binary-gnu89.c += -std=gnu89 -DOBJPFX=\"$(objpfx)\" CPPFLAGS += $(libio-mtsafe) +make-tst-freopen4-out = \ + $(run-program-prefix-before-env) \ + $(run-program-env) \ + MALLOC_TRACE=$(@:.out=.mtrace) \ + LD_PRELOAD=$(common-objpfx)malloc/libc_malloc_debug.so \ + $(run-program-prefix-after-env) $< + +freopen4-temp-dir-before = warning: could not remove temporary file: +freopen4-temp-dir-after = : No such file or directory + +$(objpfx)tst-freopen4.out: $(objpfx)tst-freopen4 + $(make-tst-freopen4-out) > $@ && \ + grep "$(freopen4-temp-dir-before)" $@ \ + | sed -e "s/$(freopen4-temp-dir-before)//; s/$(freopen4-temp-dir-after)//" \ + | xargs rm -rf; \ + $(evaluate-test) + +$(objpfx)tst-freopen64-4.out: $(objpfx)tst-freopen64-4 + $(make-tst-freopen4-out) > $@ && \ + grep "$(freopen4-temp-dir-before)" $@ \ + | sed -e "s/$(freopen4-temp-dir-before)//; s/$(freopen4-temp-dir-after)//" \ + | xargs rm -rf; \ + $(evaluate-test) + $(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1 $(test-program-cmd) > $@ 2>&1; \ $(evaluate-test) diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c index aad697a..a7ba52a 100644 --- a/stdio-common/printf-parsemb.c +++ b/stdio-common/printf-parsemb.c @@ -17,6 +17,7 @@ <https://www.gnu.org/licenses/>. */ #include <ctype.h> +#include <errno.h> #include <limits.h> #include <stdlib.h> #include <string.h> diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index 5b46ddc..0039e1b 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -29,7 +29,6 @@ #include <gmp.h> #include <ieee754.h> #include <stdlib/gmp-impl.h> -#include <stdlib/longlong.h> #include <stdlib/fpioconst.h> #include <locale/localeinfo.h> #include <limits.h> @@ -40,6 +39,7 @@ #include <stdlib.h> #include <wchar.h> #include <stdbool.h> +#include <stdbit.h> #include <rounding-mode.h> #include <printf_buffer.h> #include <printf_buffer_to_file.h> @@ -386,7 +386,7 @@ __printf_fp_buffer_1 (struct __printf_buffer *buf, locale_t loc, { int cnt; MPN_ASSIGN (p.scale, p.tmp); - count_leading_zeros (cnt, p.scale[p.scalesize - 1]); + cnt = stdc_leading_zeros (p.scale[p.scalesize - 1]); scaleexpo = (p.scalesize - 2) * BITS_PER_MP_LIMB - cnt - 1; exp10 |= 1 << explog; } @@ -408,7 +408,7 @@ __printf_fp_buffer_1 (struct __printf_buffer *buf, locale_t loc, ; /* Determine number of bits the scaling factor is misplaced. */ - count_leading_zeros (cnt_h, p.scale[p.scalesize - 1]); + cnt_h = stdc_leading_zeros (p.scale[p.scalesize - 1]); if (cnt_h == 0) { @@ -426,17 +426,17 @@ __printf_fp_buffer_1 (struct __printf_buffer *buf, locale_t loc, { if (p.scale[i] != 0) { - count_trailing_zeros (cnt_l, p.scale[i]); + cnt_l = stdc_trailing_zeros (p.scale[i]); if (p.frac[i] != 0) { int cnt_l2; - count_trailing_zeros (cnt_l2, p.frac[i]); + cnt_l2 = stdc_trailing_zeros (p.frac[i]); if (cnt_l2 < cnt_l) cnt_l = cnt_l2; } } else - count_trailing_zeros (cnt_l, p.frac[i]); + cnt_l = stdc_trailing_zeros (p.frac[i]); /* Now shift the numbers to their optimal position. */ if (i == 0 && BITS_PER_MP_LIMB - cnt_h > cnt_l) @@ -528,7 +528,7 @@ __printf_fp_buffer_1 (struct __printf_buffer *buf, locale_t loc, if (cy == 0) --p.tmpsize; - count_leading_zeros (cnt_h, p.tmp[p.tmpsize - 1]); + cnt_h = stdc_leading_zeros (p.tmp[p.tmpsize - 1]); incr = (p.tmpsize - p.fracsize) * BITS_PER_MP_LIMB + BITS_PER_MP_LIMB - 1 - cnt_h; @@ -584,7 +584,7 @@ __printf_fp_buffer_1 (struct __printf_buffer *buf, locale_t loc, } else { - count_trailing_zeros (cnt_l, p.tmp[i]); + cnt_l = stdc_trailing_zeros (p.tmp[i]); /* Now shift the numbers to their optimal position. */ if (i == 0 && BITS_PER_MP_LIMB - 1 - cnt_h > cnt_l) @@ -630,7 +630,7 @@ __printf_fp_buffer_1 (struct __printf_buffer *buf, locale_t loc, p.tmpsize = p.fracsize; assert (cy == 0 || p.tmp[p.tmpsize - 1] < 20); - count_trailing_zeros (cnt_l, p.tmp[0]); + cnt_l = stdc_trailing_zeros (p.tmp[0]); if (cnt_l < MIN (4, p.exponent)) { cy = __mpn_lshift (p.frac, p.tmp, p.tmpsize, diff --git a/stdio-common/stdio_ext.h b/stdio-common/stdio_ext.h index 3a9a981..397b37f 100644 --- a/stdio-common/stdio_ext.h +++ b/stdio-common/stdio_ext.h @@ -43,43 +43,43 @@ __BEGIN_DECLS /* Return the size of the buffer of FP in bytes currently in use by the given stream. */ -extern size_t __fbufsize (FILE *__fp) __THROW; +extern size_t __fbufsize (FILE *__fp) __THROW __nonnull ((1)); /* Return non-zero value iff the stream FP is opened readonly, or if the last operation on the stream was a read operation. */ -extern int __freading (FILE *__fp) __THROW; +extern int __freading (FILE *__fp) __THROW __nonnull ((1)); /* Return non-zero value iff the stream FP is opened write-only or append-only, or if the last operation on the stream was a write operation. */ -extern int __fwriting (FILE *__fp) __THROW; +extern int __fwriting (FILE *__fp) __THROW __nonnull ((1)); /* Return non-zero value iff stream FP is not opened write-only or append-only. */ -extern int __freadable (FILE *__fp) __THROW; +extern int __freadable (FILE *__fp) __THROW __nonnull ((1)); /* Return non-zero value iff stream FP is not opened read-only. */ -extern int __fwritable (FILE *__fp) __THROW; +extern int __fwritable (FILE *__fp) __THROW __nonnull ((1)); /* Return non-zero value iff the stream FP is line-buffered. */ -extern int __flbf (FILE *__fp) __THROW; +extern int __flbf (FILE *__fp) __THROW __nonnull ((1)); /* Discard all pending buffered I/O on the stream FP. */ -extern void __fpurge (FILE *__fp) __THROW; +extern void __fpurge (FILE *__fp) __THROW __nonnull ((1)); /* Return amount of output in bytes pending on a stream FP. */ -extern size_t __fpending (FILE *__fp) __THROW; +extern size_t __fpending (FILE *__fp) __THROW __nonnull ((1)); /* Flush all line-buffered files. */ extern void _flushlbf (void); /* Set locking status of stream FP to TYPE. */ -extern int __fsetlocking (FILE *__fp, int __type) __THROW; +extern int __fsetlocking (FILE *__fp, int __type) __THROW __nonnull ((1)); __END_DECLS diff --git a/stdio-common/tst-bz12701-c.c b/stdio-common/tst-bz12701-c.c new file mode 100644 index 0000000..ffb4330 --- /dev/null +++ b/stdio-common/tst-bz12701-c.c @@ -0,0 +1,175 @@ +/* Verify scanf field width handling with the 'c' conversion (BZ #12701). + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <string.h> + +#include <libc-diag.h> +#include <support/check.h> +#include <support/next_to_fault.h> +#include <support/xstdio.h> + +/* Verify various aspects of field width handling, including the data + obtained, the number of bytes consumed, and the stream position. */ + +static int +do_test (void) +{ + static const char s[43] = "The quick brown fox jumps over the lazy dog"; + struct support_next_to_fault ntfo, ntfi; + ntfo = support_next_to_fault_allocate (sizeof (s)); + ntfi = support_next_to_fault_allocate (sizeof (s)); + char *e = ntfo.buffer + sizeof (s); + char *b = ntfi.buffer; + + char *c; + FILE *f; + int n; + int i; + + memcpy (ntfi.buffer, s, sizeof (s)); + + i = 0; + f = fmemopen (b, sizeof (s), "r"); + if (f == NULL) + FAIL_EXIT1 ("fmemopen: %m"); + + c = e - 1; + TEST_VERIFY_EXIT (ftell (f) == i); + /* Avoid: "warning: zero width in gnu_scanf format [-Werror=format=]". */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat"); + TEST_VERIFY_EXIT (fscanf (f, "%0c%n", c, &n) == 1); + DIAG_POP_NEEDS_COMMENT; + TEST_VERIFY_EXIT (n == 1); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 1; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 1); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 1; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%1c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 1); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 2; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 2); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 4; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%4c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 4); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 8; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%8c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 8); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 16; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%16c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 16); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - (sizeof (s) - i); + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%32c%n", c, &n) == EOF); + TEST_VERIFY_EXIT (n == 16); + TEST_VERIFY_EXIT (memcmp (c, s + i, sizeof (s) - i) == 0); + + TEST_VERIFY_EXIT (ftell (f) == sizeof (s)); + TEST_VERIFY_EXIT (feof (f) != 0); + + xfclose (f); + + i = 0; + f = fmemopen (b, 3, "r"); + if (f == NULL) + FAIL_EXIT1 ("fmemopen: %m"); + + c = e - 1; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 1); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - 2; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 2); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - (3 - i); + TEST_VERIFY_EXIT (feof (f) == 0); + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == EOF); + TEST_VERIFY_EXIT (n == 2); + + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (feof (f) != 0); + + xfclose (f); + + i = 0; + f = fmemopen (b, 3, "r"); + if (f == NULL) + FAIL_EXIT1 ("fmemopen: %m"); + + c = e - 2; + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == 1); + TEST_VERIFY_EXIT (n == 2); + TEST_VERIFY_EXIT (memcmp (c, s + i, n) == 0); + i += n; + + c = e - (3 - i); + TEST_VERIFY_EXIT (ftell (f) == i); + TEST_VERIFY_EXIT (fscanf (f, "%2c%n", c, &n) == EOF); + TEST_VERIFY_EXIT (n == 2); + TEST_VERIFY_EXIT (memcmp (c, s + i, 3 - i) == 0); + + TEST_VERIFY_EXIT (ftell (f) == 3); + TEST_VERIFY_EXIT (feof (f) != 0); + + xfclose (f); + + support_next_to_fault_free (&ntfi); + support_next_to_fault_free (&ntfo); + + return 0; +} + +#include <support/test-driver.c> diff --git a/stdio-common/tst-fclose-devzero.c b/stdio-common/tst-fclose-devzero.c new file mode 100644 index 0000000..1c7b39a --- /dev/null +++ b/stdio-common/tst-fclose-devzero.c @@ -0,0 +1,50 @@ +/* Test that always-zero lseek does not cause fclose failure after fread. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <stdio.h> +#include <string.h> + +#include <support/check.h> +#include <support/xstdio.h> + +int +do_test (void) +{ + for (int do_ftello = 0; do_ftello < 2; ++do_ftello) + { + FILE *fp = xfopen ("/dev/zero", "r"); + char buf[17]; + memset (buf, 0xcc, sizeof (buf)); + xfread (buf, 1, sizeof (buf), fp); + static const char zeros[sizeof (buf)] = { 0 }; + TEST_COMPARE_BLOB (buf, sizeof (buf), zeros, sizeof (zeros)); + if (do_ftello) + { + errno = 0; + TEST_COMPARE (ftello (fp), -1); + TEST_COMPARE (errno, ESPIPE); + } + /* Do not use xfclose because it flushes first. */ + TEST_COMPARE (fclose (fp), 0); + } + + return 0; +} + +#include <support/test-driver.c> diff --git a/stdio-common/tst-scanf-format-c-c.input b/stdio-common/tst-scanf-format-c-c.input index a3a6ee2..67c7865 100644 --- a/stdio-common/tst-scanf-format-c-c.input +++ b/stdio-common/tst-scanf-format-c-c.input @@ -22,30 +22,14 @@ %*2c:brown fox:0:2: %2c:jumps over the lazy dog:1:2:ju: %*2c:jumps over the lazy dog:0:2: -# BZ12701 %5c:The:0:-1: -# BZ12701 %*5c:The:0:-1: %5c:quick:1:5:quick: %*5c:quick:0:5: %5c:brown fox:1:5:brown: %*5c:brown fox:0:5: %5c:jumps over the lazy dog:1:5:jumps: %*5c:jumps over the lazy dog:0:5: -# BZ12701 %10c:The:0:-1: -# BZ12701 %*10c:The:0:-1: -# BZ12701 %10c:quick:0:-1: -# BZ12701 %*10c:quick:0:-1: -# BZ12701 %10c:brown fox:0:-1: -# BZ12701 %*10c:brown fox:0:-1: %10c:jumps over the lazy dog:1:10:jumps over: %*10c:jumps over the lazy dog:0:10: -# BZ12701 %25c:The:0:-1: -# BZ12701 %*25c:The:0:-1: -# BZ12701 %25c:quick:0:-1: -# BZ12701 %*25c:quick:0:-1: -# BZ12701 %25c:brown fox:0:-1: -# BZ12701 %*25c:brown fox:0:-1: -# BZ12701 %25c:jumps over the lazy dog:0:-1: -# BZ12701 %*25c:jumps over the lazy dog:0:-1: %5c: The :1:5: The : %*5c: The :0:5: %5c: quick :1:5: quic: @@ -54,11 +38,5 @@ %*5c: brown fox :0:5: %5c: jumps over the lazy dog :1:5: jump: %*5c: jumps over the lazy dog :0:5: -# BZ12701 %25c: The :0:-1: -# BZ12701 %*25c: The :0:-1: -# BZ12701 %25c: quick :0:-1: -# BZ12701 %*25c: quick :0:-1: -# BZ12701 %25c: brown fox :0:-1: -# BZ12701 %*25c: brown fox :0:-1: %25c: jumps over the lazy dog :1:25: jumps over the lazy dog : %*25c: jumps over the lazy dog :0:25: diff --git a/stdio-common/tst-scanf-format-character.h b/stdio-common/tst-scanf-format-character.h index b68a5e1..170218f 100644 --- a/stdio-common/tst-scanf-format-character.h +++ b/stdio-common/tst-scanf-format-character.h @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <stdbool.h> #include <string.h> #include <support/next_to_fault.h> @@ -62,69 +63,69 @@ do \ } \ while (0) -#define verify_input(f, val, count, errp) \ -({ \ - __label__ out, skip; \ - bool match = true; \ - int err = 0; \ - size_t i; \ - int ch; \ - \ - for (i = 0; i < count; i++) \ - { \ - ch = read_input (); \ - if (ch < 0) \ - { \ - err = ch; \ - goto out; \ - } \ - if (ch == ':' && val[i] == '\0' && f == 's') \ - goto skip; \ - if (ch != val[i]) \ - { \ - match = false; \ - goto out; \ - } \ - } \ - ch = read_input (); \ - if (ch < 0) \ - { \ - err = ch; \ - goto out; \ - } \ - \ -skip: \ - if (f != 'c' && val[i++] != '\0') \ - { \ - err = OUTPUT_TERM; \ - goto out; \ - } \ - if (val[i] != '\xa5') \ - { \ - err = OUTPUT_OVERRUN; \ - goto out; \ - } \ - \ - while (ch != ':') \ - { \ - ch = read_input (); \ - if (ch < 0) \ - { \ - err = ch; \ - goto out; \ - } \ - match = false; \ - } \ - \ -out: \ - if (err || !match) \ - { \ - printf ("error: %s:%d: input buffer: `", __FILE__, __LINE__); \ - for (size_t j = 0; j <= i; j++) \ - printf ("%c", val[j]); \ - printf ("'\n"); \ - } \ - \ - *errp = err; \ - match; \ -}) +static bool +verify_input (char f, type_t val, long long count, int *errp) +{ + bool match = true; + int err = 0; + size_t i; + int ch; + + for (i = 0; i < count; i++) + { + ch = read_input (); + if (ch < 0) + { + err = ch; + goto out; + } + if (ch == ':' && val[i] == '\0' && f == 's') + goto skip; + if (ch != val[i]) + { + match = false; + goto out; + } + } + ch = read_input (); + if (ch < 0) + { + err = ch; + goto out; + } + +skip: + if (f != 'c' && val[i++] != '\0') + { + err = OUTPUT_TERM; + goto out; + } + if (val[i] != '\xa5') + { + err = OUTPUT_OVERRUN; + goto out; + } + + while (ch != ':') + { + ch = read_input (); + if (ch < 0) + { + err = ch; + goto out; + } + match = false; + } + +out: + if (err || !match) + { + printf ("error: %s:%d: input buffer: `", __FILE__, __LINE__); + for (size_t j = 0; j <= i; j++) + printf ("%c", val[j]); + printf ("'\n"); + } + + *errp = err; + return match; +} diff --git a/stdio-common/tst-scanf-format-f-c.c b/stdio-common/tst-scanf-format-f-c.c index 75ce3cd..143f94a 100644 --- a/stdio-common/tst-scanf-format-f-c.c +++ b/stdio-common/tst-scanf-format-f-c.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-character.h" -#include "tst-scanf-format-skeleton-c.c" +#include <tst-scanf-format-skeleton-c.c> diff --git a/stdio-common/tst-scanf-format-f-char.c b/stdio-common/tst-scanf-format-f-char.c index ee5fbe9..ba70d6e 100644 --- a/stdio-common/tst-scanf-format-f-char.c +++ b/stdio-common/tst-scanf-format-f-char.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-char.c" +#include <tst-scanf-format-skeleton-char.c> diff --git a/stdio-common/tst-scanf-format-f-double.c b/stdio-common/tst-scanf-format-f-double.c index 1fb25b5..45e6fee 100644 --- a/stdio-common/tst-scanf-format-f-double.c +++ b/stdio-common/tst-scanf-format-f-double.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-double.c" +#include <tst-scanf-format-skeleton-double.c> diff --git a/stdio-common/tst-scanf-format-f-float.c b/stdio-common/tst-scanf-format-f-float.c index b5a6ae4..fcf6132 100644 --- a/stdio-common/tst-scanf-format-f-float.c +++ b/stdio-common/tst-scanf-format-f-float.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-float.c" +#include <tst-scanf-format-skeleton-float.c> diff --git a/stdio-common/tst-scanf-format-f-int.c b/stdio-common/tst-scanf-format-f-int.c index 961d66b..cec4352 100644 --- a/stdio-common/tst-scanf-format-f-int.c +++ b/stdio-common/tst-scanf-format-f-int.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-int.c" +#include <tst-scanf-format-skeleton-int.c> diff --git a/stdio-common/tst-scanf-format-f-ldouble.c b/stdio-common/tst-scanf-format-f-ldouble.c index 6198d35..0128597 100644 --- a/stdio-common/tst-scanf-format-f-ldouble.c +++ b/stdio-common/tst-scanf-format-f-ldouble.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-ldouble.c" +#include <tst-scanf-format-skeleton-ldouble.c> diff --git a/stdio-common/tst-scanf-format-f-llong.c b/stdio-common/tst-scanf-format-f-llong.c index 1af672f..63ff399 100644 --- a/stdio-common/tst-scanf-format-f-llong.c +++ b/stdio-common/tst-scanf-format-f-llong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-llong.c" +#include <tst-scanf-format-skeleton-llong.c> diff --git a/stdio-common/tst-scanf-format-f-long.c b/stdio-common/tst-scanf-format-f-long.c index fc90811..fa08ef2 100644 --- a/stdio-common/tst-scanf-format-f-long.c +++ b/stdio-common/tst-scanf-format-f-long.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-long.c" +#include <tst-scanf-format-skeleton-long.c> diff --git a/stdio-common/tst-scanf-format-f-short.c b/stdio-common/tst-scanf-format-f-short.c index 61697e2..c901fbc 100644 --- a/stdio-common/tst-scanf-format-f-short.c +++ b/stdio-common/tst-scanf-format-f-short.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-short.c" +#include <tst-scanf-format-skeleton-short.c> diff --git a/stdio-common/tst-scanf-format-f-uchar.c b/stdio-common/tst-scanf-format-f-uchar.c index b4b8af3..6d0ab1a 100644 --- a/stdio-common/tst-scanf-format-f-uchar.c +++ b/stdio-common/tst-scanf-format-f-uchar.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uchar.c" +#include <tst-scanf-format-skeleton-uchar.c> diff --git a/stdio-common/tst-scanf-format-f-uint.c b/stdio-common/tst-scanf-format-f-uint.c index af226b0..b7971f8 100644 --- a/stdio-common/tst-scanf-format-f-uint.c +++ b/stdio-common/tst-scanf-format-f-uint.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uint.c" +#include <tst-scanf-format-skeleton-uint.c> diff --git a/stdio-common/tst-scanf-format-f-ullong.c b/stdio-common/tst-scanf-format-f-ullong.c index 50ea812..5faa5d6 100644 --- a/stdio-common/tst-scanf-format-f-ullong.c +++ b/stdio-common/tst-scanf-format-f-ullong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ullong.c" +#include <tst-scanf-format-skeleton-ullong.c> diff --git a/stdio-common/tst-scanf-format-f-ulong.c b/stdio-common/tst-scanf-format-f-ulong.c index 673e770..ba66498 100644 --- a/stdio-common/tst-scanf-format-f-ulong.c +++ b/stdio-common/tst-scanf-format-f-ulong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ulong.c" +#include <tst-scanf-format-skeleton-ulong.c> diff --git a/stdio-common/tst-scanf-format-f-ushort.c b/stdio-common/tst-scanf-format-f-ushort.c index 413ba67..35264ee 100644 --- a/stdio-common/tst-scanf-format-f-ushort.c +++ b/stdio-common/tst-scanf-format-f-ushort.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-f.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ushort.c" +#include <tst-scanf-format-skeleton-ushort.c> diff --git a/stdio-common/tst-scanf-format-integer.h b/stdio-common/tst-scanf-format-integer.h index 28f91a4..3d5a12a 100644 --- a/stdio-common/tst-scanf-format-integer.h +++ b/stdio-common/tst-scanf-format-integer.h @@ -16,36 +16,45 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <stdbool.h> #include <string.h> /* Reference data is a signed decimal integer constant to compare against arithmetically. */ +/* Tweak our environment according to any TYPE_T_UNSIGNED_P setting + supplied by the individual test case. */ +#ifdef TYPE_T_UNSIGNED_P +# define UNSIGNED unsigned +#else +# define UNSIGNED +#endif + #define pointer_to_value(val) (&(val)) #define initialize_value(val) \ memset (&val, 0xa5, sizeof (val)) -#define verify_input(f, val, count, errp) \ -({ \ - __label__ out; \ - bool match = true; \ - int err; \ - \ - UNSIGNED long long v = read_integer (&err); \ - if (err < 0) \ - goto out; \ - match = val == v; \ - \ -out: \ - if (err || !match) \ - { \ - printf ("error: %s:%d: input: %016llx\n", \ - __FILE__, __LINE__, (long long) val); \ - printf ("error: %s:%d: value: %016llx\n", \ - __FILE__, __LINE__, v); \ - } \ - \ - *errp = err; \ - match; \ -}) +static bool +verify_input (char f, type_t val, long long count, int *errp) +{ + bool match = true; + int err; + + UNSIGNED long long v = read_integer (&err); + if (err < 0) + goto out; + match = val == v; + +out: + if (err || !match) + { + printf ("error: %s:%d: input: %016llx\n", + __FILE__, __LINE__, (long long) val); + printf ("error: %s:%d: value: %016llx\n", + __FILE__, __LINE__, v); + } + + *errp = err; + return match; +} diff --git a/stdio-common/tst-scanf-format-real.h b/stdio-common/tst-scanf-format-real.h index 639ac74..a4e5109 100644 --- a/stdio-common/tst-scanf-format-real.h +++ b/stdio-common/tst-scanf-format-real.h @@ -66,298 +66,306 @@ #define initialize_value(val) \ memset (&val, 0xa5, sizeof (val)) -#define compare_real(x, y) \ - (memcmp (&(x), &(y), sizeof (y)) == 0) - -#define verify_input(f, val, count, errp) \ -({ \ - __label__ out; \ - bool match = true; \ - int err = 0; \ - type_t v; \ - \ - initialize_value (v); \ - /* Make sure it's been committed. */ \ - __asm__ ("" : : : "memory"); \ - v = read_real (&err); \ - if (err < 0) \ - goto out; \ - match = compare_real (val, v); \ - \ -out: \ - if (err || !match) \ - { \ - union \ - { \ - type_t v; \ - unsigned char x[sizeof (type_t)]; \ - } \ - uv = { .v = v }, ui = { .v = val }; \ - \ - printf ("error: %s:%d: input buffer: `", __FILE__, __LINE__); \ - for (size_t j = 0; j < sizeof (ui.x); j++) \ - printf ("%02hhx", ui.x[j]); \ - printf ("'\n"); \ - printf ("error: %s:%d: value buffer: `", __FILE__, __LINE__); \ - for (size_t j = 0; j < sizeof (uv.x); j++) \ - printf ("%02hhx", uv.x[j]); \ - printf ("'\n"); \ - } \ - \ - *errp = err; \ - match; \ -}) - -#define read_real(errp) \ -({ \ - __label__ out; \ - bool m = false; \ - int err = 0; \ - type_t v; \ - int ch; \ - \ - ch = read_input (); \ - if (ch == '-' || ch == '+') \ - { \ - m = ch == '-'; \ - ch = read_input (); \ - } \ - \ - switch (ch) \ - { \ - case '0': \ - break; \ - case 'I': \ - case 'i': \ - { \ - static const char unf[] = { 'N', 'F' }; \ - static const char lnf[] = { 'n', 'f' }; \ - size_t i; \ - \ - for (i = 0; i < sizeof (unf); i++) \ - { \ - ch = read_input (); \ - if (ch != unf[i] && ch != lnf[i]) \ - { \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - } \ - \ - ch = read_input (); \ - if (ch == ':') \ - { \ - v = m ? -INFINITY : +INFINITY; \ - goto out; \ - } \ - \ - static const char uinity[] = { 'I', 'N', 'I', 'T', 'Y' }; \ - static const char linity[] = { 'i', 'n', 'i', 't', 'y' }; \ - \ - for (i = 0; i < sizeof (uinity); i++) \ - { \ - if (ch != uinity[i] && ch != linity[i]) \ - { \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - ch = read_input (); \ - } \ - if (ch == ':') \ - { \ - v = m ? -INFINITY : +INFINITY; \ - goto out; \ - } \ - } \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - \ - case 'N': \ - case 'n': \ - { \ - static const char uan[] = { 'A', 'N' }; \ - static const char lan[] = { 'a', 'n' }; \ - size_t i; \ - \ - for (i = 0; i < sizeof (uan); i++) \ - { \ - ch = read_input (); \ - if (ch != uan[i] && ch != lan[i]) \ - { \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - } \ - \ - ch = read_input (); \ - if (ch == ':') \ - { \ - v = m ? -nan (v, ".") : nan (v, "."); \ - goto out; \ - } \ - \ - size_t seq_size = 0; \ - char *seq = NULL; \ - i = 0; \ - if (ch == '(') \ - while (1) \ - { \ - ch = read_input (); \ - if (ch == ')') \ - break; \ - if (ch != '_' && !isdigit (ch) \ - && !(ch >= 'A' && ch <= 'Z') \ - && !(ch >= 'a' && ch <= 'z')) \ - { \ - free (seq); \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - if (i == seq_size) \ - { \ - seq_size += SIZE_CHUNK; \ - seq = xrealloc (seq, seq_size); \ - } \ - seq[i++] = ch; \ - } \ - seq[i] = '\0'; \ - \ - ch = read_input (); \ - if (ch == ':') \ - { \ - v = m ? -nan (v, seq) : nan (v, seq); \ - free (seq); \ - goto out; \ - } \ - free (seq); \ - } \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - \ - default: \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - \ - ch = read_input (); \ - if (ch != 'X' && ch != 'x') \ - { \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - \ - type_t f = m ? -1.0 : 1.0; \ - v = m ? -0.0 : 0.0; \ - int i = 0; \ - do \ - { \ - int d = 0; \ - \ - ch = read_input (); \ - \ - if (i == 1) \ - switch (ch) \ - { \ - case '.': \ - i++; \ - continue; \ - \ - case ':': \ - case 'P': \ - case 'p': \ - break; \ - \ - default: \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - \ - switch (ch) \ - { \ - case '0': \ - case '1': \ - case '2': \ - case '3': \ - case '4': \ - case '5': \ - case '6': \ - case '7': \ - case '8': \ - case '9': \ - d = ch - '0'; \ - break; \ - \ - case 'A': \ - case 'B': \ - case 'C': \ - case 'D': \ - case 'E': \ - case 'F': \ - d = ch - 'A' + 10; \ - break; \ - \ - case 'a': \ - case 'b': \ - case 'c': \ - case 'd': \ - case 'e': \ - case 'f': \ - d = ch - 'a' + 10; \ - break; \ - \ - case ':': \ - case 'P': \ - case 'p': \ - if (i == 0) \ - { \ - err = INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - break; \ - \ - default: \ - err = ch < 0 ? ch : INPUT_FORMAT; \ - v = NAN; \ - goto out; \ - } \ - \ - v += f * d; \ - f /= 16.0l; \ - i++; \ - } \ - while (ch != ':' && ch != 'P' && ch != 'p'); \ - \ - long long exp = 0; \ - if (ch == 'P' || ch == 'p') \ - { \ - exp = read_integer (&err); \ - if (err) \ - { \ - v = NAN; \ - goto out; \ - } \ - } \ - \ - errno = 0; \ - v = ldexp (v, exp); \ - if ((v == HUGE_VALL || v == -HUGE_VALL) && errno != 0) \ - { \ - err = INPUT_OVERFLOW; \ - v = NAN; \ - goto out; \ - } \ - \ -out: \ - *errp = err; \ - v; \ -}) +#ifndef compare_real +static bool +compare_real (type_t x, type_t y) +{ + return memcmp (&x, &y, sizeof (y)) == 0; +} +#endif + +static type_t +read_real (int *errp) +{ + bool m = false; + int err = 0; + type_t v; + int ch; + + ch = read_input (); + if (ch == '-' || ch == '+') + { + m = ch == '-'; + ch = read_input (); + } + + switch (ch) + { + case '0': + break; + case 'I': + case 'i': + { + static const char unf[] = { 'N', 'F' }; + static const char lnf[] = { 'n', 'f' }; + size_t i; + + for (i = 0; i < sizeof (unf); i++) + { + ch = read_input (); + if (ch != unf[i] && ch != lnf[i]) + { + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + } + + ch = read_input (); + if (ch == ':') + { + v = m ? -INFINITY : +INFINITY; + goto out; + } + + static const char uinity[] = { 'I', 'N', 'I', 'T', 'Y' }; + static const char linity[] = { 'i', 'n', 'i', 't', 'y' }; + + for (i = 0; i < sizeof (uinity); i++) + { + if (ch != uinity[i] && ch != linity[i]) + { + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + ch = read_input (); + } + if (ch == ':') + { + v = m ? -INFINITY : +INFINITY; + goto out; + } + } + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + + case 'N': + case 'n': + { + static const char uan[] = { 'A', 'N' }; + static const char lan[] = { 'a', 'n' }; + size_t i; + + for (i = 0; i < sizeof (uan); i++) + { + ch = read_input (); + if (ch != uan[i] && ch != lan[i]) + { + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + } + + ch = read_input (); + if (ch == ':') + { + v = m ? -nan (v, ".") : nan (v, "."); + goto out; + } + + if (ch == '(') + { + size_t seq_size = 0; + char *seq = NULL; + i = 0; + while (1) + { + if (i == seq_size) + { + seq_size += SIZE_CHUNK; + seq = xrealloc (seq, seq_size); + } + ch = read_input (); + if (ch == ')') + break; + if (ch != '_' && !isdigit (ch) + && !(ch >= 'A' && ch <= 'Z') + && !(ch >= 'a' && ch <= 'z')) + { + free (seq); + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + seq[i++] = ch; + } + seq[i] = '\0'; + + ch = read_input (); + if (ch == ':') + { + v = m ? -nan (v, seq) : nan (v, seq); + free (seq); + goto out; + } + free (seq); + } + } + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + + default: + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + + ch = read_input (); + if (ch != 'X' && ch != 'x') + { + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + + type_t f = m ? -1.0 : 1.0; + v = m ? -0.0 : 0.0; + int i = 0; + do + { + int d = 0; + + ch = read_input (); + + if (i == 1) + switch (ch) + { + case '.': + i++; + continue; + + case ':': + case 'P': + case 'p': + break; + + default: + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + + switch (ch) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + d = ch - '0'; + break; + + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + d = ch - 'A' + 10; + break; + + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + d = ch - 'a' + 10; + break; + + case ':': + case 'P': + case 'p': + if (i == 0) + { + err = INPUT_FORMAT; + v = NAN; + goto out; + } + break; + + default: + err = ch < 0 ? ch : INPUT_FORMAT; + v = NAN; + goto out; + } + + v += f * d; + f /= 16.0l; + i++; + } + while (ch != ':' && ch != 'P' && ch != 'p'); + + long long exp = 0; + if (ch == 'P' || ch == 'p') + { + exp = read_integer (&err); + if (err) + { + v = NAN; + goto out; + } + } + + errno = 0; + v = ldexp (v, exp); + if ((v == HUGE_VALL || v == -HUGE_VALL) && errno != 0) + { + err = INPUT_OVERFLOW; + v = NAN; + goto out; + } + +out: + *errp = err; + return v; +} + +static bool +verify_input (char f, type_t val, long long count, int *errp) +{ + bool match = true; + int err = 0; + type_t v; + + initialize_value (v); + /* Make sure it's been committed. */ + __asm__ ("" : : : "memory"); + + v = read_real (&err); + if (err < 0) + goto out; + + match = compare_real (val, v); + if (!match) + { + union + { + type_t v; + unsigned char x[sizeof (type_t)]; + } + uv = { .v = v }, ui = { .v = val }; + + printf ("error: %s:%d: input buffer: `", __FILE__, __LINE__); + for (size_t j = 0; j < sizeof (ui.x); j++) + printf ("%02hhx", ui.x[j]); + printf ("'\n"); + printf ("error: %s:%d: value buffer: `", __FILE__, __LINE__); + for (size_t j = 0; j < sizeof (uv.x); j++) + printf ("%02hhx", uv.x[j]); + printf ("'\n"); + } + +out: + *errp = err; + return match; +} diff --git a/stdio-common/tst-scanf-format-s-c.c b/stdio-common/tst-scanf-format-s-c.c index bbfc000..6778cd1 100644 --- a/stdio-common/tst-scanf-format-s-c.c +++ b/stdio-common/tst-scanf-format-s-c.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-character.h" #include <tst-scanf-format-skeleton-c.c> diff --git a/stdio-common/tst-scanf-format-s-char.c b/stdio-common/tst-scanf-format-s-char.c index c13527d..b06756a 100644 --- a/stdio-common/tst-scanf-format-s-char.c +++ b/stdio-common/tst-scanf-format-s-char.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-char.c> diff --git a/stdio-common/tst-scanf-format-s-double.c b/stdio-common/tst-scanf-format-s-double.c index 4baad01..8af7b91 100644 --- a/stdio-common/tst-scanf-format-s-double.c +++ b/stdio-common/tst-scanf-format-s-double.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-real.h" #include <tst-scanf-format-skeleton-double.c> diff --git a/stdio-common/tst-scanf-format-s-float.c b/stdio-common/tst-scanf-format-s-float.c index 301b262..b14f4c4 100644 --- a/stdio-common/tst-scanf-format-s-float.c +++ b/stdio-common/tst-scanf-format-s-float.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-real.h" #include <tst-scanf-format-skeleton-float.c> diff --git a/stdio-common/tst-scanf-format-s-int.c b/stdio-common/tst-scanf-format-s-int.c index e176fe9..368aafc 100644 --- a/stdio-common/tst-scanf-format-s-int.c +++ b/stdio-common/tst-scanf-format-s-int.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-int.c> diff --git a/stdio-common/tst-scanf-format-s-ldouble.c b/stdio-common/tst-scanf-format-s-ldouble.c index dbb007c..67718c2 100644 --- a/stdio-common/tst-scanf-format-s-ldouble.c +++ b/stdio-common/tst-scanf-format-s-ldouble.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-real.h" #include <tst-scanf-format-skeleton-ldouble.c> diff --git a/stdio-common/tst-scanf-format-s-llong.c b/stdio-common/tst-scanf-format-s-llong.c index fe3d11a..51a98e7 100644 --- a/stdio-common/tst-scanf-format-s-llong.c +++ b/stdio-common/tst-scanf-format-s-llong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-llong.c> diff --git a/stdio-common/tst-scanf-format-s-long.c b/stdio-common/tst-scanf-format-s-long.c index 415e5fa..2061d9c 100644 --- a/stdio-common/tst-scanf-format-s-long.c +++ b/stdio-common/tst-scanf-format-s-long.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-long.c> diff --git a/stdio-common/tst-scanf-format-s-short.c b/stdio-common/tst-scanf-format-s-short.c index d545ee2..11a7bc1 100644 --- a/stdio-common/tst-scanf-format-s-short.c +++ b/stdio-common/tst-scanf-format-s-short.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-short.c> diff --git a/stdio-common/tst-scanf-format-s-uchar.c b/stdio-common/tst-scanf-format-s-uchar.c index a1a7f73..abde422 100644 --- a/stdio-common/tst-scanf-format-s-uchar.c +++ b/stdio-common/tst-scanf-format-s-uchar.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-uchar.c> diff --git a/stdio-common/tst-scanf-format-s-uint.c b/stdio-common/tst-scanf-format-s-uint.c index 27b0f4a..b51f11e 100644 --- a/stdio-common/tst-scanf-format-s-uint.c +++ b/stdio-common/tst-scanf-format-s-uint.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-uint.c> diff --git a/stdio-common/tst-scanf-format-s-ullong.c b/stdio-common/tst-scanf-format-s-ullong.c index 9cc45b4..0ecf363 100644 --- a/stdio-common/tst-scanf-format-s-ullong.c +++ b/stdio-common/tst-scanf-format-s-ullong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-ullong.c> diff --git a/stdio-common/tst-scanf-format-s-ulong.c b/stdio-common/tst-scanf-format-s-ulong.c index 9c5543e..9531e7c 100644 --- a/stdio-common/tst-scanf-format-s-ulong.c +++ b/stdio-common/tst-scanf-format-s-ulong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-ulong.c> diff --git a/stdio-common/tst-scanf-format-s-ushort.c b/stdio-common/tst-scanf-format-s-ushort.c index 052a1ca..49ff05b 100644 --- a/stdio-common/tst-scanf-format-s-ushort.c +++ b/stdio-common/tst-scanf-format-s-ushort.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-s.h" -#include "tst-scanf-format-integer.h" #include <tst-scanf-format-skeleton-ushort.c> diff --git a/stdio-common/tst-scanf-format-skeleton-c.c b/stdio-common/tst-scanf-format-skeleton-c.c index 181077f..a25fda0 100644 --- a/stdio-common/tst-scanf-format-skeleton-c.c +++ b/stdio-common/tst-scanf-format-skeleton-c.c @@ -18,4 +18,5 @@ typedef char *type_t; +#include "tst-scanf-format-character.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-char.c b/stdio-common/tst-scanf-format-skeleton-char.c index a694de4..b419d94 100644 --- a/stdio-common/tst-scanf-format-skeleton-char.c +++ b/stdio-common/tst-scanf-format-skeleton-char.c @@ -18,4 +18,5 @@ typedef signed char type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-double.c b/stdio-common/tst-scanf-format-skeleton-double.c index 502f2ad..c3aeef7 100644 --- a/stdio-common/tst-scanf-format-skeleton-double.c +++ b/stdio-common/tst-scanf-format-skeleton-double.c @@ -18,4 +18,5 @@ typedef double type_t; +#include "tst-scanf-format-real.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-float.c b/stdio-common/tst-scanf-format-skeleton-float.c index 2104c0f..5b34ee8 100644 --- a/stdio-common/tst-scanf-format-skeleton-float.c +++ b/stdio-common/tst-scanf-format-skeleton-float.c @@ -18,4 +18,5 @@ typedef float type_t; +#include "tst-scanf-format-real.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-int.c b/stdio-common/tst-scanf-format-skeleton-int.c index eb4e9de..483d4a9 100644 --- a/stdio-common/tst-scanf-format-skeleton-int.c +++ b/stdio-common/tst-scanf-format-skeleton-int.c @@ -18,4 +18,5 @@ typedef int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-ldouble.c b/stdio-common/tst-scanf-format-skeleton-ldouble.c index 3649110..83a3de7 100644 --- a/stdio-common/tst-scanf-format-skeleton-ldouble.c +++ b/stdio-common/tst-scanf-format-skeleton-ldouble.c @@ -18,4 +18,5 @@ typedef long double type_t; +#include "tst-scanf-format-real.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-llong.c b/stdio-common/tst-scanf-format-skeleton-llong.c index 8b8324e..e669f41 100644 --- a/stdio-common/tst-scanf-format-skeleton-llong.c +++ b/stdio-common/tst-scanf-format-skeleton-llong.c @@ -18,4 +18,5 @@ typedef long long int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-long.c b/stdio-common/tst-scanf-format-skeleton-long.c index 91aa091..cdf3cc3 100644 --- a/stdio-common/tst-scanf-format-skeleton-long.c +++ b/stdio-common/tst-scanf-format-skeleton-long.c @@ -18,4 +18,5 @@ typedef long int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-short.c b/stdio-common/tst-scanf-format-skeleton-short.c index ca51a25..329722c 100644 --- a/stdio-common/tst-scanf-format-skeleton-short.c +++ b/stdio-common/tst-scanf-format-skeleton-short.c @@ -18,4 +18,5 @@ typedef short int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-uchar.c b/stdio-common/tst-scanf-format-skeleton-uchar.c index 6be8917..fb52e1e 100644 --- a/stdio-common/tst-scanf-format-skeleton-uchar.c +++ b/stdio-common/tst-scanf-format-skeleton-uchar.c @@ -19,4 +19,5 @@ #define TYPE_T_UNSIGNED_P 1 typedef unsigned char type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-uint.c b/stdio-common/tst-scanf-format-skeleton-uint.c index 1508dc3..5b5a643 100644 --- a/stdio-common/tst-scanf-format-skeleton-uint.c +++ b/stdio-common/tst-scanf-format-skeleton-uint.c @@ -19,4 +19,5 @@ #define TYPE_T_UNSIGNED_P 1 typedef unsigned int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-ullong.c b/stdio-common/tst-scanf-format-skeleton-ullong.c index b0b8050..99dc8a7 100644 --- a/stdio-common/tst-scanf-format-skeleton-ullong.c +++ b/stdio-common/tst-scanf-format-skeleton-ullong.c @@ -19,4 +19,5 @@ #define TYPE_T_UNSIGNED_P 1 typedef unsigned long long int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-ulong.c b/stdio-common/tst-scanf-format-skeleton-ulong.c index 3198825..e0989b3 100644 --- a/stdio-common/tst-scanf-format-skeleton-ulong.c +++ b/stdio-common/tst-scanf-format-skeleton-ulong.c @@ -19,4 +19,5 @@ #define TYPE_T_UNSIGNED_P 1 typedef unsigned long int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton-ushort.c b/stdio-common/tst-scanf-format-skeleton-ushort.c index 2b710c5..fe006d2 100644 --- a/stdio-common/tst-scanf-format-skeleton-ushort.c +++ b/stdio-common/tst-scanf-format-skeleton-ushort.c @@ -19,4 +19,5 @@ #define TYPE_T_UNSIGNED_P 1 typedef unsigned short int type_t; +#include "tst-scanf-format-integer.h" #include "tst-scanf-format-skeleton.c" diff --git a/stdio-common/tst-scanf-format-skeleton.c b/stdio-common/tst-scanf-format-skeleton.c index bf1129b..450e340 100644 --- a/stdio-common/tst-scanf-format-skeleton.c +++ b/stdio-common/tst-scanf-format-skeleton.c @@ -60,11 +60,6 @@ #ifndef TYPE_T_UNSIGNED_P # define TYPE_T_UNSIGNED_P 0 #endif -#if TYPE_T_UNSIGNED_P -# define UNSIGNED unsigned -#else -# define UNSIGNED -#endif /* Read and return a single character from standard input, returning end-of-file or error status indication where applicable. */ diff --git a/stdio-common/tst-scanf-format-ss-c.c b/stdio-common/tst-scanf-format-ss-c.c index 58a7ce8..02e79eb 100644 --- a/stdio-common/tst-scanf-format-ss-c.c +++ b/stdio-common/tst-scanf-format-ss-c.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-character.h" -#include "tst-scanf-format-skeleton-c.c" +#include <tst-scanf-format-skeleton-c.c> diff --git a/stdio-common/tst-scanf-format-ss-char.c b/stdio-common/tst-scanf-format-ss-char.c index 66eb04c..268914a 100644 --- a/stdio-common/tst-scanf-format-ss-char.c +++ b/stdio-common/tst-scanf-format-ss-char.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-char.c" +#include <tst-scanf-format-skeleton-char.c> diff --git a/stdio-common/tst-scanf-format-ss-double.c b/stdio-common/tst-scanf-format-ss-double.c index 2a9fd8a..da29cfb 100644 --- a/stdio-common/tst-scanf-format-ss-double.c +++ b/stdio-common/tst-scanf-format-ss-double.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-double.c" +#include <tst-scanf-format-skeleton-double.c> diff --git a/stdio-common/tst-scanf-format-ss-float.c b/stdio-common/tst-scanf-format-ss-float.c index 640e35d..01ccea4 100644 --- a/stdio-common/tst-scanf-format-ss-float.c +++ b/stdio-common/tst-scanf-format-ss-float.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-float.c" +#include <tst-scanf-format-skeleton-float.c> diff --git a/stdio-common/tst-scanf-format-ss-int.c b/stdio-common/tst-scanf-format-ss-int.c index c01a0a3..8367995 100644 --- a/stdio-common/tst-scanf-format-ss-int.c +++ b/stdio-common/tst-scanf-format-ss-int.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-int.c" +#include <tst-scanf-format-skeleton-int.c> diff --git a/stdio-common/tst-scanf-format-ss-ldouble.c b/stdio-common/tst-scanf-format-ss-ldouble.c index 3e57ab5..842d758 100644 --- a/stdio-common/tst-scanf-format-ss-ldouble.c +++ b/stdio-common/tst-scanf-format-ss-ldouble.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-ldouble.c" +#include <tst-scanf-format-skeleton-ldouble.c> diff --git a/stdio-common/tst-scanf-format-ss-llong.c b/stdio-common/tst-scanf-format-ss-llong.c index 9c1603c..04d802d 100644 --- a/stdio-common/tst-scanf-format-ss-llong.c +++ b/stdio-common/tst-scanf-format-ss-llong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-llong.c" +#include <tst-scanf-format-skeleton-llong.c> diff --git a/stdio-common/tst-scanf-format-ss-long.c b/stdio-common/tst-scanf-format-ss-long.c index 003cfac..4850e02 100644 --- a/stdio-common/tst-scanf-format-ss-long.c +++ b/stdio-common/tst-scanf-format-ss-long.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-long.c" +#include <tst-scanf-format-skeleton-long.c> diff --git a/stdio-common/tst-scanf-format-ss-short.c b/stdio-common/tst-scanf-format-ss-short.c index ba1a582..f1d6a83 100644 --- a/stdio-common/tst-scanf-format-ss-short.c +++ b/stdio-common/tst-scanf-format-ss-short.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-short.c" +#include <tst-scanf-format-skeleton-short.c> diff --git a/stdio-common/tst-scanf-format-ss-uchar.c b/stdio-common/tst-scanf-format-ss-uchar.c index 1db1424..ee8eede 100644 --- a/stdio-common/tst-scanf-format-ss-uchar.c +++ b/stdio-common/tst-scanf-format-ss-uchar.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uchar.c" +#include <tst-scanf-format-skeleton-uchar.c> diff --git a/stdio-common/tst-scanf-format-ss-uint.c b/stdio-common/tst-scanf-format-ss-uint.c index a296fb4..9ba39dc 100644 --- a/stdio-common/tst-scanf-format-ss-uint.c +++ b/stdio-common/tst-scanf-format-ss-uint.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uint.c" +#include <tst-scanf-format-skeleton-uint.c> diff --git a/stdio-common/tst-scanf-format-ss-ullong.c b/stdio-common/tst-scanf-format-ss-ullong.c index 885d570..4b71d8c 100644 --- a/stdio-common/tst-scanf-format-ss-ullong.c +++ b/stdio-common/tst-scanf-format-ss-ullong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ullong.c" +#include <tst-scanf-format-skeleton-ullong.c> diff --git a/stdio-common/tst-scanf-format-ss-ulong.c b/stdio-common/tst-scanf-format-ss-ulong.c index 8a2f24d..613ccaf 100644 --- a/stdio-common/tst-scanf-format-ss-ulong.c +++ b/stdio-common/tst-scanf-format-ss-ulong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ulong.c" +#include <tst-scanf-format-skeleton-ulong.c> diff --git a/stdio-common/tst-scanf-format-ss-ushort.c b/stdio-common/tst-scanf-format-ss-ushort.c index 4061888..9145969 100644 --- a/stdio-common/tst-scanf-format-ss-ushort.c +++ b/stdio-common/tst-scanf-format-ss-ushort.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-ss.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ushort.c" +#include <tst-scanf-format-skeleton-ushort.c> diff --git a/stdio-common/tst-scanf-format-ss.h b/stdio-common/tst-scanf-format-ss.h index 2fb1ca2..b35e5bc 100644 --- a/stdio-common/tst-scanf-format-ss.h +++ b/stdio-common/tst-scanf-format-ss.h @@ -1,4 +1,4 @@ -/* Test feature wrapper for formatted 'scanf' input. +/* Test feature wrapper for formatted 'sscanf' input. Copyright (C) 2025 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/stdio-common/tst-scanf-format-v-c.c b/stdio-common/tst-scanf-format-v-c.c index 0e2c000..6ff8782 100644 --- a/stdio-common/tst-scanf-format-v-c.c +++ b/stdio-common/tst-scanf-format-v-c.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-character.h" -#include "tst-scanf-format-skeleton-c.c" +#include <tst-scanf-format-skeleton-c.c> diff --git a/stdio-common/tst-scanf-format-v-char.c b/stdio-common/tst-scanf-format-v-char.c index be3a56c..7e1ccf7 100644 --- a/stdio-common/tst-scanf-format-v-char.c +++ b/stdio-common/tst-scanf-format-v-char.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-char.c" +#include <tst-scanf-format-skeleton-char.c> diff --git a/stdio-common/tst-scanf-format-v-double.c b/stdio-common/tst-scanf-format-v-double.c index 9188631..5dfa110 100644 --- a/stdio-common/tst-scanf-format-v-double.c +++ b/stdio-common/tst-scanf-format-v-double.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-double.c" +#include <tst-scanf-format-skeleton-double.c> diff --git a/stdio-common/tst-scanf-format-v-float.c b/stdio-common/tst-scanf-format-v-float.c index 5d289d3..2243dd6 100644 --- a/stdio-common/tst-scanf-format-v-float.c +++ b/stdio-common/tst-scanf-format-v-float.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-float.c" +#include <tst-scanf-format-skeleton-float.c> diff --git a/stdio-common/tst-scanf-format-v-int.c b/stdio-common/tst-scanf-format-v-int.c index 770a686..5d59e39 100644 --- a/stdio-common/tst-scanf-format-v-int.c +++ b/stdio-common/tst-scanf-format-v-int.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-int.c" +#include <tst-scanf-format-skeleton-int.c> diff --git a/stdio-common/tst-scanf-format-v-ldouble.c b/stdio-common/tst-scanf-format-v-ldouble.c index 8215ea7..0527f0d 100644 --- a/stdio-common/tst-scanf-format-v-ldouble.c +++ b/stdio-common/tst-scanf-format-v-ldouble.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-ldouble.c" +#include <tst-scanf-format-skeleton-ldouble.c> diff --git a/stdio-common/tst-scanf-format-v-llong.c b/stdio-common/tst-scanf-format-v-llong.c index 2a1ef02..3f635d9 100644 --- a/stdio-common/tst-scanf-format-v-llong.c +++ b/stdio-common/tst-scanf-format-v-llong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-llong.c" +#include <tst-scanf-format-skeleton-llong.c> diff --git a/stdio-common/tst-scanf-format-v-long.c b/stdio-common/tst-scanf-format-v-long.c index 8376032..3473093 100644 --- a/stdio-common/tst-scanf-format-v-long.c +++ b/stdio-common/tst-scanf-format-v-long.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-long.c" +#include <tst-scanf-format-skeleton-long.c> diff --git a/stdio-common/tst-scanf-format-v-short.c b/stdio-common/tst-scanf-format-v-short.c index 23b9c56..61a66ba 100644 --- a/stdio-common/tst-scanf-format-v-short.c +++ b/stdio-common/tst-scanf-format-v-short.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-short.c" +#include <tst-scanf-format-skeleton-short.c> diff --git a/stdio-common/tst-scanf-format-v-uchar.c b/stdio-common/tst-scanf-format-v-uchar.c index 861db22..7e98b61 100644 --- a/stdio-common/tst-scanf-format-v-uchar.c +++ b/stdio-common/tst-scanf-format-v-uchar.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uchar.c" +#include <tst-scanf-format-skeleton-uchar.c> diff --git a/stdio-common/tst-scanf-format-v-uint.c b/stdio-common/tst-scanf-format-v-uint.c index 30e58c5..82ae619 100644 --- a/stdio-common/tst-scanf-format-v-uint.c +++ b/stdio-common/tst-scanf-format-v-uint.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uint.c" +#include <tst-scanf-format-skeleton-uint.c> diff --git a/stdio-common/tst-scanf-format-v-ullong.c b/stdio-common/tst-scanf-format-v-ullong.c index ee2914d..a767906 100644 --- a/stdio-common/tst-scanf-format-v-ullong.c +++ b/stdio-common/tst-scanf-format-v-ullong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ullong.c" +#include <tst-scanf-format-skeleton-ullong.c> diff --git a/stdio-common/tst-scanf-format-v-ulong.c b/stdio-common/tst-scanf-format-v-ulong.c index f7864dd..1b50b79 100644 --- a/stdio-common/tst-scanf-format-v-ulong.c +++ b/stdio-common/tst-scanf-format-v-ulong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ulong.c" +#include <tst-scanf-format-skeleton-ulong.c> diff --git a/stdio-common/tst-scanf-format-v-ushort.c b/stdio-common/tst-scanf-format-v-ushort.c index 79ca16b..e268273 100644 --- a/stdio-common/tst-scanf-format-v-ushort.c +++ b/stdio-common/tst-scanf-format-v-ushort.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-v.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ushort.c" +#include <tst-scanf-format-skeleton-ushort.c> diff --git a/stdio-common/tst-scanf-format-vf-c.c b/stdio-common/tst-scanf-format-vf-c.c index 307bfe8..d69b816 100644 --- a/stdio-common/tst-scanf-format-vf-c.c +++ b/stdio-common/tst-scanf-format-vf-c.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-character.h" -#include "tst-scanf-format-skeleton-c.c" +#include <tst-scanf-format-skeleton-c.c> diff --git a/stdio-common/tst-scanf-format-vf-char.c b/stdio-common/tst-scanf-format-vf-char.c index 602899b..7ce3b1c 100644 --- a/stdio-common/tst-scanf-format-vf-char.c +++ b/stdio-common/tst-scanf-format-vf-char.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-char.c" +#include <tst-scanf-format-skeleton-char.c> diff --git a/stdio-common/tst-scanf-format-vf-double.c b/stdio-common/tst-scanf-format-vf-double.c index 8b58bbe..5965144 100644 --- a/stdio-common/tst-scanf-format-vf-double.c +++ b/stdio-common/tst-scanf-format-vf-double.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-double.c" +#include <tst-scanf-format-skeleton-double.c> diff --git a/stdio-common/tst-scanf-format-vf-float.c b/stdio-common/tst-scanf-format-vf-float.c index 81dad06..34b069d 100644 --- a/stdio-common/tst-scanf-format-vf-float.c +++ b/stdio-common/tst-scanf-format-vf-float.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-float.c" +#include <tst-scanf-format-skeleton-float.c> diff --git a/stdio-common/tst-scanf-format-vf-int.c b/stdio-common/tst-scanf-format-vf-int.c index 8038791..289595b 100644 --- a/stdio-common/tst-scanf-format-vf-int.c +++ b/stdio-common/tst-scanf-format-vf-int.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-int.c" +#include <tst-scanf-format-skeleton-int.c> diff --git a/stdio-common/tst-scanf-format-vf-ldouble.c b/stdio-common/tst-scanf-format-vf-ldouble.c index ec9a7c4..3393703 100644 --- a/stdio-common/tst-scanf-format-vf-ldouble.c +++ b/stdio-common/tst-scanf-format-vf-ldouble.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-ldouble.c" +#include <tst-scanf-format-skeleton-ldouble.c> diff --git a/stdio-common/tst-scanf-format-vf-llong.c b/stdio-common/tst-scanf-format-vf-llong.c index adc4b12..ccc0912 100644 --- a/stdio-common/tst-scanf-format-vf-llong.c +++ b/stdio-common/tst-scanf-format-vf-llong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-llong.c" +#include <tst-scanf-format-skeleton-llong.c> diff --git a/stdio-common/tst-scanf-format-vf-long.c b/stdio-common/tst-scanf-format-vf-long.c index 5f26d6c..d5499af 100644 --- a/stdio-common/tst-scanf-format-vf-long.c +++ b/stdio-common/tst-scanf-format-vf-long.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-long.c" +#include <tst-scanf-format-skeleton-long.c> diff --git a/stdio-common/tst-scanf-format-vf-short.c b/stdio-common/tst-scanf-format-vf-short.c index 0e081ea..715967d 100644 --- a/stdio-common/tst-scanf-format-vf-short.c +++ b/stdio-common/tst-scanf-format-vf-short.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-short.c" +#include <tst-scanf-format-skeleton-short.c> diff --git a/stdio-common/tst-scanf-format-vf-uchar.c b/stdio-common/tst-scanf-format-vf-uchar.c index 2e879f5..6163545 100644 --- a/stdio-common/tst-scanf-format-vf-uchar.c +++ b/stdio-common/tst-scanf-format-vf-uchar.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uchar.c" +#include <tst-scanf-format-skeleton-uchar.c> diff --git a/stdio-common/tst-scanf-format-vf-uint.c b/stdio-common/tst-scanf-format-vf-uint.c index 4874f86..af240c5 100644 --- a/stdio-common/tst-scanf-format-vf-uint.c +++ b/stdio-common/tst-scanf-format-vf-uint.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uint.c" +#include <tst-scanf-format-skeleton-uint.c> diff --git a/stdio-common/tst-scanf-format-vf-ullong.c b/stdio-common/tst-scanf-format-vf-ullong.c index dde0901..4863b48 100644 --- a/stdio-common/tst-scanf-format-vf-ullong.c +++ b/stdio-common/tst-scanf-format-vf-ullong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ullong.c" +#include <tst-scanf-format-skeleton-ullong.c> diff --git a/stdio-common/tst-scanf-format-vf-ulong.c b/stdio-common/tst-scanf-format-vf-ulong.c index 8102306..886c771 100644 --- a/stdio-common/tst-scanf-format-vf-ulong.c +++ b/stdio-common/tst-scanf-format-vf-ulong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ulong.c" +#include <tst-scanf-format-skeleton-ulong.c> diff --git a/stdio-common/tst-scanf-format-vf-ushort.c b/stdio-common/tst-scanf-format-vf-ushort.c index cb8eb4b..b356598 100644 --- a/stdio-common/tst-scanf-format-vf-ushort.c +++ b/stdio-common/tst-scanf-format-vf-ushort.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vf.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ushort.c" +#include <tst-scanf-format-skeleton-ushort.c> diff --git a/stdio-common/tst-scanf-format-vs-c.c b/stdio-common/tst-scanf-format-vs-c.c index 2df5aa7..fb3f380 100644 --- a/stdio-common/tst-scanf-format-vs-c.c +++ b/stdio-common/tst-scanf-format-vs-c.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-character.h" -#include "tst-scanf-format-skeleton-c.c" +#include <tst-scanf-format-skeleton-c.c> diff --git a/stdio-common/tst-scanf-format-vs-char.c b/stdio-common/tst-scanf-format-vs-char.c index ae4d8e0..5161d72 100644 --- a/stdio-common/tst-scanf-format-vs-char.c +++ b/stdio-common/tst-scanf-format-vs-char.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-char.c" +#include <tst-scanf-format-skeleton-char.c> diff --git a/stdio-common/tst-scanf-format-vs-double.c b/stdio-common/tst-scanf-format-vs-double.c index cd459a8..042d3d9 100644 --- a/stdio-common/tst-scanf-format-vs-double.c +++ b/stdio-common/tst-scanf-format-vs-double.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-double.c" +#include <tst-scanf-format-skeleton-double.c> diff --git a/stdio-common/tst-scanf-format-vs-float.c b/stdio-common/tst-scanf-format-vs-float.c index 7872afe..2d25132 100644 --- a/stdio-common/tst-scanf-format-vs-float.c +++ b/stdio-common/tst-scanf-format-vs-float.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-float.c" +#include <tst-scanf-format-skeleton-float.c> diff --git a/stdio-common/tst-scanf-format-vs-int.c b/stdio-common/tst-scanf-format-vs-int.c index e67b4be..b3a40d6 100644 --- a/stdio-common/tst-scanf-format-vs-int.c +++ b/stdio-common/tst-scanf-format-vs-int.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-int.c" +#include <tst-scanf-format-skeleton-int.c> diff --git a/stdio-common/tst-scanf-format-vs-ldouble.c b/stdio-common/tst-scanf-format-vs-ldouble.c index 4d299c2..0ccc6b6 100644 --- a/stdio-common/tst-scanf-format-vs-ldouble.c +++ b/stdio-common/tst-scanf-format-vs-ldouble.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-real.h" -#include "tst-scanf-format-skeleton-ldouble.c" +#include <tst-scanf-format-skeleton-ldouble.c> diff --git a/stdio-common/tst-scanf-format-vs-llong.c b/stdio-common/tst-scanf-format-vs-llong.c index 06c8cc9..100587e 100644 --- a/stdio-common/tst-scanf-format-vs-llong.c +++ b/stdio-common/tst-scanf-format-vs-llong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-llong.c" +#include <tst-scanf-format-skeleton-llong.c> diff --git a/stdio-common/tst-scanf-format-vs-long.c b/stdio-common/tst-scanf-format-vs-long.c index 575a6cb..6f609d1 100644 --- a/stdio-common/tst-scanf-format-vs-long.c +++ b/stdio-common/tst-scanf-format-vs-long.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-long.c" +#include <tst-scanf-format-skeleton-long.c> diff --git a/stdio-common/tst-scanf-format-vs-short.c b/stdio-common/tst-scanf-format-vs-short.c index 5473471..e97faee 100644 --- a/stdio-common/tst-scanf-format-vs-short.c +++ b/stdio-common/tst-scanf-format-vs-short.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-short.c" +#include <tst-scanf-format-skeleton-short.c> diff --git a/stdio-common/tst-scanf-format-vs-uchar.c b/stdio-common/tst-scanf-format-vs-uchar.c index 5a29b9b..2ec9c89 100644 --- a/stdio-common/tst-scanf-format-vs-uchar.c +++ b/stdio-common/tst-scanf-format-vs-uchar.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uchar.c" +#include <tst-scanf-format-skeleton-uchar.c> diff --git a/stdio-common/tst-scanf-format-vs-uint.c b/stdio-common/tst-scanf-format-vs-uint.c index b9486b1..40553cf 100644 --- a/stdio-common/tst-scanf-format-vs-uint.c +++ b/stdio-common/tst-scanf-format-vs-uint.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-uint.c" +#include <tst-scanf-format-skeleton-uint.c> diff --git a/stdio-common/tst-scanf-format-vs-ullong.c b/stdio-common/tst-scanf-format-vs-ullong.c index 5396a78..a50e173 100644 --- a/stdio-common/tst-scanf-format-vs-ullong.c +++ b/stdio-common/tst-scanf-format-vs-ullong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ullong.c" +#include <tst-scanf-format-skeleton-ullong.c> diff --git a/stdio-common/tst-scanf-format-vs-ulong.c b/stdio-common/tst-scanf-format-vs-ulong.c index 3dbc142..e2076b6 100644 --- a/stdio-common/tst-scanf-format-vs-ulong.c +++ b/stdio-common/tst-scanf-format-vs-ulong.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ulong.c" +#include <tst-scanf-format-skeleton-ulong.c> diff --git a/stdio-common/tst-scanf-format-vs-ushort.c b/stdio-common/tst-scanf-format-vs-ushort.c index 0f28b36..af2a63f 100644 --- a/stdio-common/tst-scanf-format-vs-ushort.c +++ b/stdio-common/tst-scanf-format-vs-ushort.c @@ -18,5 +18,4 @@ #include "tst-scanf-format-skeleton.h" #include "tst-scanf-format-vs.h" -#include "tst-scanf-format-integer.h" -#include "tst-scanf-format-skeleton-ushort.c" +#include <tst-scanf-format-skeleton-ushort.c> diff --git a/stdio-common/tst-setvbuf2.c b/stdio-common/tst-setvbuf2.c index 84d8b43..d791b19 100644 --- a/stdio-common/tst-setvbuf2.c +++ b/stdio-common/tst-setvbuf2.c @@ -265,7 +265,7 @@ writer_thread_proc (void *closure) debug; if (td->fname) - td->fd = xopen (td->fname, O_WRONLY, 0777); + td->fd = xopen (td->fname, O_WRONLY, 0666); fd = td->fd; while (1) @@ -292,7 +292,7 @@ reader_thread_proc (void *closure) debug; if (td->fname) - td->fd = xopen (td->fname, O_RDONLY, 0777); + td->fd = xopen (td->fname, O_RDONLY, 0666); fd = td->fd; while (1) @@ -538,7 +538,7 @@ open_test_stream (enum test_source_case f, enum test_stream_case s) break; case test_stream_fdopen_w: - fd = xopen (fname, O_WRONLY|O_CREAT|O_TRUNC, 0777); + fd = xopen (fname, O_WRONLY|O_CREAT|O_TRUNC, 0666); fp = fdopen (fd, "w"); break; @@ -1030,4 +1030,3 @@ do_test (void) # include <support/test-driver.c> #endif - diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c index b965c7b..d8facb6 100644 --- a/stdio-common/vfscanf-internal.c +++ b/stdio-common/vfscanf-internal.c @@ -119,6 +119,15 @@ (void) (c != EOF \ ? ++read_in \ : (size_t) (inchar_errno = errno)), c)) +/* Same as INCHAR, but stop upon field exhaustion according to AVAIL. */ +# define inchar_in_field(avail) \ +({ \ + if (avail == 0) \ + c = EOF; \ + else \ + inchar (); \ + c; \ +}) # define ISSPACE(Ch) __isspace_l (Ch, loc) # define ISDIGIT(Ch) __isdigit_l (Ch, loc) # define ISXDIGIT(Ch) __isxdigit_l (Ch, loc) @@ -889,6 +898,8 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, else while (--width > 0 && inchar () != EOF); #endif + if (width > 0) + input_error (); if (!(flags & SUPPRESS)) { @@ -1042,6 +1053,8 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, while (--width > 0 && inchar () != EOF); } #endif + if (width > 0) + input_error (); if (!(flags & SUPPRESS)) { @@ -1639,7 +1652,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, ++wcdigits[n]; #else const char *cmpp; - int avail = width > 0 ? width : INT_MAX; + int avail = width >= 0 ? width : INT_MAX; if (__glibc_unlikely (map != NULL)) mbdigits[n] = digits_extended[n]; @@ -1657,7 +1670,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, break; else { - if (avail == 0 || inchar () == EOF) + if (inchar_in_field (avail) == EOF) break; --avail; } @@ -1701,7 +1714,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, ++wcdigits[n]; #else const char *cmpp; - int avail = width > 0 ? width : INT_MAX; + int avail = width >= 0 ? width : INT_MAX; cmpp = mbdigits[n]; while ((unsigned char) *cmpp == c && avail >= 0) @@ -1710,7 +1723,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, break; else { - if (avail == 0 || inchar () == EOF) + if (inchar_in_field (avail) == EOF) break; --avail; } @@ -1737,7 +1750,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, #endif } - if (n < 10) + if (n < num_digits_len) { /* Found it. */ from_level = level; @@ -1757,7 +1770,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, break; #else const char *cmpp = thousands; - int avail = width > 0 ? width : INT_MAX; + int avail = width >= 0 ? width : INT_MAX; while ((unsigned char) *cmpp == c && avail >= 0) { @@ -1766,7 +1779,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, break; else { - if (avail == 0 || inchar () == EOF) + if (inchar_in_field (avail) == EOF) break; --avail; } @@ -1837,7 +1850,7 @@ digits_extended_fail: break; #else const char *cmpp = thousands; - int avail = width > 0 ? width : INT_MAX; + int avail = width >= 0 ? width : INT_MAX; while ((unsigned char) *cmpp == c && avail >= 0) { @@ -1846,7 +1859,7 @@ digits_extended_fail: break; else { - if (avail == 0 || inchar () == EOF) + if (inchar_in_field (avail) == EOF) break; --avail; } @@ -2225,7 +2238,7 @@ digits_extended_fail: } #else const char *cmpp = decimal; - int avail = width > 0 ? width : INT_MAX; + int avail = width >= 0 ? width : INT_MAX; if (! got_dot) { @@ -2463,14 +2476,14 @@ digits_extended_fail: } #else const char *cmpp = mbdigits[n]; - int avail = width > 0 ? width : INT_MAX; + int avail = width >= 0 ? width : INT_MAX; while ((unsigned char) *cmpp == c && avail >= 0) if (*++cmpp == '\0') break; else { - if (avail == 0 || inchar () == EOF) + if (inchar_in_field (avail) == EOF) break; --avail; } @@ -2552,15 +2565,15 @@ digits_extended_fail: goto errout; } - /* Have we read any character? If we try to read a number - in hexadecimal notation and we have read only the `0x' - prefix this is an error. Also it is an error where we - have read no digits after the exponent character. */ + /* Have we read any character? If we try to read a number in + hexadecimal notation and we have read only the `0x' prefix, + this is an error. Also it is an error where we have read + no digits (before or after the exponent character). */ if (__glibc_unlikely (char_buffer_size (&charbuf) == got_sign || ((flags & HEXA_FLOAT) && (char_buffer_size (&charbuf) == 2 + got_sign))) - || (got_e && !got_digit)) + || !got_digit) conv_error (); scan_float: |