texinfo-commits
[Top][All Lists]
Advanced

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

[5781] make sure error message for invalid regex is shown


From: Gavin D. Smith
Subject: [5781] make sure error message for invalid regex is shown
Date: Mon, 25 Aug 2014 16:39:03 +0000

Revision: 5781
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5781
Author:   gavin
Date:     2014-08-25 16:39:01 +0000 (Mon, 25 Aug 2014)
Log Message:
-----------
make sure error message for invalid regex is shown

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-08-25 16:16:44 UTC (rev 5780)
+++ trunk/ChangeLog     2014-08-25 16:39:01 UTC (rev 5781)
@@ -10,6 +10,14 @@
        * info/terminal.c (add_seq_to_byte_map): Take char * argument and cast
        to unsigned char *.
 
+       * info/search.h (enum search_result): Change 'search_failure' value to
+       'search_invalid'.
+       * info/session.c (info_search_in_node_internal): Return value
+       properly.  Don't clobber error message printed for invalid regular
+       expression.
+       (ask_for_search_string): Return value properly.
+       * info/search.c (make_binding): Merged into caller.
+
 2014-08-25  Gavin Smith  <address@hidden>
 
        * info/window.c (set_window_pagetop): If point would end up past

Modified: trunk/info/search.c
===================================================================
--- trunk/info/search.c 2014-08-25 16:16:44 UTC (rev 5780)
+++ trunk/info/search.c 2014-08-25 16:39:01 UTC (rev 5781)
@@ -35,28 +35,16 @@
    They return a long, which is the offset from the start of the buffer
    at which the match was found.  An offset of -1 indicates failure. */
 
-/* A function which makes a binding with buffer and bounds. */
-SEARCH_BINDING *
-make_binding (char *buffer, long int start, long int end)
-{
-  SEARCH_BINDING *binding;
-
-  binding = xmalloc (sizeof (SEARCH_BINDING));
-  binding->buffer = buffer;
-  binding->start = start;
-  binding->end = end;
-  binding->flags = 0;
-
-  return binding;
-}
-
 /* Make a copy of BINDING without duplicating the data. */
 SEARCH_BINDING *
 copy_binding (SEARCH_BINDING *binding)
 {
   SEARCH_BINDING *copy;
 
-  copy = make_binding (binding->buffer, binding->start, binding->end);
+  copy = xmalloc (sizeof (SEARCH_BINDING));
+  copy->buffer = binding->buffer;
+  copy->start = binding->start;
+  copy->end = binding->end;
   copy->flags = binding->flags;
   return copy;
 }
@@ -175,7 +163,7 @@
       char *buf = xmalloc (size);
       regerror (result, &preg, buf, size);
       info_error (_("regexp error: %s"), buf);
-      return search_failure;
+      return search_invalid;
     }
 
   saved_char = buffer[buflen];

Modified: trunk/info/search.h
===================================================================
--- trunk/info/search.h 2014-08-25 16:16:44 UTC (rev 5780)
+++ trunk/info/search.h 2014-08-25 16:39:01 UTC (rev 5781)
@@ -48,10 +48,9 @@
   {
     search_success,             
     search_not_found,
-    search_failure
+    search_invalid
   };
 
-SEARCH_BINDING *make_binding (char *buffer, long int start, long int end);
 SEARCH_BINDING *copy_binding (SEARCH_BINDING *binding);
 extern enum search_result search_forward (char *string,
                                          SEARCH_BINDING *binding, long *poff);

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-08-25 16:16:44 UTC (rev 5780)
+++ trunk/info/session.c        2014-08-25 16:39:01 UTC (rev 5781)
@@ -3561,7 +3561,7 @@
     }
   
   if (result != search_success)
-    return;
+    return result;
 
   if (dir > 0)
     {
@@ -3577,7 +3577,7 @@
       end1 = node->body_start;
     }
   
-  if (result != search_failure)
+  if (result != search_invalid)
     {
       result = match_in_match_list (matches, match_count,
                                     start1, end1, &match_index);
@@ -3675,6 +3675,9 @@
       result = info_search_in_node_internal (window, node, string, start, dir,
                  case_sensitive, use_regex, start_off);
 
+      if (result == search_invalid)
+        return 1;
+
       if (result == search_success)
         {
           if (!echo_area_is_active)
@@ -3801,7 +3804,7 @@
   if (mbslen (search_string) < min_search_length)
     {
       info_error ("%s", _("Search string too short"));
-      return;
+      return 0;
     }
 
   return 1;




reply via email to

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