From: Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
Subject: Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit)
Date: Tue, 25 May 2004 16:25:03 +0200 [thread overview]
Message-ID: <uw565akiny8.fsf@merkur.math.uni-magdeburg.de> (raw)
Today I tried to format a long list of elements using the format "~{"
directive. To my surprise, the list was cut off after the 100th
element.
I am sending a testcase for Guile's test suite and a patch that fixes
the problem. The patch is against the stable branch, where it should
be applied in addition to the CVS HEAD.
2004-05-25 Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
* format.scm (format): Remove the arbitrary limit of 100 iterations
for the ~{...~} control structure.
Index: ice-9/format.scm
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/ice-9/format.scm,v
retrieving revision 1.11.2.2
diff -u -p -r1.11.2.2 format.scm
--- ice-9/format.scm 13 Jan 2004 16:56:11 -0000 1.11.2.2
+++ ice-9/format.scm 25 May 2004 14:17:06 -0000
@@ -614,8 +614,7 @@
(case modifier
((colon)
(if (not max-iterations) (set! max-iterations 1)))
- ((colon-at at) (format:error "illegal modifier"))
- (else (if (not max-iterations) (set! max-iterations 100))))
+ ((colon-at at) (format:error "illegal modifier")))
(if (not (null? params))
(format:error "no parameters allowed in ~~}"))
(if (zero? iteration-nest)
@@ -637,7 +636,8 @@
(list-tail args arg-pos))))
(i 0 (+ i 1)))
((or (>= arg-pos args-len)
- (>= i max-iterations))))))
+ (and max-iterations
+ (>= i max-iterations)))))))
((sublists)
(let ((args (next-arg))
(args-len 0))
@@ -646,7 +646,8 @@
(set! args-len (length args))
(do ((arg-pos 0 (+ arg-pos 1)))
((or (>= arg-pos args-len)
- (>= arg-pos max-iterations)))
+ (and max-iterations
+ (>= arg-pos max-iterations))))
(let ((sublist (list-ref args arg-pos)))
(if (not (list? sublist))
(format:error
@@ -663,7 +664,8 @@
args arg-pos))))
(i 0 (+ i 1)))
((or (>= arg-pos args-len)
- (>= i max-iterations))
+ (and max-iterations
+ (>= i max-iterations)))
arg-pos))))
(add-arg-pos usedup-args)))
((rest-sublists)
@@ -672,7 +674,8 @@
(usedup-args
(do ((arg-pos 0 (+ arg-pos 1)))
((or (>= arg-pos args-len)
- (>= arg-pos max-iterations))
+ (and max-iterations
+ (>= arg-pos max-iterations)))
arg-pos)
(let ((sublist (list-ref args arg-pos)))
(if (not (list? sublist))
Index: test-suite/tests/format.test
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/test-suite/tests/format.test,v
retrieving revision 1.1
diff -u -p -r1.1 format.test
--- test-suite/tests/format.test 16 Jun 2001 20:11:39 -0000 1.1
+++ test-suite/tests/format.test 25 May 2004 14:17:06 -0000
@@ -1,7 +1,7 @@
;;;; format.test --- test suite for Guile's CL-ish format -*- scheme -*-
;;;; Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> --- June 2001
;;;;
-;;;; Copyright (C) 2001 Free Software Foundation, Inc.
+;;;; Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
@@ -36,4 +36,10 @@
(format #t "~&abc")
(format #f "~&") ; shall have no effect
(format #t "~&~&")))
- "xyz\nabc\n")))
+ "xyz\nabc\n"))
+ (pass-if "format ~F (format-out-substr) maintains the column correctly"
+ (= (string-length (format "~@F~20T" 1)) 20)))
+
+(with-test-prefix "format control flow"
+ (pass-if "format ~{ has no arbitrary iteration limit"
+ (= (string-length (format "~{~a~}" (make-list 200 #\b))) 200)))
\ No newline at end of file
--
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2004-05-25 14:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-25 14:25 Matthias Koeppe [this message]
2004-07-10 1:05 ` Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit) Kevin Ryde
2004-07-13 8:32 ` Matthias Koeppe
2004-07-19 0:47 ` Kevin Ryde
2004-07-19 9:04 ` Matthias Koeppe
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=uw565akiny8.fsf@merkur.math.uni-magdeburg.de \
--to=mkoeppe@mail.math.uni-magdeburg.de \
/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).