diff --git a/collects/tests/mzscheme/basic.ss b/collects/tests/mzscheme/basic.ss index 20addb9c99..20e1fb912f 100644 --- a/collects/tests/mzscheme/basic.ss +++ b/collects/tests/mzscheme/basic.ss @@ -1054,13 +1054,22 @@ (test "my cerveza Mi Mi Mi" regexp-replace r2 "mi cerveza Mi Mi Mi" insert) (test "my cerveza My Mi Mi" regexp-replace* r2 "mi cerveza Mi Mi Mi" insert) (test "bbb" regexp-replace* "a" "aaa" "b") +(test '(#"") regexp-match "" (open-input-string "123") 3) +(test '(#"") regexp-match "$" (open-input-string "123") 3) +(test '(#"") regexp-match-peek "" (open-input-string "123") 3) ;; Test weird port offsets: (define (test-weird-offset regexp-match regexp-match-positions) (test #f regexp-match "e" (open-input-string "")) (test #f regexp-match "e" (open-input-string "") (expt 2 100)) (test #f regexp-match "e" (open-input-string "") (expt 2 100) (expt 2 101)) - (test '((3 . 4)) regexp-match-positions "e" (open-input-string "eaae") 2 (expt 2 101))) + (test #f regexp-match "e" (open-input-string "") (expt 2 100) (expt 2 101)) + (test '((3 . 4)) regexp-match-positions "e" (open-input-string "eaae") 2 (expt 2 101)) + (test #f regexp-match "" (open-input-string "123") 4) + (test #f regexp-match-positions "" (open-input-string "123") 4) + (test #f regexp-match "" (open-input-string "123") 999) + (test #f regexp-match-positions "" (open-input-string "123") 999) + (test #f regexp-match "" (open-input-string "123") (expt 2 101))) (test-weird-offset regexp-match regexp-match-positions) (test-weird-offset regexp-match-peek regexp-match-peek-positions) diff --git a/collects/tests/mzscheme/module.ss b/collects/tests/mzscheme/module.ss index d50b6e4cfa..9ad1f95ba0 100644 --- a/collects/tests/mzscheme/module.ss +++ b/collects/tests/mzscheme/module.ss @@ -184,9 +184,12 @@ (eval `(require 'f)) (let ([finished '(f b e a d c b d c b d c b c)]) (test finished values l) - (let ([n2 (make-empty-namespace)]) + (namespace-attach-module n ''f) + (test finished values l) + (parameterize ([current-namespace (make-empty-namespace)]) (namespace-attach-module n ''f) (test finished values l) + (namespace-require 'scheme/base) (eval `(require 'a)) (eval `(require 'f)) (test finished values l))))) diff --git a/collects/tests/r6rs/io/simple.ss b/collects/tests/r6rs/io/simple.ss index ec8f006073..3e4d193337 100644 --- a/collects/tests/r6rs/io/simple.ss +++ b/collects/tests/r6rs/io/simple.ss @@ -77,6 +77,10 @@ (test (read) (eof-object)) (values 70 80 90))) 70 80 90) + + (test/unspec + (when (file-exists? "io-tmp2") + (delete-file "io-tmp2"))) (test (input-port? (current-input-port)) #t) (test (binary-port? (current-input-port)) #f) diff --git a/src/mzscheme/src/regexp.c b/src/mzscheme/src/regexp.c index 2177213cb2..1d56d9c338 100644 --- a/src/mzscheme/src/regexp.c +++ b/src/mzscheme/src/regexp.c @@ -2434,6 +2434,19 @@ regexec(const char *who, if (peek) { peekskip = portstart; dropped = portstart; + /* Make sure that's there's not an EOF before peekskip: */ + if (!SAME_OBJ(peekskip, scheme_make_integer(0))) { + char tmp[1]; + long got; + got = scheme_get_byte_string_unless("regexp-match", port, + tmp, 0, 1, 1, + 1, scheme_bin_minus(peekskip, scheme_make_integer(1)), + unless_evt); + if (got == EOF) { + /* Hit EOF before peekstart, so cannot match */ + return 0; + } + } } else { /* In non-peek port mode, skip over portstart chars: */ long amt, got; @@ -2460,7 +2473,7 @@ regexec(const char *who, if (discard_oport) scheme_put_byte_string(who, discard_oport, drain, 0, got, 0); - dropped = scheme_bin_plus(dropped, scheme_make_integer(amt)); + dropped = scheme_bin_plus(dropped, scheme_make_integer(got)); delta = scheme_bin_minus(portstart, dropped); if (scheme_bin_gt(scheme_make_integer(amt), delta)) amt = SCHEME_INT_VAL(delta);