nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 076bc31ce5c433b838110091b91de13f91870f7b
parent 22c8ef6c395ec28f42812d1f54eebc0e7ff2523a
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Sat, 25 Aug 2018 17:13:33 -0500

tweaks: simplify by using a 'do/while' loop instead of 'while (TRUE)'

The do/while loop will run once when doing a justify, and enough times
for the entire file when doing a full-justify.

Diffstat:
Msrc/text.c | 18++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -2241,7 +2241,9 @@ void do_justify(bool full_justify) first_par_line = openfile->current; } - while (TRUE) { + /* Search for a paragraph(s) and justify them. If we're justifying the + * entire file, loop until we've found every paragraph. */ + do { filestruct *firstline; /* The first line of the current paragraph. */ filestruct *sampleline; @@ -2384,20 +2386,12 @@ void do_justify(bool full_justify) * edit window and finding a paragraph need correct line numbers. */ renumber(firstline); - /* We've just finished justifying the paragraph. If we're not - * justifying the entire file, break out of the loop. - * Otherwise, continue the loop so that we justify all the - * paragraphs in the file. */ - if (!full_justify) - break; - - /* Find the next line of the paragraph(s) to be justified. + /* If we're justifying the entire file, + * find the next line of the paragraph(s) to be justified. * If the search failed, it means that there are no paragraph(s) to * justify, so break out of the loop. */ - if (!find_paragraph(&quote_len, &par_len)) { - break; - } } + while (full_justify && find_paragraph(&quote_len, &par_len)); /* We are now done justifying the paragraph(s), so clean * up. totsize has been maintained above.