- /* Consider only elements at indices >= start_index.
- In this case, rightp contains the difference between the start_index
- for the parent node and the one for the child node (0 when the child
- node is the parent's left child, > 0 when the child is the parent's
- right child). */
- for (;;)
- {
- /* Descend on left branch. */
- for (;;)
- {
- if (node == NULL)
- break;
- if (node->branch_size <= start_index)
- break;
- stack_ptr->node = node;
- stack_ptr->rightp = 0;
- node = node->left;
- stack_ptr++;
- }
- /* Climb up again. */
- for (;;)
- {
- if (stack_ptr == &stack[0])
- return NULL;
- stack_ptr--;
- if (!stack_ptr->rightp)
- break;
- start_index += stack_ptr->rightp;
- }
- node = stack_ptr->node;
- {
- size_t left_branch_size1 =
- (node->left != NULL ? node->left->branch_size : 0) + 1;
- if (start_index < left_branch_size1)
- {
- /* Test against current element. */
- if (equals != NULL ? equals (elt, node->value) : elt == node->value)
- return node;
- /* Now that we have considered all indices < left_branch_size1,
- we can increment start_index. */
- start_index = left_branch_size1;
- }
- index++;
- if (index >= end_index)
- return NULL;
- /* Descend on right branch. */
- start_index -= left_branch_size1;
- stack_ptr->rightp = left_branch_size1;
- }
- node = node->right;
- stack_ptr++;
- }
+ /* Consider only elements at indices >= start_index.
+ In this case, rightp contains the difference between the start_index
+ for the parent node and the one for the child node (0 when the child
+ node is the parent's left child, > 0 when the child is the parent's
+ right child). */
+ for (;;)
+ {
+ /* Descend on left branch. */
+ for (;;)
+ {
+ if (node == NULL)
+ break;
+ if (node->branch_size <= start_index)
+ break;
+ stack_ptr->node = node;
+ stack_ptr->rightp = 0;
+ node = node->left;
+ stack_ptr++;
+ }
+ /* Climb up again. */
+ for (;;)
+ {
+ if (stack_ptr == &stack[0])
+ return NULL;
+ stack_ptr--;
+ if (!stack_ptr->rightp)
+ break;
+ start_index += stack_ptr->rightp;
+ }
+ node = stack_ptr->node;
+ {
+ size_t left_branch_size1 =
+ (node->left != NULL ? node->left->branch_size : 0) + 1;
+ if (start_index < left_branch_size1)
+ {
+ /* Test against current element. */
+ if (equals != NULL ? equals (elt, node->value) : elt == node->value)
+ return node;
+ /* Now that we have considered all indices < left_branch_size1,
+ we can increment start_index. */
+ start_index = left_branch_size1;
+ }
+ index++;
+ if (index >= end_index)
+ return NULL;
+ /* Descend on right branch. */
+ start_index -= left_branch_size1;
+ stack_ptr->rightp = left_branch_size1;
+ }
+ node = node->right;
+ stack_ptr++;
+ }