diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | win32/win32.c | 23 |
2 files changed, 14 insertions, 13 deletions
@@ -1,3 +1,7 @@ +Tue Oct 2 20:16:55 2007 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c (init_env): refactoring. remove unused code. + Tue Oct 2 12:30:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org> * array.c (rb_ary_product): generalized product, now takes diff --git a/win32/win32.c b/win32/win32.c index ce13650cfd..99199c95af 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -372,19 +372,16 @@ init_env(void) SetEnvironmentVariable("HOME", env); } } - if (GetEnvironmentVariable("USER", env, sizeof env)) { - len = strlen(env); - } - if (GetEnvironmentVariable("USERNAME", env, sizeof env)) { - len = strlen(env); - SetEnvironmentVariable("USER", env); - } - else if (GetUserName(env, (len = sizeof env, &len))) { - SetEnvironmentVariable("USER", env); - } - else { - NTLoginName = "<Unknown>"; - return; + + if (!GetEnvironmentVariable("USER", env, sizeof env)) { + if (GetEnvironmentVariable("USERNAME", env, sizeof env) || + GetUserName(env, (len = sizeof env, &len))) { + SetEnvironmentVariable("USER", env); + } + else { + NTLoginName = "<Unknown>"; + return; + } } NTLoginName = strdup(env); } |