fix justify code regression: if we're justifying the entire file, and we

haven't found any paragraph(s), we should refresh the screen and get out
instead of breaking out of the loop and acting as though we've justified
something, so as to avoid a segfault


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2384 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-03-17 04:48:14 +00:00
parent fd81a7189b
commit 102d01da6c
2 changed files with 15 additions and 10 deletions

View File

@ -236,9 +236,9 @@ CVS code -
- For consistency, preserve placewewant if we didn't unjustify
instead of setting it to 0. (DLR)
- When justifying the entire file, properly break out of the
loop if there are no more paragraphs after the current one and
the paragraph search left us on the magicline, so as to avoid
a segfault. (DLR)
loop if we've found at least one paragraph, there are no more
paragraphs after the current one, and the paragraph search
left us on the magicline. This avoids a segfault. (DLR)
do_input()
- Add finished parameter, used to indicate when we run or try to
run a function associated with a shortcut. (DLR)

View File

@ -2958,14 +2958,19 @@ void do_justify(bool full_justify)
* is the start of this paragraph if we're in one, or the start
* of the next otherwise. Save the quote length and paragraph
* length (number of lines). Don't refresh the screen yet,
* since we'll do that after we justify. If the search
* failed, we're justifying the whole file, and the search
* didn't leave us on the last line of the file, set the last
* line of the text to be justified to the last line of the file
* and break out of the loop. Otherwise, refresh the screen and
* get out. */
* since we'll do that after we justify.
*
* If the search failed, we do one of two things. If we're
* justifying the whole file, we've found at least one
* paragraph, and the search didn't leave us on the last line of
* the file, it means that we should justify all the way to the
* last line of the file, so set the last line of the text to be
* justified to the last line of the file and break out of the
* loop. Otherwise, it means that there are no paragraph(s) to
* justify, so refresh the screen and get out. */
if (!find_paragraph(&quote_len, &par_len)) {
if (full_justify && first_par_line != filebot) {
if (full_justify && first_par_line != NULL &&
first_par_line != filebot) {
last_par_line = filebot;
break;
} else {