This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Errno.pm suffers from \\ too
[perl5.git] / ext / Errno / Errno_pm.PL
index f4d5020..3df9881 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 
 use vars qw($VERSION);
 
-$VERSION = "1.09";
+$VERSION = "1.111";
 
 my %err = ();
 
@@ -31,7 +31,9 @@ sub process_file {
        }     
     } else {
        unless(open(FH,"< $file")) {
-            warn "Cannot open '$file'";
+           # This file could be a temporay file created by cppstdin
+           # so only warn under -w, and return
+            warn "Cannot open '$file'" if $^W;
             return;
        }
     }
@@ -56,6 +58,9 @@ sub get_files {
     } elsif ($^O eq 'os390') {
        # OS/390 C compiler doesn't generate #file or #line directives
        $file{'/usr/include/errno.h'} = 1;
+    } elsif ($^O eq 'vmesa') {
+       # OS/390 C compiler doesn't generate #file or #line directives
+       $file{'../../vmesa/errno.h'} = 1;
     } else {
        open(CPPI,"> errno.c") or
            die "Cannot open errno.c";
@@ -65,9 +70,14 @@ sub get_files {
        close(CPPI);
 
        # invoke CPP and read the output
-
-       open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or
-           die "Cannot exec $Config{cpprun}";
+       if ($^O eq 'MSWin32') {
+           open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or
+               die "Cannot run '$Config{cpprun} $Config{cppflags} errno.c'";
+       } else {
+           my $cpp = "$Config{cppstdin} $Config{cppflags} $Config{cppminus}";
+           open(CPPO,"$cpp < errno.c |") or
+               die "Cannot exec $cpp";
+       }
 
        my $pat;
        if ($^O eq 'MSWin32' and $Config{cc} =~ /^bcc/i) {
@@ -77,7 +87,16 @@ sub get_files {
            $pat = '^#(?:line)?\s*\d+\s+"([^"]+)"';
        }
        while(<CPPO>) {
-           $file{$1} = 1 if /$pat/o;
+           if ($^O eq 'os2') {
+               if (/$pat/o) {
+                  my $f = $1;
+                  $f =~ s,\\\\,/,g;
+                  $file{$f} = 1;
+               }
+           }
+           else {
+               $file{$1} = 1 if /$pat/o;
+           }
        }
        close(CPPO);
     }
@@ -107,14 +126,13 @@ sub write_errno_pm {
        $cpp =~ s/sys\$input//i;
        open(CPPO,"$cpp  errno.c |") or
           die "Cannot exec $Config{cppstdin}";
-    } elsif(!$Config{'cpprun'} or $^O eq 'next') {
-       # NeXT will do syntax checking unless it is reading from stdin
+    } elsif ($^O eq 'MSWin32') {
+       open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or
+           die "Cannot run '$Config{cpprun} $Config{cppflags} errno.c'";
+    } else {
        my $cpp = "$Config{cppstdin} $Config{cppflags} $Config{cppminus}";
        open(CPPO,"$cpp < errno.c |")
            or die "Cannot exec $cpp";
-    } else {
-       open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or
-           die "Cannot exec $Config{cpprun}";
     }
 
     %err = ();