| 873 | one to the whole paragraph. */ |
| 874 | |
| 875 | static void |
| 876 | fmt_paragraph (void) |
| 877 | { |
| 878 | WORD *w; |
| 879 | int len; |
| 880 | COST wcost, best; |
| 881 | int saved_length; |
| 882 | |
| 883 | word_limit->best_cost = 0; |
| 884 | saved_length = word_limit->length; |
| 885 | word_limit->length = max_width; /* sentinel */ |
| 886 | |
| 887 | for (WORD *start = word_limit - 1; start >= word; start--) |
| 888 | { |
| 889 | best = MAXCOST; |
| 890 | len = start == word ? first_indent : other_indent; |
| 891 | |
| 892 | /* At least one word, however long, in the line. */ |
| 893 | |
| 894 | w = start; |
| 895 | len += w->length; |
| 896 | do |
| 897 | { |
| 898 | w++; |
| 899 | |
| 900 | /* Consider breaking before w. */ |
| 901 | |
| 902 | wcost = line_cost (w, len) + w->best_cost; |
| 903 | if (start == word && last_line_length > 0) |
| 904 | wcost += RAGGED_COST (len - last_line_length); |
| 905 | if (wcost < best) |
| 906 | { |
| 907 | best = wcost; |
| 908 | start->next_break = w; |
| 909 | start->line_length = len; |
| 910 | } |
| 911 | |
| 912 | /* This is a kludge to keep us from computing 'len' as the |
| 913 | sum of the sentinel length and some non-zero number. |
| 914 | Since the sentinel w->length may be INT_MAX, adding |
| 915 | to that would give a negative result. */ |
| 916 | if (w == word_limit) |
| 917 | break; |
| 918 | |
| 919 | len += (w - 1)->space + w->length; /* w > start >= word */ |
| 920 | } |
| 921 | while (len <= max_width); |
| 922 | start->best_cost = best + base_cost (start); |
| 923 | } |
| 924 | |
| 925 | word_limit->length = saved_length; |
| 926 | } |
| 927 | |
| 928 | /* Work around <https://gcc.gnu.org/PR109628>. */ |
| 929 | #if __GNUC__ == 13 |
no test coverage detected