-\f
-#if 0
-/* Traverse a path down the interval tree TREE to the interval
- containing POSITION, adjusting all nodes on the path for
- an addition of LENGTH characters. Insertion between two intervals
- (i.e., point == i->position, where i is second interval) means
- text goes into second interval.
-
- Modifications are needed to handle the hungry bits -- after simply
- finding the interval at position (don't add length going down),
- if it's the beginning of the interval, get the previous interval
- and check the hungry bits of both. Then add the length going back up
- to the root. */
-
-static INTERVAL
-adjust_intervals_for_insertion (INTERVAL tree, ptrdiff_t position,
- ptrdiff_t length)
-{
- register ptrdiff_t relative_position;
- register INTERVAL this;
-
- if (TOTAL_LENGTH (tree) == 0) /* Paranoia */
- abort ();
-
- /* If inserting at point-max of a buffer, that position
- will be out of range */
- if (position > TOTAL_LENGTH (tree))
- position = TOTAL_LENGTH (tree);
- relative_position = position;
- this = tree;
-
- while (1)
- {
- if (relative_position <= LEFT_TOTAL_LENGTH (this))
- {
- this->total_length += length;
- CHECK_TOTAL_LENGTH (this);
- this = this->left;
- }
- else if (relative_position > (TOTAL_LENGTH (this)
- - RIGHT_TOTAL_LENGTH (this)))
- {
- relative_position -= (TOTAL_LENGTH (this)
- - RIGHT_TOTAL_LENGTH (this));
- this->total_length += length;
- CHECK_TOTAL_LENGTH (this);
- this = this->right;
- }
- else
- {
- /* If we are to use zero-length intervals as buffer pointers,
- then this code will have to change. */
- this->total_length += length;
- CHECK_TOTAL_LENGTH (this);
- this->position = LEFT_TOTAL_LENGTH (this)
- + position - relative_position + 1;
- return tree;
- }
- }
-}
-#endif
-