*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Tue, 09 Jan 2007 20:13:36 +0100
changeset 10297 d93eeb6c92eb
parent 10296 48eb9cc9eef0
child 10298 567ea28f3852
*** empty log message ***
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Tue Jan 09 20:02:20 2007 +0100
+++ b/Win32OperatingSystem.st	Tue Jan 09 20:13:36 2007 +0100
@@ -6017,21 +6017,31 @@
     "get an environment string"
 
 %{  /* NOCONTEXT */
-
     char *env;
 
     if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
-        char buff[2048];
-
-        env = NULL;
-        if (GetEnvironmentVariable(__stringVal(aStringOrSymbol),
+        char buff[1024];
+        int nNeeded;
+        OBJ ret = nil;
+
+        nNeeded = GetEnvironmentVariable(__stringVal(aStringOrSymbol),
                                    buff,
-                                   sizeof(buff)-1)) {
-            env = buff;
+                                   sizeof(buff));
+        if (nNeeded > sizeof(buff)) {
+            char *buff2;
+
+            buff2 = (char *)malloc(nNeeded);
+            GetEnvironmentVariable(__stringVal(aStringOrSymbol),
+                                   buff2,
+                                   nNeeded);
+            ret = __MKSTRING(buff2);
+            free(buff2);
+        } else {
+            if (nNeeded > 0) {
+                ret = __MKSTRING(buff);
+            }
         }
-        if (env) {
-            RETURN ( __MKSTRING(env) );
-        }
+        RETURN (ret);
     }
 %}
 .
@@ -6046,7 +6056,7 @@
      OperatingSystem getEnvironment:'PATH'
     "
 
-    "Modified: / 09-01-2007 / 19:54:01 / cg"
+    "Modified: / 09-01-2007 / 20:14:35 / cg"
 !
 
 getHostName
@@ -12708,7 +12718,7 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.256 2007-01-09 18:53:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.257 2007-01-09 19:13:36 cg Exp $'
 ! !
 
 Win32OperatingSystem initialize!