summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkn <kn@cvs.openbsd.org>2019-02-21 19:10:33 +0000
committerkn <kn@cvs.openbsd.org>2019-02-21 19:10:33 +0000
commit3b1192555695f84bf2dd46bcc245d843c0827303 (patch)
tree99dce74286b74160dc392ae49d3f1b6544586619 /lib
parent9a4efdf68f60308515db93e1b92fe79a1c8f9759 (diff)
Consume one leading space with %e iff given
Since strftime(3)'s %e conversion specification preceeds single digits by a blank, do the converse here to allow safe data round trips through these functions with the same format string. Positive feedback tedu deraadt, OK millert jca
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/time/strptime.38
-rw-r--r--lib/libc/time/strptime.c9
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/time/strptime.3 b/lib/libc/time/strptime.3
index 8872a8e7aaf..ed667de4f96 100644
--- a/lib/libc/time/strptime.3
+++ b/lib/libc/time/strptime.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: strptime.3,v 1.26 2019/01/21 21:35:58 tedu Exp $
+.\" $OpenBSD: strptime.3,v 1.27 2019/02/21 19:10:32 kn Exp $
.\"
.\" Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: January 21 2019 $
+.Dd $Mdocdate: February 21 2019 $
.Dt STRPTIME 3
.Os
.Sh NAME
@@ -96,8 +96,8 @@ leading zeros are permitted but not required.
.It Cm \&%D
the date as %m/%d/%y.
.It Cm \&%e
-the same as
-.Cm \&%d .
+the day of month [1,31];
+leading spaces or zeros are permitted but not required.
.It Cm \&%F
the date as %Y-%m-%d
(the
diff --git a/lib/libc/time/strptime.c b/lib/libc/time/strptime.c
index 01330b20d4b..eaf182dc773 100644
--- a/lib/libc/time/strptime.c
+++ b/lib/libc/time/strptime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strptime.c,v 1.24 2019/01/22 11:09:03 cheloha Exp $ */
+/* $OpenBSD: strptime.c,v 1.25 2019/02/21 19:10:32 kn Exp $ */
/* $NetBSD: strptime.c,v 1.12 1998/01/20 21:39:40 mycroft Exp $ */
/*-
* Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
@@ -254,8 +254,11 @@ literal:
century = i * 100;
break;
- case 'd': /* The day of month. */
- case 'e':
+ case 'e': /* The day of month. */
+ if (isspace(*bp))
+ bp++;
+ /* FALLTHROUGH */
+ case 'd':
_LEGAL_ALT(_ALT_O);
if (!(_conv_num(&bp, &tm->tm_mday, 1, 31)))
return (NULL);