aboutsummaryrefslogtreecommitdiff
path: root/libio/tst-swscanf.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /libio/tst-swscanf.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-zack/build-layout-experiment.tar
glibc-zack/build-layout-experiment.tar.gz
glibc-zack/build-layout-experiment.tar.bz2
glibc-zack/build-layout-experiment.zip
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'libio/tst-swscanf.c')
-rw-r--r--libio/tst-swscanf.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/libio/tst-swscanf.c b/libio/tst-swscanf.c
deleted file mode 100644
index 05be4e6e71..0000000000
--- a/libio/tst-swscanf.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include <locale.h>
-#include <stdio.h>
-#include <string.h>
-#include <wchar.h>
-
-
-static int do_test (const char *loc);
-
-
-int
-main (void)
-{
- int result;
-
- result = do_test ("C");
- result |= do_test ("de_DE.ISO-8859-1");
- result |= do_test ("de_DE.UTF-8");
- result |= do_test ("ja_JP.EUC-JP");
-
- return result;
-}
-
-
-static const struct
-{
- const wchar_t *fmt;
- const wchar_t *wfmt;
- const wchar_t *arg;
- int retval;
- const char *res;
- const wchar_t *wres;
- int only_C_locale;
-} tests[] =
- {
- { L"%[abc]", L"%l[abc]", L"aabbccddaabb", 1 ,"aabbcc", L"aabbcc", 0 },
- { L"%[^def]", L"%l[^def]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 0 },
- { L"%[^abc]", L"%l[^abc]", L"aabbccddaabb", 0, "", L"", 0 },
- { L"%[a-c]", L"%l[a-c]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 1 },
- { L"%[^d-f]", L"%l[^d-f]", L"aabbccddaabb", 1, "aabbcc", L"aabbcc", 1 },
- { L"%[^a-c]", L"%l[^a-c]", L"aabbccddaabb", 0, "", L"", 1 },
- { L"%[^a-c]", L"%l[^a-c]", L"bbccddaabb", 0, "", L"", 1 }
- };
-
-
-static int
-do_test (const char *loc)
-{
- size_t n;
- int result = 0;
-
- if (setlocale (LC_ALL, loc) == NULL)
- {
- printf ("cannot set locale \"%s\": %m\n", loc);
- return 1;
- }
-
- printf ("\nnew locale: \"%s\"\n", loc);
-
- for (n = 0; n < sizeof (tests) / sizeof (tests[0]); ++n)
- {
- char buf[100];
- wchar_t wbuf[100];
-
- if (tests[n].only_C_locale && strcmp (loc, "C") != 0)
- continue;
-
- if (swscanf (tests[n].arg, tests[n].fmt, buf) != tests[n].retval)
- {
- printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
- tests[n].arg, tests[n].fmt);
- result = 1;
- }
- else if (tests[n].retval != 0 && strcmp (buf, tests[n].res) != 0)
- {
- printf ("swscanf (\"%S\", \"%S\", ...) return \"%s\", expected \"%s\"\n",
- tests[n].arg, tests[n].fmt, buf, tests[n].res);
- result = 1;
- }
- else
- printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
- tests[n].arg, tests[n].fmt);
-
- if (swscanf (tests[n].arg, tests[n].wfmt, wbuf) != tests[n].retval)
- {
- printf ("swscanf (\"%S\", \"%S\", ...) failed\n",
- tests[n].arg, tests[n].wfmt);
- result = 1;
- }
- else if (tests[n].retval != 0 && wcscmp (wbuf, tests[n].wres) != 0)
- {
- printf ("swscanf (\"%S\", \"%S\", ...) return \"%S\", expected \"%S\"\n",
- tests[n].arg, tests[n].wfmt, wbuf, tests[n].wres);
- result = 1;
- }
- else
- printf ("swscanf (\"%S\", \"%S\", ...) OK\n",
- tests[n].arg, tests[n].wfmt);
- }
-
- return result;
-}