all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: 35502@debbugs.gnu.org, Robert Pluim <rpluim@gmail.com>
Subject: bug#35502: 27.0.50; encode-time apparently stopped working
Date: Tue, 30 Apr 2019 10:54:48 -0700	[thread overview]
Message-ID: <bc33752d-65ff-c7e0-5232-4f6d7700b9b1@cs.ucla.edu> (raw)
In-Reply-To: <871s1j3kz8.fsf@mbork.pl>

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

Although I don't use macOS I rigged up a version of mktime on Fedora
that reproduced the problem. The bug I found doesn't have anything to do
with ATTRIBUTE_COLD; it's an unportable assumption in the
emacs/src/timefns.c. I installed the attached into master to fix the bug
I found; please give it a try.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-decode-time-encode-time-roundtrip-on-macOS.patch --]
[-- Type: text/x-patch; name="0001-Fix-decode-time-encode-time-roundtrip-on-macOS.patch", Size: 2058 bytes --]

From 325f51c84d9ad4d9776784bd324b347ffe4fe51b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 30 Apr 2019 10:45:48 -0700
Subject: [PATCH] Fix decode-time/encode-time roundtrip on macOS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/timefns.c (Fencode_time): Ignore DST flag when the zone is
numeric or is a cons, as the doc string says it’s ignored in that
case, and not ignoring it causes encode-time to not invert
decode-time on some platforms (Bug#35502).
* test/src/timefns-tests.el (encode-time-dst-numeric-zone):
New test.
---
 src/timefns.c             | 5 +++--
 test/src/timefns-tests.el | 6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/timefns.c b/src/timefns.c
index 5005c73b7f..7b5af6a5d2 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -1488,10 +1488,11 @@ usage: (encode-time &optional TIME FORM &rest OBSOLESCENT-ARGUMENTS)  */)
       tm.tm_mon  = check_tm_member (XCAR (a), 1); a = XCDR (a);
       tm.tm_year = check_tm_member (XCAR (a), TM_YEAR_BASE); a = XCDR (a);
       a = XCDR (a);
-      if (SYMBOLP (XCAR (a)))
-	tm.tm_isdst = !NILP (XCAR (a));
+      Lisp_Object dstflag = XCAR (a);
       a = XCDR (a);
       zone = XCAR (a);
+      if (SYMBOLP (dstflag) && !FIXNUMP (zone) && !CONSP (zone))
+	tm.tm_isdst = !NILP (dstflag);
     }
   else if (nargs < 6)
     xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nargs));
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index 5c858ef3bd..2c90af757f 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -142,3 +142,9 @@ timefns-tests--have-leap-seconds
 		      (< 0.99 (/ x y) 1.01)
 		      (< 0.99 (/ (- (float-time a)) (float-time b))
 			 1.01))))))))
+
+(ert-deftest encode-time-dst-numeric-zone ()
+    "Check for Bug#35502."
+    (should (time-equal-p
+             (encode-time '(29 31 17 30 4 2019 2 t 7200))
+             '(23752 27217))))
-- 
2.20.1


  parent reply	other threads:[~2019-04-30 17:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30  9:23 bug#35502: 27.0.50; encode-time apparently stopped working Marcin Borkowski
2019-04-30 15:17 ` Eli Zaretskii
2019-04-30 15:39   ` Robert Pluim
2019-04-30 15:43     ` Eli Zaretskii
2019-04-30 15:55       ` Robert Pluim
2019-04-30 16:08         ` Eli Zaretskii
2019-04-30 16:16           ` Robert Pluim
2019-04-30 15:40   ` Marcin Borkowski
2019-04-30 16:14     ` Eli Zaretskii
2019-04-30 17:54 ` Paul Eggert [this message]
2019-04-30 18:00   ` Robert Pluim
2019-04-30 19:40     ` Paul Eggert
2019-04-30 20:16       ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc33752d-65ff-c7e0-5232-4f6d7700b9b1@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=35502@debbugs.gnu.org \
    --cc=mbork@mbork.pl \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.