From: David Vazquez Date: Sun, 23 Dec 2012 22:56:27 +0000 (+0000) Subject: Report unexpected errors in the reader X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=4f17b56fa136f97d11975d081a861351eb64db76;p=jscl.git Report unexpected errors in the reader --- diff --git a/lispstrack.lisp b/lispstrack.lisp index 0cd2d69..46c07c6 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -120,13 +120,15 @@ (skip-whitespaces-and-comments stream) (let ((ch (%peek-char stream))) (cond + ((null ch) + (error "Unspected EOF")) ((char= ch #\)) (%read-char stream) nil) ((char= ch #\.) (%read-char stream) - (skip-whitespaces-and-comments stream) (prog1 (ls-read stream) + (skip-whitespaces-and-comments stream) (unless (char= (%read-char stream) #\)) (error "')' was expected.")))) (t @@ -136,8 +138,10 @@ (let ((string "") (ch nil)) (setq ch (%read-char stream)) - (while (not (char= ch #\")) - (when (char= ch #\\) + (while (not (eql ch #\")) + (when (null ch) + (error "Unexpected EOF")) + (when (eql ch #\\) (setq ch (%read-char stream))) (setq string (concat string (string ch))) (setq ch (%read-char stream))) diff --git a/test.lisp b/test.lisp index 10187b6..adf8c12 100644 --- a/test.lisp +++ b/test.lisp @@ -454,13 +454,15 @@ (skip-whitespaces-and-comments stream) (let ((ch (%peek-char stream))) (cond + ((null ch) + (error "Unspected EOF")) ((char= ch #\)) (%read-char stream) nil) ((char= ch #\.) (%read-char stream) - (skip-whitespaces-and-comments stream) (prog1 (ls-read stream) + (skip-whitespaces-and-comments stream) (unless (char= (%read-char stream) #\)) (error "')' was expected.")))) (t @@ -470,8 +472,10 @@ (let ((string "") (ch nil)) (setq ch (%read-char stream)) - (while (not (char= ch #\")) - (when (char= ch #\\) + (while (not (eql ch #\")) + (when (null ch) + (error "Unexpected EOF")) + (when (eql ch #\\) (setq ch (%read-char stream))) (setq string (concat string (string ch))) (setq ch (%read-char stream)))