diff --git a/ChangeLog b/ChangeLog index 4e2ff928a0dca200db3c96e9502227df94881197..bf1b2a8344b0a00095428e5870aeba41d6820bcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,8 +40,8 @@ CVS code - - Tweak a few functions to remove the assumption that the file always ends in a magicline. Changes to cut_line(), do_cut_till_end(), open_buffer(), read_file(), write_file(), - do_last_line(), do_para_end(), do_alt_speller(), and - do_wordlinechar_count(). (DLR) + do_last_line(), do_para_end(), backup_lines(), + do_alt_speller(), and do_wordlinechar_count(). (DLR) - Tweak a few functions to rely on fileage and filebot instead of NULL for their checks to detect the top or bottom of the file. Changes to cut_line(), cut_to_eol(), do_page_up(), @@ -108,6 +108,8 @@ CVS code - - text.c: begpar() - Return FALSE if foo is NULL, as inpar() does. (DLR) + backup_lines() + - Remove unused quote_len parameter. (DLR) do_alt_speller() - Move the code that replaces the text of the current file with the text of the spell-checked file into its own function, diff --git a/src/proto.h b/src/proto.h index 9c3f36338e9b49574112e482229162bc0c85bb9f..a9b78314f7ba067b700a1666279e05407bc8bc71 100644 --- a/src/proto.h +++ b/src/proto.h @@ -563,8 +563,7 @@ bool indents_match(const char *a_line, size_t a_indent, const char *b_line, size_t b_indent); bool begpar(const filestruct *const foo); bool inpar(const filestruct *const foo); -filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t - quote_len); +filestruct *backup_lines(filestruct *first_line, size_t par_len); bool find_paragraph(size_t *const quote, size_t *const par); void do_justify(bool full_justify); void do_justify_void(void); diff --git a/src/text.c b/src/text.c index 42bd2d7a7a2a6d810a6511bd6432ed4ed3494c15..c9199719f05dc7534d1e62fcb512b40392c19bcc 100644 --- a/src/text.c +++ b/src/text.c @@ -949,11 +949,10 @@ bool inpar(const filestruct *const foo) } /* Put the next par_len lines, starting with first_line, into the - * justify buffer, leaving copies of those lines in place. Assume there - * are enough lines after first_line. Return the new copy of - * first_line. */ -filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t - quote_len) + * justify buffer, leaving copies of those lines in place. Assume that + * par_len is greater than zero, and that there are enough lines after + * first_line. Return the new copy of first_line. */ +filestruct *backup_lines(filestruct *first_line, size_t par_len) { filestruct *top = first_line; /* The top of the paragraph we're backing up. */ @@ -976,6 +975,9 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t } #endif + assert(par_len > 0 && openfile->current->lineno + par_len <= + filebot->lineno + 1); + /* Move bot down par_len lines to the newline after the last line of * the paragraph. */ for (i = par_len; i > 0; i--) @@ -1181,7 +1183,7 @@ void do_justify(bool full_justify) if (first_par_line == NULL) first_par_line = backup_lines(openfile->current, full_justify ? openfile->filebot->lineno - - openfile->current->lineno : par_len, quote_len); + openfile->current->lineno : par_len); /* Initialize indent_string to a blank string. */ indent_string = mallocstrcpy(NULL, "");