misprint in perlguts
[p5sagit/p5-mst-13.2.git] / utils / h2xs.PL
index f1d4045..bd0ba16 100644 (file)
@@ -41,7 +41,7 @@ h2xs - convert .h C header files to Perl extensions
 
 =head1 SYNOPSIS
 
-B<h2xs> [B<-AOPXcdf>] [B<-v> version] [B<-n> module_name] [B<-p> prefix] [B<-s> sub] [headerfile ... [extra_libraries]]
+B<h2xs> [B<-ACOPXcdf>] [B<-v> version] [B<-n> module_name] [B<-p> prefix] [B<-s> sub] [headerfile ... [extra_libraries]]
 
 B<h2xs> B<-h>
 
@@ -73,6 +73,11 @@ in the extra-libraries argument.
 Omit all autoload facilities.  This is the same as B<-c> but also removes the
 S<C<use AutoLoader>> statement from the .pm file.
 
+=item B<-C>
+
+Omits creation of the F<Changes> file, and adds a HISTORY section to
+the POD template.
+
 =item B<-F>
 
 Additional flags to specify to C preprocessor when scanning header for
@@ -117,7 +122,7 @@ Specifies a name to be used for the extension, e.g., S<-n RPC::DCE>
 
 Specify a prefix which should be removed from the Perl function names, e.g., S<-p sec_rgy_> 
 This sets up the XS B<PREFIX> keyword and removes the prefix from functions that are
-autoloaded via the C<constant()> mechansim.
+autoloaded via the C<constant()> mechanism.
 
 =item B<-s> I<sub1,sub2>
 
@@ -218,9 +223,10 @@ use Getopt::Std;
 
 sub usage{
        warn "@_\n" if @_;
-    die "h2xs [-AOPXcdfh] [-v version] [-n module_name] [-p prefix] [-s subs] [headerfile [extra_libraries]]
+    die "h2xs [-ACOPXcdfh] [-v version] [-n module_name] [-p prefix] [-s subs] [headerfile [extra_libraries]]
 version: $H2XS_VERSION
     -A   Omit all autoloading facilities (implies -c).
+    -C   Omit creating the Changes file, add HISTORY heading to stub POD.
     -F   Additional flags for C preprocessor (used with -x).
     -O   Allow overwriting of a pre-existing extension directory.
     -P   Omit the stub POD section.
@@ -241,7 +247,7 @@ extra_libraries
 }
 
 
-getopts("AF:OPXcdfhn:p:s:v:x") || usage;
+getopts("ACF:OPXcdfhn:p:s:v:x") || usage;
 
 usage if $opt_h;
 
@@ -471,7 +477,7 @@ sub AUTOLOAD {
     croak "&$module::constant not defined" if \$constname eq 'constant';
     my \$val = constant(\$constname, \@_ ? \$_[0] : 0);
     if (\$! != 0) {
-       if (\$! =~ /Invalid/) {
+       if (\$! =~ /Invalid/ || \$!{EINVAL}) {
            \$AutoLoader::AUTOLOAD = \$AUTOLOAD;
            goto &AutoLoader::AUTOLOAD;
        }
@@ -479,6 +485,7 @@ sub AUTOLOAD {
                croak "Your vendor has not defined $module macro \$constname";
        }
     }
+    no strict 'refs';
     *\$AUTOLOAD = sub () { \$val };
     goto &\$AUTOLOAD;
 }
@@ -517,11 +524,26 @@ END
 $author = "A. U. Thor";
 $email = 'a.u.thor@a.galaxy.far.far.away';
 
+my $revhist = '';
+$revhist = <<EOT if $opt_C;
+
+=head1 HISTORY
+
+=over 8
+
+=item $TEMPLATE_VERSION
+
+Original version; created by h2xs $H2XS_VERSION
+
+=back
+
+EOT
+
 my $const_doc = '';
 my $fdecl_doc = '';
 if (@const_names and not $opt_P) {
   $const_doc = <<EOD;
-\n=head1 Exported constants
+\n=head2 Exported constants
 
   @{[join "\n  ", @const_names]}
 
@@ -529,7 +551,7 @@ EOD
 }
 if (defined $fdecls and @$fdecls and not $opt_P) {
   $fdecl_doc = <<EOD;
-\n=head1 Exported functions
+\n=head2 Exported functions
 
   @{[join "\n  ", @$fdecls]}
 
@@ -555,7 +577,7 @@ $pod = <<"END" unless $opt_P;
 #unedited.
 #
 #Blah blah blah.
-#$const_doc$fdecl_doc
+#$const_doc$fdecl_doc$revhist
 #=head1 AUTHOR
 #
 #$author, $email
@@ -847,12 +869,14 @@ print "ok 1\n";
 _END_
 close(EX) || die "Can't close $ext$modpname/test.pl: $!\n";
 
-warn "Writing $ext$modpname/Changes\n";
-open(EX, ">Changes") || die "Can't create $ext$modpname/Changes: $!\n";
-print EX "Revision history for Perl extension $module.\n\n";
-print EX "$TEMPLATE_VERSION  ",scalar localtime,"\n";
-print EX "\t- original version; created by h2xs $H2XS_VERSION\n\n";
-close(EX) || die "Can't close $ext$modpname/Changes: $!\n";
+unless ($opt_C) {
+    warn "Writing $ext$modpname/Changes\n";
+    open(EX, ">Changes") || die "Can't create $ext$modpname/Changes: $!\n";
+    print EX "Revision history for Perl extension $module.\n\n";
+    print EX "$TEMPLATE_VERSION  ",scalar localtime,"\n";
+    print EX "\t- original version; created by h2xs $H2XS_VERSION\n\n";
+    close(EX) || die "Can't close $ext$modpname/Changes: $!\n";
+}
 
 warn "Writing $ext$modpname/MANIFEST\n";
 open(MANI,'>MANIFEST') or die "Can't create MANIFEST: $!";