From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthias Koeppe Newsgroups: gmane.lisp.guile.devel Subject: Patch for ice-9/format.scm (removes arbitrary ~{...~} iteration limit) Date: Tue, 25 May 2004 16:25:03 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1085509697 5620 80.91.224.253 (25 May 2004 18:28:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 May 2004 18:28:17 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue May 25 20:27:48 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BSgeR-0005kB-00 for ; Tue, 25 May 2004 20:27:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BSgdl-00019N-Pz for guile-devel@m.gmane.org; Tue, 25 May 2004 14:27:05 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BSgcE-0000rn-Lp for guile-devel@gnu.org; Tue, 25 May 2004 14:25:30 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BSfkR-0008Gm-LV for guile-devel@gnu.org; Tue, 25 May 2004 13:30:27 -0400 Original-Received: from [141.44.75.40] (helo=merkur.math.uni-magdeburg.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BScrk-0005y5-I4 for guile-devel@gnu.org; Tue, 25 May 2004 10:25:16 -0400 Original-Received: from beta ([141.44.75.78] helo=beta.math.uni-magdeburg.de) by merkur.math.uni-magdeburg.de with esmtp (Exim 4.10) id 1BScrb-0005hN-00 for guile-devel@gnu.org; Tue, 25 May 2004 16:25:07 +0200 Original-Received: (from mkoeppe@localhost) by beta.math.uni-magdeburg.de (8.11.7+Sun/8.11.7) id i4PEP4Q12346; Tue, 25 May 2004 16:25:04 +0200 (MEST) X-Authentication-Warning: beta.math.uni-magdeburg.de: mkoeppe set sender to mkoeppe@mail.math.uni-magdeburg.de using -f Original-To: guile-devel@gnu.org X-Warning: no 'abuse'-account in domain mail.math.uni-magdeburg.de (cf. RFC2142/4.) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3757 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3757 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 * 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 --- 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