From bca1281acb542f297ac4a6d099b1897872b5415e Mon Sep 17 00:00:00 2001 From: Alex Shinn <ashinn@users.noreply.github.com> Date: Fri, 11 Jul 2014 06:53:10 +0900 Subject: [PATCH] Adding missing nwb support. --- lib/chibi/regexp.scm | 4 ++++ tests/regexp-tests.scm | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lib/chibi/regexp.scm b/lib/chibi/regexp.scm index 40ef0070..fc2a16b2 100644 --- a/lib/chibi/regexp.scm +++ b/lib/chibi/regexp.scm @@ -532,6 +532,9 @@ (string-cursor>? i start) (char-word-constituent? (string-cursor-ref str (string-cursor-prev str i))))) +(define (match/nwb str i ch start end matches) + (and (not (match/bow str i ch start end matches)) + (not (match/eow str i ch start end matches)))) (define (match/bog str i ch start end matches) (and (string-cursor<? i end) (or (string-cursor=? i start) @@ -718,6 +721,7 @@ ((eol) (make-char-state match/eol flags next)) ((bow) (make-char-state match/bow flags next)) ((eow) (make-char-state match/eow flags next)) + ((nwb) (make-char-state match/nwb flags next)) ((bog) (make-char-state match/bog flags next)) ((eog) (make-char-state match/eog flags next)) ((grapheme) diff --git a/tests/regexp-tests.scm b/tests/regexp-tests.scm index ef21d0e3..3698b43c 100644 --- a/tests/regexp-tests.scm +++ b/tests/regexp-tests.scm @@ -142,6 +142,9 @@ (test-re #f '(: (* space) bow ($ (* alpha)) eow (* space)) " abc. ") +(test-re-search '("foo") '(: "foo") " foo ") +(test-re-search #f '(: nwb "foo" nwb) " foo ") +(test-re-search '("foo") '(: nwb "foo" nwb) "xfoox") (test-re '("beef") '(* (/"af"))