TZ: Replace unreliable isupper calls on wchars

In case the TZ variable is empty, Cygwin fetches timezone info from
Windows.  Extracting the timezone short name uses isupper on wide chars.
Replace with explicit check for A <= character <= Z to be independent
of undefined behaviour.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-05-25 12:13:03 +02:00
parent 3b66731698
commit 030d86d04d
1 changed files with 4 additions and 2 deletions

View File

@ -1543,7 +1543,8 @@ tzsetwall (void)
GetTimeZoneInformation(&tz);
dst = cp = buf;
for (src = tz.StandardName; *src; src++)
if (isupper(*src)) *dst++ = *src;
if (*src >= L'A' && *src <= L'Z')
*dst++ = *src;
if ((dst - cp) < 3)
{
/* In non-english Windows, converted tz.StandardName
@ -1561,7 +1562,8 @@ tzsetwall (void)
cp = strchr(cp, 0);
dst = cp;
for (src = tz.DaylightName; *src; src++)
if (isupper(*src)) *dst++ = *src;
if (*src >= L'A' && *src <= L'Z')
*dst++ = *src;
if ((dst - cp) < 3)
{
/* In non-english Windows, converted tz.DaylightName