- {
- size_t mid = low + (high - low) / 2; /* low <= mid < high */
- int cmp = compar (list->elements[mid], elt);
-
- if (cmp < 0)
- low = mid + 1;
- else if (cmp > 0)
- high = mid;
- else /* cmp == 0 */
- {
- /* We have an element equal to ELT at index MID. But we need
- the minimal such index. */
- high = mid;
- /* At each loop iteration, low <= high and
- compar (list->elements[high], elt) == 0,
- and we know that the first occurrence of the element is at
- low <= position <= high. */
- while (low < high)
- {
- size_t mid2 = low + (high - low) / 2; /* low <= mid2 < high */
- int cmp2 = compar (list->elements[mid2], elt);
-
- if (cmp2 < 0)
- low = mid2 + 1;
- else if (cmp2 > 0)
- /* The list was not sorted. */
- abort ();
- else /* cmp2 == 0 */
- {
- if (mid2 == low)
- break;
- high = mid2 - 1;
- }
- }
- return low;
- }
- }
+ {
+ size_t mid = low + (high - low) / 2; /* low <= mid < high */
+ int cmp = compar (list->elements[mid], elt);
+
+ if (cmp < 0)
+ low = mid + 1;
+ else if (cmp > 0)
+ high = mid;
+ else /* cmp == 0 */
+ {
+ /* We have an element equal to ELT at index MID. But we need
+ the minimal such index. */
+ high = mid;
+ /* At each loop iteration, low <= high and
+ compar (list->elements[high], elt) == 0,
+ and we know that the first occurrence of the element is at
+ low <= position <= high. */
+ while (low < high)
+ {
+ size_t mid2 = low + (high - low) / 2; /* low <= mid2 < high */
+ int cmp2 = compar (list->elements[mid2], elt);
+
+ if (cmp2 < 0)
+ low = mid2 + 1;
+ else if (cmp2 > 0)
+ /* The list was not sorted. */
+ abort ();
+ else /* cmp2 == 0 */
+ {
+ if (mid2 == low)
+ break;
+ high = mid2 - 1;
+ }
+ }
+ return low;
+ }
+ }