Re: 5.6.1 darwin Configure fails to extract Makefile
[p5sagit/p5-mst-13.2.git] / utils / h2xs.PL
index aad3696..1b4f387 100644 (file)
@@ -35,6 +35,8 @@ $Config{startperl}
 
 print OUT <<'!NO!SUBS!';
 
+use warnings;
+
 =head1 NAME
 
 h2xs - convert .h C header files to Perl extensions
@@ -471,7 +473,9 @@ $opt_c = 1 if $opt_A;
 $opt_c = $opt_f = 1 if $opt_X;
 
 my %const_xsub = map { $_,1 } split(/,+/, $opt_s) if $opt_s;
-my $extralibs;
+
+my $extralibs = '';
+
 my @path_h;
 
 while (my $arg = shift) {
@@ -635,7 +639,8 @@ if( @path_h ){
 
 
 my ($ext, $nested, @modparts, $modfname, $modpname);
-(chdir 'ext', $ext = 'ext/') if -d 'ext';
+
+$ext = chdir 'ext' ? 'ext/' : '';
 
 if( $module =~ /::/ ){
        $nested = 1;
@@ -799,7 +804,6 @@ package $module;
 
 use $compat_version;
 use strict;
-use Errno; # For $!{EINVAL}
 END
 } 
 else {
@@ -809,7 +813,6 @@ package $module;
 use 5.006;
 use strict;
 use warnings;
-use Errno; # For $!{EINVAL}
 END
 }
 
@@ -898,7 +901,7 @@ sub AUTOLOAD {
     my \$constname;
     $tmp
     (\$constname = \$AUTOLOAD) =~ s/.*:://;
-    croak "&$module::constant not defined" if \$constname eq 'constant';
+    croak "&${module}::constant not defined" if \$constname eq 'constant';
     my \$val = constant(\$constname, \@_ ? \$_[0] : 0);
     if (\$! != 0) {
        if (\$! =~ /Invalid/ || \$!{EINVAL}) {
@@ -1056,13 +1059,28 @@ my $pod = <<"END" unless $opt_P;
 #
 #Blah blah blah.
 $exp_doc$meth_doc$revhist
+#
+#=head1 SEE ALSO
+#
+#Mention other useful documentation such as the documentation of
+#related modules or operating system documentation (such as man pages
+#in UNIX), or any relevant external documentation such as RFCs or
+#standards.
+#
+#If you have a mailing list set up for your module, mention it here.
+#
+#If you have a web site set up for your module, mention it here.
+#
 #=head1 AUTHOR
 #
 #$author, E<lt>${email}E<gt>
 #
-#=head1 SEE ALSO
+#=head1 COPYRIGHT AND LICENSE
+#
+#Copyright YEAR(S) by YOUR NAME(s)
 #
-#L<perl>.
+#This library is free software; you can redistribute it and/or modify
+#it under the same terms as Perl itself. 
 #
 #=cut
 END
@@ -1198,7 +1216,7 @@ END
   for my $n (@$list) {
     my $c = substr $n, $off, 1;
     $leading{$c} = [] unless exists $leading{$c};
-    push @{$leading{$c}}, substr $n, $off + 1;
+    push @{$leading{$c}}, $off < length $n ? substr $n,  $off + 1 : $n
   }
 
   if (keys(%leading) == 1) {
@@ -1289,7 +1307,7 @@ if( ! $opt_c ) {
 static int
 not_here(char *s)
 {
-    croak("$module::%s not implemented on this architecture", s);
+    croak("${module}::%s not implemented on this architecture", s);
     return -1;
 }
 
@@ -1300,8 +1318,7 @@ END
 
 print_tievar_subs(\*XS, $_, $vdecl_hash{$_}) for @vdecls;
 
-my $prefix;
-$prefix = "PREFIX = $opt_p" if defined $opt_p;
+my $prefix = defined $opt_p ? "PREFIX = $opt_p" : '';
 
 # Now switch from C to XS by issuing the first MODULE declaration:
 print XS <<"END";
@@ -1636,7 +1653,7 @@ sub normalize_type {              # Second arg: do not strip const's before \*
   else {
     $type =~ s/$ignore_mods//go;
   }
-  $type =~ s/([^\s\w])/ \1 /g;
+  $type =~ s/([^\s\w])/ $1 /g;
   $type =~ s/\s+$//;
   $type =~ s/^\s+//;
   $type =~ s/\s+/ /g;
@@ -1747,7 +1764,7 @@ EOC
   print PL <<END;
     'LIBS'             => ['$extralibs'], # e.g., '-lm'
     'DEFINE'           => '$opt_F', # e.g., '-DHAVE_SOMETHING'
-$Icomment    'INC'             => '$I', # e.g., '$Ihelp-I/usr/include/other'
+$Icomment    'INC'             => '$I', # e.g., '${Ihelp}-I/usr/include/other'
 END
 
   my $C = grep $_ ne "$modfname.c", (glob '*.c'), (glob '*.cc'), (glob '*.C');