summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-02-09 11:50:04 -0700
committerKarl Williamson <khw@cpan.org>2016-02-09 23:30:54 -0700
commit46d34d0e1e7de87f74f8b2df4b32f291baf21dbb (patch)
treed1c55a71af5488e197ca31951e49f480adb1c325 /Porting
parentd8fd4ea0c782a6d356681b28eb35e215d74e4ccd (diff)
downloadperl-46d34d0e1e7de87f74f8b2df4b32f291baf21dbb.tar.gz
PATCH: [perl #8904] Revamp [:posix:] parsing
A problem with bracketed character classes, qr/[foo]/, is that there is very little structure about them, so almost anything is legal, and so typos just silently compile into something unintended. One of the possible components are posix character classes. There are 14 of them, and they have a very restricted structure, which is easy to get slightly wrong, so that instead of the intended posix class being compiled, something else silently is created. This commit causes the regex compiler to look for slightly misspelled posix character classes and to raise a warning when found. It does not change the results of the compilation. To do this, it introduces fuzzy parsing into the regex compiler, using the Damerau-Levenshtein algorithm to find out how many single character edits it would take to transform the input into one of the 14 classes. If it is 1 or 2 off, it considers the input to have been intended to be that class and raises the warning. If more edits would be needed, it remains silent. This is a heuristic, and someone could have made enough typos that this thinks a class wasn't intended that was. Conversely it could raise a warning when no class was intended, though warnings only happen when the input very closely resembles a posix class of one of the 14 legal ones. The algorithm can be tweaked if experience indicates it should. But the bottom line is that many more cases of unintended results will now be warned about. Things like having blanks in the construct and having the '^' before the colon are recognized as being intended posix classes (given that the actual names are close to one of the 14), and raise warnings. Again this commit does not change what gets compiled. This found a bug in autodoc.pl which was fixed a few commits ago. The [. .] and [= =] POSIX constructs cause perl to croak that they are unimplemented. This commit improves the parsing of these two, and fixes some false positives. See http://nntp.perl.org/group/perl.perl5.porters/230975 The new code combines two functions in regcomp.c into one new one.
Diffstat (limited to 'Porting')
0 files changed, 0 insertions, 0 deletions