From a89d412ced2d9498260dae34fa8aa9e28fa56ca8 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 23 Mar 2014 21:27:25 +0000 Subject: Provide fake getpwent_r to reduce changes from upstream --- include/mingw.h | 3 +++ libbb/lineedit.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/mingw.h b/include/mingw.h index b1a28b473..bcf61dbac 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -76,6 +76,9 @@ struct passwd { IMPL(getpwnam,struct passwd *,NULL,const char *name UNUSED_PARAM); struct passwd *getpwuid(int uid); +static inline void setpwent(void) {} +static inline void endpwent(void) {} +IMPL(getpwent_r,int,ENOENT,struct passwd *pwbuf UNUSED_PARAM,char *buf UNUSED_PARAM,size_t buflen UNUSED_PARAM,struct passwd **pwbufp UNUSED_PARAM); /* * signal.h diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 4bb1ab783..4cb9eba4b 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -672,18 +672,15 @@ static char *username_path_completion(char *ud) */ static NOINLINE unsigned complete_username(const char *ud) { -#if !ENABLE_PLATFORM_MINGW32 /* Using _r function to avoid pulling in static buffers */ char line_buff[256]; struct passwd pwd; struct passwd *result; -#endif unsigned userlen; ud++; /* skip ~ */ userlen = strlen(ud); -#if !ENABLE_PLATFORM_MINGW32 setpwent(); while (!getpwent_r(&pwd, line_buff, sizeof(line_buff), &result)) { /* Null usernames should result in all users as possible completions. */ @@ -692,7 +689,6 @@ static NOINLINE unsigned complete_username(const char *ud) } } endpwent(); -#endif return 1 + userlen; } -- cgit v1.2.3-55-g6feb