diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-22 21:21:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-22 21:21:23 -0700 |
commit | 0bd7556d869f0038a5bf58fff41ccbed891d150d (patch) | |
tree | c41f9211e32ae4e51aae97a41223008ea552e4ea /txr.1 | |
parent | e9db3a4cf7a6a292e74a8d77868eb356107591ca (diff) | |
download | txr-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 'txr.1')
-rw-r--r-- | txr.1 | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -45702,6 +45702,19 @@ of these version values, the described behaviors are provided if is given an argument which is equal or lower. For instance .code "-C 103" selects the behaviors described below for version 105, but not those for 102. +.IP 150 +Until version 150, the +.code match-regex +function behaved in a different way from what was documented. Rather +than returning the length of the match, it returned the index one +past the last matching character. In the case when the starting position +is zero, these values coincide; they are different if the match begins +at some position inside the string. Compatibility with 150 restores +the behavior. The +.code match-regst +function was also affected by this issue; however, since it returned nonsense +result not corresponding to the matching text, it was repaired without +backward compatibility. .IP 148 Up until version 148, the .code :postinit |