Tcl Source Code

Artifact [4849b67ad0]
Login

Artifact 4849b67ad02ceee5078a9a4600c5127458765018:

Attachment "685926.patch" to ticket [685926ffff] added by kennykb 2003-02-14 06:17:08.
Index: win/tclWinInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinInit.c,v
retrieving revision 1.38
diff -u -r1.38 tclWinInit.c
--- win/tclWinInit.c	4 Feb 2003 17:06:53 -0000	1.38
+++ win/tclWinInit.c	13 Feb 2003 23:08:22 -0000
@@ -13,6 +13,7 @@
 #include "tclWinInt.h"
 #include <winnt.h>
 #include <winbase.h>
+#include <lmcons.h>
 
 /*
  * The following declaration is a workaround for some Microsoft brain damage.
@@ -597,6 +598,8 @@
     OemId *oemId;
     OSVERSIONINFOA osInfo;
     Tcl_DString ds;
+    TCHAR szUserName[ UNLEN+1 ];
+    DWORD dwUserNameLen;
 
     osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
     GetVersionExA(&osInfo);
@@ -663,11 +666,12 @@
      * faster than asking the system.
      */
 
-    Tcl_DStringSetLength(&ds, 100);
+    Tcl_DStringInit( &ds );
     if (TclGetEnv("USERNAME", &ds) == NULL) {
-	if (GetUserName(Tcl_DStringValue(&ds), (LPDWORD) &Tcl_DStringLength(&ds)) == 0) {
-	    Tcl_DStringSetLength(&ds, 0);
-	}
+
+	if ( GetUserName( szUserName, &dwUserNameLen ) != 0 ) {
+	    Tcl_WinTCharToUtf( szUserName, dwUserNameLen, &ds );
+	}	
     }
     Tcl_SetVar2(interp, "tcl_platform", "user", Tcl_DStringValue(&ds),
 	    TCL_GLOBAL_ONLY);