--- lib/readline/complete.c +++ lib/readline/complete.c 2011-11-21 12:51:35.695646715 +0000 @@ -83,6 +83,7 @@ typedef int QSFUNC (); defined. */ #if defined (HAVE_GETPWENT) && (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)) extern struct passwd *getpwent PARAMS((void)); +extern void endpwent (); #endif /* HAVE_GETPWENT && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */ /* If non-zero, then this is the address of a function to call when @@ -2068,6 +2069,9 @@ rl_username_completion_function (text, s if (first_char == '~') rl_filename_completion_desired = 1; +#if defined (HAVE_GETPWENT) + /* endpwent (); */ +#endif return (value); } #endif /* !__WIN32__ && !__OPENNT */ --- lib/readline/shell.c +++ lib/readline/shell.c 2011-11-21 13:08:46.343647023 +0000 @@ -61,9 +61,18 @@ #include "rlshell.h" #include "xmalloc.h" -#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS) +#if !defined (HAVE_GETPW_DECLS) +# if defined (HAVE_GETPWUID) extern struct passwd *getpwuid PARAMS((uid_t)); -#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */ +# endif +# if defined (HAVE_GETPWENT) +extern void endpwent (); +# endif +#endif /* !HAVE_GETPW_DECLS */ + +#if !defined (savestring) +# define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x)) +#endif /* !savestring */ #ifndef NULL # define NULL 0 @@ -159,15 +168,20 @@ sh_get_env_value (varname) char * sh_get_home_dir () { - char *home_dir; + static char *home_dir; struct passwd *entry; - home_dir = (char *)NULL; + if (home_dir) + goto out; #if defined (HAVE_GETPWUID) entry = getpwuid (getuid ()); if (entry) - home_dir = entry->pw_dir; + home_dir = savestring(entry->pw_dir); #endif +#if defined (HAVE_GETPWENT) + endpwent (); +#endif +out: return (home_dir); } --- lib/readline/tilde.c +++ lib/readline/tilde.c 2011-11-11 13:09:49.000000000 +0000 @@ -61,6 +61,7 @@ extern struct passwd *getpwuid PARAMS((u # endif # if defined (HAVE_GETPWNAM) extern struct passwd *getpwnam PARAMS((const char *)); +extern void endpwent (); # endif #endif /* !HAVE_GETPW_DECLS */