diff options
Diffstat (limited to 'readline/complete.c')
-rw-r--r-- | readline/complete.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/readline/complete.c b/readline/complete.c index 21a9d70859b..a4ff24e8720 100644 --- a/readline/complete.c +++ b/readline/complete.c @@ -48,7 +48,9 @@ extern int errno; #endif /* !errno */ +#ifdef HAVE_PWD_H #include <pwd.h> +#endif #include "posixdir.h" #include "posixstat.h" @@ -79,9 +81,10 @@ typedef int QSFUNC (); /* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is defined. */ -#if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE) +#if defined(HAVE_GETPWENT) && \ + (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)) extern struct passwd *getpwent PARAMS((void)); -#endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */ +#endif /* defiend (HAVE_GETPWENT) && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */ /* If non-zero, then this is the address of a function to call when completing a word would normally display the list of possible matches. @@ -1662,16 +1665,20 @@ rl_username_completion_function (text, state) setpwent (); } +#ifdef HAVE_GETPWENT while (entry = getpwent ()) { /* Null usernames should result in all users as possible completions. */ if (namelen == 0 || (STREQN (username, entry->pw_name, namelen))) break; } +#endif if (entry == 0) { +#ifdef HAVE_GETPWENT endpwent (); +#endif return ((char *)NULL); } else |