fix regexp-match-positions* with input ports
svn: r9604
This commit is contained in:
parent
8b6f716d53
commit
0e299c5bd2
|
@ -199,13 +199,21 @@
|
||||||
;; re-match if we get a zero-length match at the
|
;; re-match if we get a zero-length match at the
|
||||||
;; beginning, and we can continue
|
;; beginning, and we can continue
|
||||||
[m (if (and (= mstart mend start)
|
[m (if (and (= mstart mend start)
|
||||||
(cond [end (< start end)]
|
(cond
|
||||||
[len (< start len)]
|
[end (< start end)]
|
||||||
[(input-port? string)
|
[len (< start len)]
|
||||||
(not (eof-object?
|
[(input-port? string)
|
||||||
(peek-byte string)))]
|
(not (eof-object? (peek-byte string)))]
|
||||||
[else (error "internal error (str)")]))
|
[else (error "internal error (str)")]))
|
||||||
(match rx string (add1 start) end)
|
(if (or peek? (not (input-port? string)))
|
||||||
|
(match rx string (add1 start) end)
|
||||||
|
;; rematching on a port requires adding `start'
|
||||||
|
;; offsets
|
||||||
|
(let ([m (match rx string 1 end)])
|
||||||
|
(if (and m (positive? start))
|
||||||
|
(list (cons (+ start (caar m))
|
||||||
|
(+ start (cdar m))))
|
||||||
|
m)))
|
||||||
m)])
|
m)])
|
||||||
;; fail if rematch failed
|
;; fail if rematch failed
|
||||||
(if (not m)
|
(if (not m)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user