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.