bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27706: MacOS: decode-time hang


From: Charles A. Roelli
Subject: bug#27706: MacOS: decode-time hang
Date: Sun, 01 Oct 2017 11:27:38 +0200

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Sat, 30 Sep 2017 17:21:49 -0400
> 
> Alan Third <alan@idiocy.org> writes:
> 
> >     (string-equal system-type "darwin")
> 
> `system-type' contains a symbol, so generally the comparison should look
> like this (unless there is some strong reason to do string comparison)
> 
>     (eq system-type 'darwin)

Thanks to both of you for your help.  Updated patch follows.  I've
also made the check a bit easier to read, and verified that it also
works on the Darwin terminal.

>From 7ddfdae2359c07bdddeeeafd69517e02ee3ee2f5 Mon Sep 17 00:00:00 2001
From: "Charles A. Roelli" <charles@aurox.ch>
Date: Sat, 30 Sep 2017 20:42:03 +0200
Subject: [PATCH] Workaround for faulty localtime() under macOS 10.6

* lisp/org/org-clock.el (org-clock--oldest-date): Only execute
'decode-time' on times later than year -2**31 under macOS 10.6.
See Bug#27706.
---
 lisp/org/org-clock.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index 8df185d..2eec817 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -478,7 +478,17 @@ org-clock--oldest-date
          (funcall dichotomy
                   most-negative-fixnum
                   0
-                  (lambda (m) (ignore-errors (decode-time (list m 0))))))
+                  (lambda (m)
+                     ;; libc in macOS 10.6 hangs when decoding times
+                     ;; around year -2**31.  Limit `high' not to go
+                     ;; any earlier than that.
+                     (unless (and (eq system-type 'darwin)
+                                  (string-match-p
+                                   "10\\.6\\.[[:digit:]]"
+                                   (shell-command-to-string
+                                    "sw_vers -productVersion"))
+                                  (<= m -1034058203136))
+                       (ignore-errors (decode-time (list m 0)))))))
         (low
          (funcall dichotomy
                   most-negative-fixnum
-- 
2.9.4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]