print OUT <<'!NO!SUBS!';
use Config;
-$perlincl = @Config{installsitearch};
+use File::Path qw(mkpath);
-chdir '/usr/include' || die "Can't cd /usr/include";
+my $Exit = 0;
+
+my $Dest_dir = (@ARGV && $ARGV[0] =~ s/^-d//)
+ ? shift || shift
+ : $Config{installsitearch};
+die "Destination directory $Dest_dir doesn't exist or isn't a directory\n"
+ unless -d $Dest_dir;
@isatype = split(' ',<<END);
char uchar u_char
print "$file -> $outfile\n";
if ($file =~ m|^(.*)/|) {
$dir = $1;
- if (!-d "$perlincl/$dir") {
- mkdir("$perlincl/$dir",0777);
- }
+ mkpath "$Dest_dir/$dir";
}
- open(IN,"$file") || ((warn "Can't open $file: $!\n"),next);
- open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n";
+ open(IN,"$file") || (($Exit = 1),(warn "Can't open $file: $!\n"),next);
+ open(OUT,">$Dest_dir/$outfile") || die "Can't create $outfile: $!\n";
}
while (<IN>) {
chop;
s/\s+$//;
if (s/^\(([\w,\s]*)\)//) {
$args = $1;
+ my $proto = '() ';
if ($args ne '') {
+ $proto = '';
foreach $arg (split(/,\s*/,$args)) {
$arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/;
$curargs{$arg} = 1;
if ($t ne '') {
$new =~ s/(['\\])/\\$1/g;
print OUT $t,
- "eval 'sub $name {\n$t ${args}eval \"$new\";\n$t}';\n";
+ "eval 'sub $name $proto\{\n$t ${args}eval \"$new\";\n$t}';\n";
}
else {
- print OUT "sub $name {\n ${args}eval \"$new\";\n}\n";
+ print OUT "sub $name $proto\{\n ${args}eval \"$new\";\n}\n";
}
%curargs = ();
}
$new = 1 if $new eq '';
if ($t ne '') {
$new =~ s/(['\\])/\\$1/g;
- print OUT $t,"eval 'sub $name {",$new,";}';\n";
+ print OUT $t,"eval 'sub $name () {",$new,";}';\n";
}
else {
- print OUT $t,"sub $name {",$new,";}\n";
+ print OUT $t,"sub $name () {",$new,";}\n";
}
}
}
print OUT "1;\n";
}
+exit $Exit;
+
sub expr {
while ($_ ne '') {
s/^(\s+)// && do {$new .= ' '; next;};
else {
if ($inif && $new !~ /defined\s*\($/) {
$new .= '(defined(&' . $id . ') ? &' . $id . ' : 0)';
- }
- elsif (/^\[/) {
+ }
+ elsif (/^\[/) {
$new .= ' $' . $id;
}
else {
cd /usr/include; h2ph * sys/*
+The output files are placed in the hierarchy rooted at Perl's
+architecture dependent library directory. You can specify a different
+hierarchy with a B<-d> switch.
+
If run with no arguments, filters standard input to standard output.
=head1 ENVIRONMENT