From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.bugs Subject: bug#13485: wrong warning for format ~! Date: Mon, 28 Jan 2013 14:36:43 +0000 Message-ID: <87ham1gyro.fsf@Kagami.home> References: <14036101-9158-4630-A94B-530B63338BB4@bluewin.ch> <87sj5yp404.fsf@Kagami.home> <87obglozlh.fsf@Kagami.home> <87fw1wzzlt.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1359383901 2822 80.91.229.3 (28 Jan 2013 14:38:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Jan 2013 14:38:21 +0000 (UTC) Cc: Daniel Llorens , 13485@debbugs.gnu.org To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Jan 28 15:38:38 2013 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tzpr2-0007Vq-AE for guile-bugs@m.gmane.org; Mon, 28 Jan 2013 15:38:36 +0100 Original-Received: from localhost ([::1]:46947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzpqk-0005oz-HT for guile-bugs@m.gmane.org; Mon, 28 Jan 2013 09:38:18 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzpqK-0005k8-9a for bug-guile@gnu.org; Mon, 28 Jan 2013 09:38:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tzpq5-0004TY-Ee for bug-guile@gnu.org; Mon, 28 Jan 2013 09:37:52 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzpq5-0004T6-80 for bug-guile@gnu.org; Mon, 28 Jan 2013 09:37:37 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TzpqU-00015n-35 for bug-guile@gnu.org; Mon, 28 Jan 2013 09:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ian Price Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 28 Jan 2013 14:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13485 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 13485-submit@debbugs.gnu.org id=B13485.13593838424151 (code B ref 13485); Mon, 28 Jan 2013 14:38:01 +0000 Original-Received: (at 13485) by debbugs.gnu.org; 28 Jan 2013 14:37:22 +0000 Original-Received: from localhost ([127.0.0.1]:52358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tzppo-00014t-U7 for submit@debbugs.gnu.org; Mon, 28 Jan 2013 09:37:21 -0500 Original-Received: from mail-we0-f170.google.com ([74.125.82.170]:37381) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tzppk-00014j-CR for 13485@debbugs.gnu.org; Mon, 28 Jan 2013 09:37:19 -0500 Original-Received: by mail-we0-f170.google.com with SMTP id z53so1571886wey.29 for <13485@debbugs.gnu.org>; Mon, 28 Jan 2013 06:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=P4fD8tmjp0Zr3R7hfl0PPuttraslGdgjYRAQpHj0OL8=; b=lMLn1JJp+ro6prWrKZrFiK7DH4tSoGtJD1aZ/9ragJr+q1APJs4dxANtXjS8Hus7uU QAybus7YBUk0iEK+7fZmDNk4QW5x84adIoL4lfKQNE1nV7yBVaBsahjnulaobVnE7r2r Qb4Aw/30k8soGqP6io1CfhwAuPF83d+OByl4cEwV53/zU91l/XHrVfBjgaCc+DlVMN0T DcdnyXOZA3+T65kHSdrFeJZZNQ0Sl6y685eV37iF9Lr6JjKfuf49lI8tP6I8AXL+8Nwj TS0mNspFbOnnJV3hNaT00hoROj1VGblH9D9vuw0G2c/p1txLvi4PZZ+6dRNYfYpGNb0b LPeg== X-Received: by 10.194.85.234 with SMTP id k10mr21618774wjz.53.1359383809917; Mon, 28 Jan 2013 06:36:49 -0800 (PST) Original-Received: from Kagami.home (host86-143-194-25.range86-143.btcentralplus.com. [86.143.194.25]) by mx.google.com with ESMTPS id ex6sm13728571wid.3.2013.01.28.06.36.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 28 Jan 2013 06:36:48 -0800 (PST) In-Reply-To: <87fw1wzzlt.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Sat, 19 Jan 2013 21:28:46 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6718 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=E8s) writes: >> Ludovic, >> are there test cases for this? I'm not sure where to look > > Yes, in tree-il.test. Can you add them? Attached a patch that squashes the previous two and adds tests. I still may want to add an additional patch to get some better errors for sequence parameters. --=20 Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled" --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-argument-count-for-various-format-string-escape-.patch Content-Description: format patch >From 90baf8cdfe8ce356ee4720a012e0deb5a2cb5818 Mon Sep 17 00:00:00 2001 From: Ian Price Date: Sat, 19 Jan 2013 17:05:27 +0000 Subject: [PATCH] Fix argument count for various format string escape sequences. * module/language/tree-il/analyze.scm (format-string-argument-count): Handle ~t and ~k options case-insensitively. ~! ~| ~/ ~q and ~Q should not update the min-count or max-count. ~^ returns the min-count and 'any + - # and ' should not increase the argument count. * test-suite/tests/tree-il.test (*): Tests for new parameters. --- module/language/tree-il/analyze.scm | 13 ++++++++++--- test-suite/tests/tree-il.test | 29 +++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm index 88f81f3..badce9f 100644 --- a/module/language/tree-il/analyze.scm +++ b/module/language/tree-il/analyze.scm @@ -1259,11 +1259,11 @@ accurate information is missing from a given `tree-il' element." (case state ((tilde) (case (car chars) - ((#\~ #\% #\& #\t #\_ #\newline #\( #\)) + ((#\~ #\% #\& #\t #\T #\_ #\newline #\( #\) #\! #\| #\/ #\q #\Q) (loop (cdr chars) 'literal '() conditions end-group min-count max-count)) - ((#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\, #\: #\@) + ((#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\, #\: #\@ #\+ #\- #\#) (loop (cdr chars) 'tilde (cons (car chars) params) conditions end-group @@ -1330,16 +1330,23 @@ accurate information is missing from a given `tree-il' element." min-count) (+ (or (previous-number params) 1) max-count)))) - ((#\? #\k) + ((#\? #\k #\K) ;; We don't have enough info to determine the exact number ;; of args, but we could determine a lower bound (TODO). (values 'any 'any)) + ((#\^) + (values min-count 'any)) ((#\h #\H) (let ((argc (if (memq #\: params) 2 1))) (loop (cdr chars) 'literal '() conditions end-group (+ argc min-count) (+ argc max-count)))) + ((#\') + (if (null? (cdr chars)) + (throw &syntax-error 'unexpected-termination) + (loop (cddr chars) 'tilde (cons (cadr chars) params) + conditions end-group min-count max-count))) (else (loop (cdr chars) 'literal '() conditions end-group (+ 1 min-count) (+ 1 max-count))))) diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test index 68dfc32..2217ffc 100644 --- a/test-suite/tests/tree-il.test +++ b/test-suite/tests/tree-il.test @@ -1415,11 +1415,11 @@ (number? (string-contains (car w) "wrong number of arguments"))))) - (pass-if "~%, ~~, ~&, ~t, ~_, and ~\\n" + (pass-if "~%, ~~, ~&, ~t, ~_, ~!, ~|, ~/, ~q and ~\\n" (null? (call-with-warnings (lambda () (compile '((@ (ice-9 format) format) some-port - "~&~3_~~ ~\n~12they~%") + "~&~3_~~ ~\n~12they~% ~!~|~/~q") #:opts %opts-w-format #:to 'assembly))))) @@ -1687,6 +1687,31 @@ #:opts %opts-w-format #:to 'assembly))))) + (pass-if "~^" + (null? (call-with-warnings + (lambda () + (compile '((@ (ice-9 format) format) #f "~a ~^ ~a" 0 1) + #:opts %opts-w-format + #:to 'assembly))))) + + (pass-if "~^, too few args" + (let ((w (call-with-warnings + (lambda () + (compile '((@ (ice-9 format) format) #f "~a ~^ ~a") + #:opts %opts-w-format + #:to 'assembly))))) + (and (= (length w) 1) + (number? (string-contains (car w) + "expected at least 1, got 0"))))) + + (pass-if "parameters: +,-,#, and '" + (null? (call-with-warnings + (lambda () + (compile '((@ (ice-9 format) format) some-port + "~#~ ~,,-2f ~,,+2f ~'A~" 1234 1234) + #:opts %opts-w-format + #:to 'assembly))))) + (pass-if "complex 1" (let ((w (call-with-warnings (lambda () -- 1.7.7.6 --=-=-=--