changeset 14133:352c2832d17f v8.1.0084

patch 8.1.0084: user name completion does not work on MS-Windows commit https://github.com/vim/vim/commit/828c3d70833a0689cc07581f2a67d06430675da5 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 19 18:58:07 2018 +0200 patch 8.1.0084: user name completion does not work on MS-Windows Problem: User name completion does not work on MS-Windows. Solution: Use NetUserEnum() to get user names. (Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Jun 2018 19:00:07 +0200
parents 0aeb4cc130cf
children ca2908f449ca
files src/Make_cyg_ming.mak src/Make_ivc.mak src/Make_mvc.mak src/misc1.c src/version.c
diffstat 5 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -662,7 +662,7 @@ endif
 CFLAGS += -s
 endif
 
-LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lversion
+LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lnetapi32 -lversion
 GUIOBJ =  $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/gui_beval.o $(OUTDIR)/os_w32exe.o
 CUIOBJ = $(OUTDIR)/iscygpty.o
 OBJ = \
--- a/src/Make_ivc.mak
+++ b/src/Make_ivc.mak
@@ -88,7 +88,7 @@ LINK32=link.exe
 CPP_PROJ= /nologo /MT /W3 /GX /I ".\proto" /D "WIN32" /c
 # ADD CPP /nologo /MT /W3 /GX /I ".\proto" /D "WIN32" /c
 
-LINK32_FLAGS= oldnames.lib kernel32.lib user32.lib gdi32.lib version.lib comdlg32.lib comctl32.lib advapi32.lib shell32.lib ole32.lib uuid.lib /nologo /machine:I386 /nodefaultlib
+LINK32_FLAGS= oldnames.lib kernel32.lib user32.lib gdi32.lib version.lib comdlg32.lib comctl32.lib advapi32.lib shell32.lib ole32.lib netapi32.lib uuid.lib /nologo /machine:I386 /nodefaultlib
 # ADD LINK32  oldnames.lib kernel32.lib user32.lib gdi32.lib version.lib comdlg32.lib comctl32.lib advapi32.lib shell32.lib ole32.lib uuid.lib /nologo /machine:I386 /nodefaultlib
 # SUBTRACT LINK32 /incremental:yes
 
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -489,10 +489,11 @@ NETBEANS_LIB	= WSock32.lib
 
 # need advapi32.lib for GetUserName()
 # need shell32.lib for ExtractIcon()
+# need netapi32.lib for NetUserEnum()
 # gdi32.lib and comdlg32.lib for printing support
 # ole32.lib and uuid.lib are needed for FEAT_SHORTCUT
 CON_LIB = oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib \
-          comdlg32.lib ole32.lib uuid.lib /machine:$(CPU)
+          comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:$(CPU)
 !if "$(DELAYLOAD)" == "yes"
 CON_LIB = $(CON_LIB) /DELAYLOAD:comdlg32.dll /DELAYLOAD:ole32.dll DelayImp.lib
 !endif
@@ -801,7 +802,7 @@ GUI_OBJ = \
 	$(OUTDIR)\os_w32exe.obj
 GUI_LIB = \
 	gdi32.lib version.lib $(IME_LIB) \
-	winspool.lib comctl32.lib advapi32.lib shell32.lib \
+	winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib \
 	/machine:$(CPU)
 !else
 SUBSYSTEM = console
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -14,6 +14,10 @@
 #include "vim.h"
 #include "version.h"
 
+#if defined(FEAT_CMDL_COMPL) && defined(WIN3264)
+# include <lm.h>
+#endif
+
 static char_u *vim_version_dir(char_u *vimdir);
 static char_u *remove_tail(char_u *p, char_u *pend, char_u *name);
 #if defined(FEAT_CMDL_COMPL)
@@ -4603,6 +4607,28 @@ init_users(void)
 	    }
 	endpwent();
     }
+# elif defined(WIN3264)
+    {
+	char_u*		user;
+	DWORD		nusers = 0, ntotal = 0, i;
+	PUSER_INFO_0	uinfo;
+
+	if (NetUserEnum(NULL, 0, 0, (LPBYTE *) &uinfo, MAX_PREFERRED_LENGTH,
+				       &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
 }
 
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    84,
+/**/
     83,
 /**/
     82,