From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85480 invoked by alias); 24 Aug 2017 08:44:31 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 85396 invoked by uid 89); 24 Aug 2017 08:44:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*R:D*sourceware.org, H*i:sk:d83734d, H*f:sk:d83734d, Attached X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Aug 2017 08:44:19 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5393B3683C for ; Thu, 24 Aug 2017 08:44:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5393B3683C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=vinschen@redhat.com Received: from calimero.vinschen.de (ovpn-117-112.ams2.redhat.com [10.36.117.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF3AA5D9C9 for ; Thu, 24 Aug 2017 08:44:17 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id AAB66A804AF; Thu, 24 Aug 2017 10:44:16 +0200 (CEST) Date: Thu, 24 Aug 2017 08:50:00 -0000 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH] newlib/libc/time/strptime.c(strptime_l) add strptime %F %s Message-ID: <20170824084416.GA29964@calimero.vinschen.de> Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <9c38bcee-fbb0-9a30-0c28-58629f54aa0e@SystematicSw.ab.ca> <20170726104918.GF14419@calimero.vinschen.de> <6ae417fd-e109-4549-f005-5cfa7b6fdb62@SystematicSw.ab.ca> <20170726193443.GD30367@calimero.vinschen.de> <20170731095532.GK24013@calimero.vinschen.de> <09a4309f-a47c-5056-16bf-fe81e9ad483a@SystematicSw.ab.ca> <20170821090124.GF16422@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-SW-Source: 2017/txt/msg00860.txt.bz2 --huq684BweRXVnRxX Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3432 Hi Brian, On Aug 23 12:59, Brian Inglis wrote: > On 2017-08-21 03:01, Corinna Vinschen wrote: > > Oh, right! I forget about it *blush* >=20 > Attached patch to support %F and %s in newlib libc time strptime.c strpti= me_l(). >=20 > In case the issue comes up, if the user wants to support %s as in date(1)= with a > preceding @ flag, they just have to include that verbatim before the form= at as > in "@%s". >=20 > Is there any way to test this newlib function on a Cygwin platform? > I don't have access to a supported platform. >=20 > Similar patch submitted for Cygwin %s. >=20 > --=20 > Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada > From 8913eb99285915fef945767340b226002a4c9502 Mon Sep 17 00:00:00 2001 > From: Brian Inglis > Date: Tue, 22 Aug 2017 15:06:02 -0600 > Subject: [PATCH] newlib/libc/time/strptime.c(strptime_l) add strptime %F = %s >=20 > --- > newlib/libc/time/strptime.c | 35 +++++++++++++++++++++++++++++++++-- > 1 file changed, 33 insertions(+), 2 deletions(-) >=20 > diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c > index c0861eb87..233658406 100644 > --- a/newlib/libc/time/strptime.c > +++ b/newlib/libc/time/strptime.c > @@ -38,6 +38,9 @@ > #include > #include > #include > +#include > +#include > +#include > #include "../locale/setlocale.h" >=20=20 > #define _ctloc(x) (_CurrentTimeLocale->x) > @@ -230,8 +233,17 @@ strptime_l (const char *buf, const char *format, str= uct tm *timeptr, > buf =3D s; > ymd |=3D SET_MDAY; > break; > + case 'F' : /* %Y-%m-%d - GNU extension */ > + fprintf( stderr, "fmt %s buf %s\n", format, buf); > + s =3D strptime_l (buf, "%Y-%m-%d", timeptr, locale); > + fprintf( stderr, "fmt %s buf %s s %s\n", format, buf, s); Debugging residue? > + if (s =3D=3D NULL || s =3D=3D buf) > + return NULL; > + buf =3D s; > + ymd |=3D SET_YMD; > + break; > case 'H' : > - case 'k' : > + case 'k' : /* hour with leading space - GNU extension */ > ret =3D strtol_l (buf, &s, 10, locale); > if (s =3D=3D buf) > return NULL; > @@ -239,7 +251,7 @@ strptime_l (const char *buf, const char *format, stru= ct tm *timeptr, > buf =3D s; > break; > case 'I' : > - case 'l' : > + case 'l' : /* hour with leading space - GNU extension */ > ret =3D strtol_l (buf, &s, 10, locale); > if (s =3D=3D buf) > return NULL; > @@ -300,6 +312,25 @@ strptime_l (const char *buf, const char *format, str= uct tm *timeptr, > return NULL; > buf =3D s; > break; > + case 's' : { /* seconds since Unix epoch - GNU extension */ Opening brace on next line, please, indented as the closing brace. > + long long sec; > + time_t t; > + int errno_save; > + > + errno_save =3D errno; > + errno =3D 0; > + sec =3D strtoll_l (buf, &s, 10, locale); > + t =3D sec; > + if (s =3D=3D buf > + || errno !=3D 0 > + || t !=3D sec > + || localtime_r (&t, timeptr) !=3D timeptr) > + return NULL; > + errno =3D errno_save; > + buf =3D s; > + ymd |=3D SET_YDAY | SET_WDAY | SET_YMD; > + break; > + } > case 'S' : > ret =3D strtol_l (buf, &s, 10, locale); > if (s =3D=3D buf) > --=20 > 2.14.0 =20 Other than the above, looks good. Thanks, Corinna --=20 Corinna Vinschen Cygwin Maintainer Red Hat --huq684BweRXVnRxX Content-Type: application/pgp-signature; name="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJZnpHgAAoJEPU2Bp2uRE+g3ogQAIgmE0J2V5Dwu2F3yt3VkVyw yMjOACs5phNgMwzb9HmbSVnbLNZjTXpmXYBBCiACIAox68iMGJAwQQtQgvL8lW6K QwWuWr3yAZ7D46qE2SYX/Mz9LaFhQQVBzN9BDCcYl7jkCwxPo9a5lgtkK6e7gRkv 6zaSVuWKiZLI388uSIa5zbk3np10xrxtrkm3lFTnDsBPWOHR2K1M4wDUT5t2oqM1 AwV6JjSg58dRhbv9pkU4sSWZsqlvxgdlMdyVqhKMYgQw5va91EXG9NSqT6SId/xx kvLZnJ4+pjgh1TUhZtbx9HDlrIDraJyEYBo0YNaclyJ/KFFYlG8mlb5F8DDiuOe6 Dzy4vT8kxKnvYWClH9zKflcP2P6TCNlmuXwj5o3VPAE+vKxelsJa+7fAImGs9lx6 QRE2nSbIpSIwhhHYiNXmuKPbTiGXlj/bomqTBnzTBVR01ZVIqReKrmYsNp+RsqeH GIx7cIewZPGlLnOTL2oLk69LfbwV+iQo3qfB9mpZzVUuJXvRDWY5SFQiVCZ6tLwY JdIP4BqUV9K0etNYkf6do+o0q2zLNZ0VH0S9zOD3F/ux25/KOjiL6Hc/l8szB25M fwT7r15U02h0oLz79pBkgIU+cT4Q+CWoIdku3VghSZznZ47t0wfTBBoSpjHozgkB LvfN3cMtWAlsn4P7Pwq9 =cFUs -----END PGP SIGNATURE----- --huq684BweRXVnRxX--