minor backup_lines() cleanups

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3127 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-11-09 18:49:16 +00:00
parent 0083bd29d2
commit 8bd960bbc9
3 changed files with 13 additions and 10 deletions

View File

@ -40,8 +40,8 @@ CVS code -
- Tweak a few functions to remove the assumption that the file - Tweak a few functions to remove the assumption that the file
always ends in a magicline. Changes to cut_line(), always ends in a magicline. Changes to cut_line(),
do_cut_till_end(), open_buffer(), read_file(), write_file(), do_cut_till_end(), open_buffer(), read_file(), write_file(),
do_last_line(), do_para_end(), do_alt_speller(), and do_last_line(), do_para_end(), backup_lines(),
do_wordlinechar_count(). (DLR) do_alt_speller(), and do_wordlinechar_count(). (DLR)
- Tweak a few functions to rely on fileage and filebot instead - Tweak a few functions to rely on fileage and filebot instead
of NULL for their checks to detect the top or bottom of the of NULL for their checks to detect the top or bottom of the
file. Changes to cut_line(), cut_to_eol(), do_page_up(), file. Changes to cut_line(), cut_to_eol(), do_page_up(),
@ -108,6 +108,8 @@ CVS code -
- text.c: - text.c:
begpar() begpar()
- Return FALSE if foo is NULL, as inpar() does. (DLR) - Return FALSE if foo is NULL, as inpar() does. (DLR)
backup_lines()
- Remove unused quote_len parameter. (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

@ -563,8 +563,7 @@ bool indents_match(const char *a_line, size_t a_indent, const char
*b_line, size_t b_indent); *b_line, size_t b_indent);
bool begpar(const filestruct *const foo); bool begpar(const filestruct *const foo);
bool inpar(const filestruct *const foo); bool inpar(const filestruct *const foo);
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t filestruct *backup_lines(filestruct *first_line, size_t par_len);
quote_len);
bool find_paragraph(size_t *const quote, size_t *const par); bool find_paragraph(size_t *const quote, size_t *const par);
void do_justify(bool full_justify); void do_justify(bool full_justify);
void do_justify_void(void); void do_justify_void(void);

View File

@ -949,11 +949,10 @@ bool inpar(const filestruct *const foo)
} }
/* Put the next par_len lines, starting with first_line, into the /* Put the next par_len lines, starting with first_line, into the
* justify buffer, leaving copies of those lines in place. Assume there * justify buffer, leaving copies of those lines in place. Assume that
* are enough lines after first_line. Return the new copy of * par_len is greater than zero, and that there are enough lines after
* first_line. */ * first_line. Return the new copy of first_line. */
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t filestruct *backup_lines(filestruct *first_line, size_t par_len)
quote_len)
{ {
filestruct *top = first_line; filestruct *top = first_line;
/* The top of the paragraph we're backing up. */ /* 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 #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 /* Move bot down par_len lines to the newline after the last line of
* the paragraph. */ * the paragraph. */
for (i = par_len; i > 0; i--) for (i = par_len; i > 0; i--)
@ -1181,7 +1183,7 @@ void do_justify(bool full_justify)
if (first_par_line == NULL) if (first_par_line == NULL)
first_par_line = backup_lines(openfile->current, first_par_line = backup_lines(openfile->current,
full_justify ? openfile->filebot->lineno - full_justify ? openfile->filebot->lineno -
openfile->current->lineno : par_len, quote_len); openfile->current->lineno : par_len);
/* Initialize indent_string to a blank string. */ /* Initialize indent_string to a blank string. */
indent_string = mallocstrcpy(NULL, ""); indent_string = mallocstrcpy(NULL, "");