From owner-svn-src-user@FreeBSD.ORG Sun Aug 14 20:54:14 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 4A002106566B; Sun, 14 Aug 2011 20:54:14 +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 DC92A8FC0C; Sun, 14 Aug 2011 20:54:13 +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 p7EKsD6J079321; Sun, 14 Aug 2011 20:54:13 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7EKsDpV079319; Sun, 14 Aug 2011 20:54:13 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108142054.p7EKsDpV079319@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 14 Aug 2011 20:54:13 +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: r224869 - 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 20:54:14 -0000 Author: gabor Date: Sun Aug 14 20:54:13 2011 New Revision: 224869 URL: http://svn.freebsd.org/changeset/base/224869 Log: - Fix word boundary matching for the remaining case Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 16:17:00 2011 (r224868) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Aug 14 20:54:13 2011 (r224869) @@ -459,29 +459,26 @@ tre_fastcomp(fastmatch_t *fg, const tre_ continue; \ } +#define _BBOUND_COND \ + ((type == STR_WIDE) ? \ + ((j == 0) || !(tre_isalnum(str_wide[j - 1]) || \ + (str_wide[j - 1] == TRE_CHAR('_')))) : \ + ((j == 0) || !(tre_isalnum(str_byte[j - 1]) || \ + (str_byte[j - 1] == '_')))) + +#define _EBOUND_COND \ + ((type == STR_WIDE) ? \ + ((j + fg->wlen == len) || !(tre_isalnum(str_wide[j + fg->wlen]) || \ + (str_wide[j + fg->wlen] == TRE_CHAR('_')))) : \ + ((j + fg->len == len) || !(tre_isalnum(str_byte[j + fg->len]) || \ + (str_byte[j + fg->len] == '_')))) + +#define IS_ON_WORD_BOUNDARY \ + (_BBOUND_COND && _EBOUND_COND) + #define CHECK_WORD_BOUNDARY \ - { \ - bool bbound, ebound; \ - \ - switch (type) \ - { \ - case STR_WIDE: \ - bbound = (j == 0) || !(tre_isalnum(str_wide[j - 1]) || \ - (str_wide[j - 1] == TRE_CHAR('_'))); \ - ebound = (j + fg->wlen == len) || \ - !(tre_isalnum(str_wide[j + fg->wlen]) || \ - (str_wide[j + fg->wlen] == TRE_CHAR('_'))); \ - break; \ - default: \ - bbound = (j == 0) || !(tre_isalnum(str_byte[j - 1]) || \ - (str_byte[j - 1] == '_')); \ - ebound = (j + fg->len == len) || \ - !(tre_isalnum(str_byte[j + fg->len]) || \ - (str_byte[j + fg->len] == '_')); \ - } \ - if (!bbound || !ebound) \ - _SHIFT_ONE; \ - } + if (!IS_ON_WORD_BOUNDARY) \ + _SHIFT_ONE; #define _BOL_COND \ ((j == 0) || ((type == STR_WIDE) ? tre_isspace(str_wide[j - 1]) : \ @@ -540,7 +537,6 @@ tre_fastexec(const fastmatch_t *fg, cons shift = fg->len; } - /* XXX: Fix with word boundaries */ /* Only try once at the beginning or ending of the line. */ if (!fg->newline && (fg->bol || fg->eol)) { @@ -554,6 +550,8 @@ tre_fastexec(const fastmatch_t *fg, cons COMPARE; if (mismatch == REG_OK) { + 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); return REG_OK;