mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #7863 'mingw64: fix gcc warnings'
This commit is contained in:
commit
0daaa49586
@ -399,7 +399,11 @@ void nvim_buf_set_lines(uint64_t channel_id,
|
||||
// Only adjust marks if we managed to switch to a window that holds
|
||||
// the buffer, otherwise line numbers will be invalid.
|
||||
if (save_curbuf.br_buf == NULL) {
|
||||
mark_adjust((linenr_T)start, (linenr_T)(end - 1), MAXLNUM, extra, false);
|
||||
mark_adjust((linenr_T)start,
|
||||
(linenr_T)(end - 1),
|
||||
MAXLNUM,
|
||||
(long)extra,
|
||||
false);
|
||||
}
|
||||
|
||||
changed_lines((linenr_T)start, 0, (linenr_T)end, (long)extra);
|
||||
|
@ -28,6 +28,11 @@
|
||||
#include "nvim/lib/kvec.h"
|
||||
#include "nvim/eval/typval_encode.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# undef fpclassify
|
||||
# define fpclassify __fpclassify
|
||||
#endif
|
||||
|
||||
#define ga_concat(a, b) ga_concat(a, (char_u *)b)
|
||||
#define utf_ptr2char(b) utf_ptr2char((char_u *)b)
|
||||
#define utf_ptr2len(b) ((size_t)utf_ptr2len((char_u *)b))
|
||||
|
@ -95,7 +95,7 @@ static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf)
|
||||
// `uv_buf_t.len` happens to have different size on Windows.
|
||||
size_t write_count;
|
||||
buf->base = rbuffer_write_ptr(stream->buffer, &write_count);
|
||||
buf->len = write_count;
|
||||
buf->len = UV_BUF_LEN(write_count);
|
||||
}
|
||||
|
||||
// Callback invoked by libuv after it copies the data into the buffer provided
|
||||
@ -146,7 +146,7 @@ static void fread_idle_cb(uv_idle_t *handle)
|
||||
// `uv_buf_t.len` happens to have different size on Windows.
|
||||
size_t write_count;
|
||||
stream->uvbuf.base = rbuffer_write_ptr(stream->buffer, &write_count);
|
||||
stream->uvbuf.len = write_count;
|
||||
stream->uvbuf.len = UV_BUF_LEN(write_count);
|
||||
|
||||
// the offset argument to uv_fs_read is int64_t, could someone really try
|
||||
// to read more than 9 quintillion (9e18) bytes?
|
||||
|
@ -90,7 +90,7 @@ bool wstream_write(Stream *stream, WBuffer *buffer)
|
||||
|
||||
uv_buf_t uvbuf;
|
||||
uvbuf.base = buffer->data;
|
||||
uvbuf.len = buffer->size;
|
||||
uvbuf.len = UV_BUF_LEN(buffer->size);
|
||||
|
||||
if (uv_write(&data->uv_req, stream->uvstream, &uvbuf, 1, write_cb)) {
|
||||
xfree(data);
|
||||
|
@ -1417,7 +1417,7 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
||||
#else
|
||||
// For shells that don't understand braces around commands, at least allow
|
||||
// the use of commands in a pipe.
|
||||
xstrlcpy(buf, cmd, len);
|
||||
xstrlcpy(buf, (char *)cmd, len);
|
||||
if (itmp != NULL) {
|
||||
// If there is a pipe, we have to put the '<' in front of it.
|
||||
// Don't do this when 'shellquote' is not empty, otherwise the
|
||||
|
@ -738,7 +738,7 @@ static int command_line_execute(VimState *state, int key)
|
||||
}
|
||||
if (vim_ispathsep(ccline.cmdbuff[s->j])
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
&& vim_strchr(" *?[{`$%#", ccline.cmdbuff[s->j + 1])
|
||||
&& vim_strchr((const char_u *)" *?[{`$%#", ccline.cmdbuff[s->j + 1])
|
||||
== NULL
|
||||
#endif
|
||||
) {
|
||||
|
@ -1586,7 +1586,7 @@ int vim_chdirfile(char_u *fname)
|
||||
}
|
||||
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
slash_adjust(dir);
|
||||
slash_adjust((char_u *)dir);
|
||||
#endif
|
||||
if (!strequal(dir, (char *)NameBuff)) {
|
||||
do_autocmd_dirchanged(dir, kCdScopeWindow);
|
||||
|
@ -148,6 +148,10 @@
|
||||
/// zero in those cases (-Wdiv-by-zero in GCC).
|
||||
#define ARRAY_SIZE(arr) ((sizeof(arr)/sizeof((arr)[0])) / ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))
|
||||
|
||||
// Duplicated in os/win_defs.h to avoid include-order sensitivity.
|
||||
#if defined(WIN32) && defined(RGB)
|
||||
# undef RGB
|
||||
#endif
|
||||
#define RGB(r, g, b) ((r << 16) | (g << 8) | b)
|
||||
|
||||
#define STR_(x) #x
|
||||
@ -183,4 +187,19 @@
|
||||
/// @return ((Type *)obj).
|
||||
#define STRUCT_CAST(Type, obj) ((Type *)(obj))
|
||||
|
||||
// Type of uv_buf_t.len is platform-dependent.
|
||||
// Related: https://github.com/libuv/libuv/pull/1236
|
||||
#if defined(WIN32)
|
||||
# define UV_BUF_LEN(x) (ULONG)(x)
|
||||
#else
|
||||
# define UV_BUF_LEN(x) (x)
|
||||
#endif
|
||||
|
||||
// Type of read()/write() `count` param is platform-dependent.
|
||||
#if defined(WIN32)
|
||||
# define IO_COUNT(x) (unsigned)(x)
|
||||
#else
|
||||
# define IO_COUNT(x) (x)
|
||||
#endif
|
||||
|
||||
#endif // NVIM_MACROS_H
|
||||
|
@ -229,7 +229,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
#if defined(WIN32) && !defined(MAKE_LIB)
|
||||
char *argv[argc];
|
||||
char **argv = xmalloc((size_t)argc * sizeof(char *));
|
||||
for (int i = 0; i < argc; i++) {
|
||||
char *buf = NULL;
|
||||
utf16_to_utf8(argv_w[i], &buf);
|
||||
@ -571,6 +571,9 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
normal_enter(false, false);
|
||||
|
||||
#if defined(WIN32) && !defined(MAKE_LIB)
|
||||
xfree(argv);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1250,12 +1253,12 @@ static void check_and_set_isatty(mparm_T *paramp)
|
||||
stdout_isatty
|
||||
= paramp->output_isatty = os_isatty(fileno(stdout));
|
||||
paramp->err_isatty = os_isatty(fileno(stderr));
|
||||
#ifndef WIN32
|
||||
int tty_fd = paramp->input_isatty
|
||||
? OS_STDIN_FILENO
|
||||
: (paramp->output_isatty
|
||||
? OS_STDOUT_FILENO
|
||||
: (paramp->err_isatty ? OS_STDERR_FILENO : -1));
|
||||
#ifndef WIN32
|
||||
pty_process_save_termios(tty_fd);
|
||||
#endif
|
||||
TIME_MSG("window checked");
|
||||
|
@ -831,25 +831,27 @@ set_option_default (
|
||||
if (flags & P_STRING) {
|
||||
/* Use set_string_option_direct() for local options to handle
|
||||
* freeing and allocating the value. */
|
||||
if (options[opt_idx].indir != PV_NONE)
|
||||
if (options[opt_idx].indir != PV_NONE) {
|
||||
set_string_option_direct(NULL, opt_idx,
|
||||
options[opt_idx].def_val[dvi], opt_flags, 0);
|
||||
else {
|
||||
if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
|
||||
} else {
|
||||
if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) {
|
||||
free_string_option(*(char_u **)(varp));
|
||||
}
|
||||
*(char_u **)varp = options[opt_idx].def_val[dvi];
|
||||
options[opt_idx].flags &= ~P_ALLOCED;
|
||||
}
|
||||
} else if (flags & P_NUM) {
|
||||
if (options[opt_idx].indir == PV_SCROLL)
|
||||
if (options[opt_idx].indir == PV_SCROLL) {
|
||||
win_comp_scroll(curwin);
|
||||
else {
|
||||
*(long *)varp = (long)options[opt_idx].def_val[dvi];
|
||||
/* May also set global value for local option. */
|
||||
if (both)
|
||||
} else {
|
||||
*(long *)varp = (long)(intptr_t)options[opt_idx].def_val[dvi];
|
||||
// May also set global value for local option.
|
||||
if (both) {
|
||||
*(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
|
||||
*(long *)varp;
|
||||
}
|
||||
}
|
||||
} else { /* P_BOOL */
|
||||
*(int *)varp = (int)(intptr_t)options[opt_idx].def_val[dvi];
|
||||
#ifdef UNIX
|
||||
@ -926,7 +928,7 @@ void set_number_default(char *name, long val)
|
||||
|
||||
opt_idx = findoption(name);
|
||||
if (opt_idx >= 0) {
|
||||
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)val;
|
||||
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(intptr_t)val;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1440,20 +1442,19 @@ do_set (
|
||||
* [-]0-9 set number
|
||||
* other error
|
||||
*/
|
||||
++arg;
|
||||
if (nextchar == '&')
|
||||
value = (long)options[opt_idx].def_val[
|
||||
((flags & P_VI_DEF) || cp_val)
|
||||
? VI_DEFAULT : VIM_DEFAULT];
|
||||
else if (nextchar == '<') {
|
||||
/* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
|
||||
* use the global value. */
|
||||
if ((long *)varp == &curbuf->b_p_ul
|
||||
&& opt_flags == OPT_LOCAL)
|
||||
arg++;
|
||||
if (nextchar == '&') {
|
||||
value = (long)(intptr_t)options[opt_idx].def_val[
|
||||
((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT];
|
||||
} else if (nextchar == '<') {
|
||||
// For 'undolevels' NO_LOCAL_UNDOLEVEL means to
|
||||
// use the global value.
|
||||
if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL) {
|
||||
value = NO_LOCAL_UNDOLEVEL;
|
||||
else
|
||||
} else {
|
||||
value = *(long *)get_varp_scope(
|
||||
&(options[opt_idx]), OPT_GLOBAL);
|
||||
}
|
||||
} else if (((long *)varp == &p_wc
|
||||
|| (long *)varp == &p_wcm)
|
||||
&& (*arg == '<'
|
||||
@ -5011,11 +5012,13 @@ static int optval_default(vimoption_T *p, char_u *varp)
|
||||
if (varp == NULL)
|
||||
return TRUE; /* hidden option is always at default */
|
||||
dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
|
||||
if (p->flags & P_NUM)
|
||||
return *(long *)varp == (long)p->def_val[dvi];
|
||||
if (p->flags & P_BOOL)
|
||||
if (p->flags & P_NUM) {
|
||||
return *(long *)varp == (long)(intptr_t)p->def_val[dvi];
|
||||
}
|
||||
if (p->flags & P_BOOL) {
|
||||
return *(int *)varp == (int)(intptr_t)p->def_val[dvi];
|
||||
/* P_STRING */
|
||||
}
|
||||
// P_STRING
|
||||
return STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0;
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ ptrdiff_t os_read(const int fd, bool *ret_eof, char *const ret_buf,
|
||||
while (read_bytes != size) {
|
||||
assert(size >= read_bytes);
|
||||
const ptrdiff_t cur_read_bytes = read(fd, ret_buf + read_bytes,
|
||||
size - read_bytes);
|
||||
IO_COUNT(size - read_bytes));
|
||||
if (cur_read_bytes > 0) {
|
||||
read_bytes += (size_t)cur_read_bytes;
|
||||
}
|
||||
@ -564,7 +564,7 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size)
|
||||
while (written_bytes != size) {
|
||||
assert(size >= written_bytes);
|
||||
const ptrdiff_t cur_written_bytes = write(fd, buf + written_bytes,
|
||||
size - written_bytes);
|
||||
IO_COUNT(size - written_bytes));
|
||||
if (cur_written_bytes > 0) {
|
||||
written_bytes += (size_t)cur_written_bytes;
|
||||
}
|
||||
@ -990,7 +990,7 @@ bool os_fileid_equal_fileinfo(const FileID *file_id,
|
||||
/// to and return that name in allocated memory.
|
||||
/// Otherwise NULL is returned.
|
||||
char *os_resolve_shortcut(const char *fname)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
|
||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
|
||||
{
|
||||
HRESULT hr;
|
||||
IPersistFile *ppf = NULL;
|
||||
|
@ -131,7 +131,7 @@ int pty_process_spawn(PtyProcess *ptyproc)
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
proc->pid = GetProcessId(process_handle);
|
||||
proc->pid = (int)GetProcessId(process_handle);
|
||||
|
||||
if (!RegisterWaitForSingleObject(
|
||||
&ptyproc->finish_wait,
|
||||
@ -339,20 +339,20 @@ static void quote_cmd_arg(char *dest, size_t dest_remaining, const char *src)
|
||||
}
|
||||
|
||||
// Expected input/output:
|
||||
// input : hello"world
|
||||
// output: "hello\"world"
|
||||
// input : hello""world
|
||||
// output: "hello\"\"world"
|
||||
// input : hello\world
|
||||
// output: hello\world
|
||||
// input : hello\\world
|
||||
// output: hello\\world
|
||||
// input : hello\"world
|
||||
// output: "hello\\\"world"
|
||||
// input : hello\\"world
|
||||
// output: "hello\\\\\"world"
|
||||
// input : hello world\
|
||||
// output: "hello world\\"
|
||||
// input : 'hello"world'
|
||||
// output: '"hello\"world"'
|
||||
// input : 'hello""world'
|
||||
// output: '"hello\"\"world"'
|
||||
// input : 'hello\world'
|
||||
// output: 'hello\world'
|
||||
// input : 'hello\\world'
|
||||
// output: 'hello\\world'
|
||||
// input : 'hello\"world'
|
||||
// output: '"hello\\\"world"'
|
||||
// input : 'hello\\"world'
|
||||
// output: '"hello\\\\\"world"'
|
||||
// input : 'hello world\'
|
||||
// output: '"hello world\\"'
|
||||
|
||||
assert(dest_remaining--);
|
||||
*(dest++) = NUL;
|
||||
|
@ -332,7 +332,7 @@ int path_fnamencmp(const char *const fname1, const char *const fname2,
|
||||
&& (p_fic ? (c1 != c2 && CH_FOLD(c1) != CH_FOLD(c2)) : c1 != c2)) {
|
||||
break;
|
||||
}
|
||||
len -= MB_PTR2LEN((const char_u *)p1);
|
||||
len -= (size_t)MB_PTR2LEN((const char_u *)p1);
|
||||
p1 += MB_PTR2LEN((const char_u *)p1);
|
||||
p2 += MB_PTR2LEN((const char_u *)p2);
|
||||
}
|
||||
@ -1691,7 +1691,7 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
|
||||
if (strlen(fname) > (len - 1)) {
|
||||
xstrlcpy(buf, fname, len); // truncate
|
||||
#ifdef WIN32
|
||||
slash_adjust(buf);
|
||||
slash_adjust((char_u *)buf);
|
||||
#endif
|
||||
return FAIL;
|
||||
}
|
||||
@ -1706,7 +1706,7 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
|
||||
xstrlcpy(buf, fname, len); // something failed; use the filename
|
||||
}
|
||||
#ifdef WIN32
|
||||
slash_adjust(buf);
|
||||
slash_adjust((char_u *)buf);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
@ -1741,7 +1741,7 @@ char *fix_fname(const char *fname)
|
||||
path_fix_case((char_u *)fname); // set correct case for file name
|
||||
# endif
|
||||
|
||||
return fname;
|
||||
return (char *)fname;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,13 @@
|
||||
#include "nvim/os/shell.h"
|
||||
#include "nvim/eval/encode.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# undef fpclassify
|
||||
# define fpclassify __fpclassify
|
||||
# undef isnan
|
||||
# define isnan _isnan
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copy "string" into newly allocated memory.
|
||||
*/
|
||||
|
@ -47,9 +47,11 @@ void term_input_init(TermInput *input, Loop *loop)
|
||||
termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
|
||||
// setup input handle
|
||||
#ifdef WIN32
|
||||
uv_tty_init(loop, &input->tty_in, 0, 1);
|
||||
uv_tty_init(&loop->uv, &input->tty_in, 0, 1);
|
||||
uv_tty_set_mode(&input->tty_in, UV_TTY_MODE_RAW);
|
||||
rstream_init_stream(&input->read_stream, &input->tty_in, 0xfff);
|
||||
rstream_init_stream(&input->read_stream,
|
||||
(uv_stream_t *)&input->tty_in,
|
||||
0xfff);
|
||||
#else
|
||||
rstream_init_fd(loop, &input->read_stream, input->in_fd, 0xfff);
|
||||
#endif
|
||||
|
@ -1744,14 +1744,14 @@ static void flush_buf(UI *ui)
|
||||
// cursor is visible. Write a "cursor invisible" command before writing the
|
||||
// buffer.
|
||||
bufp->base = data->invis;
|
||||
bufp->len = data->invislen;
|
||||
bufp->len = UV_BUF_LEN(data->invislen);
|
||||
bufp++;
|
||||
data->is_invisible = true;
|
||||
}
|
||||
|
||||
if (data->bufpos > 0) {
|
||||
bufp->base = data->buf;
|
||||
bufp->len = data->bufpos;
|
||||
bufp->len = UV_BUF_LEN(data->bufpos);
|
||||
bufp++;
|
||||
}
|
||||
|
||||
@ -1759,7 +1759,7 @@ static void flush_buf(UI *ui)
|
||||
// not busy and the cursor is invisible. Write a "cursor normal" command
|
||||
// after writing the buffer.
|
||||
bufp->base = data->norm;
|
||||
bufp->len = data->normlen;
|
||||
bufp->len = UV_BUF_LEN(data->normlen);
|
||||
bufp++;
|
||||
data->is_invisible = data->busy;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ static void walk_cb(uv_handle_t *handle, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
static void sig_handler(int signum)
|
||||
{
|
||||
switch (signum) {
|
||||
@ -57,6 +58,7 @@ static void sig_handler(int signum)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
static void sigwinch_cb(uv_signal_t *handle, int signum)
|
||||
@ -94,7 +96,14 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf)
|
||||
uv_tty_init(&write_loop, &out, fileno(stdout), 0);
|
||||
|
||||
uv_write_t req;
|
||||
uv_buf_t b = {.base = buf->base, .len = (size_t)cnt};
|
||||
uv_buf_t b = {
|
||||
.base = buf->base,
|
||||
#ifdef WIN32
|
||||
.len = (ULONG)cnt
|
||||
#else
|
||||
.len = (size_t)cnt
|
||||
#endif
|
||||
};
|
||||
uv_write(&req, STRUCT_CAST(uv_stream_t, &out), &b, 1, NULL);
|
||||
uv_run(&write_loop, UV_RUN_DEFAULT);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user