regexp: fix matching on port given prefix bytes
This commit is contained in:
parent
2840347cb8
commit
b19671f0f5
|
@ -32,6 +32,14 @@
|
|||
(let ([is (open-input-string "barfoo")])
|
||||
(test (list (rx:regexp-match "foo" is 0 3) (read-char is)) '(#f #\f)))
|
||||
|
||||
;; Don't consume bytes that corresponds to a prefix:
|
||||
(let ()
|
||||
(define in (open-input-string "a\nb\nc\n"))
|
||||
(define rx:.n (rx:byte-regexp #"(?m:^.\n)"))
|
||||
(test (rx:regexp-match rx:.n in 0 #f #f #"") '(#"a\n"))
|
||||
(test (rx:regexp-match rx:.n in 0 #f #f #"\n") '(#"b\n"))
|
||||
(test (rx:regexp-match rx:.n in 0 #f #f #"\n") '(#"c\n")))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(define (check rx in N [M (max 1 (quotient N 10))])
|
||||
|
|
|
@ -307,7 +307,7 @@
|
|||
;; Flush bytes before match:
|
||||
(lazy-bytes-advance! lb-in ms-pos #t)
|
||||
;; Consume bytes that correspond to match:
|
||||
(copy-port-bytes port-in #f me-pos))]
|
||||
(copy-port-bytes port-in #f (- me-pos prefix-len)))]
|
||||
[(eq? end-pos 'eof)
|
||||
;; copy all remaining bytes from input to output
|
||||
(copy-port-bytes port-in out #f)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user