From: David Lawrence Ramsey Date: Thu, 10 Nov 2005 21:20:32 +0000 (+0000) Subject: fix breakage in both backup_lines() and do_justify(); the latter's X-Git-Tag: v1.3.10~91 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=cd8f73521ee5e0de47e437729063e3ff161f9782;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index b11b5918..86eb2bab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/proto.h b/src/proto.h index a9b78314..f465a88d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -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); diff --git a/src/text.c b/src/text.c index 21aa6512..f28deb7a 100644 --- a/src/text.c +++ b/src/text.c @@ -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, "");