emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master e097826 5/6: Remove always-0 struct re_pattern_buff


From: Paul Eggert
Subject: [Emacs-diffs] master e097826 5/6: Remove always-0 struct re_pattern_buffer members
Date: Sun, 5 Aug 2018 22:36:19 -0400 (EDT)

branch: master
commit e097826f8972c78577d1d5a14389ec8e888be1b7
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Remove always-0 struct re_pattern_buffer members
    
    * src/regex-emacs.h (struct re_pattern_buffer):
    Remove no_sub, not_bol, not_eol.  They are always zero.
    All uses removed, and code simplified.
---
 src/regex-emacs.c | 42 +++++++++++-------------------------------
 src/regex-emacs.h | 15 ++-------------
 2 files changed, 13 insertions(+), 44 deletions(-)

diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 1ceb67a..b944fe0 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -762,9 +762,6 @@ print_compiled_pattern (struct re_pattern_buffer *bufp)
   printf ("re_nsub: %zu\t", bufp->re_nsub);
   printf ("regs_alloc: %d\t", bufp->regs_allocated);
   printf ("can_be_null: %d\t", bufp->can_be_null);
-  printf ("no_sub: %d\t", bufp->no_sub);
-  printf ("not_bol: %d\t", bufp->not_bol);
-  printf ("not_eol: %d\t", bufp->not_eol);
 #ifndef emacs
   printf ("syntax: %lx\n", bufp->syntax);
 #endif
@@ -1683,7 +1680,6 @@ static bool group_in_compile_stack (compile_stack_type, 
regnum_t);
      `used' is set to the length of the compiled pattern;
      `fastmap_accurate' is zero;
      `re_nsub' is the number of subexpressions in PATTERN;
-     `not_bol' and `not_eol' are zero;
 
    The `fastmap' field is neither examined nor set.  */
 
@@ -1787,7 +1783,6 @@ regex_compile (re_char *pattern, size_t size,
 
   /* Initialize the pattern buffer.  */
   bufp->fastmap_accurate = 0;
-  bufp->not_bol = bufp->not_eol = 0;
   bufp->used_syntax = 0;
 
   /* Set `used' to zero, so that if we return an error, the pattern
@@ -1795,7 +1790,6 @@ regex_compile (re_char *pattern, size_t size,
      at the end.  */
   bufp->used = 0;
 
-  /* Always count groups, whether or not bufp->no_sub is set.  */
   bufp->re_nsub = 0;
 
   if (bufp->allocated == 0)
@@ -3841,9 +3835,8 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
    and SIZE2, respectively).  We start matching at POS, and stop
    matching at STOP.
 
-   If REGS is non-null and the `no_sub' field of BUFP is nonzero, we
-   store offsets for the substring each group matched in REGS.  See the
-   documentation for exactly how many groups we fill.
+   If REGS is non-null, store offsets for the substring each group
+   matched in REGS.
 
    We return -1 if no match, -2 if an internal error (such as the
    failure stack overflowing).  Otherwise, we return the length of the
@@ -4130,7 +4123,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
          DEBUG_PRINT ("Accepting match.\n");
 
          /* If caller wants register contents data back, do it.  */
-         if (regs && !bufp->no_sub)
+         if (regs)
            {
              /* Have the register data arrays been allocated?  */
              if (bufp->regs_allocated == REGS_UNALLOCATED)
@@ -4185,7 +4178,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                 -1 at the end.  */
              for (reg = num_regs; reg < regs->num_regs; reg++)
                regs->start[reg] = regs->end[reg] = -1;
-           } /* regs && !bufp->no_sub */
+           }
 
          DEBUG_PRINT ("%u failure points pushed, %u popped (%u remain).\n",
                       nfailure_points_pushed, nfailure_points_popped,
@@ -4482,15 +4475,13 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
          break;
 
 
-       /* begline matches the empty string at the beginning of the string
-          (unless `not_bol' is set in `bufp'), and after newlines.  */
+       /* begline matches the empty string at the beginning of the string,
+          and after newlines.  */
        case begline:
          DEBUG_PRINT ("EXECUTING begline.\n");
 
          if (AT_STRINGS_BEG (d))
-           {
-             if (!bufp->not_bol) break;
-           }
+           break;
          else
            {
              unsigned c;
@@ -4498,7 +4489,6 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
              if (c == '\n')
                break;
            }
-         /* In all other cases, we fail.  */
          goto fail;
 
 
@@ -4507,15 +4497,10 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
          DEBUG_PRINT ("EXECUTING endline.\n");
 
          if (AT_STRINGS_END (d))
-           {
-             if (!bufp->not_eol) break;
-           }
-         else
-           {
-             PREFETCH_NOLIMIT ();
-             if (*d == '\n')
-               break;
-           }
+           break;
+         PREFETCH_NOLIMIT ();
+         if (*d == '\n')
+           break;
          goto fail;
 
 
@@ -5113,11 +5098,6 @@ re_compile_pattern (const char *pattern, size_t length,
      (and at least one extra will be -1).  */
   bufp->regs_allocated = REGS_UNALLOCATED;
 
-  /* And GNU code determines whether or not to get register information
-     by passing null for the REGS argument to re_search, etc., not by
-     setting no_sub.  */
-  bufp->no_sub = 0;
-
   ret = regex_compile ((re_char *) pattern, length,
                       posix_backtracking,
                       whitespace_regexp,
diff --git a/src/regex-emacs.h b/src/regex-emacs.h
index 159c7dc..b6dd26b 100644
--- a/src/regex-emacs.h
+++ b/src/regex-emacs.h
@@ -59,7 +59,7 @@ extern ptrdiff_t emacs_re_safe_alloca;
 
 /* This data structure represents a compiled pattern.  Before calling
    the pattern compiler, the fields `buffer', `allocated', `fastmap',
-   `translate', and `no_sub' can be set.  After the pattern has been
+   and `translate' can be set.  After the pattern has been
    compiled, the `re_nsub' field is available.  All other fields are
    private to the regex routines.  */
 
@@ -109,17 +109,6 @@ struct re_pattern_buffer
            by `re_compile_fastmap' if it updates the fastmap.  */
   unsigned fastmap_accurate : 1;
 
-        /* If set, `re_match_2' does not return information about
-           subexpressions.  */
-  unsigned no_sub : 1;
-
-        /* If set, a beginning-of-line anchor doesn't match at the
-           beginning of the string.  */
-  unsigned not_bol : 1;
-
-        /* Similarly for an end-of-line anchor.  */
-  unsigned not_eol : 1;
-
   /* If true, the compilation of the pattern had to look up the syntax table,
      so the compiled pattern is only valid for the current syntax table.  */
   unsigned used_syntax : 1;
@@ -148,7 +137,7 @@ extern const char *re_compile_pattern (const char *pattern, 
size_t length,
    compiled into BUFFER.  Start searching at position START, for RANGE
    characters.  Return the starting position of the match, -1 for no
    match, or -2 for an internal error.  Also return register
-   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
+   information in REGS (if REGS is nonzero).  */
 extern ptrdiff_t re_search (struct re_pattern_buffer *buffer,
                           const char *string, size_t length,
                           ptrdiff_t start, ptrdiff_t range,



reply via email to

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