summaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/regex.c b/regex.c
index 67f17f60..090846b1 100644
--- a/regex.c
+++ b/regex.c
@@ -1854,20 +1854,21 @@ val match_regex(val str, val reg, val pos)
return nil;
}
-val match_regex_right(val str, val regex, val pos)
+val match_regex_right(val str, val regex, val end)
{
+ val pos = zero;
val slen = length(str);
- if (!pos)
- pos = zero;
+ if (!end || gt(end, slen))
+ end = slen;
- for (;;) {
+ while (lt(pos, end)) {
cons_bind (from, len, search_regex(str, regex, pos, nil));
if (!from)
return nil;
- if (eql(plus(from, len), slen))
+ if (eql(plus(from, len), end))
return len;
pos = plus(pos, one);