From owner-svn-src-head@freebsd.org Sat Nov 3 23:37:15 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 481AF10EC6A0; Sat, 3 Nov 2018 23:37:15 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9643F70EB6; Sat, 3 Nov 2018 23:37:14 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 68F25207FB; Sat, 3 Nov 2018 23:37:14 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wA3NbE7L084082; Sat, 3 Nov 2018 23:37:14 GMT (envelope-from yuripv@FreeBSD.org) Received: (from yuripv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wA3NbDso084080; Sat, 3 Nov 2018 23:37:13 GMT (envelope-from yuripv@FreeBSD.org) Message-Id: <201811032337.wA3NbDso084080@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: yuripv set sender to yuripv@FreeBSD.org using -f From: Yuri Pankov Date: Sat, 3 Nov 2018 23:37:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340106 - in head: contrib/netbsd-tests/lib/libc/time lib/libc/stdtime X-SVN-Group: head X-SVN-Commit-Author: yuripv X-SVN-Commit-Paths: in head: contrib/netbsd-tests/lib/libc/time lib/libc/stdtime X-SVN-Commit-Revision: 340106 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9643F70EB6 X-Spamd-Result: default: False [-0.83 / 200.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: mx1.FreeBSD.org]; NEURAL_HAM_SHORT(-0.72)[-0.719,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2018 23:37:15 -0000 Author: yuripv Date: Sat Nov 3 23:37:13 2018 New Revision: 340106 URL: https://svnweb.freebsd.org/changeset/base/340106 Log: strptime: make %k and %l specifiers match their description in strftime(3), and allow them to process space-padded input. PR: 230720 Submitted by: rlittle@inetco.com (original version) Approved by: kib (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D17761 Modified: head/contrib/netbsd-tests/lib/libc/time/t_strptime.c head/lib/libc/stdtime/strptime.c Modified: head/contrib/netbsd-tests/lib/libc/time/t_strptime.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/time/t_strptime.c Sat Nov 3 22:12:21 2018 (r340105) +++ head/contrib/netbsd-tests/lib/libc/time/t_strptime.c Sat Nov 3 23:37:13 2018 (r340106) @@ -331,8 +331,19 @@ ATF_TC_BODY(hour, tc) h_fail("00", "%I"); h_fail("13", "%I"); + #ifdef __FreeBSD__ - h_fail("00", "%l"); + h_pass("0", "%k", 1, -1, -1, 0, -1, -1, -1, -1, -1); + h_pass("04", "%k", 2, -1, -1, 4, -1, -1, -1, -1, -1); + h_pass(" 8", "%k", 2, -1, -1, 8, -1, -1, -1, -1, -1); + h_pass("23", "%k", 2, -1, -1, 23, -1, -1, -1, -1, -1); + h_fail("24", "%k"); + + h_fail("0", "%l"); + h_pass("1", "%l", 1, -1, -1, 1, -1, -1, -1, -1, -1); + h_pass("05", "%l", 2, -1, -1, 5, -1, -1, -1, -1, -1); + h_pass(" 9", "%l", 2, -1, -1, 9, -1, -1, -1, -1, -1); + h_pass("12", "%l", 2, -1, -1, 12, -1, -1, -1, -1, -1); h_fail("13", "%l"); #endif Modified: head/lib/libc/stdtime/strptime.c ============================================================================== --- head/lib/libc/stdtime/strptime.c Sat Nov 3 22:12:21 2018 (r340105) +++ head/lib/libc/stdtime/strptime.c Sat Nov 3 23:37:13 2018 (r340106) @@ -272,17 +272,24 @@ label: case 'k': case 'l': /* - * Of these, %l is the only specifier explicitly - * documented as not being zero-padded. However, - * there is no harm in allowing zero-padding. + * %k and %l specifiers are documented as being + * blank-padded. However, there is no harm in + * allowing zero-padding. * - * XXX The %l specifier may gobble one too many + * XXX %k and %l specifiers may gobble one too many * digits if used incorrectly. */ + + len = 2; + if ((c == 'k' || c == 'l') && + isblank_l((unsigned char)*buf, locale)) { + buf++; + len = 1; + } + if (!isdigit_l((unsigned char)*buf, locale)) return (NULL); - len = 2; for (i = 0; len && *buf != 0 && isdigit_l((unsigned char)*buf, locale); buf++) { i *= 10;