Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Aug 2011 23:25:06 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r225302 - in user/gabor/tre-integration: contrib/tre/lib include
Message-ID:  <201108312325.p7VNP69M021730@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Wed Aug 31 23:25:06 2011
New Revision: 225302
URL: http://svn.freebsd.org/changeset/base/225302

Log:
  - Actually leave pmatch untouched if REG_NOSUB is passed to regcomp()

Modified:
  user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c
  user/gabor/tre-integration/include/fastmatch.h

Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c
==============================================================================
--- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c	Wed Aug 31 23:20:00 2011	(r225301)
+++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c	Wed Aug 31 23:25:06 2011	(r225302)
@@ -384,6 +384,7 @@ static int	fastcmp(const void *, const v
   fg->icase = (cflags & REG_ICASE);					\
   fg->word = (cflags & REG_WORD);					\
   fg->newline = (cflags & REG_NEWLINE);					\
+  fg->nosub = (cflags & REG_NOSUB);					\
 									\
   if (n == 0)								\
     {									\
@@ -602,8 +603,11 @@ tre_match_fast(const fastmatch_t *fg, co
 
   if (fg->matchall)
     {
-      pmatch[0].rm_so = 0;
-      pmatch[0].rm_eo = len;
+      if (!fg->nosub)
+	{
+	  pmatch[0].rm_so = 0;
+	  pmatch[0].rm_eo = len;
+	}
       return REG_OK;
     }
 
@@ -651,8 +655,11 @@ tre_match_fast(const fastmatch_t *fg, co
 	    {
 	      if (fg->word && !IS_ON_WORD_BOUNDARY)
 		return ret;
-	      pmatch[0].rm_so = j;
-	      pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len);
+	      if (!fg->nosub)
+		{
+		  pmatch[0].rm_so = j;
+		  pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len);
+		}
 	      return REG_OK;
             }
         }
@@ -672,8 +679,11 @@ tre_match_fast(const fastmatch_t *fg, co
 		CHECK_BOL_ANCHOR;
 	      if (fg->eol)
 		CHECK_EOL_ANCHOR;
-	      pmatch[0].rm_so = j;
-	      pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len);
+	      if (!fg->nosub)
+		{
+		  pmatch[0].rm_so = j;
+		  pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len);
+		}
 	      return REG_OK;
 	    }
 	  else if (mismatch > 0)

Modified: user/gabor/tre-integration/include/fastmatch.h
==============================================================================
--- user/gabor/tre-integration/include/fastmatch.h	Wed Aug 31 23:20:00 2011	(r225301)
+++ user/gabor/tre-integration/include/fastmatch.h	Wed Aug 31 23:25:06 2011	(r225302)
@@ -27,6 +27,7 @@ typedef struct {
   bool		 word;
   bool		 icase;
   bool		 newline;
+  bool		 nosub;
   bool		 matchall;
 } fastmatch_t;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108312325.p7VNP69M021730>