From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: newlib@sourceware.org
Subject: Re: [PATCH 2/2] newlib/libc/time/tzset_r.c(_tzset_unlocked_r): POSIX angle bracket <> support
Date: Tue, 22 Mar 2022 11:35:29 -0600 [thread overview]
Message-ID: <c7c182c0-16f6-fef0-b881-603abb8dcd69@SystematicSw.ab.ca> (raw)
In-Reply-To: <82f48cb4-c456-b745-6c07-0955316755fc@jdoubleu.de>
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.
>> <MESZ+0330>
>> 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.]
prev parent reply other threads:[~2022-03-22 17:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 16:39 [PATCH 0/2] add tzset POSIX tz abbr angle bracket <> support in TZ env var Brian Inglis
2022-02-25 16:39 ` [PATCH 1/2] newlib/libc/time/tzset.c: add POSIX angle bracket <> doc Brian Inglis
2022-02-25 16:39 ` [PATCH 2/2] newlib/libc/time/tzset_r.c(_tzset_unlocked_r): POSIX angle bracket <> support Brian Inglis
2022-02-28 12:04 ` Corinna Vinschen
2022-02-28 18:55 ` Brian Inglis
2022-02-28 19:26 ` Brian Inglis
2022-03-01 11:03 ` Corinna Vinschen
2022-03-21 16:07 ` jdoubleu
2022-03-22 17:35 ` Brian Inglis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7c182c0-16f6-fef0-b881-603abb8dcd69@SystematicSw.ab.ca \
--to=brian.inglis@systematicsw.ab.ca \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).