Fix compiler bug for classes such as [\W\p{Any}].

This commit is contained in:
Philip.Hazel 2015-10-09 16:06:53 +00:00
parent 2080c45105
commit 093412143d
4 changed files with 54 additions and 14 deletions

View File

@ -194,6 +194,10 @@ and the matching functions with NULL contexts can be tested.
55. Implemented PCRE2_SUBSTITUTE_EXTENDED.
56. In a character class such as [\W\p{Any}] where both a negative-type escape
("not a word character") and a property escape were present, the property
escape was being ignored.
Version 10.20 30-June-2015
--------------------------

View File

@ -4645,19 +4645,21 @@ for (;; ptr++)
zeroreqcu = reqcu;
zeroreqcuflags = reqcuflags;
/* If there are characters with values > 255, we have to compile an
extended class, with its own opcode, unless there was a negated special
such as \S in the class, and PCRE2_UCP is not set, because in that case all
/* If there are characters with values > 255, or Unicode property settings
(\p or \P), we have to compile an extended class, with its own opcode,
unless there were no property settings and there was a negated special such
as \S in the class, and PCRE2_UCP is not set, because in that case all
characters > 255 are in the class, so any that were explicitly given as
well can be ignored. If (when there are explicit characters > 255 that must
be listed) there are no characters < 256, we can omit the bitmap in the
actual compiled code. */
well can be ignored. If (when there are explicit characters > 255 or
property settings that must be listed) there are no characters < 256, we
can omit the bitmap in the actual compiled code. */
#ifdef SUPPORT_WIDE_CHARS
#ifdef SUPPORT_UNICODE
if (xclass && (!should_flip_negation || (options & PCRE2_UCP) != 0))
if (xclass && (xclass_has_prop || !should_flip_negation ||
(options & PCRE2_UCP) != 0))
#elif PCRE2_CODE_UNIT_WIDTH != 8
if (xclass && !should_flip_negation)
if (xclass && (xclass_has_prop || !should_flip_negation))
#endif
{
*class_uchardata++ = XCL_END; /* Marks the end of extra data */

9
testdata/testinput5 vendored
View File

@ -1690,4 +1690,13 @@
/((?<digit>\d)|(?<letter>\p{L}))/g,substitute_extended,replace=<${digit:+digit; :not digit; }${letter:+letter:not a letter}>
ab12cde
/[\W\p{Any}]/B
abc
123
/[\W\pL]/B
abc
\= Expect no match
123
# End of testinput5

25
testdata/testoutput5 vendored
View File

@ -4043,4 +4043,29 @@ MK: a\x{12345}b\x{09}(d)c
ab12cde
7: <not digit; letter><not digit; letter><digit; not a letter><digit; not a letter><not digit; letter><not digit; letter><not digit; letter>
/[\W\p{Any}]/B
------------------------------------------------------------------
Bra
[\x00-/:-@[-^`{-\xff\p{Any}]
Ket
End
------------------------------------------------------------------
abc
0: a
123
0: 1
/[\W\pL]/B
------------------------------------------------------------------
Bra
[\x00-/:-@[-^`{-\xff\p{L}]
Ket
End
------------------------------------------------------------------
abc
0: a
\= Expect no match
123
No match
# End of testinput5