From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) by sourceware.org (Postfix) with ESMTPS id 5A425385840F for ; Tue, 22 Mar 2022 17:35:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A425385840F 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-4002a.ext.cloudfilter.net ([10.228.9.250]) by cmsmtp with ESMTP id WU5wnP5zV43SgWiPpnhBqG; Tue, 22 Mar 2022 17:35:29 +0000 Received: from [10.0.0.5] ([184.64.124.72]) by cmsmtp with ESMTP id WiPpnwDUYqyysWiPpnX8dG; Tue, 22 Mar 2022 17:35:29 +0000 X-Authority-Analysis: v=2.4 cv=Y6brDzSN c=1 sm=1 tr=0 ts=623a08e1 a=oHm12aVswOWz6TMtn9zYKg==:117 a=oHm12aVswOWz6TMtn9zYKg==:17 a=IkcTkHD0fZMA:10 a=CCpqsmhAAAAA:8 a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10 a=Gy5p1UE1U9UA:10 a=ul9cdbp4aOFLsgKbc677:22 Message-ID: Date: Tue, 22 Mar 2022 11:35:29 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Reply-To: newlib@sourceware.org Subject: Re: [PATCH 2/2] newlib/libc/time/tzset_r.c(_tzset_unlocked_r): POSIX angle bracket <> support Content-Language: en-CA To: newlib@sourceware.org References: <20220225163959.48753-1-Brian.Inglis@SystematicSW.ab.ca> <20220225163959.48753-3-Brian.Inglis@SystematicSW.ab.ca> <82f48cb4-c456-b745-6c07-0955316755fc@jdoubleu.de> From: Brian Inglis Organization: Systematic Software In-Reply-To: <82f48cb4-c456-b745-6c07-0955316755fc@jdoubleu.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfNa1oUUdcl5CXbEqX8D522fz0L2DTUwmvvOo6L4t8EXZe3uuWy+5z7NHykieoG6Kyoj2Mj/L2aQBdkAPMS2a59sBxDygobq47yZrplgC3aQDSQjLoZYW ut7PDsTLqlKtHdKBzmwuG3OrzH3h1DE7I+GgUw96raNnn7OtWRQ5TbqR9C5K4znij2diIgdeO5UyzEx8LKFH6ch5f5xVQ5yn5XQ= X-Spam-Status: No, score=-1162.6 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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, 22 Mar 2022 17:35:35 -0000 On 2022-03-21 10:07, jdoubleu wrote: > Hi, > > On 2/25/2022 5:39 PM, Brian Inglis wrote: >> >> define POSIX specified minimum TZ abbr size 3 TZNAME_MIN >> use limits.h TZNAME_MAX, _POSIX_TZNAME_MAX, unistd.h >> sysconf(_SC_TZNAME_MAX) >> issue error if no symbols defined (document fallback value in case >> required) >> allow POSIX angle bracket < > quoted signed alphanumeric tz abbr e.g. >> >> allow POSIX unquoted alphabetic tz abbr e.g. MESZ >> apply same changes for DST tz abbr >> --- >>   newlib/libc/time/tzset_r.c | 74 ++++++++++++++++++++++++++++++++------ >>   1 file changed, 64 insertions(+), 10 deletions(-) >> > >> +      /* quit if no items, too few or too many chars, or no close >> quote '>' */ >> +      if (sscanf (tzenv, "%10[-+0-9A-Za-z]%n", __tzname_std, &n) <= 0 >> +        || n < TZNAME_MIN || TZNAME_MAX < n || '>' != tzenv[n]) >> +        return; > > Is it safe to use the minus (-) as first char in the sscanf format set: > "%10[-+0-9A-Za-z]%n"? The first and last positions are the only generally safe places to specify the hyphen/minus as part of the set and not part of a range. > Newlib's sscanf docs states > (https://sourceware.org/newlib/libc.html#sscanf): >> There is also a range facility which you can use as a shortcut. %[0-9] >> matches all decimal digits. The hyphen must not be the first or last >> character in the set. I read that as saying that the first or last character within the brackets can not be the hyphen a la [--@] or [!--], as it then stands alone, and is not treated as part of a range, allowing the hyphen/minus to be one of the characters matched, as is also the case when the first and last characters are not lexically ordered e.g. [z-a] == z|-|a. I presume this is a lexer limitation to allow safe and efficient range and set scanning. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in binary units and prefixes, physical quantities in SI.]