summaryrefslogtreecommitdiffstats
path: root/regex.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-22 21:21:23 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-22 21:21:23 -0700
commit0bd7556d869f0038a5bf58fff41ccbed891d150d (patch)
treec41f9211e32ae4e51aae97a41223008ea552e4ea /regex.h
parente9db3a4cf7a6a292e74a8d77868eb356107591ca (diff)
downloadtxr-0bd7556d869f0038a5bf58fff41ccbed891d150d.tar.gz
txr-0bd7556d869f0038a5bf58fff41ccbed891d150d.tar.bz2
txr-0bd7556d869f0038a5bf58fff41ccbed891d150d.zip
Fix match-regex not conforming to documentation.
The documentation says that match-regex returns the length. Actually, it returns the position after the last character matched. This makes a difference when the match doesn't begin at character zero. The actual behavior is that of the match_regex C function which has behaved that way since the dawn of TXR, and internals depend on it behaving that way. So the internal function is being retained, and a new function is being registered as the match-regex intrinsic. The choice of binding for match-regex is subject to the compatibility option. The behavior of match-regst is also being fixed since its return value is incorrect due to this issue. Since its return value makes no sense at all (does not represent the matched text), it is not subject to the compatibility option; it is just fixed to conform with the documentation. * regex.c (match_regex_len): New function. (match_regst): Keep using match_regex, but use its return value properly. This simplifies the range extraction code, which is why match_regex works that way in the first place. (regex_init): Register match-regex to match_regex_len, unless compatibility <= 150 is requested; then register to match_regex. * regex.h (match_regex_len): Declared. * txr.1: Compatibility notes added.
Diffstat (limited to 'regex.h')
-rw-r--r--regex.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/regex.h b/regex.h
index 599e985e..80494860 100644
--- a/regex.h
+++ b/regex.h
@@ -34,6 +34,7 @@ val regexp(val);
val search_regex(val haystack, val needle_regex, val start_num, val from_end);
val range_regex(val haystack, val needle_regex, val start_num, val from_end);
val match_regex(val str, val regex, val pos);
+val match_regex_len(val str, val regex, val pos);
val match_regex_right(val str, val regex, val end);
val search_regst(val haystack, val needle_regex, val start_num, val from_end);
val match_regst(val str, val regex, val pos);