diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-03-06 21:55:17 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-13 17:18:43 -0300 |
commit | 6fd9f090fc66c3ba38dc07ea6c982c3124735f32 (patch) | |
tree | 052b7d267c182c9975fb2b3e837cef66b0a166b4 /src/misc1.c | |
parent | f6ace9962d95eb12236083871154c1501f02c556 (diff) | |
download | rneovim-6fd9f090fc66c3ba38dc07ea6c982c3124735f32.tar.gz rneovim-6fd9f090fc66c3ba38dc07ea6c982c3124735f32.tar.bz2 rneovim-6fd9f090fc66c3ba38dc07ea6c982c3124735f32.zip |
refactored logic from init_users() into mch_get_usernames()
Diffstat (limited to 'src/misc1.c')
-rw-r--r-- | src/misc1.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/misc1.c b/src/misc1.c index b391cb1ee4..e78343291b 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -3256,34 +3256,17 @@ char_u *get_env_name(expand_T *xp, int idx) * Find all user names for user completion. * Done only once and then cached. */ -static void init_users(void) { +static void init_users(void) +{ static int lazy_init_done = FALSE; - if (lazy_init_done) + if (lazy_init_done) { return; + } lazy_init_done = TRUE; - ga_init2(&ga_users, sizeof(char_u *), 20); - -# if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H) - { - char_u* user; - struct passwd* pw; - - setpwent(); - while ((pw = getpwent()) != NULL) - /* pw->pw_name shouldn't be NULL but just in case... */ - if (pw->pw_name != NULL) { - if (ga_grow(&ga_users, 1) == FAIL) - break; - user = vim_strsave((char_u*)pw->pw_name); - if (user == NULL) - break; - ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user; - } - endpwent(); - } -# endif + + mch_get_usernames(&ga_users); } /* |