#BUGFIX by stefan
authorStefan Vogel <sv@exept.de>
Thu, 07 Mar 2019 16:47:47 +0100
changeset 23848 b74dc3385473
parent 23847 a74f168d8848
child 23849 931471bc4a08
#BUGFIX by stefan class: Win32OperatingSystem class changed: #documentPropertiesDialogFor:hPrinter:pDeviceName:devModeInput: #getLoginName #getSystemWow64Directory Fix various stc complaints class: Win32OperatingSystem::PerformanceData::Abstract changed: #getCounterNameIndexArray
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Wed Mar 06 16:39:17 2019 +0100
+++ b/Win32OperatingSystem.st	Thu Mar 07 16:47:47 2019 +0100
@@ -88,8 +88,8 @@
 
 Object subclass:#PerformanceData
 	instanceVariableNames:'objectArray perfTime perfFreq perfTime100nSec'
-	classVariableNames:'PerformanceText CounterIndexTextDictionary
-		HelpIndexTextDictionary'
+	classVariableNames:'CounterIndexTextDictionary HelpIndexTextDictionary
+		PerformanceText'
 	poolDictionaries:''
 	privateIn:Win32OperatingSystem
 !
@@ -6353,43 +6353,42 @@
 %{  /* STACK: 8000*/
     char buffer[MAXPATHLEN+1];
 
-    int __rslt;
-#if 1 // only change to 0 if all systems/compiles support GetSystemWow64DirectoryW
-    // starting with Windows 8, this:
+    int __rslt = 0;
+#if defined(__BORLANDC__) // only change to 0 if all systems/compiles support GetSystemWow64DirectoryW
+    // starting with Windows XP, this:
     //    GetSystemWow64DirectoryW(&fileTime);
     // can be called directly.
     {
-	typedef unsigned int (WINAPI *P_GetSystemWow64DirectoryW)(LPTSTR, unsigned int);
-	static P_GetSystemWow64DirectoryW pGetSystemWow64DirectoryW = NULL;
-	static int didCheck = 0;
-
-	if (pGetSystemWow64DirectoryW == NULL) {
-	    if (!didCheck) {
-		pGetSystemWow64DirectoryW =
-		    (P_GetSystemWow64DirectoryW)
-			GetProcAddress ( GetModuleHandle ("kernel32.dll"),
-					 "GetSystemWow64DirectoryW");
-
-		didCheck = 1;
-	    }
-	}
-
-	if (pGetSystemWow64DirectoryW != NULL) {
-	    __rslt = nil;
-	} else {
-	    __rslt = (*pGetSystemWow64DirectoryW)(buffer, MAXPATHLEN);
-	}
+        typedef unsigned int (WINAPI *P_GetSystemWow64DirectoryW)(LPTSTR, unsigned int);
+        static P_GetSystemWow64DirectoryW pGetSystemWow64DirectoryW = NULL;
+        static int didCheck = 0;
+
+        if (pGetSystemWow64DirectoryW == NULL) {
+            if (!didCheck) {
+                pGetSystemWow64DirectoryW =
+                    (P_GetSystemWow64DirectoryW)
+                        GetProcAddress ( GetModuleHandle ("kernel32.dll"),
+                                         "GetSystemWow64DirectoryW");
+
+                didCheck = 1;
+            }
+        }
+
+        if (pGetSystemWow64DirectoryW != NULL) {
+            __rslt = (*pGetSystemWow64DirectoryW)(buffer, MAXPATHLEN);
+        }
     }
 #else
     __rslt = GetSystemWow64DirectoryW(buffer, MAXPATHLEN);
 #endif
-    if (__rslt != nil) {
-	rslt = __mkStringOrU16String_maxlen(buffer, MAXPATHLEN);
+    if (__rslt != 0) {
+        rslt = __mkStringOrU16String_maxlen(buffer, MAXPATHLEN);
     }
 %}.
     ^ rslt
 
     "Modified: / 11-02-2014 / 21:18:20 / cg"
+    "Modified: / 07-03-2019 / 15:47:39 / Stefan Vogel"
 !
 
 getVolumeInformation: rootPath
@@ -10482,7 +10481,7 @@
 !
 
 documentPropertiesDialogFor:hwndOrNil hPrinter:hPrinter pDeviceName:deviceName devModeInput:pDevModeInputOrNil
-    |nBytesNeeded hPrinter rslt devModeOutput|
+    |nBytesNeeded rslt devModeOutput|
 
 "
 #define DM_UPDATE           1
@@ -10496,22 +10495,22 @@
 #define DM_OUT_DEFAULT      DM_UPDATE
 "
     nBytesNeeded := self
-	   primDocumentProperties:nil
-	   hPrinter:hPrinter
-	   pDeviceName: deviceName
-	   pDevModeOutput:nil
-	   pDevModeInput:nil
-	   fMode:0.
+           primDocumentProperties:nil
+           hPrinter:hPrinter
+           pDeviceName: deviceName
+           pDevModeOutput:nil
+           pDevModeInput:nil
+           fMode:0.
 
     devModeOutput := DevModeStructure new:(nBytesNeeded * 2 "never trust MS !!").
 
     rslt := self
-	   primDocumentProperties:nil
-	   hPrinter:hPrinter
-	   pDeviceName: deviceName
-	   pDevModeOutput:devModeOutput
-	   pDevModeInput:pDevModeInputOrNil
-	   fMode:4+2.
+           primDocumentProperties:nil
+           hPrinter:hPrinter
+           pDeviceName: deviceName
+           pDevModeOutput:devModeOutput
+           pDevModeInput:pDevModeInputOrNil
+           fMode:4+2.
 
     ^ devModeOutput
 
@@ -10523,6 +10522,7 @@
     "
 
     "Created: / 27-07-2006 / 15:39:21 / fm"
+    "Modified: / 07-03-2019 / 15:52:16 / Stefan Vogel"
 !
 
 endDoc: deviceContext
@@ -12276,40 +12276,40 @@
 
 %{  /* NOCONTEXT */
     static char cachedName[64];
-    static firstCall = 1;
+    static int firstCall = 1;
 #ifndef __BORLANDC__
     extern char *getenv();
 #endif
     char *name = (char *)0;
 
     if (firstCall) {
-	DWORD nameSize = sizeof(cachedName);
-
-	if (GetUserName(cachedName, &nameSize) == TRUE) {
-	    name = cachedName;
-	    firstCall = 0;
-	}
+        DWORD nameSize = sizeof(cachedName);
+
+        if (GetUserName(cachedName, &nameSize) == TRUE) {
+            name = cachedName;
+            firstCall = 0;
+        }
     } else {
-	name = cachedName;
+        name = cachedName;
     }
 
     /*
      * try a few common environment variables ...
      */
     if (! name || (name[0] == 0) ) {
-	name = getenv("LOGIN");
-	if (! name || (name[0] == 0) ) {
-	    name = getenv("LOGNAME");
-	    if (! name || (name[0] == 0) ) {
-		name = getenv("USER");
-	    }
-	}
+        name = getenv("LOGIN");
+        if (! name || (name[0] == 0) ) {
+            name = getenv("LOGNAME");
+            if (! name || (name[0] == 0) ) {
+                name = getenv("USER");
+            }
+        }
     }
     /*
      * nope - I really font know who you are.
      */
     if (! name || (name[0] == 0) ) {
-	name = "you";
+        name = "you";
     }
 
     RETURN ( __MKSTRING(name) );
@@ -12317,6 +12317,8 @@
     "
      OperatingSystem getLoginName
     "
+
+    "Modified: / 07-03-2019 / 16:00:27 / Stefan Vogel"
 !
 
 getUserID
@@ -14741,17 +14743,26 @@
 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'queries'!
 
 getCounterNameIndexArray
-    |data object debugBlock|
-
-    data := self data.
-
-    self indexedNameNumbered == 0 ifTrue:[
-	object := data objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
+    |index objectArray object debugBlock|
+
+    debugBlock := [:obj|
+                      ^ 'obj:', obj , ' this:', self printString , ' idx:', self indexedName
+                  ].
+
+    objectArray := self data objectArray.
+    index := self indexedNameNumbered.
+
+    index == 0 ifTrue:[
+        object := objectArray at:1 ifAbsent:[debugBlock value:(object at:#ObjectNameTitle)].
     ] ifFalse:[
-	object := data objectArray detect:[:el|(el at:#ObjectNameTitleIndex) == self indexedNameNumbered] ifNone:[self error:'counter not found'].
-    ].
-
-    ^ (object at:#Counters) collect:[:el|Array with:(el at:#CounterNameTitle) with:(el at:#CounterNameTitleIndex)].
+        object := objectArray detect:[:el| (el at:#ObjectNameTitleIndex) == index] 
+                              ifNone:[self error:'counter not found'].
+    ].
+
+    ^ (object at:#Counters) 
+         collect:[:el| {el at:#CounterNameTitle. el at:#CounterNameTitleIndex}].
+
+    "Modified: / 07-03-2019 / 16:29:51 / Stefan Vogel"
 ! !
 
 !Win32OperatingSystem::PerformanceData::Abstract methodsFor:'queries - timed'!