summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-10-12 13:11:40 +0200
committerAndy Wingo <wingo@pobox.com>2010-10-12 13:11:40 +0200
commit5414d33376e7759dfc5e4e35d32b5c8cf2452930 (patch)
treebccf0c9e4847e632c53a158c7b37d51f33544e7a
parenta36c3a458ef7d11b40b95394c0ab7bb6f54a0d51 (diff)
downloadguile-5414d33376e7759dfc5e4e35d32b5c8cf2452930.tar.gz
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".
-rw-r--r--module/language/tree-il/analyze.scm8
-rw-r--r--module/system/repl/command.scm4
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
+ ((<lexical-ref> 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 ""))