From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52110 invoked by alias); 25 May 2016 02:29:12 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 52095 invoked by uid 89); 25 May 2016 02:29:12 -0000 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 Received: from mgwym01.jp.fujitsu.com (HELO mgwym01.jp.fujitsu.com) (211.128.242.40) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 25 May 2016 02:29:01 +0000 Received: from yt-mxauth.gw.nic.fujitsu.com (unknown [192.168.229.68]) by mgwym01.jp.fujitsu.com with smtp id 47e3_2bf2_62efd39c_95c6_454b_9e02_16f2069d3dcf; Wed, 25 May 2016 11:28:54 +0900 Received: from dm.kawasaki.flab.fujitsu.co.jp (dm.kawasaki.flab.fujitsu.co.jp [10.25.192.105]) by yt-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id ECFC5AC0236 for ; Wed, 25 May 2016 11:28:53 +0900 (JST) Received: from localhost (hv-win7-64-144.flabad.flab.fujitsu.co.jp [10.25.198.94]) by dm.kawasaki.flab.fujitsu.co.jp (8.14.4/8.14.4) with ESMTP id u4P2SriB005277 for ; Wed, 25 May 2016 11:28:53 +0900 X-SecurityPolicyCheck: OK by SHieldMailChecker v2.2.3 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20140219-2 Date: Wed, 25 May 2016 09:28:00 -0000 Message-ID: From: KOBAYASHI Shinji To: cygwin@cygwin.com Subject: Re: Invalid tm_zone from localtime() when TZ is not set In-Reply-To: References: <932D033F-9DA4-4901-9158-328AA929FEC8@etr-usa.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 X-SW-Source: 2016-05/txt/msg00302.txt.bz2 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