From f39ed56551434d9b9d03cbc9c15478ad717a5e66 Mon Sep 17 00:00:00 2001 From: Grisha Levit Date: Sun, 2 Jul 2023 22:56:37 -0400 Subject: [PATCH] no username completion wo getpwent --- lib/readline/complete.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/readline/complete.c b/lib/readline/complete.c index 349c87a1..d531f541 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -2321,9 +2321,9 @@ rl_completion_matches (const char *text, rl_compentry_func_t *entry_function) char * rl_username_completion_function (const char *text, int state) { -#if defined (_WIN32) || defined (__OPENNT) +#if defined (_WIN32) || defined (__OPENNT) || !defined (HAVE_GETPWENT) return (char *)NULL; -#else /* !_WIN32 && !__OPENNT) */ +#else /* !_WIN32 && !__OPENNT) && HAVE_GETPWENT */ static char *username = (char *)NULL; static struct passwd *entry; static int namelen, first_char, first_char_loc; @@ -2338,25 +2338,19 @@ rl_username_completion_function (const char *text, int state) username = savestring (&text[first_char_loc]); namelen = strlen (username); -#if defined (HAVE_GETPWENT) setpwent (); -#endif } -#if defined (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) { -#if defined (HAVE_GETPWENT) endpwent (); -#endif return ((char *)NULL); } else @@ -2372,7 +2366,7 @@ rl_username_completion_function (const char *text, int state) return (value); } -#endif /* !_WIN32 && !__OPENNT */ +#endif /* !_WIN32 && !__OPENNT && HAVE_GETPWENT */ } /* Return non-zero if CONVFN matches FILENAME up to the length of FILENAME -- 2.41.0