NAME
XS::Check - check XS for problems
SYNOPSIS
use XS::Check;
my $check = XS::Check->new ();
$check->check_file ('some.xs');
VERSION
This documents version 0.05 of XS::Check corresponding to git commit b344a2d42e55a3e179e2836fef86bc67b736f811 released on Tue Aug 22 12:54:29 2017 +0900.
DESCRIPTION
Check XS files for errors.
METHODS
new
my $check = XS::Check->new ();
check
$check->check ($xs);
See "SUGGESTIONS" for what this reports.
check_file
$check->check ($xs_file);
Convenience method to read in $xs_file then run "check" on it.
This assumes UTF-8 encoding of $xs_file.
SUGGESTIONS
This section details the possible suggestions made by the module and the motivations behind them.
Use STRLEN in SvPV
Using an int type for the second argument to SvPV may cause errors on 64-bit Perls.
Use const char * for return value of SvPV
Be careful to not overwrite Perl's own buffer, which SvPV returns.
Don't use malloc/calloc/realloc/free
Replace with Newx etc.
These cause "free to wrong pool" errors on multithreaded Windows Perls.
Don't use the Perl_ prefix
Functions like Perl_croak
should not be used, just croak
.
LIMITATIONS
As of 0.05, the module has the following limitations.
- Error reporting
-
Errors are printed to standard error stream using
warn
. There is no way to alter this. - Struct members
-
The module is not very good at parsing struct members, so XS code like the following doesn't get dealt with properly:
s.txt = SvPV (sv, s.len);
DEPENDENCIES
- C::Tokenize
-
This supplies the regular expressions used to parse C by the module.
- "read_text" in File::Slurper
-
This is used by "check_file".
- Text::LineNumber
-
This is used to get the line numbers.
- Carp
COMMAND-LINE TOOL
A command line tool called checkxs
is installed with the module. It runs the "check_file" method on each file named on the command line.
checkxs Some.xs
As of 0.05, there are no options to the script. Its output goes to standard error.
SEE ALSO
- Perl XS modules and CPAN testers
-
A collection of more or less obscure bugs found by CPAN testers, the original inspiration for this module.
AUTHOR
Ben Bullock, <bkb@cpan.org>
COPYRIGHT & LICENCE
This package and associated files are copyright (C) 2017 Ben Bullock.
You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.