summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-04-15 04:45:26 +0000
committerRichard M. Stallman <rms@gnu.org>1997-04-15 04:45:26 +0000
commit61c80204558f0720cae94a32aeff9330b289dbec (patch)
tree2784cf1212d98bc9e07fe99778194ff07a511156
parent707c1e40f0d3b92a6c2db782d864e1446453fdd0 (diff)
downloademacs-61c80204558f0720cae94a32aeff9330b289dbec.tar.gz
(update_interval): New function.
-rw-r--r--src/intervals.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/intervals.c b/src/intervals.c
index cff718d1f8e..744128b84dc 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -670,6 +670,45 @@ previous_interval (interval)
return NULL_INTERVAL;
}
+
+/* Find the interval containing POS given some non-NULL INTERVAL
+ in the same tree. */
+INTERVAL
+update_interval (i, pos)
+ register INTERVAL i;
+ int pos;
+{
+ if (NULL_INTERVAL_P (i))
+ return NULL_INTERVAL;
+
+ while (1)
+ {
+ if (pos < i->position)
+ {
+ /* Move left. */
+ if (pos >= i->position - TOTAL_LENGTH (i->left))
+ i = i->left; /* Move to the left child */
+ else if (NULL_PARENT (i))
+ error ("Point before start of properties");
+ else i = i->parent;
+ continue;
+ }
+ else if (pos >= INTERVAL_LAST_POS (i))
+ {
+ /* Move right. */
+ if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right))
+ i = i->right; /* Move to the right child */
+ else if (NULL_PARENT (i))
+ error ("Point after end of properties");
+ else
+ i = i->parent;
+ continue;
+ }
+ else
+ return i;
+ }
+}
+
#if 0
/* Traverse a path down the interval tree TREE to the interval