]> sourceware.org Git - newlib-cygwin.git/commitdiff
* globals.cc (__getlogin_username): Remove.
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 16 May 2011 17:58:21 +0000 (17:58 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 16 May 2011 17:58:21 +0000 (17:58 +0000)
* uinfo.cc (getlogin_r): Fetch username from cygheap.
(getlogin): Add static buffer username and fetch username from
getlogin_r.

winsup/cygwin/ChangeLog
winsup/cygwin/globals.cc
winsup/cygwin/uinfo.cc

index a75f54caab8df8946819646ef0a2c236c216363c..6622ac4ea87f17c5fd80237957596d01f7369d31 100644 (file)
@@ -1,3 +1,10 @@
+2011-05-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * globals.cc (__getlogin_username): Remove.
+       * uinfo.cc (getlogin_r): Fetch username from cygheap.
+       (getlogin): Add static buffer username and fetch username from
+       getlogin_r.
+
 2011-05-16  Corinna Vinschen  <corinna@vinschen.de>
 
        * cygtls.h (struct _local_storage): Remove unused members rarg and
index 68bd5519c53bfc354ca212108701ecc23bb30263..f27429c6b2afaa68fd1f56631bc6d36895728c93 100644 (file)
@@ -56,9 +56,6 @@ bool display_title;
 bool strip_title_path;
 bool allow_glob = true;
 
-/* Static getlogin buffer. */
-char __getlogin_username[UNLEN + 1];
-
 bool NO_COPY in_forkee;
 
 int __argc_safe;
index ff96fcc7f6f32360de8629f534f38ad3daa4e285..0c9c3eca9cf69a5399496689795adef901b5498c 100644 (file)
@@ -187,7 +187,7 @@ uinfo_init ()
 extern "C" int
 getlogin_r (char *name, size_t namesize)
 {
-  char *login = getlogin ();
+  const char *login = cygheap->user.name ();
   size_t len = strlen (login) + 1;
   if (len > namesize)
     return ERANGE;
@@ -201,7 +201,14 @@ getlogin_r (char *name, size_t namesize)
 extern "C" char *
 getlogin (void)
 {
-  return strcpy (__getlogin_username, cygheap->user.name ());
+  static char username[UNLEN];
+  int ret = getlogin_r (username, UNLEN);
+  if (ret)
+    {
+      set_errno (ret);
+      return NULL;
+    }
+  return username;
 }
 
 extern "C" __uid32_t
This page took 0.036417 seconds and 5 git commands to generate.