X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:message-id:from:to:subject:in-reply-to
	:references:mime-version:content-type; q=dns; s=default; b=AqRaw
	yCMZlF/ZVLjaxLLfNbS3c394ss5gBvgkB+Top/L5mBCfwgOq8BjMmTYWup6sc9v0
	BLIEvELnCUfsYR6NnX74eb3xUMUyO3T9qVk0ig3yC3+ikpOqRK3PlskFKGkkEakG
	QSIptyMlq+kdgBL6Le+NCTqrMW1NhzSpuNDbD0=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:message-id:from:to:subject:in-reply-to
	:references:mime-version:content-type; s=default; bh=pet7Raya4gE
	QpjbqueHJeDrX3ww=; b=wEFZTmJbxlpnaSoSlxcH+6ryOQi+3wvyj3h5dLI8GLx
	+geiC6MeBcNXuNIirD/rw/qDpst977wqrrngZD3pSsCxu7g7sc8OrOmAJ/9fuZ6F
	331CIuqlVQxHwqKDUa0SFstyV9TQzy0+3GKGHYXQIr4QIXQN8CjcFEN9ZiL+POM4
	=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=oct, Oct, letters
X-HELO: mgwym01.jp.fujitsu.com
X-SecurityPolicyCheck: OK by SHieldMailChecker v2.2.3
X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20140219-2
Date: Wed, 25 May 2016 11:28:26 +0900
Message-ID: <o8xposa6fcl.wl-koba@jp.fujitsu.com>
From: KOBAYASHI Shinji <koba@jp.fujitsu.com>
To: cygwin@cygwin.com
Subject: Re: Invalid tm_zone from localtime() when TZ is not set
In-Reply-To: <o8x37pd6nlm.wl-koba@jp.fujitsu.com>
References: <o8xeg8x7e2r.wl-koba@jp.fujitsu.com>	<932D033F-9DA4-4901-9158-328AA929FEC8@etr-usa.com>	<o8x8tz573zs.wl-koba@jp.fujitsu.com>	<CAEhDDbA-ATpAtVggR7cfqn58AHw0sPK_Y3mNSJ8UO29sg2ZpuA@mail.gmail.com>	<o8x37pd6nlm.wl-koba@jp.fujitsu.com>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/24.5 (x86_64-unknown-cygwin) MULE/6.0 (HANACHIRUSATO)
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
X-TM-AS-MML: disable
X-IsSubscribed: yes


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
UTF-16 encoding.

The second option might be to use a macro as it was before the
following commit, but I prefer using standard isascii() and isupper():

commit 49808040c5fa1390983945d38c7e8267b2b8a381
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
    standard macro.
    (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.

Regards,

KOBAYASHI Shinji.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

