texinfo-commits
[Top][All Lists]
Advanced

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

[7714] match_in_match_list direction argument


From: gavinsmith0123
Subject: [7714] match_in_match_list direction argument
Date: Tue, 11 Apr 2017 02:40:52 -0400 (EDT)

Revision: 7714
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7714
Author:   gavin
Date:     2017-04-11 02:40:52 -0400 (Tue, 11 Apr 2017)
Log Message:
-----------
match_in_match_list direction argument

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-04-09 19:43:24 UTC (rev 7713)
+++ trunk/ChangeLog     2017-04-11 06:40:52 UTC (rev 7714)
@@ -1,3 +1,12 @@
+2017-04-11  Gavin Smith  <address@hidden>
+
+       * info/session.c (match_in_match_list): Take a argument to say
+       which direction to search in, instead of using the order of the
+       start and end arguments.
+       (info_search_in_node_internal): Update, and make sure that both
+       the start and end of the search area are after the 'body_start'
+       of the node.
+
 2017-04-09  Gavin Smith  <address@hidden>
 
        * info/search.c (match_in_match_list): Use helper functions

Modified: trunk/info/search.c
===================================================================
--- trunk/info/search.c 2017-04-09 19:43:24 UTC (rev 7713)
+++ trunk/info/search.c 2017-04-11 06:40:52 UTC (rev 7714)
@@ -414,35 +414,19 @@
 /*                                                                  */
 /* **************************************************************** */
 /* Search forwards or backwards for entries in MATCHES that start within
-   the search area.  The search is forwards if START_IN is greater than
-   END_IN.  Return index of match in *MATCH_INDEX. */
+   the search area.  The search is forwards if DIR > 0, backward if
+   DIR < 0.  Return index of match in *MATCH_INDEX. */
 enum search_result
 match_in_match_list (MATCH_STATE *match_state,
-                     long start_in, long end_in, int *match_index)
+                     long start, long end, int dir,
+                     int *match_index)
 {
   regmatch_t *matches = match_state->matches;
   size_t match_count = match_state->match_count;
-  int searching_backwards = 0;
+
   int i;
   int index = -1;
 
-  regoff_t start, end;
-  if (start_in < end_in)
-    {
-      start = start_in;
-      end = end_in;
-    }
-  else
-    {
-      /* Include the byte with offset 'start_in' in our range, but not
-         the byte with offset 'end_in'. */
-      start = end_in - 1;
-      end = start_in + 1;
-    }
-  
-  if (start_in > end_in)
-    searching_backwards = 1;
-
   for (i = 0; i < match_count || !match_state->finished; i++)
     {
       /* get more matches as we need them */
@@ -457,12 +441,12 @@
         }
 
       if (matches[i].rm_so >= end)
-        break; /* No matches found in search area. */
+        break; /* No  more matches found in search area. */
 
       if (matches[i].rm_so >= start)
         {
           index = i;
-          if (!searching_backwards)
+          if (dir > 0)
             {
               *match_index = index;
               return search_success;

Modified: trunk/info/search.h
===================================================================
--- trunk/info/search.h 2017-04-09 19:43:24 UTC (rev 7713)
+++ trunk/info/search.h 2017-04-11 06:40:52 UTC (rev 7714)
@@ -85,7 +85,7 @@
 
 regmatch_t match_by_index (MATCH_STATE *state, int index);
 enum search_result match_in_match_list (MATCH_STATE *state,
-                     long start_in, long end_in, int *match_index);
+                     long start, long end, int dir, int *match_index);
 
 void free_matches (MATCH_STATE *state);
 int matches_ready (MATCH_STATE *state);

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2017-04-09 19:43:24 UTC (rev 7713)
+++ trunk/info/session.c        2017-04-11 06:40:52 UTC (rev 7714)
@@ -3979,19 +3979,21 @@
 
   if (dir > 0)
     {
-      if (start >= node->body_start)
-        start1 = start;
-      else
-        start1 = node->body_start;
+      start1 = start;
       end1 = node->nodelen;
     }
   else
     {
-      start1 = start;
-      end1 = node->body_start;
+      start1 = 0;
+      end1 = start + 1; /* include start byte in search area */
     }
+
+  if (start1 < node->body_start)
+    start1 = node->body_start;
+  if (end1 < node->body_start)
+    end1 = node->body_start;
   
-  result = match_in_match_list (&matches, start1, end1, &match_index);
+  result = match_in_match_list (&matches, start1, end1, dir, &match_index);
   if (result != search_success)
     return result;
 




reply via email to

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