This is the mail archive of the
cygwin-developers@sourceware.cygnus.com
mailing list for the Cygwin project.
automatic TZ-string generation still faulty in Asian Windows
- To: cygwin-developers at sourceware dot cygnus dot com
- Subject: automatic TZ-string generation still faulty in Asian Windows
- From: Kazuhiro Fujieda <fujieda at jaist dot ac dot jp>
- Date: 02 Oct 1999 12:49:53 +0900
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)