[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 09/14: i18n: Do not represent zero as "-0".
From: |
Andy Wingo |
Subject: |
[Guile-commits] 09/14: i18n: Do not represent zero as "-0". |
Date: |
Wed, 1 Mar 2017 15:21:05 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 19d274c68063c2799436bbba3cb11b0de9a1f75b
Author: Ludovic Courtès <address@hidden>
Date: Sun Feb 12 22:59:17 2017 +0100
i18n: Do not represent zero as "-0".
Partly fixes <http://bugs.gnu.org/24990>.
Reported by Martin Michel <address@hidden>.
* module/ice-9/i18n.scm (monetary-amount->locale-string): Don't negate
AMOUNT when it's zero.
(number->locale-string): Likewise.
* test-suite/tests/i18n.test ("number->locale-string")["positive inexact
zero, 1 digit"]: New test.
("monetary-amount->locale-string")["positive inexact zero"]: New test.
---
module/ice-9/i18n.scm | 7 ++++---
test-suite/tests/i18n.test | 17 ++++++++++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/module/ice-9/i18n.scm b/module/ice-9/i18n.scm
index 1d12dd0..1326a2a 100644
--- a/module/ice-9/i18n.scm
+++ b/module/ice-9/i18n.scm
@@ -1,6 +1,7 @@
;;;; i18n.scm --- internationalization support -*- coding: utf-8 -*-
-;;;; Copyright (C) 2006, 2007, 2009, 2010, 2012 Free Software Foundation,
Inc.
+;;;; Copyright (C) 2006, 2007, 2009, 2010, 2012,
+;;;; 2017 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -335,7 +336,7 @@ locale is used."
(substring dec 0 fraction-digits)
dec)))))
- (external-repr (number->string (if (> amount 0) amount (- amount))))
+ (external-repr (number->string (if (>= amount 0) amount (- amount))))
(int+dec (string-split external-repr #\.))
(int (car int+dec))
(dec (decimal-part (if (null? (cdr int+dec))
@@ -387,7 +388,7 @@ number of fractional digits to be displayed."
(substring dec 0 fraction-digits)
dec))))))
- (let* ((external-repr (number->string (if (> number 0)
+ (let* ((external-repr (number->string (if (>= number 0)
number
(- number))))
(int+dec (string-split external-repr #\.))
diff --git a/test-suite/tests/i18n.test b/test-suite/tests/i18n.test
index 0078baa..53ed932 100644
--- a/test-suite/tests/i18n.test
+++ b/test-suite/tests/i18n.test
@@ -1,7 +1,7 @@
;;;; i18n.test --- Exercise the i18n API. -*- coding: utf-8; mode: scheme; -*-
;;;;
;;;; Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012,
-;;;; 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
+;;;; 2013, 2014, 2015, 2016, 2017 Free Software Foundation, Inc.
;;;; Ludovic Courtès
;;;;
;;;; This library is free software; you can redistribute it and/or
@@ -506,7 +506,10 @@
(string=? "1234.567" (number->locale-string 1234.567)))
(pass-if "fraction, 1 digit"
- (string=? "1234.5" (number->locale-string 1234.567 1))))
+ (string=? "1234.5" (number->locale-string 1234.567 1)))
+
+ (pass-if "positive inexact zero, 1 digit"
+ (string=? "0.0" (number->locale-string .0 1))))
(with-test-prefix "French"
@@ -572,4 +575,12 @@
(lambda ()
(let ((fr (make-locale LC_ALL %french-locale-name)))
(string=? "1 234,56 EUR "
- (monetary-amount->locale-string 1234.567 #t fr))))))))
+ (monetary-amount->locale-string 1234.567 #t
+ fr))))))
+
+ (pass-if "positive inexact zero"
+ (under-french-locale-or-unresolved
+ (lambda ()
+ (let ((fr (make-locale LC_ALL %french-locale-name)))
+ (string=? "0,0 +EUR"
+ (monetary-amount->locale-string 0. #f fr))))))))
- [Guile-commits] branch master updated (33944f6 -> 1026a76), Andy Wingo, 2017/03/01
- [Guile-commits] 01/14: build: Check for /gnu/store file names upon "make dist"., Andy Wingo, 2017/03/01
- [Guile-commits] 11/14: tests: Choose a more plausible US English locale name., Andy Wingo, 2017/03/01
- [Guile-commits] 07/14: doc: Fix typo in site packages documentation., Andy Wingo, 2017/03/01
- [Guile-commits] 09/14: i18n: Do not represent zero as "-0".,
Andy Wingo <=
- [Guile-commits] 05/14: tests: Avoid statprof test failure on systems without 'setitimer'., Andy Wingo, 2017/03/01
- [Guile-commits] 04/14: build: Honor $SOURCE_DATE_EPOCH for the recorded timestamp., Andy Wingo, 2017/03/01
- [Guile-commits] 06/14: doc: Fix typo in keywords documentation., Andy Wingo, 2017/03/01
- [Guile-commits] 10/14: tests: Use 'pass-if-equal' for (ice-9 i18n) tests., Andy Wingo, 2017/03/01
- [Guile-commits] 13/14: i18n: 'number->locale-string' guesses the minimum number of decimals., Andy Wingo, 2017/03/01
- [Guile-commits] 12/14: i18n: Fix corner cases for monetary and number string conversions., Andy Wingo, 2017/03/01
- [Guile-commits] 02/14: build: Compress with lzip too., Andy Wingo, 2017/03/01
- [Guile-commits] 03/14: scandir: Avoid 'stat' calls on each entry., Andy Wingo, 2017/03/01
- [Guile-commits] 08/14: Recognize sh3 as compilation targets, Andy Wingo, 2017/03/01
- [Guile-commits] 14/14: doc: Describe -e (module) on equal footing with (@ ...)., Andy Wingo, 2017/03/01