From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) by sourceware.org (Postfix) with ESMTPS id 7C11D3858C1F for ; Tue, 15 Feb 2022 21:57:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C11D3858C1F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSW.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=systematicsw.ab.ca Received: from shw-obgw-4003a.ext.cloudfilter.net ([10.228.9.183]) by cmsmtp with ESMTP id K1nanLLV0yr5HK5ounRAsQ; Tue, 15 Feb 2022 21:57:12 +0000 Received: from BWINGLISD.shawcable.net. ([184.64.124.72]) by cmsmtp with ESMTP id K5otnjbRWuRnyK5otnZapM; Tue, 15 Feb 2022 21:57:12 +0000 X-Authority-Analysis: v=2.4 cv=VuAwvs6n c=1 sm=1 tr=0 ts=620c21b8 a=oHm12aVswOWz6TMtn9zYKg==:117 a=oHm12aVswOWz6TMtn9zYKg==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=RnTlGnXXBckDA-ByVnAA:9 a=QEXdDO2ut3YA:10 a=Bwab9PuflVqNbyYkQaIA:9 a=B2y7HmGcmWMA:10 From: Brian Inglis To: newlib@sourceware.org Subject: [PATCH] newlib/libc/time/tzset_r.c(_tzset_unlocked_r): add POSIX <> quoted abbrs Date: Tue, 15 Feb 2022 14:57:01 -0700 Message-Id: <20220215215701.40283-1-Brian.Inglis@SystematicSW.ab.ca> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.35.1" Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfCtC7FNQsGBRRtg0qZ5PylaIZ6RZRExHyC9TiAhllN96CLz1hDtAV4SjRLI8KU7JxBUpj9dCA1/Qaq3PGRQ1/vSZMVC5My5+faUU1xeUeGJA5S8pCATw cp2lAZ1sQrTpEJJ5tbEw2qXY3u4z9skNzgH//kPT68mOgqV+X5I9K+GHZc4WIm9TZpa4iP+KHMPJaAtUUx9W1rrxUjP/5BnwV+Pf/QPkdSQX0aKXJsbQ1auJ Hx+Z2+d59wIYS026MNh8Dy4cKYi/cR6EObdTkrd2pDs= X-Spam-Status: No, score=-1169.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 21:57:13 -0000 This is a multi-part message in MIME format. --------------2.35.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit --- newlib/libc/time/tzset_r.c | 68 ++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) --------------2.35.1 Content-Type: text/x-patch; name="0001-newlib-libc-time-tzset_r.c-_tzset_unlocked_r-add-POSIX-quoted-abbrs.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-newlib-libc-time-tzset_r.c-_tzset_unlocked_r-add-POSIX-quoted-abbrs.patch" diff --git a/newlib/libc/time/tzset_r.c b/newlib/libc/time/tzset_r.c index 9e0cf834bd6b..5bf463ed3dd7 100644 --- a/newlib/libc/time/tzset_r.c +++ b/newlib/libc/time/tzset_r.c @@ -45,8 +45,30 @@ _tzset_unlocked_r (struct _reent *reent_ptr) if (*tzenv == ':') ++tzenv; - if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0) - return; + /* allow POSIX angle bracket < > quoted tz abbr e.g. <+03> */ + if (*tzenv == '<') + { + ++tzenv; + + /* scan while dest space left, not EoS, not close quote */ + for (n = 0; + n < sizeof (__tzname_std) && tzenv[n] && '>' != tzenv[n]; + ++n) + { + __tzname_std[n] = tzenv[n]; + } + + /* quit if no chars scanned, not close quote, or too many chars */ + if (!n || '>' != tzenv[n] || sizeof (__tzname_std) <= n) + return; + + __tzname_std[n] = '\0'; + } + else + { + if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0) + return; + } tzenv += n; @@ -68,17 +90,43 @@ _tzset_unlocked_r (struct _reent *reent_ptr) tz->__tzrule[0].offset = sign * (ss + SECSPERMIN * mm + SECSPERHOUR * hh); _tzname[0] = __tzname_std; tzenv += n; - - if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0) - { /* No dst */ - _tzname[1] = _tzname[0]; - _timezone = tz->__tzrule[0].offset; - _daylight = 0; - return; + + /* allow POSIX angle bracket < > quoted tz abbr e.g. <+03> */ + if (*tzenv == '<') + { + ++tzenv; + + /* scan while dest space left, not EoS, not close quote */ + for (n = 0; + n < sizeof (__tzname_dst) && tzenv[n] && '>' != tzenv[n]; + ++n) + { + __tzname_dst[n] = tzenv[n]; + } + + /* quit if no chars scanned, not close quote, or too many chars */ + if (!n || '>' != tzenv[n] || sizeof (__tzname_dst) <= n) + { /* No dst */ + _tzname[1] = _tzname[0]; + _timezone = tz->__tzrule[0].offset; + _daylight = 0; + return; + } + + __tzname_dst[n] = '\0'; } else - _tzname[1] = __tzname_dst; + { + if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0) + { /* No dst */ + _tzname[1] = _tzname[0]; + _timezone = tz->__tzrule[0].offset; + _daylight = 0; + return; + } + } + _tzname[1] = __tzname_dst; tzenv += n; /* otherwise we have a dst name, look for the offset */ --------------2.35.1--