diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-01-27 00:27:47 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-01-27 00:27:47 -0800 |
commit | bcc1770bf64c62dc5c6404596017cf73a6c9e25e (patch) | |
tree | f64c291e7a744d117c1de77507476c555b83f530 /regex.c | |
parent | 09eb73cde9c64e6fa29cbb410b25c6dd84a8a6f2 (diff) | |
download | txr-bcc1770bf64c62dc5c6404596017cf73a6c9e25e.tar.gz txr-bcc1770bf64c62dc5c6404596017cf73a6c9e25e.tar.bz2 txr-bcc1770bf64c62dc5c6404596017cf73a6c9e25e.zip |
* regex.c (match_regex_right): Fix semantics of second argument
to something more useful.
* regex.h (match_regex_right): Change name of parameter.
* txr.1: Documented match-regex-right.
Diffstat (limited to 'regex.c')
-rw-r--r-- | regex.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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); |