@@ -1,4 +1,4 @@
-/* Test fscanf of long double without <stdio.h>.
+/* Test fscanf/scanf/vfscanf/vscanf of long double without <stdio.h>.
Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -16,11 +16,35 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <stdarg.h>
#include <string.h>
struct FILE;
extern struct FILE *stdin;
extern int fscanf (struct FILE *, const char *, ...);
+extern int scanf (const char *, ...);
+extern int vfscanf (struct FILE *, const char *, va_list);
+extern int vscanf (const char *, va_list);
+
+static int
+wrap_vfscanf (struct FILE *fp, const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ int ret = vfscanf (fp, format, ap);
+ va_end (ap);
+ return ret;
+}
+
+static int
+wrap_vscanf (const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ int ret = vscanf (format, ap);
+ va_end (ap);
+ return ret;
+}
int
main (void)
@@ -30,6 +54,21 @@ main (void)
char name[50];
n = fscanf (stdin, "%d%Lf%s", &i, &x, name);
+ if (n != 3 || i != 25 || x != 24.5 || strcmp (name, "thompson"))
+ return 1;
+
+ n = scanf ("%d%Lf%s", &i, &x, name);
+
+ if (n != 3 || i != 25 || x != 24.5 || strcmp (name, "thompson"))
+ return 1;
+
+ n = wrap_vfscanf (stdin, "%d%Lf%s", &i, &x, name);
+
+ if (n != 3 || i != 25 || x != 24.5 || strcmp (name, "thompson"))
+ return 1;
+
+ n = wrap_vscanf ("%d%Lf%s", &i, &x, name);
+
if (n != 3 || i != 25 || x != 24.5 || strcmp (name, "thompson"))
return 1;
@@ -1 +1,4 @@
25 24.5 thompson
+25 24.5 thompson
+25 24.5 thompson
+25 24.5 thompson
Update test-fscanf.c to add scanf/vfscanf/vscanf tests of long double without including <stdio.h>. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> --- stdio-common/test-fscanf.c | 41 +++++++++++++++++++++++++++++++++- stdio-common/test-fscanf.input | 3 +++ 2 files changed, 43 insertions(+), 1 deletion(-)