From 8bd960bbc9472d6d373f5934bf408ed1647d2d84 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Wed, 9 Nov 2005 18:49:16 +0000
Subject: [PATCH] minor backup_lines() cleanups

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3127 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  6 ++++--
 src/proto.h |  3 +--
 src/text.c  | 14 ++++++++------
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4e2ff928..bf1b2a83 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 9c3f3633..a9b78314 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 42bd2d7a..c9199719 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, "");
-- 
GitLab