From owner-svn-src-user@FreeBSD.ORG Tue Feb 14 12:13:05 2012 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 5044A106564A; Tue, 14 Feb 2012 12:13:05 +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 249228FC14; Tue, 14 Feb 2012 12:13:05 +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 q1ECD504097685; Tue, 14 Feb 2012 12:13:05 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1ECD4Eh097683; Tue, 14 Feb 2012 12:13:04 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202141213.q1ECD4Eh097683@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 14 Feb 2012 12:13:04 +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: r231675 - 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: Tue, 14 Feb 2012 12:13:05 -0000 Author: gabor Date: Tue Feb 14 12:13:04 2012 New Revision: 231675 URL: http://svn.freebsd.org/changeset/base/231675 Log: - Add some more verbose comments about how this stuff works Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 12:06:56 2012 (r231674) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Feb 14 12:13:04 2012 (r231675) @@ -191,6 +191,10 @@ tre_match(const tre_tnfa_t *tnfa, const const char *data_byte = string; const tre_char_t *data_wide = string; + /* + * REG_NEWLINE: looking for the longest fragment and then + * isolate the line and run the automaton. + */ if (heur->type == HEUR_LONGEST) { while (st < len) @@ -198,11 +202,17 @@ tre_match(const tre_tnfa_t *tnfa, const size_t eo, so; SEEK_TO(st); + + /* Match for heuristic */ ret = tre_match_fast(heur->heurs[0], string, len - st, type, nmatch, pmatch, eflags); if (ret != REG_OK) return ret; + /* + * If we do not know the length of the possibly matching part, + * look for newlines. + */ if (heur->tlen == -1) { for (so = st + pmatch[0].rm_so - 1; ; so--) @@ -221,6 +231,11 @@ tre_match(const tre_tnfa_t *tnfa, const break; } } + + /* + * If we know the possible match length, just check the narrowest + * context that we can, without looking for explicit newlines. + */ else { size_t rem = heur->tlen - (pmatch[0].rm_eo - pmatch[0].rm_so); @@ -235,6 +250,14 @@ tre_match(const tre_tnfa_t *tnfa, const } return REG_NOMATCH; } + + /* + * General case when REG_NEWLINE is not set. Look for prefix, + * intermediate and suffix heuristics is available, to determine + * the context where the automaton will be invoked. The start + * of the context is st and the relative end offset from st is + * stored in n. + */ else { while (st < len) @@ -249,7 +272,7 @@ tre_match(const tre_tnfa_t *tnfa, const st += pmatch[0].rm_so; n = pmatch[0].rm_eo - pmatch[0].rm_so; - /* Intermediate heuristics */ + /* Intermediate heuristics (if any) */ while (!(heur->heurs[i] == NULL) && ((heur->heurs[i + 1] != NULL) || ((heur->heurs[i + 1] == NULL) && (heur->type == HEUR_PREFIX_ARRAY))))