Fw: [PATCH] Add support for TZ names with <> in tzset

C Howland cc1964t@gmail.com
Tue Nov 17 01:43:06 GMT 2020


------------------------------
> *From:* Newlib <newlib-bounces@sourceware.org> on behalf of Brian Inglis <
> Brian.Inglis@SystematicSw.ab.ca>
> *Sent:* Monday, November 16, 2020 5:30 PM
> *To:* newlib@sourceware.org <newlib@sourceware.org>
> *Subject:* Re: [PATCH] Add support for TZ names with <> in tzset
>
> On 2020-11-16 08:13, Corinna Vinschen via Newlib wrote:
> > Hi Earle,
> >
> > On Nov 14 15:03, Earle F. Philhower, III via Newlib wrote:
> >> Howdy all,
> >>
> >> Attached is a patch which extends the tzset() function to support a
> format
> >> for "unnamed" TZ environment timezones which use "<+/-nn>" as the
> timezone
> >> name instead of an alphabetic name.  These are supported in glibc and
> are
> >> present in several major TZ databases that we use on the ESP8266 Arduino
> >> core.  For example,
> >>
> >>> #define TZ_Africa_Casablanca          "<+01>-1"
> >>
> >> The existing tzset sscanf format string breaks at the first "+",
> assuming
> >> it's the
> >> beginning of the offset.  This patch special-cases names beginning with
> "<"
> >> to
> >> circumvent the issue.
> >>
> >> Signed-off-by: Earle F. Philhower, III   <earlephilhower@yahoo.com>
> >
> > Basically this looks ok.  I have two nits, though.
> >
> > - Now that the scanning got more complicated than a single sscanf call,
> >    this crys out for a helper function doing the actual scanning for
> >    both, std and dst strings.  This could be an inline function which is
> >    only inlined
> >    #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
> >
> > - The strcat call seems a bit heavy.  What about sth like this instead:
> >
> >      __tzname_ptr[n - 1] = '>';
> >      __tzname_ptr[n] = '\0';
>
> Should consider modifying the PD TZ project tzcode reference src
> localtime.c
> tzparse()
>
>         https://github.com/eggert/tz/blob/master/localtime.c#L1069
>
> (contributed to the public domain by Guy Harris): handles all the POSIX
> rules
> string edge cases to Paul Eggert's satisfaction, and gets patched if any
> upstream org (every distro) or vendor (all OSes) reports a problem.
>
> --
> Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
>
     The proposal is missing the documentation update (in tzset.c) for the
new feature.  (This of course is needed regardless of the eventual method
by which it is achieved.)
     Also, one question:  since at present the TZ string is matching POSIX
(at least, it is according to the documentation--I did not check the
present source code against the statement), shouldn't there be a gate to
control whether the extension is included or not?  (In my tzset(3) man page
in RHEL7, GLIBC does not mention this particular extension, so I don't know
what gate they might use.)  Strictly there should be; the question is how
strict we want to be.
            Craig


More information about the Newlib mailing list