develooper Front page | perl.perl5.porters | Postings from November 2013

about commit "$^E should have same handling as $! for Win32 and OS/2"

Thread Next
From:
bulk88
Date:
November 27, 2013 08:15
Subject:
about commit "$^E should have same handling as $! for Win32 and OS/2"
Message ID:
BLU0-SMTP277916D2945F1EAF2D7D970DFEF0@phx.gbl
----------------------------------------------------------------
@@ -848,12 +848,18 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
             sv_setnv(sv, (NV)Perl_rc);
             sv_setpv(sv, os2error(Perl_rc));
         }
+        if (SvOK(sv) && strNE(SvPVX(sv), "")) {
+            fixup_errno_string(sv);
+        }
 #   elif defined(WIN32)
         {
             const DWORD dwErr = GetLastError();
             sv_setnv(sv, (NV)dwErr);
             if (dwErr) {
                 PerlProc_GetOSError(sv, dwErr);
+                if (SvOK(sv)) {
+                    fixup_errno_string(sv);
+                }
             }
             else
                 sv_setpvs(sv, "");
----------------------------------------------------------------
Something about "if (SvOK(sv) && strNE(SvPVX(sv), "")) {" looks strange. 
In the previous 2 branches, sv_setnv and sv_setpv is always called on 
sv, without set magic. How would the sv be undef?

For the win32 branch, I dont see sv ever being undef since 
http://perl5.git.perl.org/perl.git/blob/a6c83041cf6cd2db8b2df9625081f214af8bc56a:/win32/win32.c#l2644 
win32_str_os_error either sets the SV to a string, or doesn't touch the 
SV. If win32_str_os_error doesn't touch the SV, then per
-------------------------
             const DWORD dwErr = GetLastError();
             sv_setnv(sv, (NV)dwErr);<<<<<<<<<<<<<<<
             if (dwErr) {
-------------------------
it wouldn't be undef.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About