From 6f7f3c9c11d16438b0ca6c7d8124767cf86595fd Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Mon, 22 Oct 2018 18:01:23 -0500
Subject: [PATCH] tweaks: swap the names of wrap_at and fill

fill should contain the original specified value, and wrap_at should
contain the column that fill translates to.
---
 src/global.c |  6 +++---
 src/nano.c   | 16 ++++++++--------
 src/proto.h  |  2 +-
 src/rcfile.c |  4 ++--
 src/text.c   |  8 ++++----
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/global.c b/src/global.c
index 26a8f3e8..41a0ed04 100644
--- a/src/global.c
+++ b/src/global.c
@@ -81,10 +81,10 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
 #endif
 
 #ifdef ENABLED_WRAPORJUSTIFY
-ssize_t wrap_at = -COLUMNS_FROM_EOL;
+ssize_t fill = -COLUMNS_FROM_EOL;
 		/* The relative column where we will wrap lines. */
-ssize_t fill = 0;
-		/* The actual column where we will wrap lines, based on wrap_at. */
+ssize_t wrap_at = 0;
+		/* The actual column where we will wrap lines, based on fill. */
 #endif
 
 char *last_search = NULL;
diff --git a/src/nano.c b/src/nano.c
index b7525aaf..cd42daf8 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -715,11 +715,11 @@ void window_init(void)
 
 #ifdef ENABLED_WRAPORJUSTIFY
 	/* Set up the wrapping point, accounting for screen width when negative. */
-	fill = wrap_at;
-	if (fill <= 0)
-		fill += COLS;
-	if (fill < 0)
-		fill = 0;
+	wrap_at = fill;
+	if (wrap_at <= 0)
+		wrap_at += COLS;
+	if (wrap_at < 0)
+		wrap_at = 0;
 #endif
 }
 
@@ -2249,7 +2249,7 @@ int main(int argc, char **argv)
 #endif
 #ifdef ENABLED_WRAPORJUSTIFY
 			case 'r':
-				if (!parse_num(optarg, &wrap_at)) {
+				if (!parse_num(optarg, &fill)) {
 					fprintf(stderr, _("Requested fill size \"%s\" is invalid"), optarg);
 					fprintf(stderr, "\n");
 					exit(1);
@@ -2321,7 +2321,7 @@ int main(int argc, char **argv)
 	if (!no_rcfiles) {
 		/* Back up the command-line options, then clear the strings. */
 #ifdef ENABLED_WRAPORJUSTIFY
-		ssize_t wrap_at_cmdline = wrap_at;
+		ssize_t fill_cmdline = fill;
 #endif
 #ifndef NANO_TINY
 		char *backup_dir_cmdline = backup_dir;
@@ -2367,7 +2367,7 @@ int main(int argc, char **argv)
 		/* If the backed-up command-line options have a value, restore them. */
 #ifdef ENABLED_WRAPORJUSTIFY
 		if (fill_used)
-			wrap_at = wrap_at_cmdline;
+			fill = fill_cmdline;
 #endif
 #ifndef NANO_TINY
 		if (backup_dir_cmdline != NULL) {
diff --git a/src/proto.h b/src/proto.h
index 9e6175c4..7fdecb54 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -73,7 +73,7 @@ extern int shiftaltup, shiftaltdown;
 #endif
 
 #ifdef ENABLED_WRAPORJUSTIFY
-extern ssize_t wrap_at, fill;
+extern ssize_t fill, wrap_at;
 #endif
 
 extern char *last_search;
diff --git a/src/rcfile.c b/src/rcfile.c
index fe6c90f7..620c7359 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -1102,10 +1102,10 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
 #endif
 #ifdef ENABLED_WRAPORJUSTIFY
 		if (strcasecmp(rcopts[i].name, "fill") == 0) {
-			if (!parse_num(option, &wrap_at)) {
+			if (!parse_num(option, &fill)) {
 				rcfile_error(N_("Requested fill size \"%s\" is invalid"),
 								option);
-				wrap_at = -COLUMNS_FROM_EOL;
+				fill = -COLUMNS_FROM_EOL;
 			} else
 				UNSET(NO_WRAP);
 			free(option);
diff --git a/src/text.c b/src/text.c
index a35d487a..8844f036 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1638,7 +1638,7 @@ bool do_wrap(filestruct *line)
 	 * at the end of it! */
 
 	/* Find the last blank where we can break the line. */
-	wrap_loc = break_line(line->data, fill, FALSE);
+	wrap_loc = break_line(line->data, wrap_at, FALSE);
 
 	/* If we couldn't break the line, or we've reached the end of it, we
 	 * don't wrap. */
@@ -1699,7 +1699,7 @@ bool do_wrap(filestruct *line)
 #endif
 		}
 
-		if (rest_length + strlen(line->next->data) <= fill) {
+		if (rest_length + strlen(line->next->data) <= wrap_at) {
 			/* Delete the LF to join the two lines. */
 			do_delete();
 			/* Delete any leading blanks from the joined-on line. */
@@ -2120,13 +2120,13 @@ void justify_paragraph(filestruct **firstline, size_t quote_len,
 	justify_format(jusline, quote_len +
 					indent_length(jusline->data + quote_len));
 
-	while (par_len > 0 && strlenpt(jusline->data) > fill) {
+	while (par_len > 0 && strlenpt(jusline->data) > wrap_at) {
 		size_t line_len = strlen(jusline->data);
 
 		/* If this line is too long, try to wrap it to the next line
 		 * to make it short enough. */
 		break_pos = break_line(jusline->data + lead_len,
-				fill - strnlenpt(jusline->data, lead_len), FALSE);
+				wrap_at - strnlenpt(jusline->data, lead_len), FALSE);
 
 		/* If we can't break the line, or don't need to, we're done. */
 		if (break_pos == -1 || break_pos + lead_len == line_len)
-- 
2.19.1

