Date: Sat, 22 Oct 2011 11:39:17 +0000 (UTC) From: Gabor Kovesdan <gabor@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r226630 - user/gabor/tre-integration/contrib/tre/lib Message-ID: <201110221139.p9MBdHc6077307@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gabor Date: Sat Oct 22 11:39:17 2011 New Revision: 226630 URL: http://svn.freebsd.org/changeset/base/226630 Log: - Use the pattern lenght if possible to limit the context that is processed with the automaton 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 Sat Oct 22 10:29:06 2011 (r226629) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Sat Oct 22 11:39:17 2011 (r226630) @@ -203,20 +203,29 @@ tre_match(const tre_tnfa_t *tnfa, const if (ret != REG_OK) return ret; - for (so = st + pmatch[0].rm_so - 1; ; so--) + if (heur->tlen == -1) { - if ((type == STR_WIDE) ? (data_wide[so] == TRE_CHAR('\n')) : - (data_byte[so] == '\n')) - break; - if (so == 0) - break; + for (so = st + pmatch[0].rm_so - 1; ; so--) + { + if ((type == STR_WIDE) ? (data_wide[so] == TRE_CHAR('\n')) : + (data_byte[so] == '\n')) + break; + if (so == 0) + break; + } + + for (eo = st + pmatch[0].rm_eo; st + eo < len; eo++) + { + if ((type == STR_WIDE) ? (data_wide[eo] == TRE_CHAR('\n')) : + (data_byte[eo] == '\n')) + break; + } } - - for (eo = st + pmatch[0].rm_eo; st + eo < len; eo++) + else { - if ((type == STR_WIDE) ? (data_wide[eo] == TRE_CHAR('\n')) : - (data_byte[eo] == '\n')) - break; + size_t rem = heur->tlen - (pmatch[0].rm_eo - pmatch[0].rm_so); + so = st + pmatch[0].rm_so - rem; + eo = st + pmatch[0].rm_eo + rem; } SEEK_TO(so); @@ -272,8 +281,12 @@ tre_match(const tre_tnfa_t *tnfa, const /* Suffix heuristic not available */ else { + size_t l = (heur->tlen == -1) ? len - st : heur->tlen; + + if (l < len - st) + return REG_NOMATCH; SEEK_TO(st); - ret = tre_match(tnfa, string, len - st, type, nmatch, + ret = tre_match(tnfa, string, l, type, nmatch, pmatch, eflags, NULL, NULL); FIX_OFFSETS(st += n); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110221139.p9MBdHc6077307>