summaryrefslogtreecommitdiff
path: root/readline/tilde.c
diff options
context:
space:
mode:
Diffstat (limited to 'readline/tilde.c')
-rw-r--r--readline/tilde.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/readline/tilde.c b/readline/tilde.c
index 154f7f8108d..60fc7fc6cdd 100644
--- a/readline/tilde.c
+++ b/readline/tilde.c
@@ -43,7 +43,9 @@
#endif /* HAVE_STDLIB_H */
#include <sys/types.h>
+#ifdef HAVE_PWD_H
#include <pwd.h>
+#endif /* HAVE_PWD_H */
#include "tilde.h"
@@ -53,10 +55,10 @@ static void *xmalloc (), *xrealloc ();
# include "xmalloc.h"
#endif /* TEST || STATIC_MALLOC */
-#if !defined (HAVE_GETPW_DECLS)
+#if defined (HAVE_GETPWNAM) && !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid PARAMS((uid_t));
extern struct passwd *getpwnam PARAMS((const char *));
-#endif /* !HAVE_GETPW_DECLS */
+#endif /* defined (HAVE_GETPWNAM) && !HAVE_GETPW_DECLS */
#if !defined (savestring)
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
@@ -347,6 +349,7 @@ tilde_expand_word (filename)
/* No preexpansion hook, or the preexpansion hook failed. Look in the
password database. */
dirname = (char *)NULL;
+#ifdef HAVE_GETPWNAM
user_entry = getpwnam (username);
if (user_entry == 0)
{
@@ -374,6 +377,7 @@ tilde_expand_word (filename)
}
endpwent ();
+#endif
return (dirname);
}