From: Tye McQueen Date: Sun, 4 Jan 1998 00:30:57 +0000 (-0600) Subject: [win32] Add a tweaked version of: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=22fae026e9f4859841088a1c5609be12b0b1d4f3;p=p5sagit%2Fp5-mst-13.2.git [win32] Add a tweaked version of: Message-Id: <199801040630.AA29298@metronet.com> Subject: New patch for $^E==GetLastError() under Win32 p4raw-id: //depot/win32/perl@392 --- diff --git a/doio.c b/doio.c index cd718a9..dce271d 100644 --- a/doio.c +++ b/doio.c @@ -500,7 +500,8 @@ nextargv(register GV *gv) return IoIFP(GvIOp(gv)); } else - PerlIO_printf(PerlIO_stderr(), "Can't open %s: %s\n",SvPV(sv, na), Strerror(errno)); + PerlIO_printf(PerlIO_stderr(), "Can't open %s: %s\n", + SvPV(sv, na), Strerror(errno)); } if (inplace) { (void)do_close(argvoutgv,FALSE); diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl index c32bc2f..cc7da89 100644 --- a/lib/dumpvar.pl +++ b/lib/dumpvar.pl @@ -22,6 +22,7 @@ $printUndef = 1 unless defined $printUndef; $tick = "auto" unless defined $tick; $unctrl = 'quote' unless defined $unctrl; $subdump = 1; +$dumpReused = 0 unless defined $dumpReused; sub main::dumpValue { local %address; @@ -118,7 +119,7 @@ sub unwrap { # Check for reused addresses if (ref $v) { ($address) = $v =~ /(0x[0-9a-f]+)\)$/ ; - if (defined $address) { + if (!$dumpReused && defined $address) { ($type) = $v =~ /=(.*?)\([^=]+$/ ; $address{$address}++ ; if ( $address{$address} > 1 ) { diff --git a/lib/perl5db.pl b/lib/perl5db.pl index ea072e0..f0774bc 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -173,7 +173,7 @@ $trace = $signal = $single = 0; # Uninitialized warning suppression # (local $^W cannot help - other packages!). $inhibit_exit = $option{PrintRet} = 1; -@options = qw(hashDepth arrayDepth DumpDBFiles DumpPackages +@options = qw(hashDepth arrayDepth DumpDBFiles DumpPackages DumpReused compactDump veryCompact quote HighBit undefPrint globPrint PrintRet UsageOnly frame AutoTrace TTY noTTY ReadLine NonStop LineInfo maxTraceLen @@ -185,6 +185,7 @@ $inhibit_exit = $option{PrintRet} = 1; arrayDepth => \$dumpvar::arrayDepth, DumpDBFiles => \$dumpvar::dumpDBFiles, DumpPackages => \$dumpvar::dumpPackages, + DumpReused => \$dumpvar::dumpReused, HighBit => \$dumpvar::quoteHighBit, undefPrint => \$dumpvar::printUndef, globPrint => \$dumpvar::globPrint, @@ -368,7 +369,7 @@ sub DB { &save; ($package, $filename, $line) = caller; $filename_ini = $filename; - $usercontext = '($@, $!, $,, $/, $\, $^W) = @saved;' . + $usercontext = '($@, $!, $^E, $,, $/, $\, $^W) = @saved;' . "package $package;"; # this won't let them modify, alas local(*dbline) = $main::{'_<' . $filename}; $max = $#dbline; @@ -1140,7 +1141,7 @@ EOP &eval; } } # if ($single || $signal) - ($@, $!, $,, $/, $\, $^W) = @saved; + ($@, $!, $^E, $,, $/, $\, $^W) = @saved; (); } @@ -1190,7 +1191,7 @@ sub sub { } sub save { - @saved = ($@, $!, $,, $/, $\, $^W); + @saved = ($@, $!, $^E, $,, $/, $\, $^W); $, = ""; $/ = "\n"; $\ = ""; $^W = 0; } @@ -1210,7 +1211,7 @@ sub eval { } my $at = $@; local $saved[0]; # Preserve the old value of $@ - eval "&DB::save"; + eval { &DB::save }; if ($at) { print $OUT $at; } elsif ($onetimeDump eq 'dump') { @@ -1785,6 +1786,7 @@ B [I[B<=>I]] [IB<\">IB<\">] [IB]... I: whether to print contents of globs; I: dump arrays holding debugged files; I: dump symbol tables of packages; + I: dump contents of \"reused\" addresses; I, I, I: change style of string dump; Option I affects printing of return value after B command, I affects printing messages on entry and exit from subroutines. diff --git a/mg.c b/mg.c index b032bf3..1d00143 100644 --- a/mg.c +++ b/mg.c @@ -69,7 +69,6 @@ restore_magic(void *p) } } - void mg_magical(SV *sv) { @@ -350,10 +349,22 @@ magic_get(SV *sv, MAGIC *mg) sv_setpv(sv, os2error(Perl_rc)); } #else +#ifdef WIN32 + { + DWORD dwErr = GetLastError(); + sv_setnv(sv, (double)dwErr); + if (dwErr) + win32_str_os_error(sv, dwErr); + else + sv_setpv(sv, ""); + SetLastError(dwErr); + } +#else sv_setnv(sv, (double)errno); sv_setpv(sv, errno ? Strerror(errno) : ""); #endif #endif +#endif SvNOK_on(sv); /* what a wonderful hack! */ break; case '\006': /* ^F */ @@ -1349,9 +1360,13 @@ magic_set(SV *sv, MAGIC *mg) #ifdef VMS set_vaxc_errno(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)); #else +#ifdef WIN32 + SetLastError( SvIV(sv) ); +#else /* will anyone ever use this? */ SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv), 4); #endif +#endif break; case '\006': /* ^F */ maxsysfd = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv); diff --git a/perl.h b/perl.h index 59d7293..9138ba6 100644 --- a/perl.h +++ b/perl.h @@ -1666,6 +1666,10 @@ struct perl_thread { #include "thrdvar.h" }; +typedef struct perl_thread *Thread; + +#else +typedef void *Thread; #endif /* Done with PERLVAR macros for now ... */ @@ -1673,8 +1677,6 @@ struct perl_thread { #undef PERLVARI #undef PERLVARIC -typedef struct perl_thread *Thread; - #include "thread.h" #include "pp.h" #include "proto.h" diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 49d455b..a89ee99 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1,3 +1,4 @@ + =head1 NAME perlfunc - Perl builtin functions @@ -79,117 +80,120 @@ than one place. =item Functions for SCALARs or strings -chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, -oct, ord, pack, q/STRING/, qq/STRING/, reverse, rindex, -sprintf, substr, tr///, uc, ucfirst, y/// +C, C, C, C, C, C, C, C, +C, C, C, C, C/STRING/, C/STRING/, C, +C, C, C, C, C, C, C/// =item Regular expressions and pattern matching -m//, pos, quotemeta, s///, split, study +C//, C, C, C///, C, C =item Numeric functions -abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, -srand +C, C, C, C, C, C, C, C, C, +C, C, C =item Functions for real @ARRAYs -pop, push, shift, splice, unshift +C, C, C, C, C =item Functions for list data -grep, join, map, qw/STRING/, reverse, sort, unpack +C, C, C, C/STRING/, C, C, C =item Functions for real %HASHes -delete, each, exists, keys, values +C, C, C, C, C =item Input and output functions -binmode, close, closedir, dbmclose, dbmopen, die, eof, -fileno, flock, format, getc, print, printf, read, readdir, -rewinddir, seek, seekdir, select, syscall, sysread, sysseek, -syswrite, tell, telldir, truncate, warn, write +C, C, C, C, C, C, C, +C, C, C, C, C, C, C, +C, C, C, C, C