From: Tim Sweetman Date: Wed, 13 Jun 2001 14:25:17 +0000 (+0100) Subject: Fix for [ID 20010124.001] POSIX::errno unreliable X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=212caf55b8a7ec0d131ccbf5f587aaed741446df;p=p5sagit%2Fp5-mst-13.2.git Fix for [ID 20010124.001] POSIX::errno unreliable Message-ID: <3B2769BD.68B4F4B3@aldigital.co.uk> p4raw-id: //depot/perl@10756 --- diff --git a/ext/POSIX/POSIX.t b/ext/POSIX/POSIX.t index cf08269..5bb6ab1 100755 --- a/ext/POSIX/POSIX.t +++ b/ext/POSIX/POSIX.t @@ -10,11 +10,12 @@ BEGIN { } } -use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write); +use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write + errno); use strict subs; $| = 1; -print "1..27\n"; +print "1..29\n"; $Is_W32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; @@ -133,6 +134,20 @@ try_strftime(26, "Wed Mar 01 00:00:00 2000 061", 0,0,0, 1,2,100); try_strftime(27, "Fri Mar 31 00:00:00 2000 091", 0,0,0, 31,2,100); &POSIX::setlocale(&POSIX::LC_TIME, $lc) if $Config{d_setlocale}; +{ + for my $test (0, 1) { + $! = 0; + # POSIX::errno is autoloaded. + # Autoloading requires many system calls. + # errno() looks at $! to generate its result. + # Autoloading should not munge the value. + my $foo = $!; + my $errno = POSIX::errno(); + print "not " unless $errno == $foo; + print "ok ", 28 + $test, "\n"; + } +} + $| = 0; # The following line assumes buffered output, which may be not true with EMX: print '@#!*$@(!@#$' unless ($^O eq 'os2' || $^O eq 'uwin' || $^O eq 'os390' || diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 564aeb1..10d13ba 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -88,6 +88,7 @@ AUTOLOAD { } } my $save = $@; + local $!; # Do not munge the value. eval { local $SIG{__DIE__}; require $filename }; if ($@) { if (substr($sub,-9) eq '::DESTROY') {