Escape newlines from format strings in warnings.
authorLudovic Courtès <ludo@gnu.org>
Sat, 9 Oct 2010 16:06:36 +0000 (18:06 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 10 Oct 2010 17:10:10 +0000 (19:10 +0200)
* module/system/base/message.scm (%warning-types)[format]: Escape
  newlines from FMT.

module/system/base/message.scm

index 0486adc..8ca2991 100644 (file)
          (format
           "report wrong number of arguments to `format'"
           ,(lambda (port loc fmt expected actual)
+             (define (escape-newlines str)
+               (list->string
+                (string-fold-right (lambda (c r)
+                                     (if (eq? c #\newline)
+                                         (append '(#\\ #\n) r)
+                                         (cons c r)))
+                                   '()
+                                   str)))
              (format port
                      "~A: warning: ~S: wrong number of `format' arguments: expected ~A, got ~A~%"
-                     loc fmt expected actual))))))
+                     loc (escape-newlines fmt) expected actual))))))
 
 (define (lookup-warning-type name)
   "Return the warning type NAME or `#f' if not found."