0.8.19.9:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 31 Jan 2005 19:25:02 +0000 (19:25 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 31 Jan 2005 19:25:02 +0000 (19:25 +0000)
Merge patch (Teemu Kalvas "bad encoding skipper for comments"
sbcl-devel 2005-01-31)
... mcclim should compile out of the box now.

NEWS
src/code/reader.lisp
src/code/sharpm.lisp
tests/compiler.pure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 75ded23..d715043 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,10 @@ changes in sbcl-0.8.20 (0.9alpha.0?) relative to sbcl-0.8.19:
        passing it through to OPEN.
     ** LOAD on source files likewise passes any EXTERNAL-FORMAT
        argument given to internal calls to OPEN.
+    ** the built-in comment readers (introduced by character sequences
+       ";" and "#|") are more forgiving to encoding errors; they will
+       STYLE-WARN and then attempt to resync the stream at a character
+       boundary.  (thanks to Teemu Kalvas)
   * fixed some bugs revealed by Paul Dietz' test suite:
     ** Space, Tab, Linefeed, Return and Page have the invalid
        secondary constituent character trait.
index 4eb3400..ac9ec2c 100644 (file)
 
 (defun read-comment (stream ignore)
   (declare (ignore ignore))
-  (let ((stream (in-synonym-of stream)))
-    (if (ansi-stream-p stream)
-       (prepare-for-fast-read-char stream
-         (do ((char (fast-read-char nil nil)
-                    (fast-read-char nil nil)))
-             ((or (not char) (char= char #\newline))
-              (done-with-fast-read-char))))
-       ;; CLOS stream
-       (do ((char (read-char stream nil :eof) (read-char stream nil :eof)))
-           ((or (eq char :eof) (char= char #\newline))))))
+  (handler-bind
+      ((character-decoding-error
+       #'(lambda (decoding-error)
+           (declare (ignorable decoding-error))
+           (style-warn "Character decoding error in a ;-comment at position ~A reading source file ~A, resyncing." (file-position stream) stream)
+           (invoke-restart 'attempt-resync))))
+    (let ((stream (in-synonym-of stream)))
+      (if (ansi-stream-p stream)
+         (prepare-for-fast-read-char stream
+          (do ((char (fast-read-char nil nil)
+                     (fast-read-char nil nil)))
+              ((or (not char) (char= char #\newline))
+               (done-with-fast-read-char))))
+         ;; CLOS stream
+         (do ((char (read-char stream nil :eof) (read-char stream nil :eof)))
+             ((or (eq char :eof) (char= char #\newline)))))))
   ;; Don't return anything.
   (values))
 
index 3f898b0..820d5f4 100644 (file)
 
 (defun sharp-vertical-bar (stream sub-char numarg)
   (ignore-numarg sub-char numarg)
-  (let ((stream (in-synonym-of stream)))
-    (if (ansi-stream-p stream)
-       (prepare-for-fast-read-char stream
+  (handler-bind
+      ((character-decoding-error
+       #'(lambda (decoding-error)
+           (declare (ignorable decoding-error))
+           (style-warn "Character decoding error in a #|-comment at position ~A reading source file ~A, resyncing." (file-position stream) stream)
+           (invoke-restart 'attempt-resync))))
+    (let ((stream (in-synonym-of stream)))
+      (if (ansi-stream-p stream)
+         (prepare-for-fast-read-char stream
+           (do ((level 1)
+                (prev (fast-read-char) char)
+                (char (fast-read-char) (fast-read-char)))
+               (())
+             (cond ((and (char= prev #\|) (char= char #\#))
+                    (setq level (1- level))
+                    (when (zerop level)
+                      (done-with-fast-read-char)
+                      (return (values)))
+                    (setq char (fast-read-char)))
+                   ((and (char= prev #\#) (char= char #\|))
+                    (setq char (fast-read-char))
+                    (setq level (1+ level))))))
+         ;; fundamental-stream
          (do ((level 1)
-              (prev (fast-read-char) char)
-              (char (fast-read-char) (fast-read-char)))
+              (prev (read-char stream t) char)
+              (char (read-char stream t) (read-char stream t)))
              (())
            (cond ((and (char= prev #\|) (char= char #\#))
                   (setq level (1- level))
                   (when (zerop level)
-                    (done-with-fast-read-char)
                     (return (values)))
-                  (setq char (fast-read-char)))
+                  (setq char (read-char stream t)))
                  ((and (char= prev #\#) (char= char #\|))
-                  (setq char (fast-read-char))
-                  (setq level (1+ level))))))
-       ;; fundamental-stream
-       (do ((level 1)
-            (prev (read-char stream t) char)
-            (char (read-char stream t) (read-char stream t)))
-           (())
-         (cond ((and (char= prev #\|) (char= char #\#))
-                (setq level (1- level))
-                (when (zerop level)
-                  (return (values)))
-                (setq char (read-char stream t)))
-               ((and (char= prev #\#) (char= char #\|))
-                (setq char (read-char stream t))
-                (setq level (1+ level))))))))
+                  (setq char (read-char stream t))
+                  (setq level (1+ level)))))))))
 \f
 ;;;; a grab bag of other sharp readmacros: #', #:, and #.
 
index 29b6b0c..3381087 100644 (file)
            (let ((b (make-array 64 :element-type 'bit :initial-element 0)))
              (setf (sbit b 63) 1)
              b)))))
-                   
-                  
\ No newline at end of file
index 4d5cc98..0679c42 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.8.19.8"
+"0.8.19.9"