diff options
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/lib/libreadline/rltty.c | 8 | ||||
| -rw-r--r-- | gnu/lib/libreadline/tilde.c | 21 |
2 files changed, 12 insertions, 17 deletions
diff --git a/gnu/lib/libreadline/rltty.c b/gnu/lib/libreadline/rltty.c index a007beb88e29..02c036d05c54 100644 --- a/gnu/lib/libreadline/rltty.c +++ b/gnu/lib/libreadline/rltty.c @@ -22,15 +22,15 @@ 675 Mass Ave, Cambridge, MA 02139, USA. */ #define READLINE_LIBRARY +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + #include <sys/types.h> #include <signal.h> #include <errno.h> #include <stdio.h> -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - #if defined (HAVE_UNISTD_H) # include <unistd.h> #endif /* HAVE_UNISTD_H */ diff --git a/gnu/lib/libreadline/tilde.c b/gnu/lib/libreadline/tilde.c index 84c24b745c51..da75d957863d 100644 --- a/gnu/lib/libreadline/tilde.c +++ b/gnu/lib/libreadline/tilde.c @@ -250,22 +250,16 @@ tilde_expand_word (filename) } 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 @@ -298,7 +292,8 @@ tilde_expand_word (filename) free (dirname); dirname = temp_name; } - endpwent (); + endpwent (); + free (username); } } return (dirname); |
