vim-patch:8.1.0941: macros for MS-Windows are inconsistent (#20215)

Problem:    Macros for MS-Windows are inconsistent, using "32", "3264 and
            others.
Solution:   Use MSWIN for all MS-Windows builds.  Use FEAT_GUI_MSWIN for the
            GUI build. (Hirohito Higashi, closes vim/vim#3932)
4f97475d32
This commit is contained in:
dundargoc
2022-09-18 03:17:15 +02:00
committed by GitHub
parent 3c3f3e7353
commit 6d557e324f
41 changed files with 134 additions and 133 deletions

View File

@@ -273,7 +273,7 @@ if(MSVC)
# XXX: /W4 gives too many warnings. #3241 # XXX: /W4 gives too many warnings. #3241
add_compile_options(/W3) add_compile_options(/W3)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DWIN32) add_definitions(-DMSWIN)
else() else()
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter
-Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion
@@ -320,6 +320,7 @@ endif()
if(MINGW) if(MINGW)
# Use POSIX compatible stdio in Mingw # Use POSIX compatible stdio in Mingw
add_definitions(-D__USE_MINGW_ANSI_STDIO) add_definitions(-D__USE_MINGW_ANSI_STDIO)
add_definitions(-DMSWIN)
endif() endif()
if(WIN32) if(WIN32)
# Windows Vista is the minimum supported version # Windows Vista is the minimum supported version

View File

@@ -1882,7 +1882,7 @@ Object nvim_get_proc(Integer pid, Error *err)
api_set_error(err, kErrorTypeException, "Invalid pid: %" PRId64, pid); api_set_error(err, kErrorTypeException, "Invalid pid: %" PRId64, pid);
return NIL; return NIL;
} }
#ifdef WIN32 #ifdef MSWIN
rvobj.data.dictionary = os_proc_info((int)pid); rvobj.data.dictionary = os_proc_info((int)pid);
if (rvobj.data.dictionary.size == 0) { // Process not found. if (rvobj.data.dictionary.size == 0) { // Process not found.
return NIL; return NIL;

View File

@@ -3448,7 +3448,7 @@ void fname_expand(buf_T *buf, char **ffname, char **sfname)
} }
*ffname = fix_fname((*ffname)); // expand to full path *ffname = fix_fname((*ffname)); // expand to full path
#ifdef WIN32 #ifdef MSWIN
if (!buf->b_p_bin) { if (!buf->b_p_bin) {
// If the file name is a shortcut file, use the file it links to. // If the file name is a shortcut file, use the file it links to.
char *rfname = os_resolve_shortcut((const char *)(*ffname)); char *rfname = os_resolve_shortcut((const char *)(*ffname));

View File

@@ -14,7 +14,7 @@
#include "nvim/msgpack_rpc/server.h" #include "nvim/msgpack_rpc/server.h"
#include "nvim/os/fs.h" #include "nvim/os/fs.h"
#include "nvim/os/shell.h" #include "nvim/os/shell.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/os_win_console.h" # include "nvim/os/os_win_console.h"
# include "nvim/os/pty_conpty_win.h" # include "nvim/os/pty_conpty_win.h"
#endif #endif
@@ -492,7 +492,7 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, const char **err
int stdin_dup_fd = STDIN_FILENO; int stdin_dup_fd = STDIN_FILENO;
int stdout_dup_fd = STDOUT_FILENO; int stdout_dup_fd = STDOUT_FILENO;
#ifdef WIN32 #ifdef MSWIN
// Strangely, ConPTY doesn't work if stdin and stdout are pipes. So replace // Strangely, ConPTY doesn't work if stdin and stdout are pipes. So replace
// stdin and stdout with CONIN$ and CONOUT$, respectively. // stdin and stdout with CONIN$ and CONOUT$, respectively.
if (embedded_mode && os_has_conpty_working()) { if (embedded_mode && os_has_conpty_working()) {

View File

@@ -1344,7 +1344,7 @@ static void f_debugbreak(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (pid == 0) { if (pid == 0) {
emsg(_(e_invarg)); emsg(_(e_invarg));
} else { } else {
#ifdef WIN32 #ifdef MSWIN
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
if (hProcess != NULL) { if (hProcess != NULL) {
@@ -1695,7 +1695,7 @@ static void f_environ(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
char c = env[i][len]; char c = env[i][len];
env[i][len] = NUL; env[i][len] = NUL;
#ifdef WIN32 #ifdef MSWIN
// Upper-case all the keys for Windows so we can detect duplicates // Upper-case all the keys for Windows so we can detect duplicates
char *const key = strcase_save(str, true); char *const key = strcase_save(str, true);
#else #else
@@ -3532,7 +3532,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
#ifdef UNIX #ifdef UNIX
"unix", "unix",
#endif #endif
#if defined(WIN32) #if defined(MSWIN)
"win32", "win32",
#endif #endif
#ifdef _WIN64 #ifdef _WIN64
@@ -4257,7 +4257,7 @@ static void f_jobresize(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
} }
static const char *ignored_env_vars[] = { static const char *ignored_env_vars[] = {
#ifndef WIN32 #ifndef MSWIN
"COLUMNS", "COLUMNS",
"LINES", "LINES",
"TERMCAP", "TERMCAP",
@@ -4269,7 +4269,7 @@ static const char *ignored_env_vars[] = {
/// According to comments in src/win/process.c of libuv, Windows has a few /// According to comments in src/win/process.c of libuv, Windows has a few
/// "essential" environment variables. /// "essential" environment variables.
static const char *required_env_vars[] = { static const char *required_env_vars[] = {
#ifdef WIN32 #ifdef MSWIN
"HOMEDRIVE", "HOMEDRIVE",
"HOMEPATH", "HOMEPATH",
"LOGONSERVER", "LOGONSERVER",
@@ -4308,7 +4308,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
tv_dict_item_remove(env, dv); tv_dict_item_remove(env, dv);
} }
} }
#ifndef WIN32 #ifndef MSWIN
// Set COLORTERM to "truecolor" if termguicolors is set and 256 // Set COLORTERM to "truecolor" if termguicolors is set and 256
// otherwise, but only if it was set in the parent terminal at all // otherwise, but only if it was set in the parent terminal at all
dictitem_T *dv = tv_dict_find(env, S_LEN("COLORTERM")); dictitem_T *dv = tv_dict_find(env, S_LEN("COLORTERM"));
@@ -4343,7 +4343,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
} }
if (job_env) { if (job_env) {
#ifdef WIN32 #ifdef MSWIN
TV_DICT_ITER(job_env->di_tv.vval.v_dict, var, { TV_DICT_ITER(job_env->di_tv.vval.v_dict, var, {
// Always use upper-case keys for Windows so we detect duplicate keys // Always use upper-case keys for Windows so we detect duplicate keys
char *const key = strcase_save((const char *)var->di_key, true); char *const key = strcase_save((const char *)var->di_key, true);
@@ -4443,7 +4443,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return; return;
} }
#ifdef WIN32 #ifdef MSWIN
if (pty && overlapped) { if (pty && overlapped) {
semsg(_(e_invarg2), semsg(_(e_invarg2),
"job cannot have both 'pty' and 'overlapped' options set"); "job cannot have both 'pty' and 'overlapped' options set");
@@ -6286,7 +6286,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{ {
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
const char *fname = tv_get_string(&argvars[0]); const char *fname = tv_get_string(&argvars[0]);
#ifdef WIN32 #ifdef MSWIN
char *v = os_resolve_shortcut(fname); char *v = os_resolve_shortcut(fname);
if (v == NULL) { if (v == NULL) {
if (os_is_reparse_point_include(fname)) { if (os_is_reparse_point_include(fname)) {

View File

@@ -25,7 +25,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
uvproc->uvopts.file = proc->argv[0]; uvproc->uvopts.file = proc->argv[0];
uvproc->uvopts.args = proc->argv; uvproc->uvopts.args = proc->argv;
uvproc->uvopts.flags = UV_PROCESS_WINDOWS_HIDE; uvproc->uvopts.flags = UV_PROCESS_WINDOWS_HIDE;
#ifdef WIN32 #ifdef MSWIN
// libuv collapses the argv to a CommandLineToArgvW()-style string. cmd.exe // libuv collapses the argv to a CommandLineToArgvW()-style string. cmd.exe
// expects a different syntax (must be prepared by the caller before now). // expects a different syntax (must be prepared by the caller before now).
if (os_shell_is_cmdexe(proc->argv[0])) { if (os_shell_is_cmdexe(proc->argv[0])) {
@@ -55,7 +55,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
if (!proc->in.closed) { if (!proc->in.closed) {
uvproc->uvstdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; uvproc->uvstdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
#ifdef WIN32 #ifdef MSWIN
uvproc->uvstdio[0].flags |= proc->overlapped ? UV_OVERLAPPED_PIPE : 0; uvproc->uvstdio[0].flags |= proc->overlapped ? UV_OVERLAPPED_PIPE : 0;
#endif #endif
uvproc->uvstdio[0].data.stream = STRUCT_CAST(uv_stream_t, uvproc->uvstdio[0].data.stream = STRUCT_CAST(uv_stream_t,
@@ -64,7 +64,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
if (!proc->out.closed) { if (!proc->out.closed) {
uvproc->uvstdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; uvproc->uvstdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
#ifdef WIN32 #ifdef MSWIN
// pipe must be readable for IOCP to work on Windows. // pipe must be readable for IOCP to work on Windows.
uvproc->uvstdio[1].flags |= proc->overlapped ? uvproc->uvstdio[1].flags |= proc->overlapped ?
(UV_READABLE_PIPE | UV_OVERLAPPED_PIPE) : 0; (UV_READABLE_PIPE | UV_OVERLAPPED_PIPE) : 0;
@@ -113,7 +113,7 @@ static void close_cb(uv_handle_t *handle)
static void exit_cb(uv_process_t *handle, int64_t status, int term_signal) static void exit_cb(uv_process_t *handle, int64_t status, int term_signal)
{ {
Process *proc = handle->data; Process *proc = handle->data;
#if defined(WIN32) #if defined(MSWIN)
// Use stored/expected signal. // Use stored/expected signal.
term_signal = proc->exit_signal; term_signal = proc->exit_signal;
#endif #endif

View File

@@ -10,7 +10,7 @@
#include "nvim/log.h" #include "nvim/log.h"
#include "nvim/macros.h" #include "nvim/macros.h"
#include "nvim/rbuffer.h" #include "nvim/rbuffer.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/os_win_console.h" # include "nvim/os/os_win_console.h"
#endif #endif
@@ -60,7 +60,7 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream)
stream->uv.idle.data = stream; stream->uv.idle.data = stream;
} else { } else {
assert(type == UV_NAMED_PIPE || type == UV_TTY); assert(type == UV_NAMED_PIPE || type == UV_TTY);
#ifdef WIN32 #ifdef MSWIN
if (type == UV_TTY) { if (type == UV_TTY) {
uv_tty_init(&loop->uv, &stream->uv.tty, fd, 0); uv_tty_init(&loop->uv, &stream->uv.tty, fd, 0);
uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_RAW); uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_RAW);
@@ -75,7 +75,7 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream)
uv_pipe_init(&loop->uv, &stream->uv.pipe, 0); uv_pipe_init(&loop->uv, &stream->uv.pipe, 0);
uv_pipe_open(&stream->uv.pipe, fd); uv_pipe_open(&stream->uv.pipe, fd);
stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.pipe); stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.pipe);
#ifdef WIN32 #ifdef MSWIN
} }
#endif #endif
} }
@@ -109,7 +109,7 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data)
stream->close_cb = on_stream_close; stream->close_cb = on_stream_close;
stream->close_cb_data = data; stream->close_cb_data = data;
#ifdef WIN32 #ifdef MSWIN
if (UV_TTY == uv_guess_handle(stream->fd)) { if (UV_TTY == uv_guess_handle(stream->fd)) {
// Undo UV_TTY_MODE_RAW from stream_init(). #10801 // Undo UV_TTY_MODE_RAW from stream_init(). #10801
uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_NORMAL); uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_NORMAL);

View File

@@ -35,7 +35,7 @@ struct stream {
uv_pipe_t pipe; uv_pipe_t pipe;
uv_tcp_t tcp; uv_tcp_t tcp;
uv_idle_t idle; uv_idle_t idle;
#ifdef WIN32 #ifdef MSWIN
uv_tty_t tty; uv_tty_t tty;
#endif #endif
} uv; } uv;

View File

@@ -1378,7 +1378,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
if (vim_isAbsName((char_u *)ff_file_to_find) if (vim_isAbsName((char_u *)ff_file_to_find)
// "..", "../path", "." and "./path": don't use the path_option // "..", "../path", "." and "./path": don't use the path_option
|| rel_to_curdir || rel_to_curdir
#if defined(WIN32) #if defined(MSWIN)
// handle "\tmp" as absolute path // handle "\tmp" as absolute path
|| vim_ispathsep(ff_file_to_find[0]) || vim_ispathsep(ff_file_to_find[0])
// handle "c:name" as absolute path // handle "c:name" as absolute path

View File

@@ -1673,7 +1673,7 @@ failed:
if (read_stdin) { if (read_stdin) {
close(fd); close(fd);
if (stdin_fd < 0) { if (stdin_fd < 0) {
#ifndef WIN32 #ifndef MSWIN
// On Unix, use stderr for stdin, makes shell commands work. // On Unix, use stderr for stdin, makes shell commands work.
vim_ignored = dup(2); vim_ignored = dup(2);
#else #else

View File

@@ -218,7 +218,7 @@ local footer = [[
local non_static = header .. [[ local non_static = header .. [[
#ifndef DLLEXPORT #ifndef DLLEXPORT
# ifdef WIN32 # ifdef MSWIN
# define DLLEXPORT __declspec(dllexport) # define DLLEXPORT __declspec(dllexport)
# else # else
# define DLLEXPORT # define DLLEXPORT

View File

@@ -23,7 +23,7 @@
#define MSG_BUF_CLEN (MSG_BUF_LEN / 6) // cell length (worst case: utf-8 #define MSG_BUF_CLEN (MSG_BUF_LEN / 6) // cell length (worst case: utf-8
// takes 6 bytes for one cell) // takes 6 bytes for one cell)
#ifdef WIN32 #ifdef MSWIN
# define _PATHSEPSTR "\\" # define _PATHSEPSTR "\\"
#else #else
# define _PATHSEPSTR "/" # define _PATHSEPSTR "/"

View File

@@ -768,7 +768,7 @@ err_closing:
#if defined(UNIX) #if defined(UNIX)
(void)snprintf(cmd, len, "exec %s -dl -f %s", prog, csinfo[i].fname); (void)snprintf(cmd, len, "exec %s -dl -f %s", prog, csinfo[i].fname);
#else #else
// WIN32 // MS-Windows
(void)snprintf(cmd, len, "%s -dl -f %s", prog, csinfo[i].fname); (void)snprintf(cmd, len, "%s -dl -f %s", prog, csinfo[i].fname);
#endif #endif
if (csinfo[i].ppath != NULL) { if (csinfo[i].ppath != NULL) {
@@ -820,7 +820,7 @@ err_closing:
} }
#else #else
// WIN32 // MS-Windows
// Create a new process to run cscope and use pipes to talk with it // Create a new process to run cscope and use pipes to talk with it
GetStartupInfo(&si); GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;

View File

@@ -270,7 +270,7 @@ void ex_language(exarg_T *eap)
static char **locales = NULL; // Array of all available locales static char **locales = NULL; // Array of all available locales
# ifndef WIN32 # ifndef MSWIN
static bool did_init_locales = false; static bool did_init_locales = false;
/// @return an array of strings for all available locales + NULL for the /// @return an array of strings for all available locales + NULL for the
@@ -311,7 +311,7 @@ static char **find_locales(void)
/// Lazy initialization of all available locales. /// Lazy initialization of all available locales.
static void init_locales(void) static void init_locales(void)
{ {
# ifndef WIN32 # ifndef MSWIN
if (!did_init_locales) { if (!did_init_locales) {
did_init_locales = true; did_init_locales = true;
locales = find_locales(); locales = find_locales();

View File

@@ -248,7 +248,7 @@ static int nlua_luv_thread_common_cfpcall(lua_State *lstate, int nargs, int nres
mch_errmsg(e_outofmem); mch_errmsg(e_outofmem);
mch_errmsg("\n"); mch_errmsg("\n");
lua_close(lstate); lua_close(lstate);
#ifdef WIN32 #ifdef MSWIN
ExitThread(0); ExitThread(0);
#else #else
pthread_exit(0); pthread_exit(0);
@@ -673,7 +673,7 @@ static bool nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
lua_setfield(lstate, -2, "debug"); lua_setfield(lstate, -2, "debug");
lua_pop(lstate, 1); lua_pop(lstate, 1);
#ifdef WIN32 #ifdef MSWIN
// os.getenv // os.getenv
lua_getglobal(lstate, "os"); lua_getglobal(lstate, "os");
lua_pushcfunction(lstate, &nlua_getenv); lua_pushcfunction(lstate, &nlua_getenv);
@@ -1201,7 +1201,7 @@ static int nlua_empty_dict_tostring(lua_State *lstate)
return 1; return 1;
} }
#ifdef WIN32 #ifdef MSWIN
/// os.getenv: override os.getenv to maintain coherency. #9681 /// os.getenv: override os.getenv to maintain coherency. #9681
/// ///
/// uv_os_setenv uses SetEnvironmentVariableW which does not update _environ. /// uv_os_setenv uses SetEnvironmentVariableW which does not update _environ.

View File

@@ -86,7 +86,7 @@
// mch_open_rw(): invoke os_open() with third argument for user R/W. // mch_open_rw(): invoke os_open() with third argument for user R/W.
#if defined(UNIX) // open in rw------- mode #if defined(UNIX) // open in rw------- mode
# define MCH_OPEN_RW(n, f) os_open((n), (f), (mode_t)0600) # define MCH_OPEN_RW(n, f) os_open((n), (f), (mode_t)0600)
#elif defined(WIN32) #elif defined(MSWIN)
# define MCH_OPEN_RW(n, f) os_open((n), (f), S_IREAD | S_IWRITE) # define MCH_OPEN_RW(n, f) os_open((n), (f), S_IREAD | S_IWRITE)
#else #else
# define MCH_OPEN_RW(n, f) os_open((n), (f), 0) # define MCH_OPEN_RW(n, f) os_open((n), (f), 0)
@@ -178,14 +178,14 @@
// Type of uv_buf_t.len is platform-dependent. // Type of uv_buf_t.len is platform-dependent.
// Related: https://github.com/libuv/libuv/pull/1236 // Related: https://github.com/libuv/libuv/pull/1236
#if defined(WIN32) #if defined(MSWIN)
# define UV_BUF_LEN(x) (ULONG)(x) # define UV_BUF_LEN(x) (ULONG)(x)
#else #else
# define UV_BUF_LEN(x) (x) # define UV_BUF_LEN(x) (x)
#endif #endif
// Type of read()/write() `count` param is platform-dependent. // Type of read()/write() `count` param is platform-dependent.
#if defined(WIN32) #if defined(MSWIN)
# define IO_COUNT(x) (unsigned)(x) # define IO_COUNT(x) (unsigned)(x)
#else #else
# define IO_COUNT(x) (x) # define IO_COUNT(x) (x)

View File

@@ -71,7 +71,7 @@
#include "nvim/version.h" #include "nvim/version.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#include "nvim/window.h" #include "nvim/window.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/os_win_console.h" # include "nvim/os/os_win_console.h"
#endif #endif
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h"
@@ -84,7 +84,7 @@
#include "nvim/msgpack_rpc/helpers.h" #include "nvim/msgpack_rpc/helpers.h"
#include "nvim/msgpack_rpc/server.h" #include "nvim/msgpack_rpc/server.h"
#include "nvim/os/signal.h" #include "nvim/os/signal.h"
#ifndef WIN32 #ifndef MSWIN
# include "nvim/os/pty_process_unix.h" # include "nvim/os/pty_process_unix.h"
#endif #endif
#include "nvim/api/extmark.h" #include "nvim/api/extmark.h"
@@ -168,7 +168,7 @@ void early_init(mparm_T *paramp)
runtime_init(); runtime_init();
highlight_init(); highlight_init();
#ifdef WIN32 #ifdef MSWIN
OSVERSIONINFO ovi; OSVERSIONINFO ovi;
ovi.dwOSVersionInfoSize = sizeof(ovi); ovi.dwOSVersionInfoSize = sizeof(ovi);
GetVersionEx(&ovi); GetVersionEx(&ovi);
@@ -210,13 +210,13 @@ void early_init(mparm_T *paramp)
#ifdef MAKE_LIB #ifdef MAKE_LIB
int nvim_main(int argc, char **argv); // silence -Wmissing-prototypes int nvim_main(int argc, char **argv); // silence -Wmissing-prototypes
int nvim_main(int argc, char **argv) int nvim_main(int argc, char **argv)
#elif defined(WIN32) #elif defined(MSWIN)
int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060 int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060
#else #else
int main(int argc, char **argv) int main(int argc, char **argv)
#endif #endif
{ {
#if defined(WIN32) && !defined(MAKE_LIB) #if defined(MSWIN) && !defined(MAKE_LIB)
char **argv = xmalloc((size_t)argc * sizeof(char *)); char **argv = xmalloc((size_t)argc * sizeof(char *));
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
char *buf = NULL; char *buf = NULL;
@@ -582,7 +582,7 @@ int main(int argc, char **argv)
// Main loop: never returns. // Main loop: never returns.
normal_enter(false, false); normal_enter(false, false);
#if defined(WIN32) && !defined(MAKE_LIB) #if defined(MSWIN) && !defined(MAKE_LIB)
xfree(argv); xfree(argv);
#endif #endif
return 0; return 0;
@@ -1273,7 +1273,7 @@ scripterror:
int error; int error;
if (strequal(argv[0], "-")) { if (strequal(argv[0], "-")) {
const int stdin_dup_fd = os_dup(STDIN_FILENO); const int stdin_dup_fd = os_dup(STDIN_FILENO);
#ifdef WIN32 #ifdef MSWIN
// Replace the original stdin with the console input handle. // Replace the original stdin with the console input handle.
os_replace_stdin_to_conin(); os_replace_stdin_to_conin();
#endif #endif
@@ -1426,7 +1426,7 @@ static void check_and_set_isatty(mparm_T *paramp)
stdout_isatty stdout_isatty
= paramp->output_isatty = os_isatty(STDOUT_FILENO); = paramp->output_isatty = os_isatty(STDOUT_FILENO);
paramp->err_isatty = os_isatty(STDERR_FILENO); paramp->err_isatty = os_isatty(STDERR_FILENO);
#ifndef WIN32 #ifndef MSWIN
int tty_fd = paramp->input_isatty int tty_fd = paramp->input_isatty
? STDIN_FILENO ? STDIN_FILENO
: (paramp->output_isatty : (paramp->output_isatty
@@ -1451,7 +1451,7 @@ static void init_path(const char *exename)
set_vim_var_string(VV_PROGPATH, exepath, -1); set_vim_var_string(VV_PROGPATH, exepath, -1);
set_vim_var_string(VV_PROGNAME, path_tail(exename), -1); set_vim_var_string(VV_PROGNAME, path_tail(exename), -1);
#ifdef WIN32 #ifdef MSWIN
// Append the process start directory to $PATH, so that ":!foo" finds tools // Append the process start directory to $PATH, so that ":!foo" finds tools
// shipped with Windows package. This also mimics SearchPath(). // shipped with Windows package. This also mimics SearchPath().
os_setenv_append_path(exepath); os_setenv_append_path(exepath);

View File

@@ -1350,7 +1350,7 @@ static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2
return n1 == 0 ? -1 : 1; return n1 == 0 ? -1 : 1;
} }
#ifdef WIN32 #ifdef MSWIN
# ifndef CP_UTF8 # ifndef CP_UTF8
# define CP_UTF8 65001 // magic number from winnls.h # define CP_UTF8 65001 // magic number from winnls.h
# endif # endif

View File

@@ -3012,7 +3012,7 @@ static int do_more_prompt(int typed_char)
return retval; return retval;
} }
#if defined(WIN32) #if defined(MSWIN)
void mch_errmsg(char *str) void mch_errmsg(char *str)
{ {
assert(str != NULL); assert(str != NULL);
@@ -3039,7 +3039,7 @@ void mch_msg(char *str)
xfree(utf16str); xfree(utf16str);
} }
} }
#endif // WIN32 #endif // MSWIN
/// Put a character on the screen at the current message position and advance /// Put a character on the screen at the current message position and advance
/// to the next position. Only for printable ASCII! /// to the next position. Only for printable ASCII!

View File

@@ -94,7 +94,7 @@ char *server_address_new(const char *name)
{ {
static uint32_t count = 0; static uint32_t count = 0;
char fmt[ADDRESS_MAX_SIZE]; char fmt[ADDRESS_MAX_SIZE];
#ifdef WIN32 #ifdef MSWIN
int r = snprintf(fmt, sizeof(fmt), "\\\\.\\pipe\\%s.%" PRIu64 ".%" PRIu32, int r = snprintf(fmt, sizeof(fmt), "\\\\.\\pipe\\%s.%" PRIu64 ".%" PRIu32,
name ? name : "nvim", os_get_pid(), count++); name ? name : "nvim", os_get_pid(), count++);
#else #else

View File

@@ -83,7 +83,7 @@
#include "nvim/undo.h" #include "nvim/undo.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#include "nvim/window.h" #include "nvim/window.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/pty_conpty_win.h" # include "nvim/os/pty_conpty_win.h"
#endif #endif
#include "nvim/api/extmark.h" #include "nvim/api/extmark.h"
@@ -1274,7 +1274,7 @@ int do_set(char *arg, int opt_flags)
s = newval; s = newval;
// Copy the string, skip over escaped chars. // Copy the string, skip over escaped chars.
// For WIN32 backslashes before normal // For MS-Windows backslashes before normal
// file name characters are not removed, and keep // file name characters are not removed, and keep
// backslash at start, for "\\machine\path", but // backslash at start, for "\\machine\path", but
// do remove it for "\\\\machine\\path". // do remove it for "\\\\machine\\path".

View File

@@ -97,7 +97,7 @@ typedef enum {
// Default values for 'errorformat'. // Default values for 'errorformat'.
// The "%f|%l| %m" one is used for when the contents of the quickfix window is // The "%f|%l| %m" one is used for when the contents of the quickfix window is
// written to a file. // written to a file.
#ifdef WIN32 #ifdef MSWIN
# define DFLT_EFM \ # define DFLT_EFM \
"%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m" "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m"
#else #else

View File

@@ -1014,7 +1014,7 @@ return {
expand=true, expand=true,
varname='p_gp', varname='p_gp',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
-- Add an extra file name so that grep will always -- Add an extra file name so that grep will always
-- insert a file name in the match line. */ -- insert a file name in the match line. */
if_true="findstr /n $* nul", if_true="findstr /n $* nul",
@@ -1276,7 +1276,7 @@ return {
deny_duplicates=true, deny_duplicates=true,
varname='p_isi', varname='p_isi',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
if_true="@,48-57,_,128-167,224-235", if_true="@,48-57,_,128-167,224-235",
if_false="@,48-57,_,192-255" if_false="@,48-57,_,192-255"
} }
@@ -2100,7 +2100,7 @@ return {
expand=true, expand=true,
varname='p_sh', varname='p_sh',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
if_true="cmd.exe", if_true="cmd.exe",
if_false="sh" if_false="sh"
} }
@@ -2112,7 +2112,7 @@ return {
secure=true, secure=true,
varname='p_shcf', varname='p_shcf',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
if_true="/s /c", if_true="/s /c",
if_false="-c" if_false="-c"
} }
@@ -2124,7 +2124,7 @@ return {
secure=true, secure=true,
varname='p_sp', varname='p_sp',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
if_true=">%s 2>&1", if_true=">%s 2>&1",
if_false="| tee", if_false="| tee",
} }
@@ -2144,7 +2144,7 @@ return {
secure=true, secure=true,
varname='p_srr', varname='p_srr',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
if_true=">%s 2>&1", if_true=">%s 2>&1",
if_false=">" if_false=">"
} }
@@ -2171,7 +2171,7 @@ return {
secure=true, secure=true,
varname='p_sxq', varname='p_sxq',
defaults={ defaults={
condition='WIN32', condition='MSWIN',
if_true="\"", if_true="\"",
if_false="", if_false="",
} }

View File

@@ -20,7 +20,7 @@
#include "nvim/version.h" #include "nvim/version.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8 # include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8
#endif #endif
@@ -128,7 +128,7 @@ int os_setenv(const char *name, const char *value, int overwrite)
if (name[0] == '\0') { if (name[0] == '\0') {
return -1; return -1;
} }
#ifdef WIN32 #ifdef MSWIN
if (!overwrite && os_getenv(name) != NULL) { if (!overwrite && os_getenv(name) != NULL) {
return 0; return 0;
} }
@@ -143,7 +143,7 @@ int os_setenv(const char *name, const char *value, int overwrite)
#endif #endif
uv_mutex_lock(&mutex); uv_mutex_lock(&mutex);
int r; int r;
#ifdef WIN32 #ifdef MSWIN
// libintl uses getenv() for LC_ALL/LANG/etc., so we must use _putenv_s(). // libintl uses getenv() for LC_ALL/LANG/etc., so we must use _putenv_s().
if (striequal(name, "LC_ALL") || striequal(name, "LANGUAGE") if (striequal(name, "LC_ALL") || striequal(name, "LANGUAGE")
|| striequal(name, "LANG") || striequal(name, "LC_MESSAGES")) { || striequal(name, "LANG") || striequal(name, "LC_MESSAGES")) {
@@ -186,7 +186,7 @@ int os_unsetenv(const char *name)
size_t os_get_fullenv_size(void) size_t os_get_fullenv_size(void)
{ {
size_t len = 0; size_t len = 0;
#ifdef _WIN32 #ifdef MSWIN
wchar_t *envstrings = GetEnvironmentStringsW(); wchar_t *envstrings = GetEnvironmentStringsW();
wchar_t *p = envstrings; wchar_t *p = envstrings;
size_t l; size_t l;
@@ -235,7 +235,7 @@ void os_free_fullenv(char **env)
/// @param env_size size of `env`, @see os_fullenv_size /// @param env_size size of `env`, @see os_fullenv_size
void os_copy_fullenv(char **env, size_t env_size) void os_copy_fullenv(char **env, size_t env_size)
{ {
#ifdef _WIN32 #ifdef MSWIN
wchar_t *envstrings = GetEnvironmentStringsW(); wchar_t *envstrings = GetEnvironmentStringsW();
if (!envstrings) { if (!envstrings) {
return; return;
@@ -280,7 +280,7 @@ void os_copy_fullenv(char **env, size_t env_size)
/// @return [allocated] environment variable's value, or NULL /// @return [allocated] environment variable's value, or NULL
char *os_getenvname_at_index(size_t index) char *os_getenvname_at_index(size_t index)
{ {
#ifdef _WIN32 #ifdef MSWIN
wchar_t *envstrings = GetEnvironmentStringsW(); wchar_t *envstrings = GetEnvironmentStringsW();
if (!envstrings) { if (!envstrings) {
return NULL; return NULL;
@@ -347,7 +347,7 @@ char *os_getenvname_at_index(size_t index)
/// @return the process ID. /// @return the process ID.
int64_t os_get_pid(void) int64_t os_get_pid(void)
{ {
#ifdef _WIN32 #ifdef MSWIN
return (int64_t)GetCurrentProcessId(); return (int64_t)GetCurrentProcessId();
#else #else
return (int64_t)getpid(); return (int64_t)getpid();
@@ -368,7 +368,7 @@ void os_get_hostname(char *hostname, size_t size)
} else { } else {
xstrlcpy(hostname, vutsname.nodename, size); xstrlcpy(hostname, vutsname.nodename, size);
} }
#elif defined(WIN32) #elif defined(MSWIN)
wchar_t host_utf16[MAX_COMPUTERNAME_LENGTH + 1]; wchar_t host_utf16[MAX_COMPUTERNAME_LENGTH + 1];
DWORD host_wsize = sizeof(host_utf16) / sizeof(host_utf16[0]); DWORD host_wsize = sizeof(host_utf16) / sizeof(host_utf16[0]);
if (GetComputerNameW(host_utf16, &host_wsize) == 0) { if (GetComputerNameW(host_utf16, &host_wsize) == 0) {
@@ -418,7 +418,7 @@ void init_homedir(void)
const char *var = os_getenv("HOME"); const char *var = os_getenv("HOME");
#ifdef WIN32 #ifdef MSWIN
// Typically, $HOME is not defined on Windows, unless the user has // Typically, $HOME is not defined on Windows, unless the user has
// specifically defined it for Vim's sake. However, on Windows NT // specifically defined it for Vim's sake. However, on Windows NT
// platforms, $HOMEDRIVE and $HOMEPATH are automatically defined for // platforms, $HOMEDRIVE and $HOMEPATH are automatically defined for
@@ -900,7 +900,7 @@ char *vim_getenv(const char *name)
// init_path() should have been called before now. // init_path() should have been called before now.
assert(get_vim_var_str(VV_PROGPATH)[0] != NUL); assert(get_vim_var_str(VV_PROGPATH)[0] != NUL);
#ifdef WIN32 #ifdef MSWIN
if (strcmp(name, "HOME") == 0) { if (strcmp(name, "HOME") == 0) {
return xstrdup(homedir); return xstrdup(homedir);
} }
@@ -1056,7 +1056,7 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
} }
const char *homedir_env = os_getenv("HOME"); const char *homedir_env = os_getenv("HOME");
#ifdef WIN32 #ifdef MSWIN
if (homedir_env == NULL) { if (homedir_env == NULL) {
homedir_env = os_getenv("USERPROFILE"); homedir_env = os_getenv("USERPROFILE");
} }
@@ -1174,7 +1174,7 @@ char *get_env_name(expand_T *xp, int idx)
bool os_setenv_append_path(const char *fname) bool os_setenv_append_path(const char *fname)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
#ifdef WIN32 #ifdef MSWIN
// 8191 (plus NUL) is considered the practical maximum. // 8191 (plus NUL) is considered the practical maximum.
# define MAX_ENVPATHLEN 8192 # define MAX_ENVPATHLEN 8192
#else #else

View File

@@ -27,7 +27,7 @@
#include "nvim/path.h" #include "nvim/path.h"
#include "nvim/strings.h" #include "nvim/strings.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8 # include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8
#endif #endif
@@ -151,7 +151,7 @@ bool os_isdir(const char *name)
int os_nodetype(const char *name) int os_nodetype(const char *name)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
#ifndef WIN32 // Unix #ifndef MSWIN // Unix
uv_stat_t statbuf; uv_stat_t statbuf;
if (0 != os_stat(name, &statbuf)) { if (0 != os_stat(name, &statbuf)) {
return NODE_NORMAL; // File doesn't exist. return NODE_NORMAL; // File doesn't exist.
@@ -241,7 +241,7 @@ bool os_can_exe(const char *name, char **abspath, bool use_path)
FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(1)
{ {
if (!use_path || gettail_dir(name) != name) { if (!use_path || gettail_dir(name) != name) {
#ifdef WIN32 #ifdef MSWIN
if (is_executable_ext(name, abspath)) { if (is_executable_ext(name, abspath)) {
#else #else
// Must have path separator, cannot execute files in the current directory. // Must have path separator, cannot execute files in the current directory.
@@ -270,7 +270,7 @@ static bool is_executable(const char *name, char **abspath)
return false; return false;
} }
#ifdef WIN32 #ifdef MSWIN
// Windows does not have exec bit; just check if the file exists and is not // Windows does not have exec bit; just check if the file exists and is not
// a directory. // a directory.
const bool ok = S_ISREG(mode); const bool ok = S_ISREG(mode);
@@ -287,7 +287,7 @@ static bool is_executable(const char *name, char **abspath)
return ok; return ok;
} }
#ifdef WIN32 #ifdef MSWIN
/// Checks if file `name` is executable under any of these conditions: /// Checks if file `name` is executable under any of these conditions:
/// - extension is in $PATHEXT and `name` is executable /// - extension is in $PATHEXT and `name` is executable
/// - result of any $PATHEXT extension appended to `name` is executable /// - result of any $PATHEXT extension appended to `name` is executable
@@ -351,7 +351,7 @@ static bool is_executable_in_path(const char *name, char **abspath)
return false; return false;
} }
#ifdef WIN32 #ifdef MSWIN
// Prepend ".;" to $PATH. // Prepend ".;" to $PATH.
size_t pathlen = strlen(path_env); size_t pathlen = strlen(path_env);
char *path = memcpy(xmallocz(pathlen + 2), "." ENV_SEPSTR, 2); char *path = memcpy(xmallocz(pathlen + 2), "." ENV_SEPSTR, 2);
@@ -374,7 +374,7 @@ static bool is_executable_in_path(const char *name, char **abspath)
STRLCPY(buf, p, e - p + 1); STRLCPY(buf, p, e - p + 1);
append_path(buf, name, buf_len); append_path(buf, name, buf_len);
#ifdef WIN32 #ifdef MSWIN
if (is_executable_ext(buf, abspath)) { if (is_executable_ext(buf, abspath)) {
#else #else
if (is_executable(buf, abspath)) { if (is_executable(buf, abspath)) {
@@ -446,7 +446,7 @@ FILE *os_fopen(const char *path, const char *flags)
default: default:
abort(); abort();
} }
#ifdef WIN32 #ifdef MSWIN
if (flags[1] == 'b') { if (flags[1] == 'b') {
iflags |= O_BINARY; iflags |= O_BINARY;
} }
@@ -1208,7 +1208,7 @@ char *os_realpath(const char *name, char *buf)
return result == kLibuvSuccess ? buf : NULL; return result == kLibuvSuccess ? buf : NULL;
} }
#ifdef WIN32 #ifdef MSWIN
# include <shlobj.h> # include <shlobj.h>
/// When "fname" is the name of a shortcut (*.lnk) resolve the file it points /// When "fname" is the name of a shortcut (*.lnk) resolve the file it points

View File

@@ -7,7 +7,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/win_defs.h" # include "nvim/os/win_defs.h"
#else #else
# include "nvim/os/unix_defs.h" # include "nvim/os/unix_defs.h"
@@ -43,7 +43,7 @@
/// Converts system error code to libuv error code. /// Converts system error code to libuv error code.
#define os_translate_sys_error uv_translate_sys_error #define os_translate_sys_error uv_translate_sys_error
#ifdef WIN32 #ifdef MSWIN
# define os_strtok strtok_s # define os_strtok strtok_s
#else #else
# define os_strtok strtok_r # define os_strtok strtok_r

View File

@@ -8,7 +8,7 @@
#include <uv.h> // for HANDLE (win32) #include <uv.h> // for HANDLE (win32)
#ifdef WIN32 #ifdef MSWIN
# include <tlhelp32.h> // for CreateToolhelp32Snapshot # include <tlhelp32.h> // for CreateToolhelp32Snapshot
#endif #endif
@@ -38,7 +38,7 @@
# include "os/process.c.generated.h" # include "os/process.c.generated.h"
#endif #endif
#ifdef WIN32 #ifdef MSWIN
static bool os_proc_tree_kill_rec(HANDLE process, int sig) static bool os_proc_tree_kill_rec(HANDLE process, int sig)
{ {
if (process == NULL) { if (process == NULL) {
@@ -114,7 +114,7 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
*proc_list = NULL; *proc_list = NULL;
*proc_count = 0; *proc_count = 0;
#ifdef WIN32 #ifdef MSWIN
PROCESSENTRY32 pe; PROCESSENTRY32 pe;
// Snapshot of all processes. // Snapshot of all processes.
@@ -215,7 +215,7 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
return 0; return 0;
} }
#ifdef WIN32 #ifdef MSWIN
/// Gets various properties of the process identified by `pid`. /// Gets various properties of the process identified by `pid`.
/// ///
/// @param pid Process to inspect. /// @param pid Process to inspect.

View File

@@ -1,7 +1,7 @@
#ifndef NVIM_OS_PTY_PROCESS_H #ifndef NVIM_OS_PTY_PROCESS_H
#define NVIM_OS_PTY_PROCESS_H #define NVIM_OS_PTY_PROCESS_H
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/pty_process_win.h" # include "nvim/os/pty_process_win.h"
#else #else
# include "nvim/os/pty_process_unix.h" # include "nvim/os/pty_process_unix.h"

View File

@@ -4,7 +4,7 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <uv.h> #include <uv.h>
#ifndef WIN32 #ifndef MSWIN
# include <signal.h> // for sigset_t # include <signal.h> // for sigset_t
#endif #endif
@@ -34,7 +34,7 @@ static bool rejecting_deadly;
void signal_init(void) void signal_init(void)
{ {
#ifndef WIN32 #ifndef MSWIN
// Ensure a clean slate by unblocking all signals. For example, if SIGCHLD is // Ensure a clean slate by unblocking all signals. For example, if SIGCHLD is
// blocked, libuv may hang after spawning a subprocess on Linux. #5230 // blocked, libuv may hang after spawning a subprocess on Linux. #5230
sigset_t mask; sigset_t mask;

View File

@@ -21,7 +21,7 @@ static const char *xdg_env_vars[] = {
[kXDGDataDirs] = "XDG_DATA_DIRS", [kXDGDataDirs] = "XDG_DATA_DIRS",
}; };
#ifdef WIN32 #ifdef MSWIN
static const char *const xdg_defaults_env_vars[] = { static const char *const xdg_defaults_env_vars[] = {
[kXDGConfigHome] = "LOCALAPPDATA", [kXDGConfigHome] = "LOCALAPPDATA",
[kXDGDataHome] = "LOCALAPPDATA", [kXDGDataHome] = "LOCALAPPDATA",
@@ -37,7 +37,7 @@ static const char *const xdg_defaults_env_vars[] = {
/// ///
/// Used in case environment variables contain nothing. Need to be expanded. /// Used in case environment variables contain nothing. Need to be expanded.
static const char *const xdg_defaults[] = { static const char *const xdg_defaults[] = {
#ifdef WIN32 #ifdef MSWIN
[kXDGConfigHome] = "~\\AppData\\Local", [kXDGConfigHome] = "~\\AppData\\Local",
[kXDGDataHome] = "~\\AppData\\Local", [kXDGDataHome] = "~\\AppData\\Local",
[kXDGCacheHome] = "~\\AppData\\Local\\Temp", [kXDGCacheHome] = "~\\AppData\\Local\\Temp",
@@ -69,7 +69,7 @@ char *stdpaths_get_xdg_var(const XDGVarType idx)
const char *env_val = os_getenv(env); const char *env_val = os_getenv(env);
#ifdef WIN32 #ifdef MSWIN
if (env_val == NULL && xdg_defaults_env_vars[idx] != NULL) { if (env_val == NULL && xdg_defaults_env_vars[idx] != NULL) {
env_val = os_getenv(xdg_defaults_env_vars[idx]); env_val = os_getenv(xdg_defaults_env_vars[idx]);
} }
@@ -107,7 +107,7 @@ char *get_xdg_home(const XDGVarType idx)
{ {
char *dir = stdpaths_get_xdg_var(idx); char *dir = stdpaths_get_xdg_var(idx);
if (dir) { if (dir) {
#if defined(WIN32) #if defined(MSWIN)
dir = concat_fnames_realloc(dir, dir = concat_fnames_realloc(dir,
((idx == kXDGDataHome ((idx == kXDGDataHome
|| idx == kXDGStateHome) ? "nvim-data" : "nvim"), || idx == kXDGStateHome) ? "nvim-data" : "nvim"),

View File

@@ -12,7 +12,7 @@
# include "os/tty.c.generated.h" # include "os/tty.c.generated.h"
#endif #endif
#ifdef WIN32 #ifdef MSWIN
# if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) # if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
# endif # endif

View File

@@ -14,7 +14,7 @@
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
# include <pwd.h> # include <pwd.h>
#endif #endif
#ifdef WIN32 #ifdef MSWIN
# include <lm.h> # include <lm.h>
#endif #endif
@@ -56,7 +56,7 @@ int os_get_usernames(garray_T *users)
} }
endpwent(); endpwent();
} }
#elif defined(WIN32) #elif defined(MSWIN)
{ {
DWORD nusers = 0, ntotal = 0, i; DWORD nusers = 0, ntotal = 0, i;
PUSER_INFO_0 uinfo; PUSER_INFO_0 uinfo;

View File

@@ -1,7 +1,7 @@
#ifndef NVIM_OS_WIN_DEFS_H #ifndef NVIM_OS_WIN_DEFS_H
#define NVIM_OS_WIN_DEFS_H #define NVIM_OS_WIN_DEFS_H
#ifndef WIN32 #ifndef MSWIN
# error Header must be included only when compiling for Windows. # error Header must be included only when compiling for Windows.
#endif #endif

View File

@@ -190,7 +190,7 @@ const char *path_next_component(const char *fname)
/// - 1 otherwise /// - 1 otherwise
int path_head_length(void) int path_head_length(void)
{ {
#ifdef WIN32 #ifdef MSWIN
return 3; return 3;
#else #else
return 1; return 1;
@@ -205,7 +205,7 @@ int path_head_length(void)
/// - False otherwise /// - False otherwise
bool is_path_head(const char_u *path) bool is_path_head(const char_u *path)
{ {
#ifdef WIN32 #ifdef MSWIN
return isalpha(path[0]) && path[1] == ':'; return isalpha(path[0]) && path[1] == ':';
#else #else
return vim_ispathsep(*path); return vim_ispathsep(*path);
@@ -219,7 +219,7 @@ char *get_past_head(const char *path)
{ {
const char *retval = path; const char *retval = path;
#ifdef WIN32 #ifdef MSWIN
// May skip "c:" // May skip "c:"
if (is_path_head((char_u *)path)) { if (is_path_head((char_u *)path)) {
retval = path + 2; retval = path + 2;
@@ -642,7 +642,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
s = p + 1; s = p + 1;
} else if (path_end >= (char_u *)path + wildoff } else if (path_end >= (char_u *)path + wildoff
&& (vim_strchr("*?[{~$", *path_end) != NULL && (vim_strchr("*?[{~$", *path_end) != NULL
#ifndef WIN32 #ifndef MSWIN
|| (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end))) || (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end)))
#endif #endif
)) { )) {
@@ -897,7 +897,7 @@ static char_u *get_path_cutoff(char_u *fname, garray_T *gap)
int j = 0; int j = 0;
while ((fname[j] == path_part[i][j] while ((fname[j] == path_part[i][j]
#ifdef WIN32 #ifdef MSWIN
|| (vim_ispathsep(fname[j]) && vim_ispathsep(path_part[i][j])) || (vim_ispathsep(fname[j]) && vim_ispathsep(path_part[i][j]))
#endif #endif
) // NOLINT(whitespace/parens) ) // NOLINT(whitespace/parens)
@@ -1816,7 +1816,7 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
if (strlen(fname) > (len - 1)) { if (strlen(fname) > (len - 1)) {
xstrlcpy(buf, fname, len); // truncate xstrlcpy(buf, fname, len); // truncate
#ifdef WIN32 #ifdef MSWIN
slash_adjust((char_u *)buf); slash_adjust((char_u *)buf);
#endif #endif
return FAIL; return FAIL;
@@ -1831,7 +1831,7 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
if (rv == FAIL) { if (rv == FAIL) {
xstrlcpy(buf, fname, len); // something failed; use the filename xstrlcpy(buf, fname, len); // something failed; use the filename
} }
#ifdef WIN32 #ifdef MSWIN
slash_adjust((char_u *)buf); slash_adjust((char_u *)buf);
#endif #endif
return rv; return rv;
@@ -2356,7 +2356,7 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
// expand it if forced or not an absolute path // expand it if forced or not an absolute path
if (force || !path_is_absolute((char_u *)fname)) { if (force || !path_is_absolute((char_u *)fname)) {
p = strrchr(fname, '/'); p = strrchr(fname, '/');
#ifdef WIN32 #ifdef MSWIN
if (p == NULL) { if (p == NULL) {
p = strrchr(fname, '\\'); p = strrchr(fname, '\\');
} }
@@ -2392,7 +2392,7 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
/// @return `true` if "fname" is absolute. /// @return `true` if "fname" is absolute.
int path_is_absolute(const char_u *fname) int path_is_absolute(const char_u *fname)
{ {
#ifdef WIN32 #ifdef MSWIN
if (*fname == NUL) { if (*fname == NUL) {
return false; return false;
} }

View File

@@ -1451,7 +1451,7 @@ static inline char *add_dir(char *dest, const char *const dir, const size_t dir_
if (!after_pathsep(dest - 1, dest)) { if (!after_pathsep(dest - 1, dest)) {
*dest++ = PATHSEP; *dest++ = PATHSEP;
} }
#if defined(WIN32) #if defined(MSWIN)
size_t size = (type == kXDGDataHome ? sizeof("nvim-data") - 1 : NVIM_SIZE); size_t size = (type == kXDGDataHome ? sizeof("nvim-data") - 1 : NVIM_SIZE);
memmove(dest, (type == kXDGDataHome ? "nvim-data" : "nvim"), size); memmove(dest, (type == kXDGDataHome ? "nvim-data" : "nvim"), size);
dest += size; dest += size;
@@ -1521,7 +1521,7 @@ char *runtimepath_default(bool clean_arg)
if (data_home != NULL) { if (data_home != NULL) {
data_len = strlen(data_home); data_len = strlen(data_home);
if (data_len != 0) { if (data_len != 0) {
#if defined(WIN32) #if defined(MSWIN)
size_t nvim_size = (sizeof("nvim-data") - 1); size_t nvim_size = (sizeof("nvim-data") - 1);
#else #else
size_t nvim_size = NVIM_SIZE; size_t nvim_size = NVIM_SIZE;
@@ -1664,7 +1664,7 @@ int source_level(void *cookie)
/// If possible the handle is closed on exec(). /// If possible the handle is closed on exec().
static FILE *fopen_noinh_readbin(char *filename) static FILE *fopen_noinh_readbin(char *filename)
{ {
#ifdef WIN32 #ifdef MSWIN
int fd_tmp = os_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0); int fd_tmp = os_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0);
#else #else
int fd_tmp = os_open(filename, O_RDONLY, 0); int fd_tmp = os_open(filename, O_RDONLY, 0);

View File

@@ -186,7 +186,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
// First count the number of extra bytes required. // First count the number of extra bytes required.
size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL
for (const char_u *p = string; *p != NUL; MB_PTR_ADV(p)) { for (const char_u *p = string; *p != NUL; MB_PTR_ADV(p)) {
#ifdef WIN32 #ifdef MSWIN
if (!p_ssl) { if (!p_ssl) {
if (*p == '"') { if (*p == '"') {
length++; // " -> "" length++; // " -> ""
@@ -217,7 +217,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
d = (char *)escaped_string; d = (char *)escaped_string;
// add opening quote // add opening quote
#ifdef WIN32 #ifdef MSWIN
if (!p_ssl) { if (!p_ssl) {
*d++ = '"'; *d++ = '"';
} else } else
@@ -225,7 +225,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
*d++ = '\''; *d++ = '\'';
for (const char *p = (char *)string; *p != NUL;) { for (const char *p = (char *)string; *p != NUL;) {
#ifdef WIN32 #ifdef MSWIN
if (!p_ssl) { if (!p_ssl) {
if (*p == '"') { if (*p == '"') {
*d++ = '"'; *d++ = '"';
@@ -269,7 +269,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
} }
// add terminating quote and finish with a NUL // add terminating quote and finish with a NUL
#ifdef WIN32 #ifdef MSWIN
if (!p_ssl) { if (!p_ssl) {
*d++ = '"'; *d++ = '"';
} else } else

View File

@@ -15,7 +15,7 @@
#include "nvim/tui/input.h" #include "nvim/tui/input.h"
#include "nvim/tui/tui.h" #include "nvim/tui/tui.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/os_win_console.h" # include "nvim/os/os_win_console.h"
#endif #endif
#include "nvim/event/rstream.h" #include "nvim/event/rstream.h"
@@ -143,7 +143,7 @@ void tinput_init(TermInput *input, Loop *loop)
// If stdin is not a pty, switch to stderr. For cases like: // If stdin is not a pty, switch to stderr. For cases like:
// echo q | nvim -es // echo q | nvim -es
// ls *.md | xargs nvim // ls *.md | xargs nvim
#ifdef WIN32 #ifdef MSWIN
if (!os_isatty(input->in_fd)) { if (!os_isatty(input->in_fd)) {
input->in_fd = os_get_conin_fd(); input->in_fd = os_get_conin_fd();
} }

View File

@@ -31,7 +31,7 @@
#include "nvim/os/tty.h" #include "nvim/os/tty.h"
#include "nvim/ui.h" #include "nvim/ui.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#ifdef WIN32 #ifdef MSWIN
# include "nvim/os/os_win_console.h" # include "nvim/os/os_win_console.h"
#endif #endif
#include "nvim/cursor_shape.h" #include "nvim/cursor_shape.h"
@@ -263,7 +263,7 @@ static void terminfo_start(UI *ui)
data->input.tui_data = data; data->input.tui_data = data;
const char *term = os_getenv("TERM"); const char *term = os_getenv("TERM");
#ifdef WIN32 #ifdef MSWIN
os_tty_guess_term(&term, data->out_fd); os_tty_guess_term(&term, data->out_fd);
os_setenv("TERM", term, 1); os_setenv("TERM", term, 1);
// Old os_getenv() pointer is invalid after os_setenv(), fetch it again. // Old os_getenv() pointer is invalid after os_setenv(), fetch it again.
@@ -353,7 +353,7 @@ static void terminfo_start(UI *ui)
if (ret) { if (ret) {
ELOG("uv_tty_init failed: %s", uv_strerror(ret)); ELOG("uv_tty_init failed: %s", uv_strerror(ret));
} }
#ifdef WIN32 #ifdef MSWIN
ret = uv_tty_set_mode(&data->output_handle.tty, UV_TTY_MODE_RAW); ret = uv_tty_set_mode(&data->output_handle.tty, UV_TTY_MODE_RAW);
if (ret) { if (ret) {
ELOG("uv_tty_set_mode failed: %s", uv_strerror(ret)); ELOG("uv_tty_set_mode failed: %s", uv_strerror(ret));
@@ -1810,7 +1810,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, const char *col
} }
} }
#ifdef WIN32 #ifdef MSWIN
// XXX: workaround libuv implicit LF => CRLF conversion. #10558 // XXX: workaround libuv implicit LF => CRLF conversion. #10558
unibi_set_str(ut, unibi_cursor_down, "\x1b[B"); unibi_set_str(ut, unibi_cursor_down, "\x1b[B");
#endif #endif

View File

@@ -256,7 +256,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
// functions of these names. The declarations would break if the defines had // functions of these names. The declarations would break if the defines had
// been seen at that stage. But it must be before globals.h, where error_ga // been seen at that stage. But it must be before globals.h, where error_ga
// is declared. // is declared.
#ifndef WIN32 #ifndef MSWIN
# define mch_errmsg(str) fprintf(stderr, "%s", (str)) # define mch_errmsg(str) fprintf(stderr, "%s", (str))
# define mch_msg(str) printf("%s", (str)) # define mch_msg(str) printf("%s", (str))
#endif #endif

View File

@@ -3,13 +3,13 @@
#include <stdio.h> #include <stdio.h>
#ifdef WIN32 #ifdef MSWIN
# include <windows.h> # include <windows.h>
#else #else
# include <stdlib.h> # include <stdlib.h>
#endif #endif
#ifdef WIN32 #ifdef MSWIN
int wmain(int argc, wchar_t **argv) int wmain(int argc, wchar_t **argv)
#else #else
int main(int argc, char **argv) int main(int argc, char **argv)
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
#ifdef WIN32 #ifdef MSWIN
wchar_t *value = _wgetenv(argv[1]); wchar_t *value = _wgetenv(argv[1]);
if (value == NULL) { if (value == NULL) {
return 1; return 1;

View File

@@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <uv.h> #include <uv.h>
#ifdef _WIN32 #ifdef MSWIN
# include <windows.h> # include <windows.h>
#else #else
# include <unistd.h> # include <unistd.h>
@@ -23,7 +23,7 @@ uv_tty_t tty_out;
bool owns_tty(void); // silence -Wmissing-prototypes bool owns_tty(void); // silence -Wmissing-prototypes
bool owns_tty(void) bool owns_tty(void)
{ {
#ifdef _WIN32 #ifdef MSWIN
// XXX: We need to make proper detect owns tty // XXX: We need to make proper detect owns tty
// HWND consoleWnd = GetConsoleWindow(); // HWND consoleWnd = GetConsoleWindow();
// DWORD dwProcessId; // DWORD dwProcessId;
@@ -38,14 +38,14 @@ bool owns_tty(void)
static void walk_cb(uv_handle_t *handle, void *arg) static void walk_cb(uv_handle_t *handle, void *arg)
{ {
if (!uv_is_closing(handle)) { if (!uv_is_closing(handle)) {
#ifdef WIN32 #ifdef MSWIN
uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL); uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL);
#endif #endif
uv_close(handle, NULL); uv_close(handle, NULL);
} }
} }
#ifndef WIN32 #ifndef MSWIN
static void sig_handler(int signum) static void sig_handler(int signum)
{ {
switch (signum) { switch (signum) {
@@ -64,7 +64,7 @@ static void sig_handler(int signum)
} }
#endif #endif
#ifdef WIN32 #ifdef MSWIN
static void sigwinch_cb(uv_signal_t *handle, int signum) static void sigwinch_cb(uv_signal_t *handle, int signum)
{ {
int width, height; int width, height;
@@ -102,7 +102,7 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf)
uv_write_t req; uv_write_t req;
uv_buf_t b = { uv_buf_t b = {
.base = buf->base, .base = buf->base,
#ifdef WIN32 #ifdef MSWIN
.len = (ULONG)cnt .len = (ULONG)cnt
#else #else
.len = (size_t)cnt .len = (size_t)cnt
@@ -171,7 +171,7 @@ int main(int argc, char **argv)
uv_prepare_t prepare; uv_prepare_t prepare;
uv_prepare_init(uv_default_loop(), &prepare); uv_prepare_init(uv_default_loop(), &prepare);
uv_prepare_start(&prepare, prepare_cb); uv_prepare_start(&prepare, prepare_cb);
#ifndef WIN32 #ifndef MSWIN
uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1); uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1);
#else #else
uv_tty_init(uv_default_loop(), &tty, fileno(stdin), 1); uv_tty_init(uv_default_loop(), &tty, fileno(stdin), 1);
@@ -182,7 +182,7 @@ int main(int argc, char **argv)
uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); uv_tty_set_mode(&tty, UV_TTY_MODE_RAW);
tty.data = &interrupted; tty.data = &interrupted;
uv_read_start(STRUCT_CAST(uv_stream_t, &tty), alloc_cb, read_cb); uv_read_start(STRUCT_CAST(uv_stream_t, &tty), alloc_cb, read_cb);
#ifndef WIN32 #ifndef MSWIN
struct sigaction sa; struct sigaction sa;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; sa.sa_flags = 0;
@@ -196,7 +196,7 @@ int main(int argc, char **argv)
#endif #endif
uv_run(uv_default_loop(), UV_RUN_DEFAULT); uv_run(uv_default_loop(), UV_RUN_DEFAULT);
#ifndef WIN32 #ifndef MSWIN
// XXX: Without this the SIGHUP handler is skipped on some systems. // XXX: Without this the SIGHUP handler is skipped on some systems.
sleep(100); sleep(100);
#endif #endif