aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2016-06-01 21:00:58 -0700
committerPaul Eggert2016-06-01 21:09:17 -0700
commit6b985764f07ae164d8142ba64774f2beb2856ca8 (patch)
tree8e4d3deb0d0c798f00489e4dc743737925296d76
parent1e5539e0b35d2a7fcd1f1772c4532430cb18471b (diff)
downloademacs-6b985764f07ae164d8142ba64774f2beb2856ca8.tar.gz
emacs-6b985764f07ae164d8142ba64774f2beb2856ca8.zip
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).
-rw-r--r--doc/lispref/os.texi3
-rw-r--r--src/w32.c29
2 files changed, 31 insertions, 1 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index becb691581b..38dde26d03a 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1327,7 +1327,8 @@ If it is @code{t}, the conversion uses Universal Time. If it is
1327a string, the conversion uses the time zone rule equivalent to setting 1327a string, the conversion uses the time zone rule equivalent to setting
1328@env{TZ} to that string. If it is an integer @var{offset}, the 1328@env{TZ} to that string. If it is an integer @var{offset}, the
1329conversion uses a fixed time zone with the given offset and a numeric 1329conversion uses a fixed time zone with the given offset and a numeric
1330abbreviation. If it is a list (@var{offset} @var{abbr}), where 1330abbreviation on POSIX-compatible platforms and an unspecified abbreviation
1331on MS-Windows. If it is a list (@var{offset} @var{abbr}), where
1331@var{offset} is an integer number of seconds east of Universal Time 1332@var{offset} is an integer number of seconds east of Universal Time
1332and @var{abbr} is a string, the conversion uses a fixed time zone with 1333and @var{abbr} is a string, the conversion uses a fixed time zone with
1333the given offset and abbreviation. 1334the given offset and abbreviation.
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)
2505 return unsetenv (str); 2505 return unsetenv (str);
2506 } 2506 }
2507 2507
2508 if (strncmp (str, "TZ=<", 4) == 0)
2509 {
2510 /* MS-Windows does not support POSIX.1-2001 angle-bracket TZ
2511 abbreviation syntax. Convert to POSIX.1-1988 syntax if possible,
2512 and to the undocumented placeholder "ZZZ" otherwise. */
2513 bool supported_abbr = true;
2514 for (char *p = str + 4; *p; p++)
2515 {
2516 if (('0' <= *p && *p <= '9') || *p == '-' || *p == '+')
2517 supported_abbr = false;
2518 else if (*p == '>')
2519 {
2520 ptrdiff_t abbrlen;
2521 if (supported_abbr)
2522 {
2523 abbrlen = p - (str + 4);
2524 memmove (str + 3, str + 4, abbrlen);
2525 }
2526 else
2527 {
2528 abbrlen = 3;
2529 memset (str + 3, 'Z', abbrlen);
2530 }
2531 memmove (str + 3 + abbrlen, p + 1, strlen (p));
2532 break;
2533 }
2534 }
2535 }
2536
2508 return _putenv (str); 2537 return _putenv (str);
2509} 2538}
2510 2539