Skip to content

Instantly share code, notes, and snippets.

@leque
Created November 8, 2013 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leque/7365349 to your computer and use it in GitHub Desktop.
Save leque/7365349 to your computer and use it in GitHub Desktop.
diff --git a/src/regexp.c b/src/regexp.c
index 7a621fd..58c621e 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -2476,9 +2476,11 @@ static void rex_rec(const unsigned char *code,
case RE_BEGIN: {
int grpno = *code++;
const char *opos = ctx->matches[grpno]->startp;
+ const char *oend = ctx->matches[grpno]->endp;
ctx->matches[grpno]->startp = input;
rex_rec(code, input, ctx);
ctx->matches[grpno]->startp = opos;
+ ctx->matches[grpno]->endp = oend;
return;
}
case RE_BEGIN_RL: {
diff --git a/test/regexp.scm b/test/regexp.scm
index 7757df5..bc150d7 100644
--- a/test/regexp.scm
+++ b/test/regexp.scm
@@ -240,6 +240,11 @@
(test-re #/(.)*/ "abc" '("abc" "c"))
(test-re #/(a([^a])*)*/ "abcaBC" '("abcaBC" "aBC" "C"))
(test-re #/b|()|a/ "cac" '("" ""))
+(test-re #/(a)*a/ "a" '("a" #f))
+(test-re #/(a)*a/ "aa" '("aa" "a"))
+(test-re #/(a)*a/ "aaa" '("aaa" "a"))
+(test-re #/(a)*?a/ "a" '("a" #f))
+(test-re #/(a)*?a/ "aa" '("a" #f))
;;-------------------------------------------------------------------------
(test-section "simple meta")
@@ -521,6 +526,7 @@
(test-re #/(.+)\1/i "AbCaBC" '("AbCaBC" "AbC"))
(test-re #/(.+)\1/ "AbCAb1" '())
(test-re #/((.)\2)/ "aa" '("aa" "aa" "a"))
+(test-re #/(a)*\1/ "aa" '("aa" "a"))
(test* "^\\1(.)$" (test-error) (string->regexp "^\\1(.)"))
(test* "^(\\1)$" (test-error) (string->regexp "^(\\1)$"))
(test* "(.)\\2" (test-error) (string->regexp "(.)\\2"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment