aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-04-15 04:45:26 +0000
committerRichard M. Stallman1997-04-15 04:45:26 +0000
commit25eeac41e0088307231cc0c1831d2c1a08cacd0f (patch)
treeae1f788d103bd91d6916ee0108791c8e02ca0ca0 /src
parentc81a9bdcd08bfc0a5c14c0e72924ba5f1e29f26b (diff)
downloademacs-25eeac41e0088307231cc0c1831d2c1a08cacd0f.tar.gz
emacs-25eeac41e0088307231cc0c1831d2c1a08cacd0f.zip
(update_interval): New function.
Diffstat (limited to 'src')
-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)
670 670
671 return NULL_INTERVAL; 671 return NULL_INTERVAL;
672} 672}
673
674/* Find the interval containing POS given some non-NULL INTERVAL
675 in the same tree. */
676INTERVAL
677update_interval (i, pos)
678 register INTERVAL i;
679 int pos;
680{
681 if (NULL_INTERVAL_P (i))
682 return NULL_INTERVAL;
683
684 while (1)
685 {
686 if (pos < i->position)
687 {
688 /* Move left. */
689 if (pos >= i->position - TOTAL_LENGTH (i->left))
690 i = i->left; /* Move to the left child */
691 else if (NULL_PARENT (i))
692 error ("Point before start of properties");
693 else i = i->parent;
694 continue;
695 }
696 else if (pos >= INTERVAL_LAST_POS (i))
697 {
698 /* Move right. */
699 if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right))
700 i = i->right; /* Move to the right child */
701 else if (NULL_PARENT (i))
702 error ("Point after end of properties");
703 else
704 i = i->parent;
705 continue;
706 }
707 else
708 return i;
709 }
710}
711
673 712
674#if 0 713#if 0
675/* Traverse a path down the interval tree TREE to the interval 714/* Traverse a path down the interval tree TREE to the interval