Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/time Only apply am/pm adjustment to tm_hour when it...
details: https://anonhg.NetBSD.org/src/rev/a925a289e457
branches: trunk
changeset: 339597:a925a289e457
user: ginsbach <ginsbach%NetBSD.org@localhost>
date: Wed Jul 29 20:32:54 2015 +0000
description:
Only apply am/pm adjustment to tm_hour when it has actually been parsed.
diffstat:
lib/libc/time/strptime.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (58 lines):
diff -r 67a1014bf288 -r a925a289e457 lib/libc/time/strptime.c
--- a/lib/libc/time/strptime.c Wed Jul 29 19:44:47 2015 +0000
+++ b/lib/libc/time/strptime.c Wed Jul 29 20:32:54 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strptime.c,v 1.47 2015/07/22 13:33:59 ginsbach Exp $ */
+/* $NetBSD: strptime.c,v 1.48 2015/07/29 20:32:54 ginsbach Exp $ */
/*-
* Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strptime.c,v 1.47 2015/07/22 13:33:59 ginsbach Exp $");
+__RCSID("$NetBSD: strptime.c,v 1.48 2015/07/29 20:32:54 ginsbach Exp $");
#endif
#include "namespace.h"
@@ -70,12 +70,14 @@
#define S_YDAY (1 << 2)
#define S_MDAY (1 << 3)
#define S_WDAY (1 << 4)
+#define S_HOUR (1 << 5)
#define HAVE_MDAY(s) (s & S_MDAY)
#define HAVE_MON(s) (s & S_MON)
#define HAVE_WDAY(s) (s & S_WDAY)
#define HAVE_YDAY(s) (s & S_YDAY)
#define HAVE_YEAR(s) (s & S_YEAR)
+#define HAVE_HOUR(s) (s & S_HOUR)
static char gmt[] = { "GMT" };
static char utc[] = { "UTC" };
@@ -262,6 +264,7 @@
case 'H':
bp = conv_num(bp, &tm->tm_hour, 0, 23);
LEGAL_ALT(ALT_O);
+ state |= S_HOUR;
continue;
case 'l': /* The hour (12-hour clock representation). */
@@ -272,6 +275,7 @@
if (tm->tm_hour == 12)
tm->tm_hour = 0;
LEGAL_ALT(ALT_O);
+ state |= S_HOUR;
continue;
case 'j': /* The day of year. */
@@ -298,7 +302,7 @@
case 'p': /* The locale's equivalent of AM/PM. */
bp = find_string(bp, &i, _TIME_LOCALE(loc)->am_pm,
NULL, 2);
- if (tm->tm_hour > 11)
+ if (HAVE_HOUR(state) && tm->tm_hour > 11)
return NULL;
tm->tm_hour += i * 12;
LEGAL_ALT(0);
Home |
Main Index |
Thread Index |
Old Index