fix breakage in both backup_lines() and do_justify(); the latter's

return value is unneeded, as current will point to the same line when
it's done, and making first_par_line point to current in the former
ensures that the two will properly stay in sync


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3155 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-11-10 21:20:32 +00:00
parent 52161ee3a1
commit cd8f73521e
3 changed files with 16 additions and 11 deletions

View File

@ -110,6 +110,10 @@ CVS code -
begpar()
- Return FALSE if foo is NULL, as inpar() does. (DLR)
backup_lines()
- Return void instead of a pointer to the copy of the first
line, since current will point to the same location after the
text is copied and so can be used instead of the old return
value. (DLR)
- Remove unused quote_len parameter. (DLR)
do_alt_speller()
- Move the code that replaces the text of the current file with

View File

@ -563,7 +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);
void 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);

View File

@ -950,8 +950,8 @@ bool inpar(const filestruct *const foo)
/* Move the next par_len lines, starting with first_line, into the
* 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)
* first_line. */
void backup_lines(filestruct *first_line, size_t par_len)
{
filestruct *top = first_line;
/* The top of the paragraph we're backing up. */
@ -1023,8 +1023,6 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len)
openfile->current_x = current_x_save;
set_modified();
return first_line;
}
/* Find the beginning of the current paragraph if we're in one, or the
@ -1209,14 +1207,17 @@ void do_justify(bool full_justify)
filebot_inpar = (openfile->current->lineno + par_len ==
openfile->filebot->lineno + 1);
/* If we haven't already done it, copy the original paragraph(s)
* to the justify buffer. */
if (first_par_line == NULL)
first_par_line = backup_lines(openfile->current,
full_justify ? (openfile->filebot->lineno -
openfile->current->lineno +
/* If we haven't already done it, move the original paragraph(s)
* to the justify buffer, splice a copy of the original
* paragraph(s) into the file in the same place, and set
* first_par_line to the first line of the copy. */
if (first_par_line == NULL) {
backup_lines(openfile->current, full_justify ?
(openfile->filebot->lineno - openfile->current->lineno +
(openfile->filebot->data[0] != '\0') ? 1 : 0) :
par_len);
first_par_line = openfile->current;
}
/* Initialize indent_string to a blank string. */
indent_string = mallocstrcpy(NULL, "");