bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tzset: add native Windows workaround


From: Paul Eggert
Subject: Re: tzset: add native Windows workaround
Date: Tue, 2 May 2017 08:52:13 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 05/01/2017 09:40 AM, Bruno Haible wrote:
+  /* If the environment variable TZ has been set by Cygwin, neutralize it.
+     The Microsoft CRT interprets TZ differently than Cygwin and produces
+     incorrect results if TZ has the syntax used by Cygwin.  */
+  const char *tz = getenv ("TZ");
+  if (tz != NULL && strchr (tz, '/') != NULL)
+    _putenv ("TZ=");

I'm puzzled why setting TZ="" is desirable here. Does this cause the Microsoft CRT to use UTC? Is TZ="" a good thing because switching to UTC is better than the undefined behavior one would get with TZ set to a value not documented by Microsoft? If so, perhaps a comment to that effect would help.

Also, the test "strchr (tz, '/') != NULL" allows many Cygwin-compatible TZ settings that Microsoft does not document support for, e.g., TZ="PST8PDT,M3.2.0,M11.1.0" for Los Angeles. Admittedly most Cygwin users in L.A. probably just use TZ="America/Los_Angeles" so fixing this is not that important. Still, if the intent is to limit the TZ value to what Microsoft documents, I suppose you could nuke the TZ value if it does not match the C-locale ERE "^[A-Za-z]{3}[-+]?[01]?[0-9](:[0-5][0-9](:[0-5][0-9])?)?([A-Za-z]{3})?$", or maybe put in a FIXME comment to that effect.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]