Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: automatic TZ-string generation still faulty in Asian Windows Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII From: Kazuhiro Fujieda Date: 02 Oct 1999 12:49:53 +0900 Message-ID: Lines: 81 X-Mailer: Gnus v5.3/Emacs 19.34 In Japanese Windows, probably in Chinese and Korean ones, the automatic TZ-string generation always fails about any timezones, because GetTimeZoneInformation() can't return valid timezone and daylight names. In Japanese Windows, tz.StandardName and tz.DaylightName don't contain the timezone and daylight name but Japanese descriptions of them. So it is necessary to accommodate tzsetwall() to such case as the following patch. In my patch, WILDABBR is modified into " " and used as the fall back name in Asian Windows. Then, my patch doesn't convert tz.StandardName and tz.DaylightName to multi-byte characters. Multi-byte characters in Japanese, Chinese, and Korean encoding methods can't be classified into upper-case ASCII characters or not by each byte. Such kind of operation should be operated on wide characters. --- localtime.c- Thu Sep 30 03:56:37 1999 +++ localtime.c Sat Oct 02 01:50:20 1999 @@ -523,7 +523,7 @@ struct tzhead { #define WILDABBR " " #endif /* !defined WILDABBR */ -static char wildabbr[] = "WILDABBR"; +static char wildabbr[] = WILDABBR; static const char gmt[] = "GMT"; @@ -1436,24 +1436,40 @@ tzsetwall P((void)) { TIME_ZONE_INFORMATION tz; char buf[BUFSIZ]; - char* cp = buf; - char* src; + char *cp, *dst; + wchar_t *src; div_t d; GetTimeZoneInformation(&tz); - wcstombs(cp, tz.StandardName, sizeof(tz.StandardName)); - for (src = cp; *src; ++src) { - if (is_upper(*src)) *cp++ = *src; - } + dst = cp = buf; + for (src = tz.StandardName; *src; src++) + if (is_upper(*src)) *dst++ = *src; + if (cp == dst) + { + /* In Asian Windows, tz.StandardName may not contain + the timezone name. */ + strcpy(cp, wildabbr); + cp += strlen(wildabbr); + } + else + cp = dst; d = div(tz.Bias+tz.StandardBias, 60); sprintf(cp, "%d", d.quot); if (d.rem) sprintf(cp=strchr(cp, 0), ":%d", abs(d.rem)); if(tz.StandardDate.wMonth) { cp = strchr(cp, 0); - wcstombs(cp, tz.DaylightName, sizeof(tz.DaylightName)); - for (src = cp; *src; ++src) { - if (is_upper(*src)) *cp++ = *src; - } + dst = cp; + for (src = tz.DaylightName; *src; src++) + if (is_upper(*src)) *dst++ = *src; + if (cp == dst) + { + /* In Asian Windows, tz.StandardName may not contain + the daylight name. */ + strcpy(buf, wildabbr); + cp += strlen(wildabbr); + } + else + cp = dst; d = div(tz.Bias+tz.DaylightBias, 60); sprintf(cp, "%d", d.quot); if (d.rem)