aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/tst-sscanf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-04-20 04:28:00 +0000
committerUlrich Drepper <drepper@redhat.com>2004-04-20 04:28:00 +0000
commitd3b520289178bbe9c252c0a2784a529b89951945 (patch)
treebbfda740b0fc0d4c64d817f7a24eb4be8ff269a5 /stdio-common/tst-sscanf.c
parenta5dd0a6caf0a45a945dadaa48a831e2215351e61 (diff)
downloadglibc-d3b520289178bbe9c252c0a2784a529b89951945.zip
glibc-d3b520289178bbe9c252c0a2784a529b89951945.tar.gz
glibc-d3b520289178bbe9c252c0a2784a529b89951945.tar.bz2
Update.
2004-04-20 Jakub Jelinek <jakub@redhat.com> * stdio-common/vfscanf.c (_IO_vfscanf): When skipping whitespace, do input_error () instead of conv_error () and don't look at errno. Don't eat any whitespace before %% if skip_space == 0. * stdio-common/tst-sscanf.c (int_tests): New array. (main): Run int_tests. See ChangeLog.14 for earlier changes.
Diffstat (limited to 'stdio-common/tst-sscanf.c')
-rw-r--r--stdio-common/tst-sscanf.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/stdio-common/tst-sscanf.c b/stdio-common/tst-sscanf.c
index 3ec5a28..3bd7c35 100644
--- a/stdio-common/tst-sscanf.c
+++ b/stdio-common/tst-sscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
@@ -59,6 +59,39 @@ const long int val_long[] =
-12345678, 987654321, 123456789, 987654321, 123456789, 987654321
};
+struct int_test
+{
+ const char *str;
+ const char *fmt;
+ int retval;
+} int_tests[] =
+{
+ { "foo\n", "foo\nbar", -1 },
+ { "foo\n", "foo bar", -1 },
+ { "foo\n", "foo %d", -1 },
+ { "foo\n", "foo\n%d", -1 },
+ { "foon", "foonbar", -1 },
+ { "foon", "foon%d", -1 },
+ { "foo ", "foo bar", -1 },
+ { "foo ", "foo %d", -1 },
+ { "foo\t", "foo\tbar", -1 },
+ { "foo\t", "foo bar", -1 },
+ { "foo\t", "foo %d", -1 },
+ { "foo\t", "foo\t%d", -1 },
+ { "foo \t %bar1", "foo%%bar%d", 0 },
+ { "foo", "foo", 0 },
+ { "foon", "foo bar", 0 },
+ { "foon", "foo %d", 0 },
+ { "foo ", "fooxbar", 0 },
+ { "foo ", "foox%d", 0 },
+ { "foo bar", "foon", 0 },
+ { "foo bar", "foo bar", 0 },
+ { "foo bar", "foo %d", 0 },
+ { "foo bar", "foon%d", 0 },
+ { "foo ", "foo %n", 0 },
+ { "foo%bar1", "foo%%bar%d", 1 }
+};
+
int
main (void)
{
@@ -119,5 +152,18 @@ main (void)
break;
}
+ for (i = 0; i < sizeof (int_tests) / sizeof (int_tests[0]); ++i)
+ {
+ int dummy, ret;
+
+ if ((ret = sscanf (int_tests[i].str, int_tests[i].fmt,
+ &dummy)) != int_tests[i].retval)
+ {
+ printf ("int_tests[%d] returned %d != %d\n",
+ i, ret, int_tests[i].retval);
+ result = 1;
+ }
+ }
+
return result;
}