From 74bb31b15a603b270eb3ad47d0ff4ab615eeba10 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Wed, 14 Mar 2001 09:08:14 +0000
Subject: [PATCH] Fix BUG #56 found on SourceForge

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@559 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 BUGS      |  2 ++
 ChangeLog |  4 ++++
 search.c  | 11 ++++++++---
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/BUGS b/BUGS
index 8bd13b50..a3412e8a 100644
--- a/BUGS
+++ b/BUGS
@@ -99,6 +99,8 @@
   higuita@cadernoverde.com) (54) [FIXED].
 - When using autoindent (-i), wrapped text does not get auto-indented
   (55, discovered by Mark Senior) [FIXED].
+- When using -R (regex) and -p (pico mode), subsequent searches after
+  the first fail if no string is entered (56) [FIXED].
 
 ** Open BUGS **
 
diff --git a/ChangeLog b/ChangeLog
index 71d5dc2f..1b5565ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,11 @@ CVS code -
 	- Added SAMELINE case to above.  Added checks to cases 1b and
 	  2b for placement of cursor.
 - search.c:
+  print_replaced()
 	- s/occurence/occurrence typos (Jordi).
+  search_init()
+	- If using Pico mode and regex and same answer is entered, use
+	  last_search string instead of answer (fixes BUG #56).
 - nano.texi:
 	- Meta-Z correction and grammar in --enable-tiny desc (Neil Parks).
 
diff --git a/search.c b/search.c
index fb59b523..041e7740 100644
--- a/search.c
+++ b/search.c
@@ -81,7 +81,6 @@ int search_init(int replacing)
     buf = nmalloc(strlen(last_search) + 5);
     buf[0] = 0;
 
-
      /* Okay, fun time.  backupstring is our holder for what is being 
 	returned from the statusq call.  Using answer for this would be tricky.
 	Here, if we're using PICO_MODE, we only want nano to put the
@@ -140,8 +139,14 @@ int search_init(int replacing)
 	return -1;
     } else if (i == -2) {	/* Same string */
 #ifdef HAVE_REGEX_H
-	if (ISSET(USE_REGEXP))
-	    regexp_init(answer);
+	if (ISSET(USE_REGEXP)) {
+
+	    /* If we're in pico mode, answer is "", use last_search! */
+	    if (ISSET(PICO_MODE))
+		regexp_init(last_search);
+	    else
+		regexp_init(answer);
+	}
 #else
 	;
 #endif
-- 
GitLab