[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-patches
Subject:    User-Agent and Windows Versions
From:       Jerry Baker <jbaker6953 () yahoo ! com>
Date:       2000-03-10 18:46:54
[Download RAW message or body]

We have all seen the case where a new version of Windows comes out and
older versions of Netscape and/or Mozilla were not set up to handle
them. This results in an incorrectly identified platform in the UA
string. Not really a big deal, but for sniffers that want to check the
OS, it is annoying when someone on Windows 98 is using Netscape 4.04 or
lower because it will identify the platform as Windows 95. We see the
same thing with Netscape < 4.72 and Mozilla < M14 with Windows 2000. In
order to make differentiation of Windows versions that have yet to be
released automatic, I propose the attached patch. I guess I just want to
see if anyone sees any potential problems with it and if you want, test
building it on Mac and/or a *nix platform just to make sure that the
compiler never sees the _itoa() function (it's Win only as far as I
know). It's inside the "#ifdef XP_PC", so it should be OK, but you never
know.

There is not an explicit definition for Windows Millennium yet because
it is unclear what I.E. is going to report. Currently, in the Windows ME
betas, I.E. is reporting (...Windows 98, Windows 4.90). Which to use?
The
reason it matters what I.E. reports is because it will be a good thing
for Mozilla to use compatible OS identifiers where it doesn't break
backwards compatibility. Since Mozilla/Netscape have never had an OS
identifier for Windows ME, there is no reason not to use the I.E.
string.

The ordering of the cases in the switch() function may look funny, but
they are in the order that I think they are most likely to occur (I am
counting on Millennium to be adopted as rapidly as Win98 SE was). This
should make branch prediction more accurate on CPU's that do this (I
know it's almost pointless to worry about it in such a small piece of
code, but why not?).

Any and all comments/flames welcome.

-- 
Jerry Baker

PGP Mail Preferred
Key: http://pgpkeys.mit.edu:11371/pks/lookup?op=get&search=0x09DE91C6
["diff.txt" (text/plain)]

Index: nsHTTPHandler.cpp
===================================================================
RCS file: /cvsroot/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp,v
retrieving revision 1.83
diff -u -r1.83 nsHTTPHandler.cpp
--- nsHTTPHandler.cpp   2000/03/09 22:29:00 1.83
+++ nsHTTPHandler.cpp   2000/03/10 18:38:14
@@ -608,26 +608,38 @@
 #ifdef XP_PC
     OSVERSIONINFO info = { sizeof OSVERSIONINFO };
     if (GetVersionEx(&info)) {
-        if ( info.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
-            if (info.dwMajorVersion      == 3) {
-                mAppOSCPU = "WinNT3.51";
+    
+    char mWinMajorVer[5];
+        _itoa(info.dwMajorVersion, mWinMajorVer, 10);
+    char mWinMinorVer[5];
+        _itoa(info.dwMinorVersion, mWinMinorVer, 10);
+
+        if (info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+        
+                switch (info.dwMajorVersion) {
+                    case 4:         mAppOSCPU = "WinNT4.0"; break;
+                    default:        mAppOSCPU = "Windows NT ";
+                                    mAppOSCPU += mWinMajorVer;
+                                    mAppOSCPU += ".";
+                                    mAppOSCPU += mWinMinorVer;
+                                    break;
+                    case 3:         mAppOSCPU = "WinNT3.51"; break;
+                }
+        } 
+        else if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+            
+            switch (info.dwMinorVersion) {        
+                case 10:        mAppOSCPU = "Win98"; break;
+                default:        mAppOSCPU = "Windows ";
+                                mAppOSCPU += mWinMajorVer;
+                                mAppOSCPU += ".";
+                                mAppOSCPU += mWinMinorVer;
+                                break;
+                case 0:         mAppOSCPU = "Win95"; break;
             }
-            else if (info.dwMajorVersion == 4) {
-                mAppOSCPU = "WinNT4.0";
-            }
-            else if (info.dwMajorVersion == 5) {
-                mAppOSCPU = "Windows NT 5.0";
-            }
-            else {
-                mAppOSCPU = "WinNT";
-            }
-        } else if (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
-            if (info.dwMinorVersion > 0)
-                mAppOSCPU = "Win98";
-            else
-                mAppOSCPU = "Win95";
         }
     }
+    
 #elif defined (XP_UNIX)
     struct utsname name;
     





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic