Re: [perl #21261] B::Terse not outputting correct constants or variable names
[p5sagit/p5-mst-13.2.git] / ext / Errno / Errno_pm.PL
index d429146..41560d5 100644 (file)
@@ -5,6 +5,7 @@ use strict;
 our $VERSION = "1.09_00";
 
 my %err = ();
+my %wsa = ();
 
 unlink "Errno.pm" if -f "Errno.pm";
 open OUT, ">Errno.pm" or die "Cannot open Errno.pm: $!";
@@ -20,6 +21,7 @@ sub process_file {
     my($file) = @_;
 
     return unless defined $file and -f $file;
+#   warn "Processing $file\n";
 
     local *FH;
     if (($^O eq 'VMS') && ($Config{vms_cc_type} ne 'gnuc')) {
@@ -55,6 +57,10 @@ sub process_file {
        while(<FH>) {
            $err{$1} = 1
                if /^\s*#\s*define\s+(E\w+)\s+/;
+            if ($^O eq 'MSWin32') {
+               $wsa{$1} = 1
+                   if /^\s*#\s*define\s+WSA(E\w+)\s+/;
+            }
        }
     }
     close(FH);
@@ -113,14 +119,21 @@ sub get_files {
        # hidden in a special place
        $file{'/boot/develop/headers/posix/errno.h'} = 1;
 
+    } elsif ($^O eq 'vos') {
+       # avoid problem where cpp returns non-POSIX pathnames
+       $file{'/system/include_library/errno.h'} = 1;
     } else {
        open(CPPI,"> errno.c") or
            die "Cannot open errno.c";
 
        if ($^O eq 'NetWare') {
-               print CPPI "#include <nwerrno.h>\n";
+           print CPPI "#include <nwerrno.h>\n";
        } else {
-               print CPPI "#include <errno.h>\n";
+           print CPPI "#include <errno.h>\n";
+           if ($^O eq 'MSWin32') {
+               print CPPI "#define _WINSOCKAPI_\n"; # don't drag in everything
+               print CPPI "#include <winsock.h>\n";
+           }
        }
 
        close(CPPI);
@@ -172,11 +185,21 @@ sub write_errno_pm {
        die "Cannot open errno.c";
 
     if ($^O eq 'NetWare') {
-               print CPPI "#include <nwerrno.h>\n";
-       } else {
-               print CPPI "#include <errno.h>\n";
+       print CPPI "#include <nwerrno.h>\n";
+       } 
+    else {
+       print CPPI "#include <errno.h>\n";
+    }
+    if ($^O eq 'MSWin32') {
+       print CPPI "#include <winsock.h>\n";
+       foreach $err (keys %wsa) {
+           print CPPI "#ifndef $err\n";
+           print CPPI "#define $err WSA$err\n";
+           print CPPI "#endif\n";
+           $err{$err} = 1;
        }
-
+    }
     foreach $err (keys %err) {
        print CPPI '"',$err,'" [[',$err,']]',"\n";
     }
@@ -264,6 +287,7 @@ use strict;
        die "Errno architecture ($Config{'archname'}-$Config{'osvers'}) does not match executable architecture (\$Config{'archname'}-\$Config{'osvers'})";
 
 \$VERSION = "$VERSION";
+\$VERSION = eval \$VERSION;
 \@ISA = qw(Exporter);
 
 EDQ