in do_justify(), renumber after justifying each individual paragraph,

since find_paragraph() needs the line numbers to be right as well as
edit_refresh(); this fixes a potential segfault when doing full justify
with auto-indent turned on


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3226 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-11-29 19:00:09 +00:00
parent 79383beef3
commit ad1b64cdfa
2 changed files with 16 additions and 9 deletions

View File

@ -211,6 +211,10 @@ CVS code -
as the reset_cursor() called by edit_refresh() after restoring as the reset_cursor() called by edit_refresh() after restoring
edittop and current will ensure that current_y is restored to edittop and current will ensure that current_y is restored to
its original value. (DLR) its original value. (DLR)
- Renumber after justifying each individual paragraph, since
find_paragraph() needs the line numbers to be right as well as
edit_refresh(). This fixes a potential segfault when doing
full justify with auto-indent turned on. (DLR)
do_alt_speller() do_alt_speller()
- Move the code that replaces the text of the current file with - Move the code that replaces the text of the current file with
the text of the spell-checked file into its own function, the text of the spell-checked file into its own function,

View File

@ -1448,22 +1448,25 @@ void do_justify(bool full_justify)
} else } else
openfile->current_x = strlen(openfile->current->data); openfile->current_x = strlen(openfile->current->data);
/* We've just justified a paragraph. If we're not justifying the /* Renumber the lines of the now-justified paragraph, since both
* entire file, break out of the loop. Otherwise, continue the * find_paragraph() and edit_refresh() need the line numbers to
* loop so that we justify all the paragraphs in the file. */ * be right. */
renumber(first_par_line);
/* 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) if (!full_justify)
break; break;
} }
/* We are now done justifying the paragraph or the file, so clean /* We are now done justifying the paragraph or the file, so clean
* up. current_y and totsize have been maintained above. If we * up. current_y and totsize have been maintained above. If we
* actually justified something, renumber, since edit_refresh() * actually justified something, set last_par_line to the new end of
* needs the line numbers to be right, and set last_par_line to the * the paragraph. */
* new end of the paragraph. */ if (first_par_line != NULL)
if (first_par_line != NULL) {
renumber(first_par_line);
last_par_line = openfile->current; last_par_line = openfile->current;
}
edit_refresh(); edit_refresh();