~ chicken-core (chicken-5) fa97b396f13b36ad8179c6a485a37e001ee272f7
commit fa97b396f13b36ad8179c6a485a37e001ee272f7 Author: Evan Hanson <evhan@foldling.org> AuthorDate: Sat Dec 21 20:20:49 2013 +1300 Commit: Peter Bex <peter.bex@xs4all.nl> CommitDate: Tue Dec 24 18:52:02 2013 +0100 Signal read errors on unterminated string literals ending with '\' Signed-off-by: Peter Bex <peter.bex@xs4all.nl> diff --git a/library.scm b/library.scm index e9e2dc7a..fe545394 100644 --- a/library.scm +++ b/library.scm @@ -2574,7 +2574,9 @@ EOF "escaped whitespace, but no newline - collapsing anyway")) (loop c lst))))) (else - (cond ((and (char-numeric? c) + (cond ((##core#inline "C_eofp" c) + (##sys#read-error port "unterminated string")) + ((and (char-numeric? c) (char>=? c #\0) (char<=? c #\7)) (let ((ch (integer->char diff --git a/tests/library-tests.scm b/tests/library-tests.scm index cdf6b092..562f8846 100644 --- a/tests/library-tests.scm +++ b/tests/library-tests.scm @@ -364,6 +364,19 @@ (assert (every keyword? (with-input-from-string "(42: abc: .: #:: ::)" read))) +;;; reading unterminated objects + +(assert-fail (with-input-from-string "(" read)) +(assert-fail (with-input-from-string "(1 . 2" read)) +(assert-fail (with-input-from-string "|" read)) +(assert-fail (with-input-from-string "\"" read)) +(assert-fail (with-input-from-string "#|" read)) +(assert-fail (with-input-from-string "#(" read)) +(assert-fail (with-input-from-string "#${" read)) +(assert-fail (with-input-from-string "\\" read)) +(assert-fail (with-input-from-string "|\\" read)) +(assert-fail (with-input-from-string "\"\\" read)) + ;;; setters (define x '(a b c))Trap