diff options
author | Yves Orton <demerphq@gmail.com> | 2012-02-19 21:32:05 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2012-03-03 13:27:28 +0100 |
commit | fab2782b37b5570d7f8f8065fd7d18621117ed49 (patch) | |
tree | 5c7ef3c0c69d4998c89e2469998092747584f68b /regnodes.h | |
parent | 2f137bbd018b7f86a6a557d3552cbb7a760bb43a (diff) | |
download | perl-fab2782b37b5570d7f8f8065fd7d18621117ed49.tar.gz |
rework how the trie logic handles the newer EXACT nodetypes
This cleans up and simplifies and extends how the trie
logic interacts with the new node types. This change ultimately
makes the EXACTFU, EXACTFU_SS, EXACTFU_NO_TRIE (renamed to
EXACTFU_TRICKYFOLD) work properly with the trie engine regardless
of whether the string is utf8 or latin1.
This patch depends on the following:
EXACT => utf8 or "binary" text
EXACTFU => either pre-folded utf8, or latin1 that has to be folded as though it was utf8
EXACTFU_SS => special case of EXACTFU to handle \xDF/ss (affects latin1 treatment)
EXACTFU_TRICKYFOLD => special case of EXACTFU to handle tricky non-latin1 fold rules
EXACTF => "old style fold logic" untriable nodetype
EXACTFA => (currently) untriable nodetype
EXACTFL => (currently) untriable nodetype
See the comments in regcomp.sym for these fold types.
This patch involves a number of distinct, but related parts. Starting
from compilation:
* Simplify how we detect a triable sequence given the new nodetypes,
this also probably fixed some "bugs" in how we detected certain
sequences, like /||foo|bar/.
* Simplify how we read EXACTFU nodes under utf8 by removing the now
redundant folding logic (EXACTFU nodes under utf8 are prefolded).
Also extend this logic to handle latin1 patterns properly (in
conjunction with other changes)
* Part of the problems associated with EXACTFU_SS and EXACTFU_TRICKYFOLD
have to do with how the trie logic interacts with the minlen logic.
This change handles both by pessimising the minlen when encounting
these nodetypes. One observation is that the minlen logic is basically
broken, and works only because it conflates bytes and codepoints in
such a way that we more or less always get a value small enough that things work out
anyway. Fixing that is properly is the job of another patch.
* Part of the problem of doing folding under unicode rules is that
there are a lot of foldings possible, some with strange rules. This
means that the bitmap logic does not work correctly in all cases,
as we currently do not have any way to populate it properly.
So this patch disables the bitmap entirely when folding is involved
until that is fixed.
The end result of this is: we can TRIE/AHOCORASICK any sequence of
EXACT, or EXACTFU (ish) nodes, regardless of utf8 or not, but we disable
the bitmap when folding.
A note for follow up relating to this patch is that the way EXACTFU_XXX
nodes are currently dealt with we wont build the "maximal" trie because
of their presence, instead creating a "jumptrie" consisting of either a
leading EXACTFU node followed by a EXACTFU_XXX node, or vice versa. We
should eventually address that.
Diffstat (limited to 'regnodes.h')
-rw-r--r-- | regnodes.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/regnodes.h b/regnodes.h index 994159342f..5561243882 100644 --- a/regnodes.h +++ b/regnodes.h @@ -62,7 +62,7 @@ #define EXACTFL 50 /* 0x32 Match this string (not guaranteed to be folded) using /il rules (w/len). */ #define EXACTFU 51 /* 0x33 Match this string (folded iff in UTF-8, length in folding doesn't change if not in UTF-8) using /iu rules (w/len). */ #define EXACTFU_SS 52 /* 0x34 Match this string (folded iff in UTF-8, length in folding may change even if not in UTF-8) using /iu rules (w/len). */ -#define EXACTFU_NO_TRIE 53 /* 0x35 Match this folded UTF-8 string using /iu rules, but don't generate a trie for it */ +#define EXACTFU_TRICKYFOLD 53 /* 0x35 Match this folded UTF-8 string using /iu rules, but don't generate a trie for it */ #define EXACTFA 54 /* 0x36 Match this string (not guaranteed to be folded) using /iaa rules (w/len). */ #define NOTHING 55 /* 0x37 Match empty string. */ #define TAIL 56 /* 0x38 Match empty string. Can jump here from outside. */ @@ -223,7 +223,7 @@ EXTCONST U8 PL_regkind[] = { EXACT, /* EXACTFL */ EXACT, /* EXACTFU */ EXACT, /* EXACTFU_SS */ - EXACT, /* EXACTFU_NO_TRIE */ + EXACT, /* EXACTFU_TRICKYFOLD */ EXACT, /* EXACTFA */ NOTHING, /* NOTHING */ NOTHING, /* TAIL */ @@ -384,7 +384,7 @@ static const U8 regarglen[] = { 0, /* EXACTFL */ 0, /* EXACTFU */ 0, /* EXACTFU_SS */ - 0, /* EXACTFU_NO_TRIE */ + 0, /* EXACTFU_TRICKYFOLD */ 0, /* EXACTFA */ 0, /* NOTHING */ 0, /* TAIL */ @@ -502,7 +502,7 @@ static const char reg_off_by_arg[] = { 0, /* EXACTFL */ 0, /* EXACTFU */ 0, /* EXACTFU_SS */ - 0, /* EXACTFU_NO_TRIE */ + 0, /* EXACTFU_TRICKYFOLD */ 0, /* EXACTFA */ 0, /* NOTHING */ 0, /* TAIL */ @@ -625,7 +625,7 @@ EXTCONST char * const PL_reg_name[] = { "EXACTFL", /* 0x32 */ "EXACTFU", /* 0x33 */ "EXACTFU_SS", /* 0x34 */ - "EXACTFU_NO_TRIE", /* 0x35 */ + "EXACTFU_TRICKYFOLD", /* 0x35 */ "EXACTFA", /* 0x36 */ "NOTHING", /* 0x37 */ "TAIL", /* 0x38 */ |