This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: extract charnames code from S_new_constant
authorKarl Williamson <khw@cpan.org>
Fri, 31 Jan 2020 21:07:42 +0000 (14:07 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 12 Feb 2020 23:25:53 +0000 (16:25 -0700)
commit7303cc1fd7b20cfd3aa029c9cfd0ea711e974bb7
treefc5a5d7d74fd53914d765b24621e9d139e1d1b33
parent4eecf4e587dc70863e2a3705f5e277e2bd8b0fc5
toke.c: extract charnames code from S_new_constant

The code for dealing with charnames is intertwined and special cased in
S_new_constant.  My guess is it was originally to offer customized,
better error messages when things go wrong.  Much later the function was
changed so that a message could be returned instead of output, and the
code didn't really need the customization any longer.  But by then
autoloading of charnames had been added when a \N[} was parsed, meaning
that more special casing was added instead, as that had been the logical
place to do it.

This commit extracts the special charnames handling to the one place it
is actually used, and the disentangled S_new_constant is then called.
This is in preparation for future commits, and makes the code cleaner.

This adds testing of the new syntax to lib/charnames.t.  That file
randomly generates some tests, simply because there are too many names
to test reasonably at once.  To compensate for the added tests, I
lowered the percentage per run of characters tested so that this file
takes about the same amount of time as before.
toke.c