From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 22:53:03 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26B6E1065675; Sun, 14 Aug 2011 22:53:03 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 163148FC1A; Sun, 14 Aug 2011 22:53:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7EMr2rn082935; Sun, 14 Aug 2011 22:53:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7EMr2hr082931; Sun, 14 Aug 2011 22:53:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108142253.p7EMr2hr082931@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 14 Aug 2011 22:53:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224871 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Aug 2011 22:53:03 -0000 Author: gabor Date: Sun Aug 14 22:53:02 2011 New Revision: 224871 URL: http://svn.freebsd.org/changeset/base/224871 Log: - Implement TRE-specific REG_NOTBOL and REG_NOTEOL - Adjust an older comment Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 20:55:32 2011 (r224870) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 22:53:02 2011 (r224871) @@ -503,9 +503,9 @@ tre_fastcomp(fastmatch_t *fg, const tre_ */ int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, - tre_str_type_t type, int nmatch, regmatch_t pmatch[]) + tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags) { - unsigned int j; + unsigned int j = 0; int ret = REG_NOMATCH; int mismatch, shift, u = 0, v; const char *str_byte = data; @@ -537,8 +537,23 @@ tre_fastexec(const fastmatch_t *fg, cons shift = fg->len; } + /* + * REG_NOTBOL means not anchoring ^ to the beginning of the line, so we + * can shift one because there can't be a match at the beginning. + */ + if (fg->bol && (eflags & REG_NOTBOL)) + j = 1; + + /* + * Like above, we cannot have a match at the very end when anchoring to + * the end and REG_NOTEOL is specified. + */ + if (fg->eol && (eflags & REG_NOTEOL)) + len--; + /* Only try once at the beginning or ending of the line. */ - if (!fg->newline && (fg->bol || fg->eol)) + if ((fg->bol || fg->eol) && !fg->newline && !(eflags & REG_NOTBOL) && + !(eflags & REG_NOTEOL)) { /* Simple text comparison. */ if (!((fg->bol && fg->eol) && @@ -561,7 +576,6 @@ tre_fastexec(const fastmatch_t *fg, cons else { /* Quick Search / Turbo Boyer-Moore algorithm. */ - j = 0; do { SKIP_CHARS(j); Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 20:55:32 2011 (r224870) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Sun Aug 14 22:53:02 2011 (r224871) @@ -62,7 +62,7 @@ int tre_fastcomp_literal(fastmatch_t *pr size_t, int); int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t, int); int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, - tre_str_type_t type, int nmatch, regmatch_t pmatch[]); + tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags); void tre_fastfree(fastmatch_t *preg); #endif /* FASTMATCH_H */ Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 14 20:55:32 2011 (r224870) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 14 22:53:02 2011 (r224871) @@ -156,9 +156,9 @@ tre_match(const tre_tnfa_t *tnfa, const reg_errcode_t status; int *tags = NULL, eo; - /* Check if we can cheat with a fixed string */ + /* Check if we can cheat with a faster algorithm */ if (shortcut != NULL) - return tre_fastexec(shortcut, string, len, type, nmatch, pmatch); + return tre_fastexec(shortcut, string, len, type, nmatch, pmatch, eflags); if (tnfa->num_tags > 0 && nmatch > 0) {