From 1cc29f626dbce43d4c374bb02410bc099944bd6e Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Mon, 20 Nov 2000 01:29:37 +0000
Subject: [PATCH] Rocco's fix for current_x increment

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@303 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  2 +-
 po/nano.pot | 28 ++++++++++++++--------------
 search.c    | 20 ++++++++------------
 3 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 662d44d6..71b69929 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
 CVS code -
 - search.c:
   findnextstr()
-	- Set current_x back before aborting (oops!).
+	- Fix curent_x increment bug by using another variable (Rocco Corsi).
   search_init()
 	- Silly typo in our "one simple call" of statusq.  Stopped
 	  previous search string from being displayed.
diff --git a/po/nano.pot b/po/nano.pot
index 5af4cb20..448ca503 100644
--- a/po/nano.pot
+++ b/po/nano.pot
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-11-19 14:12-0500\n"
+"POT-Creation-Date: 2000-11-19 20:28-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -751,7 +751,7 @@ msgstr ""
 msgid " (to replace)"
 msgstr ""
 
-#: search.c:136 search.c:322
+#: search.c:136 search.c:318
 msgid "Search Cancelled"
 msgstr ""
 
@@ -760,54 +760,54 @@ msgstr ""
 msgid "\"%s...\" not found"
 msgstr ""
 
-#: search.c:245
+#: search.c:243
 msgid "Search Wrapped"
 msgstr ""
 
-#: search.c:344
+#: search.c:340
 #, c-format
 msgid "Replaced %d occurences"
 msgstr ""
 
-#: search.c:346
+#: search.c:342
 msgid "Replaced 1 occurence"
 msgstr ""
 
-#: search.c:483 search.c:576 search.c:592
+#: search.c:479 search.c:572 search.c:588
 msgid "Replace Cancelled"
 msgstr ""
 
-#: search.c:526
+#: search.c:522
 msgid "Replace this instance?"
 msgstr ""
 
-#: search.c:534
+#: search.c:530
 msgid "Replace failed: unknown subexpression!"
 msgstr ""
 
-#: search.c:617
+#: search.c:613
 #, c-format
 msgid "Replace with [%s]"
 msgstr ""
 
-#: search.c:621 search.c:625
+#: search.c:617 search.c:621
 msgid "Replace with"
 msgstr ""
 
 #. Ask for it
-#: search.c:660
+#: search.c:656
 msgid "Enter line number"
 msgstr ""
 
-#: search.c:662
+#: search.c:658
 msgid "Aborted"
 msgstr ""
 
-#: search.c:682
+#: search.c:678
 msgid "Come on, be reasonable"
 msgstr ""
 
-#: search.c:687
+#: search.c:683
 #, c-format
 msgid "Only %d lines available, skipping to last line"
 msgstr ""
diff --git a/search.c b/search.c
index 2663c75f..b6b3c73b 100644
--- a/search.c
+++ b/search.c
@@ -202,31 +202,29 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
 {
     filestruct *fileptr;
     char *searchstr, *found = NULL, *tmp;
-    int past_editbot = 0;
+    int past_editbot = 0, current_x_find = current_x;
 
     fileptr = current;
 
-    current_x++;
+    current_x_find++;
 
     /* Are we searching the last line? (i.e. the line where search started) */
-    if ((fileptr == begin) && (current_x < beginx))
+    if ((fileptr == begin) && (current_x_find < beginx))
 	search_last_line = 1;
 
     /* Make sure we haven't passed the end of the string */
-    if (strlen(fileptr->data) + 1 < current_x)
-	current_x--;
+    if (strlen(fileptr->data) < current_x_find)
+	current_x_find--;
 
-    searchstr = &fileptr->data[current_x];
+    searchstr = &fileptr->data[current_x_find];
 
     /* Look for needle in searchstr */
     while ((found = strstrwrapper(searchstr, needle)) == NULL) {
 
 	/* finished processing file, get out */
 	if (search_last_line) {
-	    if (!quiet) {
+	    if (!quiet)
 		not_found_msg(needle);
-		current_x--;
-	    }
 	    return NULL;
 	}
 
@@ -260,10 +258,8 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
 
     /* Ensure we haven't wrap around again! */
     if ((search_last_line) && (current_x >= beginx)) {
-	if (!quiet) { 
+	if (!quiet)
 	    not_found_msg(needle);
-	    current_x--;
-	}
 	return NULL;
     }
 
-- 
GitLab