Re: [PATCH 2/2] newlib/libc/time/tzset_r.c(_tzset_unlocked_r): POSIX angle bracket <> support

jdoubleu <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
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"?

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.

Cheers
---
🙎🏻‍♂️ jdoubleu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.