diff options
| author | Paul Eggert | 2018-03-19 16:49:09 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-03-19 16:49:41 -0700 |
| commit | 6d12e7af88b8287b8dd520aa3a3470f7f112cfe0 (patch) | |
| tree | 43ec3825deaae1e0a500a2afb57a07eee896f3b9 | |
| parent | 6b168a3b243dea4500ba5518316abb6e447af35e (diff) | |
| download | emacs-6d12e7af88b8287b8dd520aa3a3470f7f112cfe0.tar.gz emacs-6d12e7af88b8287b8dd520aa3a3470f7f112cfe0.zip | |
Improve port to NetBSD tzalloc
Problem reported by Valery Ushakov (Bug#30738#22).
* src/editfns.c (HAVE_TZALLOC_BUG): New macro.
(tzlookup): Use it. Compile on all platforms, not just on NetBSD.
| -rw-r--r-- | src/editfns.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/editfns.c b/src/editfns.c index cb7353a48c6..7e35fe87972 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -48,6 +48,16 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 48 | #include <float.h> | 48 | #include <float.h> |
| 49 | #include <limits.h> | 49 | #include <limits.h> |
| 50 | 50 | ||
| 51 | #ifdef HAVE_TIMEZONE_T | ||
| 52 | # include <sys/param.h> | ||
| 53 | # if defined __NetBSD_Version__ && __NetBSD_Version__ < 700000000 | ||
| 54 | # define HAVE_TZALLOC_BUG true | ||
| 55 | # endif | ||
| 56 | #endif | ||
| 57 | #ifndef HAVE_TZALLOC_BUG | ||
| 58 | # define HAVE_TZALLOC_BUG false | ||
| 59 | #endif | ||
| 60 | |||
| 51 | #include <c-ctype.h> | 61 | #include <c-ctype.h> |
| 52 | #include <intprops.h> | 62 | #include <intprops.h> |
| 53 | #include <stdlib.h> | 63 | #include <stdlib.h> |
| @@ -205,16 +215,14 @@ tzlookup (Lisp_Object zone, bool settz) | |||
| 205 | 215 | ||
| 206 | new_tz = tzalloc (zone_string); | 216 | new_tz = tzalloc (zone_string); |
| 207 | 217 | ||
| 208 | #if defined __NetBSD_Version__ && __NetBSD_Version__ < 700000000 | 218 | if (HAVE_TZALLOC_BUG && !new_tz && errno != ENOMEM && plain_integer |
| 209 | /* NetBSD 6 tzalloc mishandles POSIX TZ strings (Bug#30738). | ||
| 210 | If possible, fall back on tzdb. */ | ||
| 211 | if (!new_tz && errno != ENOMEM && plain_integer | ||
| 212 | && XINT (zone) % (60 * 60) == 0) | 219 | && XINT (zone) % (60 * 60) == 0) |
| 213 | { | 220 | { |
| 221 | /* tzalloc mishandles POSIX strings; fall back on tzdb if | ||
| 222 | possible (Bug#30738). */ | ||
| 214 | sprintf (tzbuf, "Etc/GMT%+"pI"d", - (XINT (zone) / (60 * 60))); | 223 | sprintf (tzbuf, "Etc/GMT%+"pI"d", - (XINT (zone) / (60 * 60))); |
| 215 | new_tz = tzalloc (zone_string); | 224 | new_tz = tzalloc (zone_string); |
| 216 | } | 225 | } |
| 217 | #endif | ||
| 218 | 226 | ||
| 219 | if (!new_tz) | 227 | if (!new_tz) |
| 220 | { | 228 | { |