STRLEN numlen;
STRLEN ulen;
STRLEN foldlen;
- U8 tmpbuf[UTF8_MAXLEN_UCLC+1], *foldbuf;
+ U8 tmpbuf[UTF8_MAXLEN_FOLD+1], *foldbuf;
parse_start = RExC_parse - 1;
}
if (RExC_flags16 & PMf_EXTENDED)
p = regwhite(p, RExC_end);
- if (UTF && FOLD)
+ if (UTF && FOLD) {
+ /* Prime the casefolded buffer. */
toFOLD_uni(ender, tmpbuf, &foldlen);
+ /* Need to peek at the first character. */
+ ender = utf8_to_uvchr(tmpbuf, 0);
+ }
if (ISMULT2(p)) { /* Back off on ?+*. */
if (len)
p = oldp;
else if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(ender)) && UTF) {
if (FOLD) {
+ /* Emit all the Unicode characters. */
for (foldbuf = tmpbuf;
foldlen;
foldlen -= numlen) {
}
if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(ender)) && UTF) {
if (FOLD) {
+ /* Emit all the Unicode characters. */
for (foldbuf = tmpbuf;
foldlen;
foldlen -= numlen) {
break;
}
+ /* If the encoding pragma is in effect recode the text of
+ * any EXACT-kind nodes. */
if (PL_encoding && PL_regkind[(U8)OP(ret)] == EXACT) {
STRLEN oldlen = STR_LEN(ret);
SV *sv = sv_2mortal(newSVpvn(STRING(ret), oldlen));
to_utf8_fold(tmpbuf, foldbuf, &foldlen);
f = utf8_to_uvchr(foldbuf, 0);
+ /* If folding and foldable, insert also
+ * the folded version to the charclass. */
if (f != value)
Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n", f);
+ /* If folding and the value is one of the Greek
+ * sigmas insert a few more sigmas to make the
+ * folding rules of the sigmas to work right.
+ * Note that not all the possible combinations
+ * are handled here: some of them are handled
+ * handled by the standard folding rules, and
+ * some of them (literal or EXACTF cases) are
+ * handled during runtime in
+ * regexec.c:S_find_byclass(). */
if (value == UNICODE_GREEK_SMALL_LETTER_FINAL_SIGMA) {
Perl_sv_catpvf(aTHX_ listsv, "%04"UVxf"\n",
(UV)UNICODE_GREEK_CAPITAL_LETTER_SIGMA);
if (norun && e < s)
e = s; /* Due to minlen logic of intuit() */
+ /* The idea in the EXACTF* cases is to first find the
+ * first character of the EXACTF* node and then, if
+ * necessary, case-insensitively compare the full
+ * text of the node. The c1 and c2 are the first
+ * characters (though in Unicode it gets a bit
+ * more complicated because there are more cases
+ * than just upper and lower: one is really supposed
+ * to use the so-called folding case for case-insensitive
+ * matching (called "loose matching" in Unicode). */
+
if (do_utf8) {
UV c, f;
U8 tmpbuf [UTF8_MAXLEN+1];
while (s <= e) {
c = utf8_to_uvchr((U8*)s, &len);
+ /* Handle some of the three Greek sigmas cases.
+ * Note that not all the possible combinations
+ * are handled here: some of them are handled
+ * handled by the standard folding rules, and
+ * some of them (the character class or ANYOF
+ * cases) are handled during compiletime in
+ * regexec.c:S_regclass(). */
if (c == (UV)UNICODE_GREEK_CAPITAL_LETTER_SIGMA ||
c == (UV)UNICODE_GREEK_SMALL_LETTER_FINAL_SIGMA)
c = (UV)UNICODE_GREEK_SMALL_LETTER_SIGMA;
U8 lfoldbuf[UTF8_MAXLEN_FOLD+1];
STRLEN lfoldlen;
+ /* Try one of them folded. */
+
to_utf8_fold((U8*)l, lfoldbuf, &lfoldlen);
if (UTF8SKIP(s) != lfoldlen ||
memNE(s, (char*)lfoldbuf, lfoldlen)) {
U8 sfoldbuf[UTF8_MAXLEN_FOLD+1];
STRLEN sfoldlen;
+ /* Try both of them folded. */
+
to_utf8_fold((U8*)s, sfoldbuf, &sfoldlen);
if (sfoldlen != lfoldlen ||
memNE((char*)sfoldbuf,