Fix [perl #27357] Scalar Win32::GetOSVersion() broken in 5.8.3
Rafael Garcia-Suarez [Thu, 4 Mar 2004 10:35:59 +0000 (10:35 +0000)]
(by Steve Hay)

p4raw-id: //depot/perl@22431

MANIFEST
t/win32/getosversion.t [new file with mode: 0644]
win32/win32.c

index 2d038bd..91479a5 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2949,6 +2949,7 @@ t/uni/tr_sjis.t                   See if Unicode tr/// works
 t/uni/tr_utf8.t                        See if Unicode tr/// works
 t/uni/upper.t                  See if Unicode casing works
 t/uni/write.t                  See if Unicode formats work
+t/win32/getosversion.t         Test if Win32::GetOSVersion() works
 t/win32/longpath.t             Test if Win32::GetLongPathName() works
 t/win32/system.t               See if system works in Win*
 t/win32/system_tests           Test runner for system.t
diff --git a/t/win32/getosversion.t b/t/win32/getosversion.t
new file mode 100644 (file)
index 0000000..2a708cb
--- /dev/null
@@ -0,0 +1,13 @@
+#!perl -w
+
+# tests for Win32::GetOSVersion()
+
+$^O =~ /^MSWin/ or print("1..0 # not win32\n" ), exit;
+
+print "1..1\n";
+
+my $scalar = Win32::GetOSVersion();
+my @array  = Win32::GetOSVersion();
+
+print "not " unless $scalar == $array[4];
+print "ok 1\n";
index f4c43fc..19662af 100644 (file)
@@ -4618,6 +4618,9 @@ XS(w32_GetOSVersion)
                 XSRETURN_EMPTY;
             }
        }
+       if (GIMME_V == G_SCALAR) {
+           XSRETURN_IV(osverw.dwPlatformId);
+       }
        W2AHELPER(osverw.szCSDVersion, szCSDVersion, sizeof(szCSDVersion));
        XPUSHs(newSVpvn(szCSDVersion, strlen(szCSDVersion)));
         osver.dwMajorVersion    = osverw.dwMajorVersion;
@@ -4638,6 +4641,9 @@ XS(w32_GetOSVersion)
                 XSRETURN_EMPTY;
             }
        }
+       if (GIMME_V == G_SCALAR) {
+           XSRETURN_IV(osver.dwPlatformId);
+       }
        XPUSHs(newSVpvn(osver.szCSDVersion, strlen(osver.szCSDVersion)));
     }
     XPUSHs(newSViv(osver.dwMajorVersion));