mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
2001-08-09 Ulrich Drepper <drepper@redhat.com> * time/tst-strptime.c: Add tests in different locales. * time/Makefile (tst-strptime-ENV): Define.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2001-08-09 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* time/tst-strptime.c: Add tests in different locales.
|
||||||
|
* time/Makefile (tst-strptime-ENV): Define.
|
||||||
|
|
||||||
2001-08-09 Jakub Jelinek <jakub@redhat.com>
|
2001-08-09 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* catgets/catgets.c (catclose): Be liberal about catalog_desc in
|
* catgets/catgets.c (catclose): Be liberal about catalog_desc in
|
||||||
|
@ -755,7 +755,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
|
|||||||
{
|
{
|
||||||
/* We have to convert the multibyte input sequence to wide
|
/* We have to convert the multibyte input sequence to wide
|
||||||
characters. */
|
characters. */
|
||||||
char buf[0];
|
char buf[1];
|
||||||
mbstate_t cstate;
|
mbstate_t cstate;
|
||||||
|
|
||||||
memset (&cstate, '\0', sizeof (cstate));
|
memset (&cstate, '\0', sizeof (cstate));
|
||||||
@ -1058,7 +1058,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
char buf[0];
|
char buf[1];
|
||||||
|
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
|
|
||||||
|
@ -49,3 +49,5 @@ CFLAGS-test_time.c = -Wno-format
|
|||||||
|
|
||||||
tst-getdate-ENV= DATEMSK=datemsk TZDIR=${common-objpfx}timezone/testdata
|
tst-getdate-ENV= DATEMSK=datemsk TZDIR=${common-objpfx}timezone/testdata
|
||||||
test_time-ARGS= EST5EDT CST
|
test_time-ARGS= EST5EDT CST
|
||||||
|
|
||||||
|
tst-strptime-ENV = LOCPATH=${common-objpfx}localedata
|
||||||
|
@ -18,25 +18,32 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#include <locale.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
|
const char *locale;
|
||||||
const char *input;
|
const char *input;
|
||||||
const char *format;
|
const char *format;
|
||||||
int wday;
|
int wday;
|
||||||
int yday;
|
int yday;
|
||||||
|
int mon;
|
||||||
|
int mday;
|
||||||
} day_tests[] =
|
} day_tests[] =
|
||||||
{
|
{
|
||||||
{ "2000-01-01", "%Y-%m-%d", 6, 0 },
|
{ "C", "2000-01-01", "%Y-%m-%d", 6, 0, 0, 1 },
|
||||||
{ "03/03/00", "%D", 5, 62 },
|
{ "C", "03/03/00", "%D", 5, 62, 2, 3 },
|
||||||
{ "9/9/99", "%x", 4, 251 },
|
{ "C", "9/9/99", "%x", 4, 251, 8, 9 },
|
||||||
{ "19990502123412", "%Y%m%d%H%M%S", 0, 121 },
|
{ "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
|
||||||
{ "2001 20 Mon", "%Y %U %a", 1, 140 },
|
{ "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
|
||||||
{ "2001 21 Mon", "%Y %W %a", 1, 140 },
|
{ "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
|
||||||
|
{ "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
|
||||||
|
{ "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -114,6 +121,12 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
memset (&tm, '\0', sizeof (tm));
|
memset (&tm, '\0', sizeof (tm));
|
||||||
|
|
||||||
|
if (setlocale (LC_ALL, day_tests[i].locale) == NULL)
|
||||||
|
{
|
||||||
|
printf ("cannot set locale %s: %m\n", day_tests[i].locale);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (*strptime (day_tests[i].input, day_tests[i].format, &tm) != '\0')
|
if (*strptime (day_tests[i].input, day_tests[i].format, &tm) != '\0')
|
||||||
{
|
{
|
||||||
printf ("not all of `%s' read\n", day_tests[i].input);
|
printf ("not all of `%s' read\n", day_tests[i].input);
|
||||||
@ -121,11 +134,12 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf ("strptime (\"%s\", \"%s\", ...)\n"
|
printf ("strptime (\"%s\", \"%s\", ...)\n"
|
||||||
"\tshould be: wday = %d, yday = %3d\n"
|
"\tshould be: wday = %d, yday = %3d, mon = %2d, mday = %2d\n"
|
||||||
"\t is: wday = %d, yday = %3d\n",
|
"\t is: wday = %d, yday = %3d, mon = %2d, mday = %2d\n",
|
||||||
day_tests[i].input, day_tests[i].format,
|
day_tests[i].input, day_tests[i].format,
|
||||||
day_tests[i].wday, day_tests[i].yday,
|
day_tests[i].wday, day_tests[i].yday,
|
||||||
tm.tm_wday, tm.tm_yday);
|
day_tests[i].mon, day_tests[i].mday,
|
||||||
|
tm.tm_wday, tm.tm_yday, tm.tm_mon, tm.tm_mday);
|
||||||
|
|
||||||
if (tm.tm_wday != day_tests[i].wday)
|
if (tm.tm_wday != day_tests[i].wday)
|
||||||
{
|
{
|
||||||
@ -139,8 +153,22 @@ main (int argc, char *argv[])
|
|||||||
day_tests[i].input, tm.tm_yday, day_tests[i].yday);
|
day_tests[i].input, tm.tm_yday, day_tests[i].yday);
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
if (tm.tm_mon != day_tests[i].mon)
|
||||||
|
{
|
||||||
|
printf ("month for `%s' incorrect: %d instead of %d\n",
|
||||||
|
day_tests[i].input, tm.tm_mon, day_tests[i].mon);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
if (tm.tm_mday != day_tests[i].mday)
|
||||||
|
{
|
||||||
|
printf ("monthday for `%s' incorrect: %d instead of %d\n",
|
||||||
|
day_tests[i].input, tm.tm_mday, day_tests[i].mday);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setlocale (LC_ALL, "C");
|
||||||
|
|
||||||
result |= test_tm ();
|
result |= test_tm ();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user