From: "Piotr Eljasiak" To: Eli Zaretskii Date: Mon, 24 Jul 2000 10:15:08 +0200 MIME-Version: 1.0 Content-type: Multipart/Mixed; boundary=Message-Boundary-30081 Subject: Re: Patch to make getlogin() examine env. var. USERNAME CC: Richard Dawe , djgpp-workers AT delorie DOT com Message-ID: <397C172C.12597.F9F8BD4@localhost> X-Confirm-Reading-To: "Piotr Eljasiak" X-pmrqc: 1 References: <397BFE79 DOT 31739 DOT F3F111C AT localhost> In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.12c) Reply-To: djgpp-workers AT delorie DOT com --Message-Boundary-30081 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body > Why not change the order of precedence in getlogin()? If there are > systems where USERNAME is defined, but USER is not, that would be the > logical solution, no? Why not? What about the order of searching env. vars - is USERNAME, USER, LOGNAME ok? If so - I've attached the patch changing this (getlogin.c+getlogin.txh). Piotr Eljasiak --Message-Boundary-30081 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Text from file 'getlogin-2.dif' *** src/libc/posix/unistd/getlogin.c Wed Aug 4 13:58:24 1999 --- getlogin.c Mon Jul 24 08:04:30 2000 *************** *** 1,3 **** --- 1,4 ---- + /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include *************** *** 10,16 **** { char *p; ! p = getenv("USER"); if (!p) p = getenv("LOGNAME"); if (!p) --- 11,19 ---- { char *p; ! p = getenv("USERNAME"); ! if (!p) ! p = getenv("USER"); if (!p) p = getenv("LOGNAME"); if (!p) *** src/libc/posix/unistd/getlogin.txh Sun Sep 27 09:22:24 1998 --- getlogin.txh Mon Jul 24 08:04:50 2000 *************** *** 13,20 **** @subheading Return Value ! Returns the value of the @code{USER} environment variable, else the ! @code{LOGNAME} environment variable, else @code{"dosuser"}. @subheading Portability --- 13,24 ---- @subheading Return Value ! Returns the value of the @code{USERNAME} environment variable, else the ! @code{USER} environment variable, else the @code{LOGNAME} environment ! variable, else @code{dosuser}. ! ! @code{USERNAME} is set automatically under Windows NT and 2000. None of these ! environment variables are set automatically under DOS, Windows '95 or '98. @subheading Portability --Message-Boundary-30081--