diff options
author | David Leonard <d@cvs.openbsd.org> | 2001-01-08 15:23:21 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2001-01-08 15:23:21 +0000 |
commit | 4673f5e5c0b62a0bbbdebc4e335e48f94c201c68 (patch) | |
tree | 6787d3db339a58090522abe69e069ffef0191904 | |
parent | bea31c5c2a688685c0a14473df9bfbf5481aa0b8 (diff) |
fix %p matching. checked by angelos. closes PR1612
-rw-r--r-- | lib/libc/time/strptime.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/time/strptime.c b/lib/libc/time/strptime.c index 534c8e4ffce..412dfec2e4d 100644 --- a/lib/libc/time/strptime.c +++ b/lib/libc/time/strptime.c @@ -36,7 +36,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: strptime.c,v 1.5 1998/04/25 08:08:25 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: strptime.c,v 1.6 2001/01/08 15:23:20 d Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/localedef.h> @@ -276,23 +276,25 @@ literal: case 'p': /* The locale's equivalent of AM/PM. */ _LEGAL_ALT(0); /* AM? */ - if (strcmp(_ctloc(am_pm[0]), bp) == 0) { + len = strlen(_ctloc(am_pm[0])); + if (strncasecmp(_ctloc(am_pm[0]), bp, len) == 0) { if (tm->tm_hour > 12) /* i.e., 13:00 AM ?! */ return (NULL); else if (tm->tm_hour == 12) tm->tm_hour = 0; - bp += strlen(_ctloc(am_pm[0])); + bp += len; break; } /* PM? */ - else if (strcmp(_ctloc(am_pm[1]), bp) == 0) { + len = strlen(_ctloc(am_pm[1])); + if (strncasecmp(_ctloc(am_pm[1]), bp, len) == 0) { if (tm->tm_hour > 12) /* i.e., 13:00 PM ?! */ return (NULL); else if (tm->tm_hour < 12) tm->tm_hour += 12; - bp += strlen(_ctloc(am_pm[1])); + bp += len; break; } |