diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-03-15 09:35:33 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-03-15 09:36:28 -0700 |
commit | 64a1da4989b0551481600facb1781ac92089d182 (patch) | |
tree | 20bdac9a212d1f42fa648ea69cdb846de4d2bde2 | |
parent | 711b94c8bb2d25bb3cd13be8b1f88feb2edbd186 (diff) | |
download | emacs-64a1da4989b0551481600facb1781ac92089d182.tar.gz |
Improve port to NetBSD tzalloc
Problem reported by Valery Ushakov (Bug#30738#13).
* src/editfns.c (tzlookup) [__NetBSD_Version__ < 700000000]:
If tzalloc fails for any reason other than memory exhaustion,
assume it’s because NetBSD 6 does not support tzalloc on
POSIX-format TZ strings, and fall back on tzdb if possible.
-rw-r--r-- | src/editfns.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c index 6ecc83fc302..d26319441b3 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -204,6 +204,18 @@ tzlookup (Lisp_Object zone, bool settz) invalid_time_zone_specification (zone); new_tz = tzalloc (zone_string); + +#if defined __NetBSD_Version__ && __NetBSD_Version__ < 700000000 + /* NetBSD 6 tzalloc mishandles POSIX TZ strings (Bug#30738). + If possible, fall back on tzdb. */ + if (!new_tz && errno != ENOMEM && plain_integer + && XINT (zone) % (60 * 60) == 0) + { + sprintf (tzbuf, "Etc/GMT%+"pI"d", - (XINT (zone) / (60 * 60))); + new_tz = tzalloc (zone_string); + } +#endif + if (!new_tz) { if (errno == ENOMEM) |