mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
* stdio-common/Makefile (tests): Add tst-swscanf.
* stdio-common/tst-sscanf.c: Make tests usable for swscanf testing. * stdio-common/tst-swscanf.c: New file.
This commit is contained in:
parent
7acd205c59
commit
821d3e7031
@ -1,3 +1,10 @@
|
|||||||
|
2007-02-18 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* stdio-common/Makefile (tests): Add tst-swscanf.
|
||||||
|
* stdio-common/tst-sscanf.c: Make tests usable for swscanf
|
||||||
|
testing.
|
||||||
|
* stdio-common/tst-swscanf.c: New file.
|
||||||
|
|
||||||
2007-02-17 Ulrich Drepper <drepper@redhat.com>
|
2007-02-17 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
[BZ #2633]
|
[BZ #2633]
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2007-02-18 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* locales/vi_VN: Don't define HOK here as well.
|
||||||
|
|
||||||
2007-02-17 Ulrich Drepper <drepper@redhat.com>
|
2007-02-17 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* SUPPORTED (SUPPORTED-LOCALES): Remove sr_CS locales.
|
* SUPPORTED (SUPPORTED-LOCALES): Remove sr_CS locales.
|
||||||
|
@ -74,8 +74,6 @@ collating-symbol <o/>>
|
|||||||
collating-symbol <o9>
|
collating-symbol <o9>
|
||||||
collating-symbol <u9>
|
collating-symbol <u9>
|
||||||
|
|
||||||
collating-symbol <HOK>
|
|
||||||
|
|
||||||
reorder-after <BAS>
|
reorder-after <BAS>
|
||||||
<GRA>
|
<GRA>
|
||||||
<HOK>
|
<HOK>
|
||||||
|
@ -54,7 +54,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
|
|||||||
tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
|
tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
|
||||||
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
|
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
|
||||||
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
|
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
|
||||||
tst-fwrite bug16 bug17
|
tst-fwrite bug16 bug17 tst-swscanf
|
||||||
|
|
||||||
test-srcs = tst-unbputc tst-printf
|
test-srcs = tst-unbputc tst-printf
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
|
/* Copyright (C) 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
|
Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
|
||||||
|
|
||||||
@ -21,12 +21,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
const char *str_double[] =
|
#ifndef CHAR
|
||||||
|
# define CHAR char
|
||||||
|
# define L(str) str
|
||||||
|
# define SSCANF sscanf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const CHAR *str_double[] =
|
||||||
{
|
{
|
||||||
"-.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01",
|
L("-.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01"),
|
||||||
"0.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01",
|
L("0.10000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01"),
|
||||||
"-1234567E0198765432E0912345678901987654321091234567890198765432109",
|
L("-1234567E0198765432E0912345678901987654321091234567890198765432109"),
|
||||||
"-0.1000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01"
|
L("-0.1000E+020.20000E+020.25000E+010.40000E+010.50000E+010.12500E+01")
|
||||||
};
|
};
|
||||||
|
|
||||||
const double val_double[] =
|
const double val_double[] =
|
||||||
@ -38,20 +44,20 @@ const double val_double[] =
|
|||||||
-0.1000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01
|
-0.1000E+02, 0.20000E+02, 0.25000E+01, 0.40000E+01, 0.50000E+01, 0.12500E+01
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *str_long[] =
|
const CHAR *str_long[] =
|
||||||
{
|
{
|
||||||
"-12345678987654321123456789987654321123456789987654321",
|
L("-12345678987654321123456789987654321123456789987654321"),
|
||||||
"-12345678987654321123456789987654321123456789987654321",
|
L("-12345678987654321123456789987654321123456789987654321"),
|
||||||
"-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321",
|
L("-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321"),
|
||||||
"-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321"
|
L("-12,345,678987,654,321123,456,789987,654,321123,456,789987,654,321")
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *fmt_long[] =
|
const CHAR *fmt_long[] =
|
||||||
{
|
{
|
||||||
"%9ld%9ld%9ld%9ld%9ld%9ld",
|
L("%9ld%9ld%9ld%9ld%9ld%9ld"),
|
||||||
"%I9ld%I9ld%I9ld%I9ld%I9ld%I9ld",
|
L("%I9ld%I9ld%I9ld%I9ld%I9ld%I9ld"),
|
||||||
"%'11ld%'11ld%'11ld%'11ld%'11ld%'11ld",
|
L("%'11ld%'11ld%'11ld%'11ld%'11ld%'11ld"),
|
||||||
"%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld"
|
L("%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld%I'11ld")
|
||||||
};
|
};
|
||||||
|
|
||||||
const long int val_long[] =
|
const long int val_long[] =
|
||||||
@ -61,36 +67,36 @@ const long int val_long[] =
|
|||||||
|
|
||||||
struct int_test
|
struct int_test
|
||||||
{
|
{
|
||||||
const char *str;
|
const CHAR *str;
|
||||||
const char *fmt;
|
const CHAR *fmt;
|
||||||
int retval;
|
int retval;
|
||||||
} int_tests[] =
|
} int_tests[] =
|
||||||
{
|
{
|
||||||
{ "foo\n", "foo\nbar", -1 },
|
{ L("foo\n"), L("foo\nbar"), -1 },
|
||||||
{ "foo\n", "foo bar", -1 },
|
{ L("foo\n"), L("foo bar"), -1 },
|
||||||
{ "foo\n", "foo %d", -1 },
|
{ L("foo\n"), L("foo %d"), -1 },
|
||||||
{ "foo\n", "foo\n%d", -1 },
|
{ L("foo\n"), L("foo\n%d"), -1 },
|
||||||
{ "foon", "foonbar", -1 },
|
{ L("foon"), L("foonbar"), -1 },
|
||||||
{ "foon", "foon%d", -1 },
|
{ L("foon"), L("foon%d"), -1 },
|
||||||
{ "foo ", "foo bar", -1 },
|
{ L("foo "), L("foo bar"), -1 },
|
||||||
{ "foo ", "foo %d", -1 },
|
{ L("foo "), L("foo %d"), -1 },
|
||||||
{ "foo\t", "foo\tbar", -1 },
|
{ L("foo\t"), L("foo\tbar"), -1 },
|
||||||
{ "foo\t", "foo bar", -1 },
|
{ L("foo\t"), L("foo bar"), -1 },
|
||||||
{ "foo\t", "foo %d", -1 },
|
{ L("foo\t"), L("foo %d"), -1 },
|
||||||
{ "foo\t", "foo\t%d", -1 },
|
{ L("foo\t"), L("foo\t%d"), -1 },
|
||||||
{ "foo", "foo", 0 },
|
{ L("foo"), L("foo"), 0 },
|
||||||
{ "foon", "foo bar", 0 },
|
{ L("foon"), L("foo bar"), 0 },
|
||||||
{ "foon", "foo %d", 0 },
|
{ L("foon"), L("foo %d"), 0 },
|
||||||
{ "foo ", "fooxbar", 0 },
|
{ L("foo "), L("fooxbar"), 0 },
|
||||||
{ "foo ", "foox%d", 0 },
|
{ L("foo "), L("foox%d"), 0 },
|
||||||
{ "foo bar", "foon", 0 },
|
{ L("foo bar"), L("foon"), 0 },
|
||||||
{ "foo bar", "foo bar", 0 },
|
{ L("foo bar"), L("foo bar"), 0 },
|
||||||
{ "foo bar", "foo %d", 0 },
|
{ L("foo bar"), L("foo %d"), 0 },
|
||||||
{ "foo bar", "foon%d", 0 },
|
{ L("foo bar"), L("foon%d"), 0 },
|
||||||
{ "foo ", "foo %n", 0 },
|
{ L("foo "), L("foo %n"), 0 },
|
||||||
{ "foo%bar1", "foo%%bar%d", 1 },
|
{ L("foo%bar1"), L("foo%%bar%d"), 1 },
|
||||||
/* Some OSes skip whitespace here while others don't. */
|
/* Some OSes skip whitespace here while others don't. */
|
||||||
{ "foo \t %bar1", "foo%%bar%d", 1 }
|
{ L("foo \t %bar1"), L("foo%%bar%d"), 1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -112,7 +118,7 @@ main (void)
|
|||||||
|
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
if (sscanf (str_double[i], "%11lf%11lf%11lf%11lf%11lf%11lf",
|
if (SSCANF (str_double[i], L("%11lf%11lf%11lf%11lf%11lf%11lf"),
|
||||||
&d[0], &d[1], &d[2], &d[3], &d[4], &d[5]) != 6)
|
&d[0], &d[1], &d[2], &d[3], &d[4], &d[5]) != 6)
|
||||||
{
|
{
|
||||||
printf ("Double sscanf test %d wrong number of "
|
printf ("Double sscanf test %d wrong number of "
|
||||||
@ -132,7 +138,7 @@ main (void)
|
|||||||
|
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
if (sscanf (str_long[i], fmt_long[i],
|
if (SSCANF (str_long[i], fmt_long[i],
|
||||||
&l[0], &l[1], &l[2], &l[3], &l[4], &l[5]) != 6)
|
&l[0], &l[1], &l[2], &l[3], &l[4], &l[5]) != 6)
|
||||||
{
|
{
|
||||||
printf ("Integer sscanf test %d wrong number of "
|
printf ("Integer sscanf test %d wrong number of "
|
||||||
@ -157,7 +163,7 @@ main (void)
|
|||||||
{
|
{
|
||||||
int dummy, ret;
|
int dummy, ret;
|
||||||
|
|
||||||
if ((ret = sscanf (int_tests[i].str, int_tests[i].fmt,
|
if ((ret = SSCANF (int_tests[i].str, int_tests[i].fmt,
|
||||||
&dummy)) != int_tests[i].retval)
|
&dummy)) != int_tests[i].retval)
|
||||||
{
|
{
|
||||||
printf ("int_tests[%d] returned %d != %d\n",
|
printf ("int_tests[%d] returned %d != %d\n",
|
||||||
|
5
stdio-common/tst-swscanf.c
Normal file
5
stdio-common/tst-swscanf.c
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#define CHAR wchar_t
|
||||||
|
#define L(str) L##str
|
||||||
|
#define SSCANF swscanf
|
||||||
|
#include <wchar.h>
|
||||||
|
#include "tst-sscanf.c"
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006
|
/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006, 2007
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@ -59,7 +59,6 @@
|
|||||||
#define SUPPRESS 0x008 /* *: suppress assignment */
|
#define SUPPRESS 0x008 /* *: suppress assignment */
|
||||||
#define POINTER 0x010 /* weird %p pointer (`fake hex') */
|
#define POINTER 0x010 /* weird %p pointer (`fake hex') */
|
||||||
#define NOSKIP 0x020 /* do not skip blanks */
|
#define NOSKIP 0x020 /* do not skip blanks */
|
||||||
#define WIDTH 0x040 /* width was given */
|
|
||||||
#define GROUP 0x080 /* ': group numbers */
|
#define GROUP 0x080 /* ': group numbers */
|
||||||
#define MALLOC 0x100 /* a: malloc strings */
|
#define MALLOC 0x100 /* a: malloc strings */
|
||||||
#define CHAR 0x200 /* hh: char */
|
#define CHAR 0x200 /* hh: char */
|
||||||
@ -424,7 +423,6 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
|
|||||||
{
|
{
|
||||||
/* Oops; that was actually the field width. */
|
/* Oops; that was actually the field width. */
|
||||||
width = argpos;
|
width = argpos;
|
||||||
flags |= WIDTH;
|
|
||||||
argpos = 0;
|
argpos = 0;
|
||||||
goto got_width;
|
goto got_width;
|
||||||
}
|
}
|
||||||
@ -446,10 +444,6 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have seen width. */
|
|
||||||
if (ISDIGIT ((UCHAR_T) *f))
|
|
||||||
flags |= WIDTH;
|
|
||||||
|
|
||||||
/* Find the maximum field width. */
|
/* Find the maximum field width. */
|
||||||
width = 0;
|
width = 0;
|
||||||
while (ISDIGIT ((UCHAR_T) *f))
|
while (ISDIGIT ((UCHAR_T) *f))
|
||||||
|
Loading…
Reference in New Issue
Block a user