This is the mail archive of the
mailing list for the Cygwin project.
Re: Invalid tm_zone from localtime() when TZ is not set
- From: KOBAYASHI Shinji <koba at jp dot fujitsu dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 25 May 2016 11:28:26 +0900
- Subject: Re: Invalid tm_zone from localtime() when TZ is not set
- Authentication-results: sourceware.org; auth=none
- References: <o8xeg8x7e2r dot wl-koba at jp dot fujitsu dot com> <932D033F-9DA4-4901-9158-328AA929FEC8 at etr-usa dot com> <o8x8tz573zs dot wl-koba at jp dot fujitsu dot com> <CAEhDDbA-ATpAtVggR7cfqn58AHw0sPK_Y3mNSJ8UO29sg2ZpuA at mail dot gmail dot com> <o8x37pd6nlm dot wl-koba at jp dot fujitsu dot com>
Any other comments on this topic? Let me explain my proposal again.
The intention of the following code in tzsetwall() should be to pick
up UPPERCASE letters "in ASCII range":
if (isupper(*src)) *dst++ = *src;
NOTE: src is wchar_t *, dst is char *.
As Csaba Raduly pointed out, isw*() functions should be the first
choice if they achieve the desired behavior (select uppercase AND
ASCII). However, iswupper() does not fit for this purpose, as it
returns 1 for L'\uff21' for example. And I could not find isw*()
functions to achieve the behavior.
As the man page mentions, isupper() accepts int as its argument, but
it is defined only when isascii() is true (or EOF). Both isascii() and
isupper() accept int, not char. So it seems to me that
isascii(*src) && isupper(*src)
is fine even if *src is wchar_t, provided that:
1. Type of *src (wchar_t) <= int.
2. Code points used is an extension of ASCII.
I think these conditions are met. Because sizeof(wchar_t) is 2, and
sizeof(int) is 4 in Cygwin. The code points used here is an extension
of ASCII because the Windows function GetTimeZoneInformation() uses
The second option might be to use a macro as it was before the
following commit, but I prefer using standard isascii() and isupper():
Author: Christopher Faylor
Date: Sat Oct 30 19:22:42 2010 +0000
* localtime.cc (is_upper): Rename to isupper and include ctype.h to pull in
(lcl_is_set): Define as an enum.
(tzsetwall): Assign lcl_is_set to correct enum values.
(tzset): Ditto. Copy as much of TZ as will fit to TZ buffer.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple