unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit)
@ 2004-05-25 14:25 Matthias Koeppe
  2004-07-10  1:05 ` Kevin Ryde
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias Koeppe @ 2004-05-25 14:25 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-07-19  9:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-25 14:25 Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit) Matthias Koeppe
2004-07-10  1:05 ` Kevin Ryde
2004-07-13  8:32   ` Matthias Koeppe
2004-07-19  0:47     ` Kevin Ryde
2004-07-19  9:04       ` Matthias Koeppe

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).