texinfo-commits
[Top][All Lists]
Advanced

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

[6185] info zero-length search matches


From: Gavin D. Smith
Subject: [6185] info zero-length search matches
Date: Mon, 09 Mar 2015 19:34:11 +0000

Revision: 6185
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6185
Author:   gavin
Date:     2015-03-09 19:34:10 +0000 (Mon, 09 Mar 2015)
Log Message:
-----------
info zero-length search matches

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-03-09 19:08:16 UTC (rev 6184)
+++ trunk/ChangeLog     2015-03-09 19:34:10 UTC (rev 6185)
@@ -1,5 +1,11 @@
 2015-03-09  Gavin Smith  <address@hidden>
 
+       * info/search.c (regexp_search): Permit zero-length matches, so 
+       that "^" doesn't search through entire file.  Pass REG_NOTBOL 
+       flag to regexec.
+
+2015-03-09  Gavin Smith  <address@hidden>
+
        * info/info-utils.c (parse_top_node_line): Check for 
        INFO_ALTPREV_LABEL, as was done before.
 

Modified: trunk/info/search.c
===================================================================
--- trunk/info/search.c 2015-03-09 19:08:16 UTC (rev 6184)
+++ trunk/info/search.c 2015-03-09 19:34:10 UTC (rev 6185)
@@ -175,27 +175,25 @@
       int result = 0;
       regmatch_t m;
 
-      result = regexec (&preg, &buffer[offset], 1, &m, 0);
+      result = regexec (&preg, &buffer[offset], 1, &m, REG_NOTBOL);
       if (result == 0)
         {
-          if (m.rm_eo == 0)
-            offset++; /* Ignore empty matches. */
-          else
+          if (match_count == match_alloc)
             {
-              if (match_count == match_alloc)
-                {
-                  /* The match list is full. */
-                  if (match_alloc == 0)
-                    match_alloc = 50;
-                  matches = x2nrealloc
-                    (matches, &match_alloc, sizeof matches[0]);
-                }
-
-              matches[match_count] = m;
-              matches[match_count].rm_so += offset;
-              matches[match_count].rm_eo += offset;
-              offset = matches[match_count++].rm_eo;
+              /* The match list is full. */
+              if (match_alloc == 0)
+                match_alloc = 50;
+              matches = x2nrealloc
+                (matches, &match_alloc, sizeof matches[0]);
             }
+
+          matches[match_count] = m;
+          matches[match_count].rm_so += offset;
+          matches[match_count].rm_eo += offset;
+          offset = matches[match_count++].rm_eo;
+
+          if (m.rm_eo == 0)
+            offset++; /* Avoid finding match again for a pattern of "$". */
         }
       else
         break;




reply via email to

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