]> gitweb.factorcode.org Git - factor.git/commitdiff
regexp: fix take-until to handle escapes at the end of a regexp.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 17 Mar 2019 16:52:53 +0000 (09:52 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 17 Mar 2019 16:52:53 +0000 (09:52 -0700)
this worked:
R\ //.\

this didn't:
R\ //\

basis/regexp/regexp.factor

index 19d2d8710b9f884fd927b5e2300002b09401364b..c31571c718711f02bec2549ec94bd848a02afc49 100644 (file)
@@ -200,10 +200,11 @@ PRIVATE>
 : take-until ( lexer -- string )
     dup skip-blank [
         dupd [
-            [ CHAR: / -rot index-from ] keep
-            over [ "Unterminated regexp" throw ] unless
-            2dup [ 1 - ] dip nth CHAR: \\ =
-            [ [ [ 1 + ] dip ] when ] keep
+            [ [ "\\/" member? ] find-from ] keep swap [
+                CHAR: \ = [ [ 2 + ] dip t ] [ f ] if
+            ] [
+                "Unterminated regexp" throw
+            ] if*
         ] loop over [ subseq ] dip 1 +
     ] change-lexer-column ;