Merge #8084 'build/win: support MSVC'

This commit is contained in:
Justin M. Keyes
2018-03-08 20:26:18 +01:00
committed by GitHub
26 changed files with 290 additions and 96 deletions

View File

@@ -5936,6 +5936,14 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
}
#ifdef INCLUDE_GENERATED_DECLARATIONS
#ifdef _MSC_VER
// This prevents MSVC from replacing the functions with intrinsics,
// and causing errors when trying to get their addresses in funcs.generated.h
#pragma function (ceil)
#pragma function (floor)
#endif
# include "funcs.generated.h"
#endif

View File

@@ -224,23 +224,15 @@ local static = header
local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"'
local curfile
local init = 0
local init = 1
local curfile = nil
local neededfile = fname:match('[^/]+$')
local declline = 0
local declendpos = 0
local curdir = nil
local is_needed_file = false
local init_is_nl = true
while init ~= nil do
init = text:find('[\n;}]', init)
if init == nil then
break
end
local init_is_nl = text:sub(init, init) == '\n'
init = init + 1
if init_is_nl and is_needed_file then
declline = declline + 1
end
if init_is_nl and text:sub(init, init) == '#' then
local line, dir, file = text:match(filepattern, init)
if file ~= nil then
@@ -293,6 +285,15 @@ while init ~= nil do
declendpos = e
end
end
init = text:find('[\n;}]', init)
if init == nil then
break
end
init_is_nl = text:sub(init, init) == '\n'
init = init + 1
if init_is_nl and is_needed_file then
declline = declline + 1
end
end
non_static = non_static .. footer

View File

@@ -41,6 +41,7 @@
#include <string.h>
#include "nvim/memory.h"
#include "nvim/os/os_defs.h"
#define kv_roundup32(x) \
((--(x)), \

View File

@@ -7,11 +7,6 @@
#include <string.h>
#include <stdbool.h>
#ifdef WIN32
# include <wchar.h>
# include <winnls.h>
#endif
#include <msgpack.h>
#include "nvim/ascii.h"
@@ -795,7 +790,7 @@ static void command_line_scan(mparm_T *parmp)
mch_exit(0);
} else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) {
FileDescriptor fp;
const int fof_ret = file_open_fd(&fp, OS_STDOUT_FILENO, true);
const int fof_ret = file_open_fd(&fp, STDOUT_FILENO, true);
msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
if (fof_ret != 0) {
@@ -1256,10 +1251,10 @@ static void check_and_set_isatty(mparm_T *paramp)
paramp->err_isatty = os_isatty(fileno(stderr));
#ifndef WIN32
int tty_fd = paramp->input_isatty
? OS_STDIN_FILENO
? STDIN_FILENO
: (paramp->output_isatty
? OS_STDOUT_FILENO
: (paramp->err_isatty ? OS_STDERR_FILENO : -1));
? STDOUT_FILENO
: (paramp->err_isatty ? STDERR_FILENO : -1));
pty_process_save_termios(tty_fd);
#endif
TIME_MSG("window checked");

View File

@@ -2436,6 +2436,11 @@ static bool valid_filetype(char_u *val)
return true;
}
#ifdef _MSC_VER
// MSVC optimizations are disabled for this function because it
// incorrectly generates an empty string for SHM_ALL.
#pragma optimize("", off)
#endif
/*
* Handle string options that need some action to perform when changed.
* Returns NULL for success, or an error message for an error.
@@ -3305,6 +3310,9 @@ did_set_string_option (
return errmsg;
}
#ifdef _MSC_VER
#pragma optimize("", on)
#endif
/*
* Simple int comparison function for use with qsort()

View File

@@ -4,7 +4,6 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -14,13 +13,6 @@
# include "nvim/os/unix_defs.h"
#endif
/// File descriptor number used for standard IO streams
enum {
OS_STDIN_FILENO = STDIN_FILENO,
OS_STDOUT_FILENO = STDOUT_FILENO,
OS_STDERR_FILENO = STDERR_FILENO,
};
#define BASENAMELEN (NAME_MAX - 5)
// Use the system path length if it makes sense.

View File

@@ -1,9 +1,8 @@
#ifndef NVIM_OS_UNIX_DEFS_H
#define NVIM_OS_UNIX_DEFS_H
// Windows doesn't have unistd.h, so we include it here to avoid numerous
// instances of `#ifdef WIN32'.
#include <unistd.h>
#include <sys/param.h>
// POSIX.1-2008 says that NAME_MAX should be in here
#include <limits.h>

View File

@@ -45,6 +45,9 @@
# ifndef restrict
# define restrict __restrict
# endif
# ifndef STDIN_FILENO
# define STDIN_FILENO _fileno(stdin)
# endif
# ifndef STDOUT_FILENO
# define STDOUT_FILENO _fileno(stdout)
# endif
@@ -60,6 +63,7 @@
#ifdef _MSC_VER
typedef SSIZE_T ssize_t;
typedef int mode_t;
#endif
#ifndef SSIZE_MAX

View File

@@ -228,7 +228,6 @@
#include <stdio.h>
#include <stdint.h>
#include <wctype.h>
#include <strings.h>
#include "nvim/vim.h"
#include "nvim/spell_defs.h"