# HG changeset patch # User Richard M. Stallman # Date 861079526 0 # Node ID 156dd2e144528f65b57bd0eda4ca6f947d9a2b40 # Parent 6923ae3375f7296a37c221ecd18ebf65eec64ccf (update_interval): New function. diff -r 6923ae3375f7 -r 156dd2e14452 src/intervals.c --- a/src/intervals.c Tue Apr 15 04:44:36 1997 +0000 +++ b/src/intervals.c Tue Apr 15 04:45:26 1997 +0000 @@ -670,6 +670,45 @@ 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