Skip to content

Commit

Permalink
PATCH: [perl #122655] 5.20 regression: '"X" !~ /[x]/i'
Browse files Browse the repository at this point in the history
This problem occurs only when the pattern is UTF-8, contains a single ASCII
lowercase letter.  It does not match its uppercase counterpart.
  • Loading branch information
khwilliamson committed Sep 1, 2014
1 parent 2d698e9 commit b6e093f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 10 additions & 4 deletions regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11046,10 +11046,16 @@ S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_state,
EBCDIC, but it works there, as the extra invariants
fold to themselves) */
*character = toFOLD((U8) code_point);
if (downgradable
&& *character == code_point
&& ! HAS_NONLATIN1_FOLD_CLOSURE(code_point))
{

/* We can downgrade to an EXACT node if this character
* isn't a folding one. Note that this assumes that
* nothing above Latin1 folds to some other invariant than
* one of these alphabetics; otherwise we would also have
* to check:
* && (! HAS_NONLATIN1_FOLD_CLOSURE(code_point)
* || ASCII_FOLD_RESTRICTED))
*/
if (downgradable && PL_fold[code_point] == code_point) {
OP(node) = EXACT;
}
}
Expand Down
8 changes: 7 additions & 1 deletion t/re/pat.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BEGIN {
require './test.pl';
}

plan tests => 737; # Update this when adding/deleting tests.
plan tests => 738; # Update this when adding/deleting tests.

run_tests() unless caller;

Expand Down Expand Up @@ -1606,6 +1606,12 @@ EOP
ok('a<b>c' =~ qr<a\<b\>c>, "'\\<' is a literal in qr<...>)");
}

{ # Was getting optimized into EXACT (non-folding node)
my $x = qr/[x]/i;
utf8::upgrade($x);
like("X", qr/$x/, "UTF-8 of /[x]/i matches upper case");
}

} # End of sub run_tests

1;

0 comments on commit b6e093f

Please sign in to comment.