This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move isUTF8_CHAR helper function, and reimplement it
authorKarl Williamson <khw@cpan.org>
Fri, 26 Aug 2016 22:29:54 +0000 (16:29 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 1 Sep 2016 02:32:37 +0000 (20:32 -0600)
commit35f8c9bd0ff4f298f8bc09ae9848a14a9667a95a
tree2d3a60c10c7a5b9e8f379eb4389f44e8c64a1195
parenteda91ad75c71796ed6c5d3da7850b2fd7566c2a2
Move isUTF8_CHAR helper function, and reimplement it

The macro isUTF8_CHAR calls a helper function for code points higher
than it can handle.  That function had been an inlined wrapper around
utf8n_to_uvchr().

The function has been rewritten to not call utf8n_to_uvchr(), so it is
now too big to be effectively inlined.  Instead, it implements a faster
method of checking the validity of the UTF-8 without having to decode
it.  It just checks for valid syntax and now knows where the
few discontinuities are in UTF-8 where overlongs can occur, and uses a
string compare to verify that overflow won't occur.

As a result this is now a pure function.

This also causes a previously generated deprecation warning to not be,
because in printing UTF-8, no longer does it have to be converted to
internal form.  I could add a check for that, but I think it's best not
to.  If you manipulated what is getting printed in any way, the
deprecation message will already have been raised.

This commit also fleshes out the documentation of isUTF8_CHAR.
embed.fnc
embed.h
inline.h
proto.h
t/lib/warnings/utf8
utf8.c
utf8.h