On Sun, Jul 2, 2023, 11:36 alex xmb ratchev <[email protected]> wrote:
> complete.c:2342:7: error: call to undeclared function 'setpwent'; ISO C99 > and later do not support implicit function declarations > [-Wimplicit-function-declaration] > setpwent (); > ^ > The regular rl_username_completion_function body should probably be skipped on platforms without getpwent, not just for _WIN32 explicitly (patch attached). This would solve the issue on older Android versions. But it doesn't actually solve the issue reported, which is due to a (imho) bug in Termux [1], where the default clang target doesn't have the same API level as that of libc, so some functions that are linkable are nevertheless not declared in headers unless the API level is overridden. [1]: https://github.com/termux/termux-packages/issues/2469#issuecomment-522669644 >
From f39ed56551434d9b9d03cbc9c15478ad717a5e66 Mon Sep 17 00:00:00 2001 From: Grisha Levit <[email protected]> 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
