use strict;
BEGIN { $^W = 1; }
require "./parts/ppptools.pl";
+require "./parts/inc/inctools";
my $INCLUDE = 'parts/inc';
my $DPPP = 'DPPP_';
$data = expand($data);
-my @api = sort { lc $a cmp lc $b or $a cmp $b } keys %provides;
+my @api = sort dictionary_order keys %provides;
$data =~ s{^(.*)__PROVIDED_API__(\s*?)^}
{join '', map "$1$_\n", @api}gem;
sprintf("$1$format\n", 'Function / Variable', 'Static Request', 'Global Request') .
$1 . '-'x$len . "\n" .
join('', map { sprintf "$1$format\n", $explicit{$_} eq 'var' ? $_ : "$_()", "NEED_$_", "NEED_${_}_GLOBAL" }
- sort keys %explicit)
+ sort dictionary_order keys %explicit)
!gem;
}
}
push @perl_api, keys %embed;
+@perl_api = sort dictionary_order @perl_api;
for (@perl_api) {
if (exists $provides{$_} && !exists $raw_base{$_}) {
}
$data =~ s/^([\t ]*)__PERL_API__(\s*?)$/
- join "\n", map "$1$_", sort @perl_api
+ join "\n", map "$1$_", sort dictionary_order @perl_api
/gem;
my $undocumented = "(undocumented)";
for (reverse sort keys %todo) {
my $ver = format_version($_);
my $todo = "=item perl $ver\n\n";
- for (sort @{$todo{$_}}) {
+ for (sort dictionary_order @{$todo{$_}}) {
$todo .= " $_";
$todo .= " (DEPRECATED)" if $embed{$_}->{flags}{D};
$todo .= " (marked experimental)" if $embed{$_}->{flags}{x};
%include ppphdoc { indent => '|>' }
+%include inctools
+
%include ppphbin
__DATA__
return ($r, $v, $s);
}
+sub dictionary_order($$) # Sort caselessly, ignoring punct
+{
+ my ($lc_a, $lc_b);
+ my ($squeezed_a, $squeezed_b);
+ my ($valid_a, $valid_b); # Meaning valid for all releases
+
+ # On early perls, the implicit pass by reference doesn't work, so we have
+ # to use the globals to initialize.
+ if ("$]" < "5.006" ) {
+ $valid_a = $a; $valid_b = $b;
+ }
+ else {
+ ($valid_a, $valid_b) = @_;
+ }
+
+ $lc_a = lc $valid_a;
+ $lc_b = lc $valid_b;
+
+ $squeezed_a = $lc_a;
+ $squeezed_a =~ s/[\W_]//g; # No punct, including no underscore
+ $squeezed_b = $lc_b;
+ $squeezed_b =~ s/[\W_]//g;
+
+ return( $squeezed_a cmp $squeezed_b
+ or $lc_a cmp $lc_b
+ or $valid_a cmp $valid_b);
+}
+
1;
if (exists $opt{'list-unsupported'}) {
my $f;
- for $f (sort { lc $a cmp lc $b } keys %API) {
+ for $f (sort dictionary_order keys %API) {
next unless $API{$f}{todo};
print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
}
for (values %depends) {
my %s;
- $_ = [sort grep !$s{$_}++, @$_];
+ $_ = [sort dictionary_order grep !$s{$_}++, @$_];
}
if (exists $opt{'api-info'}) {
my $f;
my $count = 0;
my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
- for $f (sort { lc $a cmp lc $b } keys %API) {
+ for $f (sort dictionary_order keys %API) {
next unless $f =~ /$match/;
print "\n=== $f ===\n\n";
my $info = 0;
if (exists $opt{'list-provided'}) {
my $f;
- for $f (sort { lc $a cmp lc $b } keys %API) {
+ for $f (sort dictionary_order keys %API) {
next unless $API{$f}{provided};
my @flags;
push @flags, 'explicit' if exists $need{$f};
my $c = $file{code};
my $warnings = 0;
- for $func (sort keys %{$file{uses_Perl}}) {
+ for $func (sort dictionary_order keys %{$file{uses_Perl}}) {
if ($API{$func}{varargs}) {
unless ($API{$func}{nothxarg}) {
my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
}
}
- for $func (sort keys %{$file{uses_replace}}) {
+ for $func (sort dictionary_order keys %{$file{uses_replace}}) {
warning("Uses $func instead of $replace{$func}");
$file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
}
- for $func (sort keys %{$file{uses_provided}}) {
+ for $func (sort dictionary_order keys %{$file{uses_provided}}) {
if ($file{uses}{$func}) {
if (exists $file{uses_deps}{$func}) {
diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
}
unless ($opt{quiet}) {
- for $func (sort keys %{$file{uses_todo}}) {
+ for $func (sort dictionary_order keys %{$file{uses_todo}}) {
print "*** WARNING: Uses $func, which may not be portable below perl ",
format_version($API{$func}{todo}), ", even with '$ppport'\n";
$warnings++;
}
}
- for $func (sort keys %{$file{needed_static}}) {
+ for $func (sort dictionary_order keys %{$file{needed_static}}) {
my $message = '';
if (not exists $file{uses}{$func}) {
$message = "No need to define NEED_$func if $func is never used";
}
}
- for $func (sort keys %{$file{needed_global}}) {
+ for $func (sort dictionary_order keys %{$file{needed_global}}) {
my $message = '';
if (not exists $global{uses}{$func}) {
$message = "No need to define NEED_${func}_GLOBAL if $func is never used";
if ($file{needs_inc_ppport}) {
my $pp = '';
- for $func (sort keys %{$file{needs}}) {
+ for $func (sort dictionary_order keys %{$file{needs}}) {
my $type = $file{needs}{$func};
next if $type eq 'extern';
my $suffix = $type eq 'global' ? '_GLOBAL' : '';