texinfo-commits
[Top][All Lists]
Advanced

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

[5756] don't ask for search string in info_search_1


From: Gavin D. Smith
Subject: [5756] don't ask for search string in info_search_1
Date: Sun, 17 Aug 2014 19:00:33 +0000

Revision: 5756
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5756
Author:   gavin
Date:     2014-08-17 19:00:32 +0000 (Sun, 17 Aug 2014)
Log Message:
-----------
don't ask for search string in info_search_1

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-08-17 17:28:29 UTC (rev 5755)
+++ trunk/ChangeLog     2014-08-17 19:00:32 UTC (rev 5756)
@@ -1,5 +1,15 @@
 2014-08-17  Gavin Smith  <address@hidden>
 
+       * info/session.c (info_search_1): Argument removed.  Don't call
+       ask_for_search_string.
+       (info_search_case_sensitively, info_search, info_search_backward): Do
+       it here instead.
+       (ask_for_search_string): Don't display "[]" in prompt if no previous
+       search string.  Check if search string is too long here instead of in
+       info_search_1.
+
+2014-08-17  Gavin Smith  <address@hidden>
+
        * info/session.c (incremental_search): Use same call to
        info_search_internal for both regex and non-regex searches.
 

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-08-17 17:28:29 UTC (rev 5755)
+++ trunk/info/session.c        2014-08-17 19:00:32 UTC (rev 5756)
@@ -3397,7 +3397,7 @@
 int gc_compressed_files = 0;
 
 static void info_search_1 (WINDOW *window, int count, int case_sensitive,
-                          int ask_for_string, long start);
+                          long start);
 #define DFL_START (-1) /* a special value for the START argument of
                          info_search_1, meaning to use the default
                          starting position */
@@ -3741,49 +3741,25 @@
   return -1;
 }
 
-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;
-  info_search_1 (window, count, 1, 1, DFL_START);
-}
-
-DECLARE_INFO_COMMAND (info_search, _("Read a string and search for it"))
-{
-  last_search_direction = count > 0 ? 1 : -1;
-  last_search_case_sensitive = 0;
-  info_search_1 (window, count, 0, 1, DFL_START);
-}
-
-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;
-  info_search_1 (window, -count, 0, 1, DFL_START);
-}
-
 /* Read a string from the user. */
 static int
-ask_for_search_string (char **search_string_out, int case_sensitive,
-                       int use_regex, int direction, WINDOW *window)
+ask_for_search_string (int case_sensitive, int use_regex,
+                       int direction, WINDOW *window)
 {
   char *line, *prompt;
-  char *search_string = *search_string_out;
 
-  prompt = xmalloc (strlen (_("%s%s%s [%s]: "))
-                    + strlen (_("Regexp search"))
-                    + strlen (_(" case-sensitively"))
-                    + strlen (_(" backward"))
-                    + strlen (search_string));
+  if (search_string)
+    asprintf (&prompt, _("%s%s%s [%s]: "),
+             use_regex ? _("Regexp search") : _("Search"),
+             case_sensitive ? _(" case-sensitively") : "",
+             direction < 0 ? _(" backward") : "",
+             search_string);
+  else
+    asprintf (&prompt, _("%s%s%s: "),
+             use_regex ? _("Regexp search") : _("Search"),
+             case_sensitive ? _(" case-sensitively") : "",
+             direction < 0 ? _(" backward") : "");
 
-  sprintf (prompt, _("%s%s%s [%s]: "),
-           use_regex ? _("Regexp search") : _("Search"),
-           case_sensitive ? _(" case-sensitively") : "",
-           direction < 0 ? _(" backward") : "",
-           search_string);
-
   line = info_read_in_echo_area (window, prompt);
   free (prompt);
 
@@ -3803,7 +3779,13 @@
       strcpy (search_string, line);
       free (line);
     }
-  *search_string_out = search_string;
+
+  if (mbslen (search_string) < min_search_length)
+    {
+      info_error ("%s", _("Search string too short"));
+      return;
+    }
+
   return 1;
 }
 
@@ -3813,15 +3795,12 @@
                     direction (negative for searching backwards);
                    its absolute value gives number of repetitions.
    CASE_SENSITIVE   Whether the search is case-sensitive or not.
-   ASK_FOR_STRING   When true, ask for the search string.  Otherwise
-                    use the previously supplied one (repeated search).
    START            Start position for the search.  If DFL_START, start
                     at window point + direction (see info_search_internal
                    for details).
 */
 static void
-info_search_1 (WINDOW *window, int count, int case_sensitive,
-               int ask_for_string, long start)
+info_search_1 (WINDOW *window, int count, int case_sensitive, long start)
 {
   int result, old_pagetop;
   int direction;
@@ -3851,20 +3830,6 @@
       search_string[0] = '\0';
     }
 
-  if (ask_for_string)
-    {
-      int success = ask_for_search_string (&search_string, case_sensitive,
-                                           use_regex, direction, window);
-      if (!success)
-        return;
-    }
-
-  if (mbslen (search_string) < min_search_length)
-    {
-      info_error ("%s", _("Search string too short"));
-      return;
-    }
-
   /* If the search string includes upper-case letters, make the search
      case-sensitive.  */
   if (case_sensitive == 0)
@@ -3897,6 +3862,41 @@
   gc_file_buffers_and_nodes ();
 }
 
+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, window))
+    return;
+
+  info_search_1 (window, count, 1, DFL_START);
+}
+
+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, window))
+    return;
+
+  info_search_1 (window, count, 0, DFL_START);
+}
+
+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, window))
+    return;
+
+  info_search_1 (window, -count, 0, DFL_START);
+}
+
 int search_skip_screen_p = 0;
 
 DECLARE_INFO_COMMAND (info_search_next,
@@ -3913,11 +3913,11 @@
       else
        n = window->node->nodelen;
       info_search_1 (window, last_search_direction * count,
-                    last_search_case_sensitive, 0, n);
+                    last_search_case_sensitive, n);
     }
   else
     info_search_1 (window, last_search_direction * count,
-                   last_search_case_sensitive, 0, DFL_START);
+                   last_search_case_sensitive, DFL_START);
 }
 
 DECLARE_INFO_COMMAND (info_search_previous,
@@ -3934,11 +3934,11 @@
       if (n < 0)
        n = 0;
       info_search_1 (window, -last_search_direction * count,
-                    last_search_case_sensitive, 0, n);
+                    last_search_case_sensitive, n);
     }
   else
     info_search_1 (window, -last_search_direction * count,
-                   last_search_case_sensitive, 0, DFL_START);
+                   last_search_case_sensitive, DFL_START);
 }
 
 




reply via email to

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