factor: detect unclosed strings.
authorJoel Martin <github@martintribe.org>
Wed, 31 Jul 2019 04:58:48 +0000 (23:58 -0500)
committerJoel Martin <github@martintribe.org>
Wed, 31 Jul 2019 04:59:26 +0000 (23:59 -0500)
Detect strings that are not properly terminated.

factor/lib/reader/reader.factor

index 568eae0..ae228bd 100644 (file)
@@ -9,7 +9,8 @@ CONSTANT: token-regex R/ (~@|[\[\]{}()'`~^@]|"(?:\\.|[^\\"])*"?|;.*|[^\s\[\]{}('
 DEFER: read-form
 
 : (read-string) ( str -- maltype )
-    dup last CHAR: " = [
+!    dup last CHAR: " = [
+    dup R/ ^"(?:\\.|[^\\"])*"$/ matches? [
         rest but-last R/ \\./ [
             {
                 { [ dup >string "\\\\" = ] [ drop "\\" ] }