]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve port to NetBSD tzalloc
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Mar 2018 23:49:09 +0000 (16:49 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Mar 2018 23:49:41 +0000 (16:49 -0700)
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.

src/editfns.c

index cb7353a48c6aeeae81de1473226dcfe40ba946c9..7e35fe879728023a1798fe337b47f17f7ef1350d 100644 (file)
@@ -48,6 +48,16 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include <float.h>
 #include <limits.h>
 
+#ifdef HAVE_TIMEZONE_T
+# include <sys/param.h>
+# if defined __NetBSD_Version__ && __NetBSD_Version__ < 700000000
+#  define HAVE_TZALLOC_BUG true
+# endif
+#endif
+#ifndef HAVE_TZALLOC_BUG
+# define HAVE_TZALLOC_BUG false
+#endif
+
 #include <c-ctype.h>
 #include <intprops.h>
 #include <stdlib.h>
@@ -205,16 +215,14 @@ tzlookup (Lisp_Object zone, bool settz)
 
       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
+      if (HAVE_TZALLOC_BUG && !new_tz && errno != ENOMEM && plain_integer
          && XINT (zone) % (60 * 60) == 0)
        {
+         /* tzalloc mishandles POSIX strings; fall back on tzdb if
+            possible (Bug#30738).  */
          sprintf (tzbuf, "Etc/GMT%+"pI"d", - (XINT (zone) / (60 * 60)));
          new_tz = tzalloc (zone_string);
        }
-#endif
 
       if (!new_tz)
        {