public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Charles <chturne@gmail.com>
To: Sudarshan S Chawathe <chaw@eip10.org>
Cc: Kawa mailing list <kawa@sourceware.org>
Subject: Re: Q about format's behavior with ~R directive
Date: Thu, 4 Feb 2021 23:42:40 +0000	[thread overview]
Message-ID: <CAPMhJv0NFVgfOpRz6MOo1BeRp2Swt-63_vbqpkimhBvO4dGdrw@mail.gmail.com> (raw)
In-Reply-To: <CAPMhJv2Ze41zWPZjJBnh6n+LFWEhJ0vvD4vN=rEny81SxQedtQ@mail.gmail.com>

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

On Thu, Feb 4, 2021 at 11:41 PM Charles <chturne@gmail.com> wrote:

>
> There isn't a specification to my knowledge on the specific language used
> to count the numbers, although in this case Kawa is an oddity. I attached a
> patch to fix that. The testsuite errors for me from a fresh git clone and
> it's been a while since I've contributed, so I don't know if it breaks in
> other areas aside from the obvious formatting cases.
>

And with that patch I mentioned ...

B.R,
   Charles.

[-- Attachment #2: 0001-Make-R-cardinal-counting-more-consistent.patch --]
[-- Type: text/x-patch, Size: 1802 bytes --]

From 085bc7cb13213a21c5397e49457e16b580123766 Mon Sep 17 00:00:00 2001
From: Charles Turner <chturne@gmail.com>
Date: Thu, 4 Feb 2021 23:31:30 +0000
Subject: [PATCH] Make ~R cardinal counting more consistent

(format #t "~R" 100) returns "hundred", whereas other Lisps tend to
return "one hundred". It's arguable that both are in some sense
correct (since this is not an area heavily specified anywhere), but
it's not good that we're inconsistent, since we also return (format #t
"~R" 1000) as "one thousand".

Reported by Sudarshan S Chawathe.
---
 gnu/kawa/format/EnglishIntegerFormat.java | 2 +-
 testsuite/formatst.scm                    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/kawa/format/EnglishIntegerFormat.java b/gnu/kawa/format/EnglishIntegerFormat.java
index 16f72e8c7..16b246199 100644
--- a/gnu/kawa/format/EnglishIntegerFormat.java
+++ b/gnu/kawa/format/EnglishIntegerFormat.java
@@ -78,7 +78,7 @@ public class EnglishIntegerFormat extends java.text.NumberFormat
       {
 	int num100s = num / 100;
 	num = num % 100;
-	if (num100s > 1)
+	if (num100s >= 1)
 	  {
 	    sbuf.append(ones[num100s]);
 	    sbuf.append(' ');
diff --git a/testsuite/formatst.scm b/testsuite/formatst.scm
index 055d03767..35a4ad23e 100644
--- a/testsuite/formatst.scm
+++ b/testsuite/formatst.scm
@@ -28,7 +28,7 @@
 ;      (newline)
 ;      (format:abort)))
 
-(test-begin "format" 454)
+(test-begin "format" 455)
 (define-syntax test 
   (syntax-rules ()
     ((test format-args out-str)
@@ -155,6 +155,7 @@
 (test '("~r" 4) "four")
 (test '("~r" 10) "ten")
 (test '("~r" 19) "nineteen")
+(test '("~r" 101) "one hundred one")
 (test '("~r" 1984) "one thousand, nine hundred eighty-four")
 (test '("~:r" -1984) "minus one thousand, nine hundred eighty-fourth")
 
-- 
2.27.0


  reply	other threads:[~2021-02-04 23:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 21:34 Sudarshan S Chawathe
2021-02-04 23:41 ` Charles
2021-02-04 23:42   ` Charles [this message]
2021-02-05  1:04     ` Per Bothner
2021-02-05  0:09 ` Per Bothner

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=CAPMhJv0NFVgfOpRz6MOo1BeRp2Swt-63_vbqpkimhBvO4dGdrw@mail.gmail.com \
    --to=chturne@gmail.com \
    --cc=chaw@eip10.org \
    --cc=kawa@sourceware.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).