fix parsing of backslash-dollar in #rx mode, as opposed to #px

svn: r4396
This commit is contained in:
Matthew Flatt 2006-09-20 13:31:19 +00:00
parent ed8eef79a9
commit 0828cd338c
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,8 @@
(load-relative "loadtest.ss")
(Section 'rx)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (test-regexp result pattern input)
@ -1655,4 +1657,19 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that rx doesn't parse as px:
(test '(#"") regexp-match #px#"\\$" #"a$b")
(test '(#"$") regexp-match #rx#"\\$" #"a$b")
(test '(#"aa" #"a") regexp-match #px#"(a)\\1" #"aa")
(test '(#"a1" #"a") regexp-match #rx#"(a)\\1" #"a1")
(test '(#"a") regexp-match #px#"\\w" #"aw")
(test '(#"w") regexp-match #rx#"\\w" #"aw")
(test '(#"0") regexp-match #px#"\\d" #"0w")
(test '(#"d") regexp-match #rx#"\\d" #"0d")
(test '(#"0") regexp-match #px#"[\\d]" #"0w")
(test '(#"d") regexp-match #rx#"[\\d]" #"0d")
(test '(#"\\") regexp-match #rx#"[\\d]" #"0\\")
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -1263,7 +1263,7 @@ regatom(int *flagp, int parse_flags, int at_start)
if (regparse == regparse_end)
FAIL("trailing backslash in pattern");
c = regparsestr[regparse++];
if (c == '$') {
if ((c == '$') && (parse_flags & PARSE_PCRE)) {
ret = regnode(NOTHING);
regmatchmin = regmatchmax = 0;
*flagp |= SIMPLE|SPNOTHING;