public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: newlib@sourceware.org
Subject: Re: [PATCH] Add support for TZ names with <> in tzset
Date: Mon, 16 Nov 2020 21:59:29 -0700	[thread overview]
Message-ID: <76c91228-465f-1c99-9a8e-6269063b04bd@SystematicSw.ab.ca> (raw)
In-Reply-To: <CANk6obSE6KegjJhKm7phMwGxYLscsaDp9ayhpAVDEpreSMV4NQ@mail.gmail.com>

On 2020-11-16 18:43, C Howland via Newlib wrote:
> On Monday, November 16, 2020 5:30 PM, Brian Inglis wrote:
>> On 2020-11-16 08:13, Corinna Vinschen via Newlib wrote:
>>> On Nov 14 15:03, Earle F. Philhower, III via Newlib wrote:
>>>> 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.
>>>>

>>> 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.

> 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.
The <> quoted format has been a POSIX standard since Issue 6 IEEE Std 1003.1, 
2004; see under Base Definitions, 8.3 Other Environment Variables, bottom of web 
page, under TZ:

https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.htmltag_08_03

also Rationale, A.8.3 Other Environment Variables, bottom of web page, under TZ:

https://pubs.opengroup.org/onlinepubs/009695399/xrat/xbd_chap08.html#tag_01_08_03_05

and not an extension, intended to allow specification of signed alpha/numeric 
character time zone designations, not just the original alphabetic character 
designations, with at least 3 not more than TZNAME_MAX (minimum 
_POSIX_TZNAME_MAX == 6) characters.

The POSIX TZ env var current spec is essentially unchanged under Base 
Definitions, 8.3 Other Environment Variables, bottom of web page, under TZ:

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03

also Rationale, A.8.3 Other Environment Variables, bottom of web page, under TZ:

https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap08.html#tag_21_08_03_05

where the leading : for implementation defined zones is treated as optional by 
implementations supporting zoneinfo TZif files, and better implementations will 
handle relative paths specially (normally prefix with TZDIR, or at least start 
by trying that location, then try alternatives), and allow and handle absolute 
paths in the obvious way.

Perhaps Eric Blake if available could shed more light as a POSIX contributor.

-- 
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.]

  reply	other threads:[~2020-11-17  4:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <080401d6bada$6c52f060$44f8d120$.ref@yahoo.com>
2020-11-14 23:03 ` earlephilhower
2020-11-16 15:13   ` Corinna Vinschen
2020-11-16 22:30     ` Brian Inglis
     [not found]       ` <DM2P110MB01699F833CC488133A5AE9E99AE20@DM2P110MB0169.NAMP110.PROD.OUTLOOK.COM>
2020-11-17  1:43         ` Fw: " C Howland
2020-11-17  4:59           ` Brian Inglis [this message]
2020-12-12 17:56             ` Earle F. Philhower, III
2020-12-12 18:59               ` Brian Inglis
2020-12-14  9:30               ` Corinna Vinschen

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=76c91228-465f-1c99-9a8e-6269063b04bd@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).