[Winbash-checkins] CVS: winbash/lib/tilde tilde.c,1.1.1.1,1.2
Brought to you by:
enricobrunetta,
xks
From: Enrico B. <enr...@us...> - 2002-03-09 16:05:47
|
Update of /cvsroot/winbash/winbash/lib/tilde In directory usw-pr-cvs1:/tmp/cvs-serv14844/lib/tilde Modified Files: tilde.c Log Message: Applied 1.14.3 diffs from GNU bash Index: tilde.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/tilde/tilde.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- tilde.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ tilde.c 9 Mar 2002 16:05:44 -0000 1.2 @@ -19,8 +19,6 @@ along with Readline; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "memalloc.h" - #if defined (HAVE_STRING_H) # include <string.h> #else /* !HAVE_STRING_H */ @@ -34,6 +32,7 @@ #endif /* HAVE_STDLIB_H */ #include "tilde.h" +#include <sys/types.h> #include <pwd.h> #if defined (USG) && !defined (HAVE_GETPW_DECLS) @@ -251,22 +250,16 @@ } else { - char u_name[257]; - struct passwd *user_entry; char *username; - int i, c; + struct passwd *user_entry; + int i; - username = u_name; - for (i = 1; c = dirname[i]; i++) - { - if (c == '/') - break; - else - username[i - 1] = c; - } + username = xmalloc (strlen (dirname)); + for (i = 1; dirname[i] && dirname[i] != '/'; i++) + username[i - 1] = dirname[i]; username[i - 1] = '\0'; - if (!(user_entry = getpwnam (username))) + if ((user_entry = getpwnam (username)) == 0) { /* If the calling program has a special syntax for expanding tildes, and we couldn't find a standard @@ -299,7 +292,8 @@ free (dirname); dirname = temp_name; } - endpwent (); + endpwent (); + free (username); } } return (dirname); |