From: Karl Williamson Date: Tue, 10 Jul 2012 04:00:16 +0000 (-0600) Subject: regcomp.c: Relax some restrictions on optimizations for locale X-Git-Tag: upstream/5.20.0~6030^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce712dffad41e08420bdc13aa14486bb92469cc2;p=platform%2Fupstream%2Fperl.git regcomp.c: Relax some restrictions on optimizations for locale Prior to this commit, we didn't do any inversions for bracketed character classes running under locale. However, this is more strict than necessary. If there is no folding, and everything else is known at compile time, then what is matched when the result is complemented is well-defined, and can be done now. (Also clarifies one of the affected comments) --- diff --git a/regcomp.c b/regcomp.c index c237c64..5a87e9c 100644 --- a/regcomp.c +++ b/regcomp.c @@ -12397,15 +12397,14 @@ parseit: * Now we can see about various optimizations. Fold calculation (which we * did above) needs to take place before inversion. Otherwise /[^k]/i * would invert to include K, which under /i would match k, which it - * shouldn't. */ + * shouldn't. Therefore we can't invert folded locale now, as it won't be + * folded until runtime */ - /* Optimize inverted simple patterns (e.g. [^a-z]). Note that we haven't - * set the FOLD flag yet, so this does optimize those. It doesn't - * optimize locale. Doing so perhaps could be done as long as there is - * nothing like \w in it; some thought also would have to be given to the - * interaction with above 0x100 chars */ + /* Optimize inverted simple patterns (e.g. [^a-z]) when everything is known + * at compile time. Besides not inverting folded locale now, we can't invert + * if there are things such as \w, which aren't known until runtime */ if (invert - && ! LOC + && ! (LOC && (FOLD || (ANYOF_FLAGS(ret) & ANYOF_CLASS))) && ! depends_list && ! unicode_alternate && ! HAS_NONLOCALE_RUNTIME_PROPERTY_DEFINITION)