regexp: fix take-until to handle escapes at the end of a regexp.

this worked:
R\ //.\

this didn't:
R\ //\
windows-drag
John Benediktsson 2019-03-17 09:52:53 -07:00
parent a3d5e3ffcb
commit 2136abc1d6
1 changed files with 5 additions and 4 deletions

View 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 ;