From 5414d33376e7759dfc5e4e35d32b5c8cf2452930 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 12 Oct 2010 13:11:40 +0200 Subject: [PATCH] don't warn for (format #t fmt) -- format string actually named fmt * module/language/tree-il/analyze.scm (format-analysis): Don't warn on non-literal format string if the format string is a lexical ref to a variable named "fmt". A slight hack, but effective :) * module/system/repl/command.scm (display-stat): Rename the format string to "fmt". --- module/language/tree-il/analyze.scm | 8 +++++++- module/system/repl/command.scm | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm index 8e7e2ef6c..8a5104016 100644 --- a/module/language/tree-il/analyze.scm +++ b/module/language/tree-il/analyze.scm @@ -1369,7 +1369,13 @@ accurate information is missing from a given `tree-il' element." (warning 'format loc 'syntax-error key fmt))) (warning 'format loc 'wrong-format-string fmt)))) ((,port ,fmt . ,rest) - (warning 'format loc 'non-literal-format-string)) + ;; Warn on non-literal format strings, unless they refer to a + ;; lexical variable named "fmt". + (if (record-case fmt + (( name) + (not (eq? name 'fmt))) + (else #t)) + (warning 'format loc 'non-literal-format-string))) (else (warning 'format loc 'wrong-num-args (length args))))) diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm index 0ec31e4d8..e58b1167d 100644 --- a/module/system/repl/command.scm +++ b/module/system/repl/command.scm @@ -838,8 +838,8 @@ Display statistics." (set! (repl-gc-stats repl) this-gcs))) (define (display-stat title flag field1 field2 unit) - (let ((str (format #f "~~20~AA ~~10@A /~~10@A ~~A~~%" (if flag "" "@")))) - (format #t str title field1 field2 unit))) + (let ((fmt (format #f "~~20~AA ~~10@A /~~10@A ~~A~~%" (if flag "" "@")))) + (format #t fmt title field1 field2 unit))) (define (display-stat-title title field1 field2) (display-stat title #t field1 field2 ""))