1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0361
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0361
Problem: Remote user not used for completion. (Stucki)
Solution: Use $USER too. (Dominique Pelle, closes #3407)
Files: src/misc1.c
*** ../vim-8.1.0360/src/misc1.c 2018-08-26 21:23:03.400383307 +0200
--- src/misc1.c 2018-09-10 18:53:46.863908096 +0200
***************
*** 4717,4722 ****
--- 4717,4741 ----
}
/*
+ * Add a user name to the list of users in ga_users.
+ * Do nothing if user name is NULL or empty.
+ */
+ static void
+ add_user(char_u *user, int need_copy)
+ {
+ char_u *user_copy = (user != NULL && need_copy)
+ ? vim_strsave(user) : user;
+
+ if (user_copy == NULL || *user_copy == NUL || ga_grow(&ga_users, 1) == FAIL)
+ {
+ if (need_copy)
+ vim_free(user);
+ return;
+ }
+ ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user_copy;
+ }
+
+ /*
* Find all user names for user completion.
* Done only once and then cached.
*/
***************
*** 4733,4758 ****
# 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();
}
# elif defined(WIN3264)
{
- char_u* user;
DWORD nusers = 0, ntotal = 0, i;
PUSER_INFO_0 uinfo;
--- 4752,4766 ----
# if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H)
{
struct passwd* pw;
setpwent();
while ((pw = getpwent()) != NULL)
! add_user((char_u *)pw->pw_name, TRUE);
endpwent();
}
# elif defined(WIN3264)
{
DWORD nusers = 0, ntotal = 0, i;
PUSER_INFO_0 uinfo;
***************
*** 4760,4775 ****
&nusers, &ntotal, NULL) == NERR_Success)
{
for (i = 0; i < nusers; i++)
{
! if (ga_grow(&ga_users, 1) == FAIL)
! break;
! user = utf16_to_enc(uinfo[i].usri0_name, NULL);
! if (user == NULL)
break;
- ((char_u **)(ga_users.ga_data))[ga_users.ga_len++] = user;
}
! NetApiBufferFree(uinfo);
}
}
# endif
--- 4768,4808 ----
&nusers, &ntotal, NULL) == NERR_Success)
{
for (i = 0; i < nusers; i++)
+ add_user(utf16_to_enc(uinfo[i].usri0_name, NULL), FALSE);
+
+ NetApiBufferFree(uinfo);
+ }
+ }
+ # endif
+ # if defined(HAVE_GETPWNAM)
+ {
+ char_u *user_env = mch_getenv((char_u *)"USER");
+
+ // The $USER environment variable may be a valid remote user name (NIS,
+ // LDAP) not already listed by getpwent(), as getpwent() only lists
+ // local user names. If $USER is not already listed, check whether it
+ // is a valid remote user name using getpwnam() and if it is, add it to
+ // the list of user names.
+
+ if (user_env != NULL && *user_env != NUL)
+ {
+ int i;
+
+ for (i = 0; i < ga_users.ga_len; i++)
{
! char_u *local_user = ((char_u **)ga_users.ga_data)[i];
!
! if (STRCMP(local_user, user_env) == 0)
break;
}
! if (i == ga_users.ga_len)
! {
! struct passwd *pw = getpwnam((char *)user_env);
!
! if (pw != NULL)
! add_user((char_u *)pw->pw_name, TRUE);
! }
}
}
# endif
*** ../vim-8.1.0360/src/version.c 2018-09-10 17:50:32.717306902 +0200
--- src/version.c 2018-09-10 18:48:00.579950668 +0200
***************
*** 796,797 ****
--- 796,799 ----
{ /* Add new patch number below this line */
+ /**/
+ 361,
/**/
--
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
-- Arthur Dent and Ford Prefect in Douglas Adams'
"The Hitchhiker's Guide to the Galaxy"
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|