Invalid tm_zone from localtime() when TZ is not set

Corinna Vinschen corinna-cygwin@cygwin.com
Thu May 26 14:56:00 GMT 2016


On May 26 15:54, KOBAYASHI Shinji wrote:
> On Wed, 25 May 2016 22:02:50 +0200, Hans-Bernhard Bröker wrote:
> > On May 25 11:28, KOBAYASHI Shinji wrote:
> >> The intention of the following code in tzsetwall() should be to pick
> >> up UPPERCASE letters "in ASCII range":
> > Are you sure you're not mixing ASCII with '8-bit character' range there?
> 
> I'm not sure if non-ASCII 8-bit characters are allowed as TZ
> names. I just guessed the intention from the fact isupper() is used,
> and from the description of isupper() man page:
> 
> - isupper is a macro which classifies ASCII integer values by table
>   lookup.
> - It is defined only when isascii(c) is true or c is EOF.
> 
> However, the implementation of isupper() seems to work for 8-bit
> characters even if isascii() is false. Does the man page need some
> changes?
> 
> > A proper solution may have to be more like this:
> >     int mapped = wctob(*src);
> >     /* this call is safe now because of how wctob() works: */
> >     if (isupper(mapped)) {
> >        *dst++ = (unsigned char)mapped;
> >     }
> 
> Thank you for pointing out wctob(). I'm in favor of fixing this way.

I fixed it already in the repo using explicit testing for
L'A' <= wchar <= L'Z', see
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=030d86d04dbd6ae878ff894256c5a465890d5970

> On Wed, 25 May 2016 10:44:30 +0200, Corinna Vinschen wrote:
> > However, testing this with GLibc it turns out that GLibc's towlower does not
> > transform the character but returns 0xff21.  Can anybody explain to me why?  
> It seems that it depends on locale. The man page (on Linux) says:
> 
>   The behavior of towlower() depends on the LC_CTYPE category of the
>   current locale.
> 
> I observed that it returns 0xff41 when LANG=ja_JP.UTF-8, and 0xff21
> when LANG=C.
> 
> Cygwin's implementation (and man page) does not seem to depend on
> locale.

No, it's basically fixed code inside newlib.  I have some code prepared
to update newlib from Unicode 5.2 to Unicode 8.0, but it adds a lot of
extra code.  So many new characters...


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160526/8edf44d5/attachment.sig>


More information about the Cygwin mailing list