From owner-svn-src-user@FreeBSD.ORG Thu Aug 18 15:13:09 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 1AC2A106566C; Thu, 18 Aug 2011 15:13:09 +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 E524A8FC08; Thu, 18 Aug 2011 15:13:08 +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 p7IFD8Bs062379; Thu, 18 Aug 2011 15:13:08 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7IFD8OU062377; Thu, 18 Aug 2011 15:13:08 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108181513.p7IFD8OU062377@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 18 Aug 2011 15:13:08 +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: r224970 - 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: Thu, 18 Aug 2011 15:13:09 -0000 Author: gabor Date: Thu Aug 18 15:13:08 2011 New Revision: 224970 URL: http://svn.freebsd.org/changeset/base/224970 Log: - Add REG_STARTEND support 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 Thu Aug 18 15:12:39 2011 (r224969) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Aug 18 15:13:08 2011 (r224970) @@ -162,14 +162,39 @@ tre_fastfree(fastmatch_t *preg) tre_free_fast(preg); } +/* XXX: avoid duplication */ +#define ADJUST_OFFSETS \ + { \ + size_t slen = (size_t)(pmatch[0].rm_eo - pmatch[0].rm_so); \ + size_t offset = pmatch[0].rm_so; \ + int ret; \ + \ + if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) \ + return REG_NOMATCH; \ + if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ + return REG_NOMATCH; \ + ret = tre_match_fast(preg, &string[offset], slen, type, nmatch, \ + pmatch, eflags); \ + for (unsigned i = 0; (i == 0) || (!(eflags & REG_NOSUB) && \ + (i < nmatch)); i++) \ + { \ + pmatch[i].rm_so += offset; \ + pmatch[i].rm_eo += offset; \ + } \ + return ret; \ + } + int -tre_fastnexec(const fastmatch_t *preg, const char *string, size_t n, +tre_fastnexec(const fastmatch_t *preg, const char *string, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) { tre_str_type_t type = (TRE_MB_CUR_MAX == 1) ? STR_BYTE : STR_MBS; - return tre_match_fast(preg, string, n, type, nmatch, - pmatch, eflags); + if (eflags & REG_STARTEND) + ADJUST_OFFSETS + else + return tre_match_fast(preg, string, len, type, nmatch, + pmatch, eflags); } int @@ -180,11 +205,16 @@ tre_fastexec(const fastmatch_t *preg, co } int -tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t n, +tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) { - return tre_match_fast(preg, string, n, STR_WIDE, nmatch, - pmatch, eflags); + tre_str_type_t type = STR_WIDE; + + if (eflags & REG_STARTEND) + ADJUST_OFFSETS + else + return tre_match_fast(preg, string, len, type, nmatch, + pmatch, eflags); } int