From: Andrew Moss <andrewmoss@pobox.com>
To: 26261@debbugs.gnu.org
Subject: bug#26261: ~N mishandles small nanoseconds value
Date: Mon, 27 Mar 2017 12:06:10 -0400 [thread overview]
Message-ID: <CA+j0N_Ou0X3NyuKkbXiobFM_ExLHy3YTETh3jD0514MkH7YRsg@mail.gmail.com> (raw)
In-Reply-To: <20170326021924.GE6453@fysh.org>
[-- Attachment #1.1: Type: text/plain, Size: 140 bytes --]
I believe I have fixed this bug, but I'm not sure if I put the test case in
the right place within the file. Please see the attached patch.
[-- Attachment #1.2: Type: text/html, Size: 180 bytes --]
[-- Attachment #2: 0001-Fixed-bug-N-mishandles-small-nanoseconds-value.patch --]
[-- Type: text/x-patch, Size: 1802 bytes --]
From e975f8ae8d494985a51faed5b15c5664a557e0e2 Mon Sep 17 00:00:00 2001
From: Andrew Moss <andrewmoss@pobox.com>
Date: Mon, 27 Mar 2017 11:58:29 -0400
Subject: [PATCH] Fixed bug: ~N mishandles small nanoseconds value
Fixes <http://bugs.gnu.org/26261>.
Reported by Zefram <zefram@fysh.org>.
* module/srfi/srfi-19.scm ("define directives"): N padding increased from 7 to 9
* test-suite/tests/srfi-19.test ("date->string"): New test.
---
module/srfi/srfi-19.scm | 2 +-
test-suite/tests/srfi-19.test | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm
index 658ccd9..4823f2f 100644
--- a/module/srfi/srfi-19.scm
+++ b/module/srfi/srfi-19.scm
@@ -1060,7 +1060,7 @@
(newline port)))
(cons #\N (lambda (date pad-with port)
(display (padding (date-nanosecond date)
- pad-with 7)
+ pad-with 9)
port)))
(cons #\p (lambda (date pad-with port)
(display (locale-am-string/pm (date-hour date)) port)))
diff --git a/test-suite/tests/srfi-19.test b/test-suite/tests/srfi-19.test
index d63e622..534cd7c 100644
--- a/test-suite/tests/srfi-19.test
+++ b/test-suite/tests/srfi-19.test
@@ -175,6 +175,11 @@ incomplete numerical tower implementation.)"
(equal? "Sun Jun 05 18:33:00+0200 2005"
(date->string date))))
+ (pass-if "date->string pads small nanoseconds values correctly"
+ (let* ((date (make-date 99999999 5 34 12 26 3 2017 0)))
+ (equal? "099999999"
+ (date->string date "~N"))))
+
;; check time comparison procedures
(let* ((time1 (make-time time-monotonic 0 0))
(time2 (make-time time-monotonic 0 0))
--
2.7.4
next prev parent reply other threads:[~2017-03-27 16:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-26 2:19 bug#26261: ~N mishandles small nanoseconds value Zefram
2017-03-27 16:06 ` Andrew Moss [this message]
2017-04-19 13:14 ` Andy Wingo
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/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+j0N_Ou0X3NyuKkbXiobFM_ExLHy3YTETh3jD0514MkH7YRsg@mail.gmail.com \
--to=andrewmoss@pobox.com \
--cc=26261@debbugs.gnu.org \
/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.
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).