[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit)
From: |
Matthias Koeppe |
Subject: |
Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit) |
Date: |
Tue, 25 May 2004 16:25:03 +0200 |
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 <address@hidden>
* 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 <address@hidden> --- 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 "address@hidden" 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit),
Matthias Koeppe <=