From c1049aced1c11de996a050bd68e8c385b0bef154 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Fri, 17 Aug 2001 00:03:46 +0000
Subject: [PATCH] Add and fix bugs #63 and 64

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@744 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 BUGS      |  6 +++++-
 ChangeLog |  5 +++++
 nano.c    |  1 +
 nano.h    |  1 +
 nano.info |  8 ++++----
 search.c  | 19 ++++++++-----------
 winio.c   |  6 ++----
 7 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/BUGS b/BUGS
index 9db3c859..2cbaa7d0 100644
--- a/BUGS
+++ b/BUGS
@@ -117,7 +117,11 @@
 - Blank lines are not kept when cutting with -k (discovered by Rocco)
   (61) [FIXED].
 - Nano will not suspend properly inside of mutt (62) [FIXED].
-
+- When switching from Pico mode to normal mode, the previous search is
+  not displayed until cancelling the search (63) [FIXED].
+- If you change search options but don't change the search string in
+  normal mode, hitting  enter causes the search/replace to abort (64)
+  (Jordi Mallach) [FIXED].
 
 ** Open BUGS **
 
diff --git a/ChangeLog b/ChangeLog
index b43e15cb..8fa5fcdc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
 CVS code -
+- General
+	- Added BUGS #63 & 64.  Fixes in search_init() and nanogetstr(),
+	  new flag CLEAR_BACKUPSTRING because there's no easy way to
+	  clear the backupstring without making it global (messy), so we
+	  use a flag instead (just as messy?)
 - nano.texi:
 	-corrected the Mouse Toggle section, noticed by Daniel Bonniot.
 
diff --git a/nano.c b/nano.c
index 6d5c34c6..1357b616 100644
--- a/nano.c
+++ b/nano.c
@@ -2274,6 +2274,7 @@ void do_toggle(int which)
     switch (toggles[which].val) {
     case TOGGLE_PICOMODE_KEY:
 	shortcut_init(0);
+	SET(CLEAR_BACKUPSTRING);
 	display_main_list();
 	break;
     case TOGGLE_SUSPEND_KEY:
diff --git a/nano.h b/nano.h
index 8ff945a3..d6914897 100644
--- a/nano.h
+++ b/nano.h
@@ -140,6 +140,7 @@ typedef struct rcoption {
 #define DISABLE_CURPOS         	(1<<18)
 #define REVERSE_SEARCH		(1<<19)
 #define MULTIBUFFER		(1<<20)
+#define CLEAR_BACKUPSTRING	(1<<21)
 
 /* Control key sequences, changing these would be very very bad */
 
diff --git a/nano.info b/nano.info
index 55309cd2..8a3406f7 100644
--- a/nano.info
+++ b/nano.info
@@ -258,7 +258,7 @@ following toggles are available:
 `Cut To End Toggle (Meta-K)'
      toggles the -k (-cut) command line flag.
 
-`Cut To End Toggle (Meta-M)'
+`Mouse Toggle (Meta-M)'
      toggles the -m (-mouse) command line flag.
 
 `Pico Mode Toggle (Meta-P)'
@@ -404,8 +404,8 @@ Node: The Statusbar6367
 Node: Shortcut Lists6948
 Node: Online Help7341
 Node: Feature Toggles7717
-Node: The File Browser8860
-Node: Pico Compatibility9569
-Node: Building and Configure Options11611
+Node: The File Browser8855
+Node: Pico Compatibility9564
+Node: Building and Configure Options11606
 
 End Tag Table
diff --git a/search.c b/search.c
index 8a2dd430..0145fb16 100644
--- a/search.c
+++ b/search.c
@@ -85,6 +85,14 @@ int search_init(int replacing)
     buf = charalloc(strlen(last_search) + 5);
     buf[0] = 0;
 
+
+    /* Clear the backupstring if we've changed from Pico mode to regular
+	mode */
+    if (ISSET(CLEAR_BACKUPSTRING)) {
+	free(backupstring);
+	backupstring = NULL;
+    }
+	
      /* 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
@@ -183,17 +191,6 @@ int search_init(int replacing)
     case NANO_OTHERSEARCH_KEY:
 	backupstring = mallocstrcpy(backupstring, answer);
 	return -2;		/* Call the opposite search function */
-/*
-    } else if (i == NANO_REVERSESEARCH_KEY) {
-	free(backupstring);
-	backupstring = NULL;
-	backupstring = mallocstrcpy(backupstring, answer);
-
-	TOGGLE(REVERSE_SEARCH);
-
-	return 1;
-    } else if (i == NANO_FROMSEARCHTOGOTO_KEY) {
-*/
     case NANO_FROMSEARCHTOGOTO_KEY:
 	free(backupstring);
 	backupstring = NULL;
diff --git a/winio.c b/winio.c
index 3181c86d..f96e563d 100644
--- a/winio.c
+++ b/winio.c
@@ -499,10 +499,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
     answer = mallocstrcpy(answer, inputbuf);
     free(inputbuf);
 
-    /* Now that the text is editable instead of bracketed, we have to 
-       check for answer == def, instead of answer == "" */
-    if  (((ISSET(PICO_MODE)) && !strcmp(answer, "")) || 
-	((!ISSET(PICO_MODE)) && !strcmp(answer, def)))
+    /* In pico mode, just check for a blank answer here */
+    if  (((ISSET(PICO_MODE)) && !strcmp(answer, "")))
 	return -2;
     else
 	return 0;
-- 
GitLab