summaryrefslogtreecommitdiff
path: root/module/language
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2012-01-30 19:59:08 +0100
committerAndy Wingo <wingo@pobox.com>2012-01-30 20:27:35 +0100
commitdfadcf85cb3ae9133dece6bc39ed03dd25323d6e (patch)
tree93c918a793ee86c8406fd1bac521ea2b870361cf /module/language
parent252acfe8e70ac4c7d325588ffea1905fcf6f86b2 (diff)
parente1fbe716e8596b7027af57623ebc72a0c6393187 (diff)
downloadguile-dfadcf85cb3ae9133dece6bc39ed03dd25323d6e.tar.gz
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts: libguile/debug.h module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm module/language/tree-il/peval.scm module/language/tree-il/primitives.scm
Diffstat (limited to 'module/language')
-rw-r--r--module/language/scheme/spec.scm9
-rw-r--r--module/language/tree-il/analyze.scm49
-rw-r--r--module/language/tree-il/peval.scm2
-rw-r--r--module/language/tree-il/primitives.scm6
4 files changed, 57 insertions, 9 deletions
diff --git a/module/language/scheme/spec.scm b/module/language/scheme/spec.scm
index 0df4171ff..e4cf55c4c 100644
--- a/module/language/scheme/spec.scm
+++ b/module/language/scheme/spec.scm
@@ -1,6 +1,6 @@
;;; Guile Scheme specification
-;; Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -53,4 +53,11 @@
;; compile-time changes to `current-reader' are
;; limited to the current compilation unit.
(module-define! m 'current-reader (make-fluid))
+
+ ;; Default to `simple-format', as is the case until
+ ;; (ice-9 format) is loaded. This allows
+ ;; compile-time warnings to be emitted when using
+ ;; unsupported options.
+ (module-set! m 'format simple-format)
+
m)))
diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm
index f75c9f16a..04687a8c9 100644
--- a/module/language/tree-il/analyze.scm
+++ b/module/language/tree-il/analyze.scm
@@ -22,6 +22,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-11)
+ #:use-module (srfi srfi-26)
#:use-module (ice-9 vlist)
#:use-module (ice-9 match)
#:use-module (system base syntax)
@@ -1392,7 +1393,7 @@ accurate information is missing from a given `tree-il' element."
((,port ,fmt . ,rest)
(if (and (const? port)
(not (boolean? (const-exp port))))
- (warn 'format loc 'wrong-port (const-exp port)))
+ (warning 'format loc 'wrong-port (const-exp port)))
;; Warn on non-literal format strings, unless they refer to a
;; lexical variable named "fmt".
(if (record-case fmt
@@ -1403,6 +1404,36 @@ accurate information is missing from a given `tree-il' element."
(else
(warning 'format loc 'wrong-num-args (length args)))))
+ (define (check-simple-format-args args loc)
+ ;; Check the arguments to the `simple-format' procedure, which is
+ ;; less capable than that of (ice-9 format).
+
+ (define allowed-chars
+ '(#\A #\S #\a #\s #\~ #\%))
+
+ (define (format-chars fmt)
+ (let loop ((chars (string->list fmt))
+ (result '()))
+ (match chars
+ (()
+ (reverse result))
+ ((#\~ opt rest ...)
+ (loop rest (cons opt result)))
+ ((_ rest ...)
+ (loop rest result)))))
+
+ (match args
+ ((port ($ <const> _ (? string? fmt)) _ ...)
+ (let ((opts (format-chars fmt)))
+ (or (every (cut memq <> allowed-chars) opts)
+ (begin
+ (warning 'format loc 'simple-format fmt
+ (find (negate (cut memq <> allowed-chars)) opts))
+ #f))))
+ ((port (($ <const> _ '_) fmt) args ...)
+ (check-simple-format-args `(,port ,fmt ,args) loc))
+ (_ #t)))
+
(define (resolve-toplevel name)
(and (module? env)
(false-if-exception (module-ref env name))))
@@ -1410,9 +1441,19 @@ accurate information is missing from a given `tree-il' element."
(match x
(($ <call> src ($ <toplevel-ref> _ name) args)
(let ((proc (resolve-toplevel name)))
- (and (or (eq? proc format)
- (eq? proc (@ (ice-9 format) format)))
- (check-format-args args (or src (find pair? locs))))))
+ (if (or (and (eq? proc (@ (guile) simple-format))
+ (check-simple-format-args args
+ (or src (find pair? locs))))
+ (eq? proc (@ (ice-9 format) format)))
+ (check-format-args args (or src (find pair? locs))))))
+ (($ <call> src ($ <module-ref> _ '(ice-9 format) 'format) args)
+ (check-format-args args (or src (find pair? locs))))
+ (($ <call> src ($ <module-ref> _ '(guile)
+ (or 'format 'simple-format))
+ args)
+ (and (check-simple-format-args args
+ (or src (find pair? locs)))
+ (check-format-args args (or src (find pair? locs)))))
(_ #t))
#t)
diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm
index aab872164..9aac24cc1 100644
--- a/module/language/tree-il/peval.scm
+++ b/module/language/tree-il/peval.scm
@@ -411,7 +411,7 @@ top-level bindings from ENV and return the resulting expression."
(define (fresh-gensyms vars)
(map (lambda (var)
(let ((new (gensym (string-append (symbol->string (var-name var))
- " "))))
+ "-"))))
(set! store (vhash-consq new var store))
new))
vars))
diff --git a/module/language/tree-il/primitives.scm b/module/language/tree-il/primitives.scm
index 8e9d2eb6e..f192c4fc3 100644
--- a/module/language/tree-il/primitives.scm
+++ b/module/language/tree-il/primitives.scm
@@ -1,6 +1,6 @@
;;; open-coding primitive procedures
-;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -487,8 +487,8 @@
'@dynamic-wind
(case-lambda
((src pre expr post)
- (let ((PRE (gensym " pre"))
- (POST (gensym " post")))
+ (let ((PRE (gensym "pre-"))
+ (POST (gensym "post-")))
(make-let
src
'(pre post)