>From 6904b62f58d9ee5a8c193cf201af2882571919c3 Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Sat, 21 Dec 2013 20:20:49 +1300 Subject: [PATCH] Signal read errors on unterminated string literals ending with '\' --- library.scm | 4 +++- tests/library-tests.scm | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/library.scm b/library.scm index c14d069..83acf6d 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 cdf6b09..562f884 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)) -- 1.7.10.4