summaryrefslogtreecommitdiffstats
path: root/src/os_win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_win32.c')
-rw-r--r--src/os_win32.c706
1 files changed, 163 insertions, 543 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 5eacce635c..9ff2f7ee40 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -141,43 +141,11 @@ typedef int LPSECURITY_ATTRIBUTES;
# define __stdcall /* empty */
#endif
-#ifndef FEAT_GUI_W32
-/* Undocumented API in kernel32.dll needed to work around dead key bug in
- * console-mode applications in NT 4.0. If you switch keyboard layouts
- * in a console app to a layout that includes dead keys and then hit a
- * dead key, a call to ToAscii will trash the stack. My thanks to Ian James
- * and Michael Dietrich for helping me figure out this workaround.
- */
-
-/* WINAPI BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR); */
-#ifndef WINAPI
-# define WINAPI __stdcall
-#endif
-#if defined(__BORLANDC__)
-typedef BOOL (__stdcall *PFNGCKLN)(LPSTR);
-#else
-typedef BOOL (WINAPI *PFNGCKLN)(LPSTR);
-#endif
-static PFNGCKLN s_pfnGetConsoleKeyboardLayoutName = NULL;
-#endif
-
#if defined(__BORLANDC__)
/* Strangely Borland uses a non-standard name. */
# define wcsicmp(a, b) wcscmpi((a), (b))
#endif
-#ifndef PROTO
-
-/* Enable common dialogs input unicode from IME if possible. */
-#ifdef FEAT_MBYTE
-LRESULT (WINAPI *pDispatchMessage)(CONST MSG *) = DispatchMessage;
-BOOL (WINAPI *pGetMessage)(LPMSG, HWND, UINT, UINT) = GetMessage;
-BOOL (WINAPI *pIsDialogMessage)(HWND, LPMSG) = IsDialogMessage;
-BOOL (WINAPI *pPeekMessage)(LPMSG, HWND, UINT, UINT, UINT) = PeekMessage;
-#endif
-
-#endif /* PROTO */
-
#ifndef FEAT_GUI_W32
/* Win32 Console handles for input and output */
static HANDLE g_hConIn = INVALID_HANDLE_VALUE;
@@ -430,7 +398,6 @@ unescape_shellxquote(char_u *p, char_u *escaped)
vimLoadLib(char *name)
{
HINSTANCE dll = NULL;
- char old_dir[MAXPATHL];
/* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
* vimLoadLib() recursively, which causes a stack overflow. */
@@ -438,7 +405,6 @@ vimLoadLib(char *name)
get_exe_name();
if (exe_path != NULL)
{
-#ifdef FEAT_MBYTE
WCHAR old_dirw[MAXPATHL];
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
@@ -451,18 +417,6 @@ vimLoadLib(char *name)
SetCurrentDirectoryW(old_dirw);
return dll;
}
- /* Retry with non-wide function (for Windows 98). */
- if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
-#endif
- if (GetCurrentDirectory(MAXPATHL, old_dir) != 0)
- {
- /* Change directory to where the executable is, both to make
- * sure we find a .dll there and to avoid looking for a .dll
- * in the current directory. */
- SetCurrentDirectory((LPCSTR)exe_path);
- dll = LoadLibrary(name);
- SetCurrentDirectory(old_dir);
- }
}
return dll;
}
@@ -621,38 +575,8 @@ DWORD g_PlatformId;
# ifndef PROTECTED_DACL_SECURITY_INFORMATION
# define PROTECTED_DACL_SECURITY_INFORMATION 0x80000000L
# endif
-
-/*
- * These are needed to dynamically load the ADVAPI DLL, which is not
- * implemented under Windows 95 (and causes VIM to crash)
- */
-typedef DWORD (WINAPI *PSNSECINFO) (LPSTR, SE_OBJECT_TYPE,
- SECURITY_INFORMATION, PSID, PSID, PACL, PACL);
-typedef DWORD (WINAPI *PGNSECINFO) (LPSTR, SE_OBJECT_TYPE,
- SECURITY_INFORMATION, PSID *, PSID *, PACL *, PACL *,
- PSECURITY_DESCRIPTOR *);
-# ifdef FEAT_MBYTE
-typedef DWORD (WINAPI *PSNSECINFOW) (LPWSTR, SE_OBJECT_TYPE,
- SECURITY_INFORMATION, PSID, PSID, PACL, PACL);
-typedef DWORD (WINAPI *PGNSECINFOW) (LPWSTR, SE_OBJECT_TYPE,
- SECURITY_INFORMATION, PSID *, PSID *, PACL *, PACL *,
- PSECURITY_DESCRIPTOR *);
-# endif
-
-static HANDLE advapi_lib = NULL; /* Handle for ADVAPI library */
-static PSNSECINFO pSetNamedSecurityInfo;
-static PGNSECINFO pGetNamedSecurityInfo;
-# ifdef FEAT_MBYTE
-static PSNSECINFOW pSetNamedSecurityInfoW;
-static PGNSECINFOW pGetNamedSecurityInfoW;
-# endif
#endif
-typedef BOOL (WINAPI *PSETHANDLEINFORMATION)(HANDLE, DWORD, DWORD);
-
-static BOOL allowPiping = FALSE;
-static PSETHANDLEINFORMATION pSetHandleInformation;
-
#ifdef HAVE_ACL
/*
* Enables or disables the specified privilege.
@@ -712,93 +636,13 @@ PlatformId(void)
win8_or_later = TRUE;
#ifdef HAVE_ACL
- /*
- * Load the ADVAPI runtime if we are on anything
- * other than Windows 95
- */
- if (g_PlatformId == VER_PLATFORM_WIN32_NT)
- {
- /*
- * do this load. Problems: Doesn't unload at end of run (this is
- * theoretically okay, since Windows should unload it when VIM
- * terminates). Should we be using the 'mch_libcall' routines?
- * Seems like a lot of overhead to load/unload ADVAPI32.DLL each
- * time we verify security...
- */
- advapi_lib = vimLoadLib("ADVAPI32.DLL");
- if (advapi_lib != NULL)
- {
- pSetNamedSecurityInfo = (PSNSECINFO)GetProcAddress(advapi_lib,
- "SetNamedSecurityInfoA");
- pGetNamedSecurityInfo = (PGNSECINFO)GetProcAddress(advapi_lib,
- "GetNamedSecurityInfoA");
-# ifdef FEAT_MBYTE
- pSetNamedSecurityInfoW = (PSNSECINFOW)GetProcAddress(advapi_lib,
- "SetNamedSecurityInfoW");
- pGetNamedSecurityInfoW = (PGNSECINFOW)GetProcAddress(advapi_lib,
- "GetNamedSecurityInfoW");
-# endif
- if (pSetNamedSecurityInfo == NULL
- || pGetNamedSecurityInfo == NULL
-# ifdef FEAT_MBYTE
- || pSetNamedSecurityInfoW == NULL
- || pGetNamedSecurityInfoW == NULL
-# endif
- )
- {
- /* If we can't get the function addresses, set advapi_lib
- * to NULL so that we don't use them. */
- FreeLibrary(advapi_lib);
- advapi_lib = NULL;
- }
- /* Enable privilege for getting or setting SACLs. */
- win32_enable_privilege(SE_SECURITY_NAME, TRUE);
- }
- }
+ /* Enable privilege for getting or setting SACLs. */
+ win32_enable_privilege(SE_SECURITY_NAME, TRUE);
#endif
- /*
- * If we are on windows NT, try to load the pipe functions, only
- * available from Win2K.
- */
- if (g_PlatformId == VER_PLATFORM_WIN32_NT)
- {
- HANDLE kernel32 = GetModuleHandle("kernel32");
- pSetHandleInformation = (PSETHANDLEINFORMATION)GetProcAddress(
- kernel32, "SetHandleInformation");
-
- allowPiping = pSetHandleInformation != NULL;
- }
done = TRUE;
}
}
-/*
- * Return TRUE when running on Windows 95 (or 98 or ME).
- * Only to be used after mch_init().
- */
- int
-mch_windows95(void)
-{
- return g_PlatformId == VER_PLATFORM_WIN32_WINDOWS;
-}
-
-#ifdef FEAT_GUI_W32
-/*
- * Used to work around the "can't do synchronous spawn"
- * problem on Win32s, without resorting to Universal Thunk.
- */
-static int old_num_windows;
-static int num_windows;
-
-/*ARGSUSED*/
- static BOOL CALLBACK
-win32ssynch_cb(HWND hwnd, LPARAM lparam)
-{
- num_windows++;
- return TRUE;
-}
-#endif
-
#ifndef FEAT_GUI_W32
#define SHIFT (SHIFT_PRESSED)
@@ -926,15 +770,6 @@ win32_kbd_patch_key(
vim_memset(abKeystate, 0, sizeof (abKeystate));
- // Should only be non-NULL on NT 4.0
- if (s_pfnGetConsoleKeyboardLayoutName != NULL)
- {
- CHAR szKLID[KL_NAMELENGTH];
-
- if ((*s_pfnGetConsoleKeyboardLayoutName)(szKLID))
- (void)LoadKeyboardLayout(szKLID, KLF_ACTIVATE);
- }
-
/* Clear any pending dead keys */
ToUnicode(VK_SPACE, MapVirtualKey(VK_SPACE, 0), abKeystate, awAnsiCode, 2, 0);
@@ -1977,17 +1812,13 @@ executable_exists(char *name, char_u **path)
n = (long)SearchPathW(wnewpath, p, NULL, _MAX_PATH, fnamew, &dumw);
vim_free(wnewpath);
vim_free(p);
- if (n > 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- {
- if (n == 0)
- return FALSE;
- if (GetFileAttributesW(fnamew) & FILE_ATTRIBUTE_DIRECTORY)
- return FALSE;
- if (path != NULL)
- *path = utf16_to_enc(fnamew, NULL);
- return TRUE;
- }
- /* Retry with non-wide function (for Windows 98). */
+ if (n == 0)
+ return FALSE;
+ if (GetFileAttributesW(fnamew) & FILE_ATTRIBUTE_DIRECTORY)
+ return FALSE;
+ if (path != NULL)
+ *path = utf16_to_enc(fnamew, NULL);
+ return TRUE;
}
}
#endif
@@ -2462,8 +2293,6 @@ SetConsoleIcon(
static void
SaveConsoleTitleAndIcon(void)
{
- GETCONSOLEWINDOWPROC GetConsoleWindowProc;
-
/* Save the original title. */
if (!GetConsoleTitle(g_szOrigTitle, sizeof(g_szOrigTitle)))
return;
@@ -2475,12 +2304,7 @@ SaveConsoleTitleAndIcon(void)
* 2000. On older operating systems, we can't change the window icon
* anyway.
*/
- if ((GetConsoleWindowProc = (GETCONSOLEWINDOWPROC)
- GetProcAddress(GetModuleHandle("KERNEL32.DLL"),
- "GetConsoleWindow")) != NULL)
- {
- g_hWnd = (*GetConsoleWindowProc)();
- }
+ g_hWnd = GetConsoleWindow();
if (g_hWnd == NULL)
return;
@@ -2589,11 +2413,6 @@ mch_init(void)
#ifdef FEAT_CLIPBOARD
win_clip_init();
#endif
-
- /* This will be NULL on anything but NT 4.0 */
- s_pfnGetConsoleKeyboardLayoutName =
- (PFNGCKLN) GetProcAddress(GetModuleHandle("kernel32.dll"),
- "GetConsoleKeyboardLayoutNameA");
}
/*
@@ -2775,9 +2594,6 @@ fname_casew(
*porig = c;
ptrue = ptruePrev + wcslen(ptruePrev);
}
- else if (hFind == INVALID_HANDLE_VALUE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- return FAIL;
}
wcscpy(name, szTrueName);
@@ -2836,7 +2652,7 @@ fname_case(
}
}
}
- /* Retry with non-wide function (for Windows 98). */
+ return;
}
#endif
@@ -2966,9 +2782,6 @@ mch_get_user_name(
return OK;
}
}
- else if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return FAIL;
- /* Retry with non-wide function (for Windows 98). */
}
#endif
if (GetUserName(szUserName, &cch))
@@ -3008,9 +2821,6 @@ mch_get_host_name(
return;
}
}
- else if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return;
- /* Retry with non-wide function (for Windows 98). */
}
#endif
if (!GetComputerName((LPSTR)s, &cch))
@@ -3059,9 +2869,7 @@ mch_dirname(
return OK;
}
}
- else if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return FAIL;
- /* Retry with non-wide function (for Windows 98). */
+ return FAIL;
}
#endif
return (GetCurrentDirectory(len, (LPSTR)buf) != 0 ? OK : FAIL);
@@ -3101,9 +2909,8 @@ mch_setperm(char_u *name, long perm)
{
n = _wchmod(p, perm);
vim_free(p);
- if (n == -1 && g_PlatformId == VER_PLATFORM_WIN32_NT)
+ if (n == -1)
return FAIL;
- /* Retry with non-wide function (for Windows 98). */
}
}
if (n == -1)
@@ -3251,18 +3058,7 @@ mch_is_symbolic_link(char_u *name)
{
hFind = FindFirstFileW(wn, &findDataW);
vim_free(wn);
- if (hFind == INVALID_HANDLE_VALUE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- /* Retry with non-wide function (for Windows 98). */
- hFind = FindFirstFile((LPCSTR)name, &findDataA);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- fileFlags = findDataA.dwFileAttributes;
- reparseTag = findDataA.dwReserved0;
- }
- }
- else
+ if (hFind != INVALID_HANDLE_VALUE)
{
fileFlags = findDataW.dwFileAttributes;
reparseTag = findDataW.dwReserved0;
@@ -3321,7 +3117,7 @@ win32_fileinfo(char_u *fname, BY_HANDLE_FILE_INFORMATION *info)
{
wn = enc_to_utf16(fname, NULL);
if (wn == NULL)
- res = FILEINFO_ENC_FAIL;
+ return FILEINFO_ENC_FAIL;
}
if (wn != NULL)
{
@@ -3332,15 +3128,9 @@ win32_fileinfo(char_u *fname, BY_HANDLE_FILE_INFORMATION *info)
OPEN_EXISTING, /* creation disposition */
FILE_FLAG_BACKUP_SEMANTICS, /* file attributes */
NULL); /* handle to template file */
- if (hFile == INVALID_HANDLE_VALUE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- /* Retry with non-wide function (for Windows 98). */
- vim_free(wn);
- wn = NULL;
- }
+ vim_free(wn);
}
- if (wn == NULL)
+ else
#endif
hFile = CreateFile((LPCSTR)fname, /* file name */
GENERIC_READ, /* access mode */
@@ -3359,9 +3149,6 @@ win32_fileinfo(char_u *fname, BY_HANDLE_FILE_INFORMATION *info)
CloseHandle(hFile);
}
-#ifdef FEAT_MBYTE
- vim_free(wn);
-#endif
return res;
}
@@ -3383,19 +3170,12 @@ win32_getattrs(char_u *name)
if (p != NULL)
{
attr = GetFileAttributesW(p);
- if (attr < 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- /* Retry with non-wide function (for Windows 98). */
- vim_free(p);
- p = NULL;
- }
+ vim_free(p);
}
- if (p == NULL)
+ else
#endif
attr = GetFileAttributes((char *)name);
-#ifdef FEAT_MBYTE
- vim_free(p);
-#endif
+
return attr;
}
@@ -3418,20 +3198,12 @@ win32_setattrs(char_u *name, int attrs)
if (p != NULL)
{
res = SetFileAttributesW(p, attrs);
- if (res == FALSE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- /* Retry with non-wide function (for Windows 98). */
- vim_free(p);
- p = NULL;
- }
+ vim_free(p);
}
- if (p == NULL)
+ else
#endif
res = SetFileAttributes((char *)name, attrs);
-#ifdef FEAT_MBYTE
- vim_free(p);
-#endif
+
return res ? 0 : -1;
}
@@ -3539,27 +3311,20 @@ mch_nodetype(char_u *name)
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- {
wn = enc_to_utf16(name, NULL);
- if (wn != NULL)
- {
- hFile = CreateFileW(wn, /* file name */
- GENERIC_WRITE, /* access mode */
- 0, /* share mode */
- NULL, /* security descriptor */
- OPEN_EXISTING, /* creation disposition */
- 0, /* file attributes */
- NULL); /* handle to template file */
- if (hFile == INVALID_HANDLE_VALUE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- /* Retry with non-wide function (for Windows 98). */
- vim_free(wn);
- wn = NULL;
- }
- }
+
+ if (wn != NULL)
+ {
+ hFile = CreateFileW(wn, /* file name */
+ GENERIC_WRITE, /* access mode */
+ 0, /* share mode */
+ NULL, /* security descriptor */
+ OPEN_EXISTING, /* creation disposition */
+ 0, /* file attributes */
+ NULL); /* handle to template file */
+ vim_free(wn);
}
- if (wn == NULL)
+ else
#endif
hFile = CreateFile((LPCSTR)name, /* file name */
GENERIC_WRITE, /* access mode */
@@ -3569,9 +3334,6 @@ mch_nodetype(char_u *name)
0, /* file attributes */
NULL); /* handle to template file */
-#ifdef FEAT_MBYTE
- vim_free(wn);
-#endif
if (hFile == INVALID_HANDLE_VALUE)
return NODE_NORMAL;
@@ -3608,88 +3370,84 @@ mch_get_acl(char_u *fname)
struct my_acl *p = NULL;
DWORD err;
- /* This only works on Windows NT and 2000. */
- if (g_PlatformId == VER_PLATFORM_WIN32_NT && advapi_lib != NULL)
+ p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl));
+ if (p != NULL)
{
- p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl));
- if (p != NULL)
- {
# ifdef FEAT_MBYTE
- WCHAR *wn = NULL;
+ WCHAR *wn = NULL;
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
- wn = enc_to_utf16(fname, NULL);
- if (wn != NULL)
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ wn = enc_to_utf16(fname, NULL);
+ if (wn != NULL)
+ {
+ /* Try to retrieve the entire security descriptor. */
+ err = GetNamedSecurityInfoW(
+ wn, // Abstract filename
+ SE_FILE_OBJECT, // File Object
+ OWNER_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ DACL_SECURITY_INFORMATION |
+ SACL_SECURITY_INFORMATION,
+ &p->pSidOwner, // Ownership information.
+ &p->pSidGroup, // Group membership.
+ &p->pDacl, // Discretionary information.
+ &p->pSacl, // For auditing purposes.
+ &p->pSecurityDescriptor);
+ if (err == ERROR_ACCESS_DENIED ||
+ err == ERROR_PRIVILEGE_NOT_HELD)
{
- /* Try to retrieve the entire security descriptor. */
- err = pGetNamedSecurityInfoW(
- wn, // Abstract filename
- SE_FILE_OBJECT, // File Object
- OWNER_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION |
- SACL_SECURITY_INFORMATION,
- &p->pSidOwner, // Ownership information.
- &p->pSidGroup, // Group membership.
- &p->pDacl, // Discretionary information.
- &p->pSacl, // For auditing purposes.
- &p->pSecurityDescriptor);
- if (err == ERROR_ACCESS_DENIED ||
- err == ERROR_PRIVILEGE_NOT_HELD)
- {
- /* Retrieve only DACL. */
- (void)pGetNamedSecurityInfoW(
- wn,
- SE_FILE_OBJECT,
- DACL_SECURITY_INFORMATION,
- NULL,
- NULL,
- &p->pDacl,
- NULL,
- &p->pSecurityDescriptor);
- }
- if (p->pSecurityDescriptor == NULL)
- {
- mch_free_acl((vim_acl_T)p);
- p = NULL;
- }
- vim_free(wn);
+ /* Retrieve only DACL. */
+ (void)GetNamedSecurityInfoW(
+ wn,
+ SE_FILE_OBJECT,
+ DACL_SECURITY_INFORMATION,
+ NULL,
+ NULL,
+ &p->pDacl,
+ NULL,
+ &p->pSecurityDescriptor);
}
- else
+ if (p->pSecurityDescriptor == NULL)
+ {
+ mch_free_acl((vim_acl_T)p);
+ p = NULL;
+ }
+ vim_free(wn);
+ }
+ else
# endif
+ {
+ /* Try to retrieve the entire security descriptor. */
+ err = GetNamedSecurityInfo(
+ (LPSTR)fname, // Abstract filename
+ SE_FILE_OBJECT, // File Object
+ OWNER_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ DACL_SECURITY_INFORMATION |
+ SACL_SECURITY_INFORMATION,
+ &p->pSidOwner, // Ownership information.
+ &p->pSidGroup, // Group membership.
+ &p->pDacl, // Discretionary information.
+ &p->pSacl, // For auditing purposes.
+ &p->pSecurityDescriptor);
+ if (err == ERROR_ACCESS_DENIED ||
+ err == ERROR_PRIVILEGE_NOT_HELD)
{
- /* Try to retrieve the entire security descriptor. */
- err = pGetNamedSecurityInfo(
- (LPSTR)fname, // Abstract filename
- SE_FILE_OBJECT, // File Object
- OWNER_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION |
- SACL_SECURITY_INFORMATION,
- &p->pSidOwner, // Ownership information.
- &p->pSidGroup, // Group membership.
- &p->pDacl, // Discretionary information.
- &p->pSacl, // For auditing purposes.
- &p->pSecurityDescriptor);
- if (err == ERROR_ACCESS_DENIED ||
- err == ERROR_PRIVILEGE_NOT_HELD)
- {
- /* Retrieve only DACL. */
- (void)pGetNamedSecurityInfo(
- (LPSTR)fname,
- SE_FILE_OBJECT,
- DACL_SECURITY_INFORMATION,
- NULL,
- NULL,
- &p->pDacl,
- NULL,
- &p->pSecurityDescriptor);
- }
- if (p->pSecurityDescriptor == NULL)
- {
- mch_free_acl((vim_acl_T)p);
- p = NULL;
- }
+ /* Retrieve only DACL. */
+ (void)GetNamedSecurityInfo(
+ (LPSTR)fname,
+ SE_FILE_OBJECT,
+ DACL_SECURITY_INFORMATION,
+ NULL,
+ NULL,
+ &p->pDacl,
+ NULL,
+ &p->pSecurityDescriptor);
+ }
+ if (p->pSecurityDescriptor == NULL)
+ {
+ mch_free_acl((vim_acl_T)p);
+ p = NULL;
}
}
}
@@ -3733,7 +3491,7 @@ mch_set_acl(char_u *fname, vim_acl_T acl)
struct my_acl *p = (struct my_acl *)acl;
SECURITY_INFORMATION sec_info = 0;
- if (p != NULL && advapi_lib != NULL)
+ if (p != NULL)
{
# ifdef FEAT_MBYTE
WCHAR *wn = NULL;
@@ -3761,7 +3519,7 @@ mch_set_acl(char_u *fname, vim_acl_T acl)
wn = enc_to_utf16(fname, NULL);
if (wn != NULL)
{
- (void)pSetNamedSecurityInfoW(
+ (void)SetNamedSecurityInfoW(
wn, // Abstract filename
SE_FILE_OBJECT, // File Object
sec_info,
@@ -3775,7 +3533,7 @@ mch_set_acl(char_u *fname, vim_acl_T acl)
else
# endif
{
- (void)pSetNamedSecurityInfo(
+ (void)SetNamedSecurityInfo(
(LPSTR)fname, // Abstract filename
SE_FILE_OBJECT, // File Object
sec_info,
@@ -4076,7 +3834,7 @@ vim_create_process(
STARTUPINFO *si,
PROCESS_INFORMATION *pi)
{
-# ifdef FEAT_MBYTE
+#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
WCHAR *wcmd = enc_to_utf16((char_u *)cmd, NULL);
@@ -4138,31 +3896,21 @@ mch_system_classic(char *cmd, int options)
si.lpTitle = NULL;
si.dwFlags = STARTF_USESHOWWINDOW;
/*
- * It's nicer to run a filter command in a minimized window, but in
- * Windows 95 this makes the command MUCH slower. We can't do it under
- * Win32s either as it stops the synchronous spawn workaround working.
+ * It's nicer to run a filter command in a minimized window.
* Don't activate the window to keep focus on Vim.
*/
- if ((options & SHELL_DOOUT) && !mch_windows95())
+ if (options & SHELL_DOOUT)
si.wShowWindow = SW_SHOWMINNOACTIVE;
else
si.wShowWindow = SW_SHOWNORMAL;
si.cbReserved2 = 0;
si.lpReserved2 = NULL;
- /* There is a strange error on Windows 95 when using "c:\command.com".
- * When the "c:\\" is left out it works OK...? */
- if (mch_windows95()
- && (STRNICMP(cmd, "c:/command.com", 14) == 0
- || STRNICMP(cmd, "c:\\command.com", 14) == 0))
- cmd += 3;
-
/* Now, run the command */
vim_create_process(cmd, FALSE,
CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE, &si, &pi);
/* Wait for the command to terminate before continuing */
- if (g_PlatformId != VER_PLATFORM_WIN32s)
{
#ifdef FEAT_GUI
int delay = 1;
@@ -4195,23 +3943,6 @@ mch_system_classic(char *cmd, int options)
/* Get the command exit code */
GetExitCodeProcess(pi.hProcess, &ret);
}
- else
- {
- /*
- * This ugly code is the only quick way of performing
- * a synchronous spawn under Win32s. Yuk.
- */
- num_windows = 0;
- EnumWindows(win32ssynch_cb, 0);
- old_num_windows = num_windows;
- do
- {
- Sleep(1000);
- num_windows = 0;
- EnumWindows(win32ssynch_cb, 0);
- } while (num_windows == old_num_windows);
- ret = 0;
- }
/* Close the handles to the subprocess, so that it goes away */
CloseHandle(pi.hThread);
@@ -4453,11 +4184,11 @@ mch_system_piped(char *cmd, int options)
if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, 0)
/* Ensure the read handle to the pipe for STDOUT is not inherited. */
- || ! pSetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)
+ || ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)
/* Create a pipe for the child process's STDIN. */
|| ! CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &saAttr, 0)
/* Ensure the write handle to the pipe for STDIN is not inherited. */
- || ! pSetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0) )
+ || ! SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0) )
{
CloseHandle(g_hChildStd_IN_Rd);
CloseHandle(g_hChildStd_IN_Wr);
@@ -4707,7 +4438,7 @@ mch_system_piped(char *cmd, int options)
mch_system(char *cmd, int options)
{
/* if we can pipe and the shelltemp option is off */
- if (allowPiping && !p_stmp)
+ if (!p_stmp)
return mch_system_piped(cmd, options);
else
return mch_system_classic(cmd, options);
@@ -4960,7 +4691,7 @@ mch_call_shell(
{
cmdlen = (
#ifdef FEAT_GUI_W32
- (allowPiping && !p_stmp ? 0 : STRLEN(vimrun_path)) +
+ (!p_stmp ? 0 : STRLEN(vimrun_path)) +
#endif
STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10);
@@ -4978,7 +4709,7 @@ mch_call_shell(
MB_ICONWARNING);
need_vimrun_warning = FALSE;
}
- if (!s_dont_use_vimrun && (!allowPiping || p_stmp))
+ if (!s_dont_use_vimrun && p_stmp)
/* Use vimrun to execute the command. It opens a console
* window, which can be closed without killing Vim. */
vim_snprintf((char *)newcmd, cmdlen, "%s%s%s %s %s",
@@ -5002,8 +4733,7 @@ mch_call_shell(
/* Print the return value, unless "vimrun" was used. */
if (x != 0 && !(options & SHELL_SILENT) && !emsg_silent
#if defined(FEAT_GUI_W32)
- && ((options & SHELL_DOOUT) || s_dont_use_vimrun
- || (allowPiping && !p_stmp))
+ && ((options & SHELL_DOOUT) || s_dont_use_vimrun || !p_stmp)
#endif
)
{
@@ -5051,14 +4781,10 @@ job_io_file_open(
lpSecurityAttributes, dwCreationDisposition,
dwFlagsAndAttributes, NULL);
vim_free(wn);
- if (h == INVALID_HANDLE_VALUE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- wn = NULL;
}
}
if (wn == NULL)
# endif
-
h = CreateFile((LPCSTR)fname, dwDesiredAccess, dwShareMode,
lpSecurityAttributes, dwCreationDisposition,
dwFlagsAndAttributes, NULL);
@@ -5127,7 +4853,7 @@ mch_start_job(char *cmd, job_T *job, jobopt_T *options)
}
else if (!use_null_for_in &&
(!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0)
- || !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)))
+ || !SetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)))
goto failed;
if (use_file_for_out)
@@ -5145,7 +4871,7 @@ mch_start_job(char *cmd, job_T *job, jobopt_T *options)
}
else if (!use_null_for_out &&
(!CreatePipe(&ofd[0], &ofd[1], &saAttr, 0)
- || !pSetHandleInformation(ofd[0], HANDLE_FLAG_INHERIT, 0)))
+ || !SetHandleInformation(ofd[0], HANDLE_FLAG_INHERIT, 0)))
goto failed;
if (use_file_for_err)
@@ -5163,7 +4889,7 @@ mch_start_job(char *cmd, job_T *job, jobopt_T *options)
}
else if (!use_out_for_err && !use_null_for_err &&
(!CreatePipe(&efd[0], &efd[1], &saAttr, 0)
- || !pSetHandleInformation(efd[0], HANDLE_FLAG_INHERIT, 0)))
+ || !SetHandleInformation(efd[0], HANDLE_FLAG_INHERIT, 0)))
goto failed;
si.dwFlags |= STARTF_USESTDHANDLES;
@@ -6176,9 +5902,7 @@ mch_remove(char_u *name)
{
n = DeleteFileW(wn) ? 0 : -1;
vim_free(wn);
- if (n == 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return n;
- /* Retry with non-wide function (for Windows 98). */
+ return n;
}
}
#endif
@@ -6203,7 +5927,6 @@ mch_breakcheck(int force)
/* physical RAM to leave for the OS */
#define WINNT_RESERVE_BYTES (256*1024*1024)
-#define WIN95_RESERVE_BYTES (8*1024*1024)
/*
* How much main memory in KiB that can be used by VIM.
@@ -6212,54 +5935,25 @@ mch_breakcheck(int force)
long_u
mch_total_mem(int special)
{
+ MEMORYSTATUSEX ms;
+
PlatformId();
-#if (defined(_MSC_VER) && (WINVER > 0x0400)) || defined(MEMORYSTATUSEX)
- if (g_PlatformId == VER_PLATFORM_WIN32_NT)
+ /* Need to use GlobalMemoryStatusEx() when there is more memory than
+ * what fits in 32 bits. But it's not always available. */
+ ms.dwLength = sizeof(MEMORYSTATUSEX);
+ GlobalMemoryStatusEx(&ms);
+ if (ms.ullAvailVirtual < ms.ullTotalPhys)
{
- MEMORYSTATUSEX ms;
-
- /* Need to use GlobalMemoryStatusEx() when there is more memory than
- * what fits in 32 bits. But it's not always available. */
- ms.dwLength = sizeof(MEMORYSTATUSEX);
- GlobalMemoryStatusEx(&ms);
- if (ms.ullAvailVirtual < ms.ullTotalPhys)
- {
- /* Process address space fits in physical RAM, use all of it. */
- return (long_u)(ms.ullAvailVirtual / 1024);
- }
- if (ms.ullTotalPhys <= WINNT_RESERVE_BYTES)
- {
- /* Catch old NT box or perverse hardware setup. */
- return (long_u)((ms.ullTotalPhys / 2) / 1024);
- }
- /* Use physical RAM less reserve for OS + data. */
- return (long_u)((ms.ullTotalPhys - WINNT_RESERVE_BYTES) / 1024);
+ /* Process address space fits in physical RAM, use all of it. */
+ return (long_u)(ms.ullAvailVirtual / 1024);
}
- else
-#endif
+ if (ms.ullTotalPhys <= WINNT_RESERVE_BYTES)
{
- /* Pre-XP or 95 OS handling. */
- MEMORYSTATUS ms;
- long_u os_reserve_bytes;
-
- ms.dwLength = sizeof(MEMORYSTATUS);
- GlobalMemoryStatus(&ms);
- if (ms.dwAvailVirtual < ms.dwTotalPhys)
- {
- /* Process address space fits in physical RAM, use all of it. */
- return (long_u)(ms.dwAvailVirtual / 1024);
- }
- os_reserve_bytes = (g_PlatformId == VER_PLATFORM_WIN32_NT)
- ? WINNT_RESERVE_BYTES
- : WIN95_RESERVE_BYTES;
- if (ms.dwTotalPhys <= os_reserve_bytes)
- {
- /* Catch old boxes or perverse hardware setup. */
- return (long_u)((ms.dwTotalPhys / 2) / 1024);
- }
- /* Use physical RAM less reserve for OS + data. */
- return (long_u)((ms.dwTotalPhys - os_reserve_bytes) / 1024);
+ /* Catch old NT box or perverse hardware setup. */
+ return (long_u)((ms.ullTotalPhys / 2) / 1024);
}
+ /* Use physical RAM less reserve for OS + data. */
+ return (long_u)((ms.ullTotalPhys - WINNT_RESERVE_BYTES) / 1024);
}
#ifdef FEAT_MBYTE
@@ -6276,16 +5970,13 @@ mch_wrename(WCHAR *wold, WCHAR *wnew)
WCHAR szNewPath[_MAX_PATH + 1];
HANDLE hf;
- if (!mch_windows95())
- {
- p = wold;
- for (i = 0; wold[i] != NUL; ++i)
- if ((wold[i] == '/' || wold[i] == '\\' || wold[i] == ':')
- && wold[i + 1] != 0)
- p = wold + i + 1;
- if ((int)(wold + i - p) < 8 || p[6] != '~')
- return (MoveFileW(wold, wnew) == 0);
- }
+ p = wold;
+ for (i = 0; wold[i] != NUL; ++i)
+ if ((wold[i] == '/' || wold[i] == '\\' || wold[i] == ':')
+ && wold[i + 1] != 0)
+ p = wold + i + 1;
+ if ((int)(wold + i - p) < 8 || p[6] != '~')
+ return (MoveFileW(wold, wnew) == 0);
if (GetFullPathNameW(wnew, _MAX_PATH, szNewPath, &p) == 0 || p == NULL)
return -1;
@@ -6363,22 +6054,17 @@ mch_rename(
retval = mch_wrename(wold, wnew);
vim_free(wold);
vim_free(wnew);
- if (retval == 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- return retval;
- /* Retry with non-wide function (for Windows 98). */
+ return retval;
}
#endif
/*
- * No need to play tricks if not running Windows 95, unless the file name
- * contains a "~" as the seventh character.
+ * No need to play tricks unless the file name contains a "~" as the
+ * seventh character.
*/
- if (!mch_windows95())
- {
- pszFilePart = (char *)gettail((char_u *)pszOldFile);
- if (STRLEN(pszFilePart) < 8 || pszFilePart[6] != '~')
- return rename(pszOldFile, pszNewFile);
- }
+ pszFilePart = (char *)gettail((char_u *)pszOldFile);
+ if (STRLEN(pszFilePart) < 8 || pszFilePart[6] != '~')
+ return rename(pszOldFile, pszNewFile);
/* Get base path of new file name. Undocumented feature: If pszNewFile is
* a directory, no error is returned and pszFilePart will be NULL. */
@@ -6441,16 +6127,9 @@ mch_rename(
char *
default_shell(void)
{
- char* psz = NULL;
-
PlatformId();
- if (g_PlatformId == VER_PLATFORM_WIN32_NT) /* Windows NT */
- psz = "cmd.exe";
- else if (g_PlatformId == VER_PLATFORM_WIN32_WINDOWS) /* Windows 95 */
- psz = "command.com";
-
- return psz;
+ return "cmd.exe";
}
/*
@@ -6496,18 +6175,11 @@ mch_access(char *n, int p)
hFile = FindFirstFileW(TempNameW, &d);
if (hFile == INVALID_HANDLE_VALUE)
- {
- if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- goto getout;
-
- /* Retry with non-wide function (for Windows 98). */
- vim_free(wn);
- wn = NULL;
- }
+ goto getout;
else
(void)FindClose(hFile);
}
- if (wn == NULL)
+ else
#endif
{
char *pch;
@@ -6537,18 +6209,11 @@ mch_access(char *n, int p)
if (wn != NULL)
{
if (!GetTempFileNameW(wn, L"VIM", 0, TempNameW))
- {
- if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- goto getout;
-
- /* Retry with non-wide function (for Windows 98). */
- vim_free(wn);
- wn = NULL;
- }
+ goto getout;
else
DeleteFileW(TempNameW);
}
- if (wn == NULL)
+ else
#endif
{
if (!GetTempFileName(n, "VIM", 0, TempName))
@@ -6565,17 +6230,8 @@ mch_access(char *n, int p)
| ((p & R_OK) ? GENERIC_READ : 0);
#ifdef FEAT_MBYTE
if (wn != NULL)
- {
hFile = CreateFileW(wn, am, 0, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile == INVALID_HANDLE_VALUE
- && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
- {
- /* Retry with non-wide function (for Windows 98). */
- vim_free(wn);
- wn = NULL;
- }
- }
- if (wn == NULL)
+ else
#endif
hFile = CreateFile(n, am, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
@@ -6610,11 +6266,7 @@ mch_open(char *name, int flags, int mode)
{
f = _wopen(wn, flags, mode);
vim_free(wn);
- if (f >= 0 || g_PlatformId == VER_PLATFORM_WIN32_NT)
- return f;
- /* Retry with non-wide function (for Windows 98). Can't use
- * GetLastError() here and it's unclear what errno gets set to if
- * the _wopen() fails for missing wide functions. */
+ return f;
}
}
# endif
@@ -6638,12 +6290,7 @@ mch_fopen(char *name, char *mode)
WCHAR *wn, *wm;
FILE *f = NULL;
- if (enc_codepage >= 0 && (int)GetACP() != enc_codepage
-# ifdef __BORLANDC__
- /* Wide functions of Borland C 5.5 do not work on Windows 98. */
- && g_PlatformId == VER_PLATFORM_WIN32_NT
-# endif
- )
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
# if defined(DEBUG) && _MSC_VER >= 1400
/* Work around an annoying assertion in the Microsoft debug CRT
@@ -6667,12 +6314,7 @@ mch_fopen(char *name, char *mode)
# if defined(DEBUG) && _MSC_VER >= 1400
_set_fmode(oldMode);
# endif
-
- if (f != NULL || g_PlatformId == VER_PLATFORM_WIN32_NT)
- return f;
- /* Retry with non-wide function (for Windows 98). Can't use
- * GetLastError() here and it's unclear what errno gets set to if
- * the _wfopen() fails for missing wide functions. */
+ return f;
}
/* fopen() can open a file which name is longer than _MAX_PATH bytes
@@ -6843,8 +6485,7 @@ mch_copy_file_attribute(char_u *from, char_u *to)
#ifdef FEAT_MBYTE
/* File streams only work on Windows NT and later. */
PlatformId();
- if (g_PlatformId == VER_PLATFORM_WIN32_NT)
- copy_infostreams(from, to);
+ copy_infostreams(from, to);
#endif
return 0;
}
@@ -6856,7 +6497,6 @@ mch_copy_file_attribute(char_u *from, char_u *to)
*/
/* These magic numbers are from the MS header files */
-#define MIN_STACK_WIN9X 17
#define MIN_STACK_WINNT 2
/*
@@ -6876,10 +6516,7 @@ myresetstkoflw(void)
DWORD nPageSize;
DWORD dummy;
- /* This code will not work on win32s. */
PlatformId();
- if (g_PlatformId == VER_PLATFORM_WIN32s)
- return 0;