It's surprising to find that there are modules on CPAN that aren't using
ppport.h that could stand to benefit from it.
ppport.h is a file that is part of the Devel::PPPort distribution. As you
know, Perl has evolved over the years, adding new features, and new API for XS
writers to use. Some of that is to support the new features, and some to make
tasks easier to accomplish. ppport.h implements portions of the API that
people have found desirable to have when a module gets installed in a Perl that
was released before that API element was created. You can write your module
using the latest API, and have it automatically work on old Perls, simply by
#including ppport.h in your XS code. ppport.h generally provides support for
an API element as is reasonably practicable, with many supported to 5.03007.
Importantly, but often overlooked, ppport.h can override buggy early Perl
implementations of an API element. By using it, you get fixed, proper
behavior. That sure beats trying to reproduce a reported problem in your
module that only happens in some ancient Perl, and then try to come up with a
workaround in an area you aren't familiar with.
This is especially important if your XS code interacts with Unicode in any way.
Early versions of the Unicode standard and early Perls allowed things that we
now know are potential attack vectors. Right now, someone could be using your
module to hack into systems, so you are actually being negligent if you don't
use ppport.h.
If your XS code has preprocessor #if statements that check for the existence of
functions, macros, etc, that are only in later perls, you can generally avoid
that by simply using ppport.h
ppport.h is now being actively developed and supported by perl5 porters, with
hundreds of new commits since we took it over.
If you have had to backport something that isn't currently in ppport.h, send a
pull request so you can stop it from cluttering up your code, and others can
benefit from effort you've already done. I'm eager to get these to improve
ppport.h. The link is
https://github.com/Dual-Life/Devel-PPPort/pulls
We examine these, and potentially think of edge cases that you didn't, which
will save you headaches down the road.
To use ppport.h, drop a copy of the latest version into your module each time
you release it, and #include it in you XS code.
For more information, see https://metacpan.org/pod/Devel::PPPort
That contains a section "Start using Devel::PPPort for XS projects"
which gives steps to easily fix up your files.
Dozens of functions and macros are newly implemented. The suite of SV handling functions is more complete, with more flags handled. Also the character classification macros (alpha, punct, etc) and case changing functions are greatly expanded. There is more Unicode support, including modern security standards.
ppport.h --api-info foo
is much more complete than before. If you make 'foo' to instead be '/./' you'll get information about every known API element.
And it still supports 5.003, with a surprising number of elements functioning that far back.
The full documentation is available at .
The version backporting is valid for is unknown for quite a few API elements. That is because documentation is lacking on the parameters these take, and so the automatic tests for these elements can't be generated. If you know what some of the missing things do, we would greatly appreciate your contributing documentation for them. in the form of a github pull request.
A glitch from the past was that a lot of links didn't work on autogenerated files. I couldn't find any failures in my brief attempts, so maybe that has been fixed.
]]>Unicode::UCD::charprops_all() returns all the Unicode properties for its code point argument
prop_invlist() can be used to get a list of code points matching a binary property.
And UnicodeVersion() returns the version of the Unicode release being used.
]]>Unicode::UCD::num(), since Perl 5.14, can be used to make sure that a string of digits are all from the same script, so are not spoofing attempts, returning the numeric value the string represents, or undef if it is illegal.
]]>