add argument to `regexp-try-match' to match docs
Closes PR 6579 --- which was actually about the now next-to-last argument, but close enough
This commit is contained in:
parent
70e3074baf
commit
d5fdee7e06
|
@ -87,14 +87,14 @@
|
|||
(or (hash-ref t key #f)
|
||||
(let ([rx* (run-tweak)]) (hash-set! t key rx*) rx*))))))
|
||||
|
||||
(define (regexp-try-match pattern input-port [start-k 0] [end-k #f] [out #f])
|
||||
(define (regexp-try-match pattern input-port [start-k 0] [end-k #f] [out #f] [prefix #""])
|
||||
(unless (input-port? input-port)
|
||||
(raise-type-error 'regexp-try-match
|
||||
"input port" input-port))
|
||||
(unless (or (not out) (output-port? out))
|
||||
(raise-type-error 'regexp-try-match
|
||||
"output port or #f" out))
|
||||
(let ([m (regexp-match-peek-positions pattern input-port start-k end-k)])
|
||||
(let ([m (regexp-match-peek-positions pattern input-port start-k end-k #f prefix)])
|
||||
(and m
|
||||
;; What happens if someone swipes our bytes before we can get them?
|
||||
(let ([drop (caar m)])
|
||||
|
|
|
@ -39,6 +39,18 @@
|
|||
(test #f regexp-match/fail-without-reading #rx"hello there!!!" s)
|
||||
(test "hello there" read-string 50 s))
|
||||
|
||||
;; Check remaining `regexp-match/fail-without-reading' arguments
|
||||
(let ([s (open-input-string "hello there")]
|
||||
[o (open-output-bytes)])
|
||||
(test #f regexp-match/fail-without-reading #rx"not there" s 0 5 o)
|
||||
(test #"" get-output-bytes o)
|
||||
(test #f regexp-match/fail-without-reading #rx"^hello" s 1 #f o)
|
||||
(test #"" get-output-bytes o)
|
||||
(test #f regexp-match/fail-without-reading #rx"^hello" s 0 #f o #"_")
|
||||
(test #"" get-output-bytes o)
|
||||
(test '(#"ello") regexp-match/fail-without-reading #rx"ello" s 0 #f o)
|
||||
(test #"h" get-output-bytes o))
|
||||
|
||||
(let ([g->re-test
|
||||
(lambda (glob . more)
|
||||
(let ([re (apply glob->regexp glob more)])
|
||||
|
|
Loading…
Reference in New Issue
Block a user