This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] merge changes#989,990,992 from maintbranch
[perl5.git] / t / op / ipcmsg.t
index 98cf8bc..ab2b073 100755 (executable)
@@ -30,12 +30,15 @@ BEGIN {
        print "1..0\n";
        exit;
     }
+
+    use strict;
+
     my @incpath = (split(/\s+/, $Config{usrinc}), split(/\s+/ ,$Config{locincpth}));
     my %done = ();
     my %define = ();
 
     sub process_file {
-       my($file) = @_;
+       my($file,$level) = @_;
 
        return unless defined $file;
 
@@ -51,40 +54,55 @@ BEGIN {
        return if exists $done{$path};
        $done{$path} = 1;
 
-       unless(defined $path) {
+       if(not defined $path and $level == 0) {
            warn "Cannot find '$file'";
            return;
        }
 
+       local(*F);
        open(F,$path) or return;
+        $level = 1 unless defined $level;
+       my $indent = " " x $level;
+       print "#$indent open $path\n";
        while(<F>) {
            s#/\*.*(\*/|$)##;
 
-           process_file($mm,$1)
-                   if /^#\s*include\s*[<"]([^>"]+)[>"]/;
+           if ( /^#\s*include\s*[<"]([^>"]+)[>"]/ ) {
+               print "#${indent} include $1\n";
+               process_file($1,$level+1);
+               print "#${indent} done include $1\n";
+               print "#${indent} back in $path\n";
+           }
 
            s/(?:\([^)]*\)\s*)//;
 
-           $define{$1} = $2
-               if /^#\s*define\s+(\w+)\s+((0x)?\d+|\w+)/;
+           if ( /^#\s*define\s+(\w+)\s+(\w+)/ ) {
+               print "#${indent} define $1 $2\n";
+               $define{$1} = $2;
+           }
        }
        close(F);
+       print "#$indent close $path\n";
     }
 
     process_file("sys/sem.h");
     process_file("sys/ipc.h");
     process_file("sys/stat.h");
 
-    foreach $d (@define) {
+    foreach my $d (@define) {
        while(defined($define{$d}) && $define{$d} !~ /^(0x)?\d+$/) {
            $define{$d} = exists $define{$define{$d}}
                    ? $define{$define{$d}} : undef;
        }
        unless(defined $define{$d}) {
-           print "0..0\n";
+           print "# $d undefined\n";
+           print "1..0\n";
            exit;
-       };
-       ${ $d } = eval $define{$d};
+       }
+       {
+           no strict 'refs';
+           ${ $d } = eval $define{$d};
+        }
     }
 }