From 4673f5e5c0b62a0bbbdebc4e335e48f94c201c68 Mon Sep 17 00:00:00 2001 From: David Leonard Date: Mon, 8 Jan 2001 15:23:21 +0000 Subject: fix %p matching. checked by angelos. closes PR1612 --- lib/libc/time/strptime.c | 12 +++++++----- 1 file 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 @@ -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; } -- cgit v1.2.3