diff --git a/collects/racket/private/string.rkt b/collects/racket/private/string.rkt index b4e7b0f3f8..4121fe9076 100644 --- a/collects/racket/private/string.rkt +++ b/collects/racket/private/string.rkt @@ -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)]) diff --git a/collects/tests/racket/string-mzlib.rktl b/collects/tests/racket/string-mzlib.rktl index 2a5c20d640..b0c6406c79 100644 --- a/collects/tests/racket/string-mzlib.rktl +++ b/collects/tests/racket/string-mzlib.rktl @@ -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)])