unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Cc: 23600@debbugs.gnu.org
Subject: bug#23600: 25.1.50; encode-time returns wrong result
Date: Wed, 1 Jun 2016 01:19:50 -0700	[thread overview]
Message-ID: <574E9AA6.1070606@cs.ucla.edu> (raw)
In-Reply-To: <86oa7xaglt.wl--xmue@d1.dion.ne.jp>

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

Thanks for the bug report. This appears to be due to an incompatibility between 
MS-Windows and POSIX that I didn't know about. Please try the attached patch. I 
have not tested or installed this (I don't use MS-Windows).

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Port-angle-bracket-TZ-settings-to-MS-Windows.patch --]
[-- Type: text/x-diff; name="0001-Port-angle-bracket-TZ-settings-to-MS-Windows.patch", Size: 2442 bytes --]

From fef3119fc136889673a1a032ee0a5a47584a03fe Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 1 Jun 2016 01:09:42 -0700
Subject: [PATCH] Port angle-bracket TZ settings to MS-Windows

* doc/lispref/os.texi (Time Zone Rules): Document MS-Windows
lack of support for numeric time zone abbreviations.
* src/w32.c (sys_putenv): Convert angle-bracket TZ syntax
to MS-compatible syntax if possible, and to "ZZZ" otherwise.
Problem reported by Kazuhiro Ito (Bug#23600).
---
 doc/lispref/os.texi |  3 ++-
 src/w32.c           | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index becb691..38dde26 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1327,7 +1327,8 @@ Time Zone Rules
 a string, the conversion uses the time zone rule equivalent to setting
 @env{TZ} to that string.  If it is an integer @var{offset}, the
 conversion uses a fixed time zone with the given offset and a numeric
-abbreviation.  If it is a list (@var{offset} @var{abbr}), where
+abbreviation on POSIX-compatible platforms and an unspecified abbreviation
+on MS-Windows.  If it is a list (@var{offset} @var{abbr}), where
 @var{offset} is an integer number of seconds east of Universal Time
 and @var{abbr} is a string, the conversion uses a fixed time zone with
 the given offset and abbreviation.
diff --git a/src/w32.c b/src/w32.c
index 442ce79..71a38b9 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2505,6 +2505,35 @@ sys_putenv (char *str)
       return unsetenv (str);
     }
 
+  if (strncmp (str, "TZ=<", 4) == 0)
+    {
+      /* MS-Windows does not support POSIX.1-2001 angle-bracket TZ
+	 abbreviation syntax.  Convert to POSIX.1-1988 syntax if possible,
+	 and to the undocumented placeholder "ZZZ" otherwise.  */
+      bool supported_abbr = true;
+      for (char *p = str + 4; *p; p++)
+	{
+	  if (('0' <= *p && *p <= '9') || *p == '-' || *p == '+')
+	    supported_abbr = false;
+	  else if (*p == '>')
+	    {
+	      ptrdiff_t abbrlen;
+	      if (supported_abbr)
+		{
+		  abbrlen = p - (str + 4);
+		  memmove (str + 3, str + 4, abbrlen);
+		}
+	      else
+		{
+		  abbrlen = 3;
+		  memset (str + 3, 'Z', abbrlen);
+		}
+	      memmove (str + 3 + abbrlen, p + 1, strlen (p));
+	      break;
+	    }
+	}
+    }
+
   return _putenv (str);
 }
 
-- 
2.7.4


  reply	other threads:[~2016-06-01  8:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-22 22:10 bug#23600: 25.1.50; encode-time returns wrong result Kazuhiro Ito
2016-06-01  8:19 ` Paul Eggert [this message]
2016-06-02  1:54   ` Kazuhiro Ito
2016-06-02  6:38     ` Paul Eggert
2016-06-05 11:08       ` Kazuhiro Ito
2016-06-12 10:45       ` Kazuhiro Ito
2016-06-13 21:54         ` Paul Eggert
2016-06-14 14:05           ` Kazuhiro Ito
2016-06-14 14:40             ` Paul Eggert
2016-06-04 15:51   ` Eli Zaretskii
2016-06-04 17:15     ` Paul Eggert
2016-06-04 17:37       ` Eli Zaretskii
2016-06-04 22:18         ` Paul Eggert
2016-06-05  2:47           ` Eli Zaretskii
2016-06-05 15:20             ` Eli Zaretskii
2016-06-06  1:48               ` Paul Eggert

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=574E9AA6.1070606@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=23600@debbugs.gnu.org \
    --cc=kzhr@d1.dion.ne.jp \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).