summaryrefslogtreecommitdiff
path: root/src/intervals.h
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2019-03-01 17:35:12 +0000
committerAlan Mackenzie <acm@muc.de>2019-03-01 17:37:56 +0000
commit31182c1d17f6f7bc946d5e4576e025c9b975e0b5 (patch)
tree49f54fc69a83fbc5f7a7c01a82fe1e1417a94a59 /src/intervals.h
parent287f2a676405009a6927fe7c33e36299a86b2827 (diff)
downloademacs-31182c1d17f6f7bc946d5e4576e025c9b975e0b5.tar.gz
Maintain interval ->position fields correctly in update_interval
Also fix some anomalies in the handling of byte positions in regexp-emacs.c This fixes bug #34525. * src/intervals.c (SET_PARENT_POSITION): New macro. (update_interval): When moving to an interval's parent, set that parent's ->position field, to maintain the consistency of the tree. * src/intervals.h (struct interval): Amend the comment describing when ->position is valid. * src/pdumper.c: Update the hash associated with struct interval. * src/regex-emacs.c: (re_match_2_internal): Only invoke POINTER_TO_OFFSET on a known character boundary. Only perform arithmetic on character positions, not on byte positions. Correct the argument to an invocation of UPDATE_SYNTAX_TABLE_FORWARD by adding 1 to it (in case wordend:). * src/syntax.c: (update_syntax_table): Remove the now redundant code that set the ->position field of all parents of the interval found by update_interval.
Diffstat (limited to 'src/intervals.h')
-rw-r--r--src/intervals.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/intervals.h b/src/intervals.h
index 9c5adf33a14..e9166946d9a 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -31,11 +31,15 @@ struct interval
/* The first group of entries deal with the tree structure. */
ptrdiff_t total_length; /* Length of myself and both children. */
ptrdiff_t position; /* Cache of interval's character position. */
- /* This field is usually updated
- simultaneously with an interval
- traversal, there is no guarantee
- that it is valid for a random
- interval. */
+ /* This field is valid in the final
+ target interval returned by
+ find_interval, next_interval,
+ previous_interval and
+ update_interval. It cannot be
+ depended upon in any intermediate
+ intervals traversed by these
+ functions, or any other
+ interval. */
struct interval *left; /* Intervals which precede me. */
struct interval *right; /* Intervals which succeed me. */