Fix user name detection for Windows.
author <shinichiro.hamaji@gmail.com> <>
Wed, 29 Jul 2009 08:38:20 +0000 (08:38 +0000)
committer <shinichiro.hamaji@gmail.com> <>
Wed, 29 Jul 2009 08:38:20 +0000 (08:38 +0000)
This patch was given by ademin (thanks!).

http://code.google.com/p/google-glog/issues/detail?id=12

git-svn-id: https://google-glog.googlecode.com/svn/trunk@64 eb4d4688-79bd-11dd-afb4-1d65580434c0

src/utilities.cc

index 149245c2ff0b0716a9ed464e3a65fc0a1216a61e..d35744e447368ba9856c52eae0c14c46e1f4bea3 100644 (file)
@@ -268,7 +268,11 @@ const string& MyUserName() {
 }
 static void MyUserNameInitializer() {
   // TODO(hamaji): Probably this is not portable.
+#if defined(OS_WINDOWS)
+  const char* user = getenv("USERNAME");
+#else
   const char* user = getenv("USER");
+#endif
   if (user != NULL) {
     g_my_user_name = user;
   } else {