texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5930] accept default search string


From: Gavin D. Smith
Subject: [5930] accept default search string
Date: Sun, 16 Nov 2014 13:48:42 +0000

Revision: 5930
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5930
Author:   gavin
Date:     2014-11-16 13:48:41 +0000 (Sun, 16 Nov 2014)
Log Message:
-----------
accept default search string

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/session.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-11-15 00:06:14 UTC (rev 5929)
+++ trunk/ChangeLog     2014-11-16 13:48:41 UTC (rev 5930)
@@ -1,3 +1,13 @@
+2014-11-16  Gavin Smith  <address@hidden>
+
+       * info/session.c (ask_for_search_string): Return 1 for empty 
+       input, and 0 only when it was aborted.
+       (info_search_case_sensitively, info_search)
+       (info_search_backward): Set last_search_direction and 
+       last_search_case sensitive in info_search_1.  Call 
+       ask_for_search_string in info_search_1.  Perform search if 
+       default search string was accepted.
+
 2014-11-15  Gavin Smith  <address@hidden>
 
        * tp/Texinfo/Convert/Plaintext.pm (_convert) <@quotation with

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-11-15 00:06:14 UTC (rev 5929)
+++ trunk/info/session.c        2014-11-16 13:48:41 UTC (rev 5930)
@@ -3734,8 +3734,6 @@
    to gc even those file buffer contents which had to be uncompressed. */
 int gc_compressed_files = 0;
 
-static void info_search_1 (WINDOW *window, int count, int case_sensitive);
-
 static char *search_string = NULL;
 static int isearch_is_active = 0;
 
@@ -4071,7 +4069,8 @@
 /* Minimal length of a search string */
 int min_search_length = 1;
 
-/* Read a string from the user. */
+/* Read a string from the user, storing the result in SEARCH_STRING.  Return 0 
+   if the user aborted. */
 static int
 ask_for_search_string (int case_sensitive, int use_regex, int direction)
 {
@@ -4092,17 +4091,21 @@
   line = info_read_in_echo_area (prompt);
   free (prompt);
 
-  if (!line || !*line)
+  if (!line) /* User aborted. */
     {
-      free (line);
       return 0;
     }
+  if (!*line)
+    {
+      free (line);
+      return 1;
+    }
 
   if (mbslen (line) < min_search_length)
     {
       info_error ("%s", _("Search string too short"));
       free (line);
-      return 0;
+      return 1;
     }
 
   free (search_string);
@@ -4138,6 +4141,10 @@
         count = 1;      /* for backward compatibility */
     }
 
+  if (!ask_for_search_string (case_sensitive, use_regex, direction)
+      || !search_string)
+    return;
+
   start_off = window->point + direction;
   
   /* If the search string includes upper-case letters, make the search
@@ -4150,6 +4157,9 @@
           break;
         }
 
+  last_search_direction = direction;
+  last_search_case_sensitive = case_sensitive;
+
   for (result = 0; result == 0 && count--; )
     result = info_search_internal (search_string,
                                    active_window, direction, case_sensitive,
@@ -4165,35 +4175,17 @@
 DECLARE_INFO_COMMAND (info_search_case_sensitively,
                       _("Read a string and search for it case-sensitively"))
 {
-  last_search_direction = count > 0 ? 1 : -1;
-  last_search_case_sensitive = 1;
-
-  if (!ask_for_search_string (1, use_regex, count))
-    return;
-
   info_search_1 (window, count, 1);
 }
 
 DECLARE_INFO_COMMAND (info_search, _("Read a string and search for it"))
 {
-  last_search_direction = count > 0 ? 1 : -1;
-  last_search_case_sensitive = 0;
-
-  if (!ask_for_search_string (0, use_regex, count))
-    return;
-
   info_search_1 (window, count, 0);
 }
 
 DECLARE_INFO_COMMAND (info_search_backward,
                       _("Read a string and search backward for it"))
 {
-  last_search_direction = count > 0 ? -1 : 1;
-  last_search_case_sensitive = 0;
-
-  if (!ask_for_search_string (0, use_regex, -count))
-    return;
-
   info_search_1 (window, -count, 0);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]