* [PATCH] Fix strptime
@ 2005-01-10 22:30 Jakub Jelinek
2005-01-12 2:45 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-01-10 22:30 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
Hi!
The last change to strptime_l.c causes unexpected fall through into
the 'r' case, as shown by the testcase below (that used to succeed
but on current glibc fails).
2005-01-10 Jakub Jelinek <jakub@redhat.com>
* time/strptime_l.c (__strptime_internal): Avoid fallthrough
to 'r' case from 'p' case.
* time/tst-strptime.c (day_tests): Add 2 new tests.
(test_tm, main): Issue an error instead of segfaulting if
strptime returns NULL.
--- libc/time/strptime_l.c.jj 2005-01-10 09:41:52.000000000 +0100
+++ libc/time/strptime_l.c 2005-01-10 23:24:58.498879544 +0100
@@ -544,8 +544,8 @@ __strptime_internal (rp, fmt, tm, decide
is_pm = 1;
else
return NULL;
- break;
}
+ break;
case 'r':
#ifdef _NL_CURRENT
if (*decided != raw)
--- libc/time/tst-strptime.c.jj 2002-09-24 06:21:04.000000000 +0200
+++ libc/time/tst-strptime.c 2005-01-10 23:24:25.903681989 +0100
@@ -42,6 +42,10 @@ static const struct
{ "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
{ "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
{ "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
+ { "ja_JP.EUC-JP", "2000-01-01 08:12:21 AM", "%Y-%m-%d %I:%M:%S %p",
+ 6, 0, 0, 1 },
+ { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",
+ 6, 0, 0, 1 },
{ "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 },
};
@@ -73,7 +77,14 @@ test_tm (void)
{
memset (&tm, '\0', sizeof (tm));
- if (*strptime (tm_tests[i].input, tm_tests[i].format, &tm) != '\0')
+ char *ret = strptime (tm_tests[i].input, tm_tests[i].format, &tm);
+ if (ret == NULL)
+ {
+ printf ("strptime returned NULL for `%s'\n", tm_tests[i].input);
+ result = 1;
+ continue;
+ }
+ else if (*ret != '\0')
{
printf ("not all of `%s' read\n", tm_tests[i].input);
result = 1;
@@ -127,7 +138,14 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
- if (*strptime (day_tests[i].input, day_tests[i].format, &tm) != '\0')
+ char *ret = strptime (day_tests[i].input, day_tests[i].format, &tm);
+ if (ret == NULL)
+ {
+ printf ("strptime returned NULL for `%s'\n", day_tests[i].input);
+ result = 1;
+ continue;
+ }
+ else if (*ret != '\0')
{
printf ("not all of `%s' read\n", day_tests[i].input);
result = 1;
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix strptime
2005-01-10 22:30 [PATCH] Fix strptime Jakub Jelinek
@ 2005-01-12 2:45 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-01-12 2:45 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
[-- Attachment #1: Type: text/plain, Size: 137 bytes --]
Applied as far as it was necessary.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-01-12 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-10 22:30 [PATCH] Fix strptime Jakub Jelinek
2005-01-12 2:45 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).