summaryrefslogtreecommitdiff
path: root/src/w32.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-06-01 21:00:58 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-06-01 21:09:17 -0700
commit6b985764f07ae164d8142ba64774f2beb2856ca8 (patch)
tree8e4d3deb0d0c798f00489e4dc743737925296d76 /src/w32.c
parent1e5539e0b35d2a7fcd1f1772c4532430cb18471b (diff)
downloademacs-6b985764f07ae164d8142ba64774f2beb2856ca8.tar.gz
Port angle-bracket TZ settings to MS-Windows
* doc/lispref/os.texi (Time Zone Rules): Document MS-Windows lack of support for numeric time zone abbreviations. * src/w32.c (sys_putenv): Convert angle-bracket TZ syntax to MS-compatible syntax if possible, and to "ZZZ" otherwise. Problem reported by Kazuhiro Ito (Bug#23600).
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/w32.c b/src/w32.c
index 442ce79b23c..71a38b91946 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2505,6 +2505,35 @@ sys_putenv (char *str)
return unsetenv (str);
}
+ if (strncmp (str, "TZ=<", 4) == 0)
+ {
+ /* MS-Windows does not support POSIX.1-2001 angle-bracket TZ
+ abbreviation syntax. Convert to POSIX.1-1988 syntax if possible,
+ and to the undocumented placeholder "ZZZ" otherwise. */
+ bool supported_abbr = true;
+ for (char *p = str + 4; *p; p++)
+ {
+ if (('0' <= *p && *p <= '9') || *p == '-' || *p == '+')
+ supported_abbr = false;
+ else if (*p == '>')
+ {
+ ptrdiff_t abbrlen;
+ if (supported_abbr)
+ {
+ abbrlen = p - (str + 4);
+ memmove (str + 3, str + 4, abbrlen);
+ }
+ else
+ {
+ abbrlen = 3;
+ memset (str + 3, 'Z', abbrlen);
+ }
+ memmove (str + 3 + abbrlen, p + 1, strlen (p));
+ break;
+ }
+ }
+ }
+
return _putenv (str);
}