aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intervals.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/intervals.c b/src/intervals.c
index f52e6ea4727..c5dad670926 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -672,7 +672,8 @@ previous_interval (interval)
672} 672}
673 673
674/* Find the interval containing POS given some non-NULL INTERVAL 674/* Find the interval containing POS given some non-NULL INTERVAL
675 in the same tree. */ 675 in the same tree. Note that we need to update interval->position
676 if we go down the tree. */
676INTERVAL 677INTERVAL
677update_interval (i, pos) 678update_interval (i, pos)
678 register INTERVAL i; 679 register INTERVAL i;
@@ -686,22 +687,31 @@ update_interval (i, pos)
686 if (pos < i->position) 687 if (pos < i->position)
687 { 688 {
688 /* Move left. */ 689 /* Move left. */
689 if (pos >= i->position - TOTAL_LENGTH (i->left)) 690 if (pos >= i->position - TOTAL_LENGTH (i->left))
690 i = i->left; /* Move to the left child */ 691 {
692 i->left->position = i->position - TOTAL_LENGTH (i->left)
693 + LEFT_TOTAL_LENGTH (i->left);
694 i = i->left; /* Move to the left child */
695 }
691 else if (NULL_PARENT (i)) 696 else if (NULL_PARENT (i))
692 error ("Point before start of properties"); 697 error ("Point before start of properties");
693 else i = i->parent; 698 else
699 i = i->parent;
694 continue; 700 continue;
695 } 701 }
696 else if (pos >= INTERVAL_LAST_POS (i)) 702 else if (pos >= INTERVAL_LAST_POS (i))
697 { 703 {
698 /* Move right. */ 704 /* Move right. */
699 if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right)) 705 if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right))
700 i = i->right; /* Move to the right child */ 706 {
707 i->right->position = INTERVAL_LAST_POS (i) +
708 LEFT_TOTAL_LENGTH (i->right);
709 i = i->right; /* Move to the right child */
710 }
701 else if (NULL_PARENT (i)) 711 else if (NULL_PARENT (i))
702 error ("Point after end of properties"); 712 error ("Point after end of properties");
703 else 713 else
704 i = i->parent; 714 i = i->parent;
705 continue; 715 continue;
706 } 716 }
707 else 717 else