From 06994e0e21eb5545aef7c2234f5d1a271865366e Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:35:57 +0800 Subject: [PATCH 01/13] Fix warning about conversion on mingw64 --- src/nvim/api/buffer.c | 6 +++++- src/nvim/ex_cmds.c | 2 +- src/nvim/ex_getln.c | 2 +- src/nvim/file_search.c | 2 +- src/nvim/option.c | 8 ++++---- src/nvim/os/pty_process_win.c | 2 +- src/nvim/path.c | 8 ++++---- src/nvim/tui/input.c | 2 +- 8 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 01dde9dd09..af723639c5 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -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); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 06379f159c..6ffd255dc7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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 diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 82fac8d78e..ade8b46956 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -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 ) { diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 8094a1b266..c6f2166dab 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -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); diff --git a/src/nvim/option.c b/src/nvim/option.c index 192d2b0f78..d9ee8f8b94 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -844,7 +844,7 @@ set_option_default ( if (options[opt_idx].indir == PV_SCROLL) win_comp_scroll(curwin); else { - *(long *)varp = (long)options[opt_idx].def_val[dvi]; + *(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) = @@ -926,7 +926,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; } } @@ -1442,7 +1442,7 @@ do_set ( */ ++arg; if (nextchar == '&') - value = (long)options[opt_idx].def_val[ + value = (long)(intptr_t)options[opt_idx].def_val[ ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT]; else if (nextchar == '<') { @@ -5012,7 +5012,7 @@ static int optval_default(vimoption_T *p, char_u *varp) 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]; + 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 */ diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 3c4839a076..c249536536 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -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, diff --git a/src/nvim/path.c b/src/nvim/path.c index 51adcfb135..09cede8805 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -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 } diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 96bb692db9..698be02dbf 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -49,7 +49,7 @@ void term_input_init(TermInput *input, Loop *loop) #ifdef WIN32 uv_tty_init(loop, &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 From bac86a194117008656d02951de6d303ab8687eec Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:36:59 +0800 Subject: [PATCH 02/13] Fix warning when redefine RGB on Windows 1 --- src/nvim/macros.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 26d4f74b6a..0bec9af733 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -148,6 +148,11 @@ /// 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]))))) +// Windows defines a RGB macro that produces 0x00bbggrr color values for use +// with GDI. Our macro is different, and we don't use GDI. +#if defined(WIN32) && defined(RGB) +# undef RGB +#endif #define RGB(r, g, b) ((r << 16) | (g << 8) | b) #define STR_(x) #x From 12acf0f7a76160e33bb84876121d3a63dde3c252 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:40:31 +0800 Subject: [PATCH 03/13] Fix warning when assing size_t type value to uv_buf_t.len, convert type to ULONG on Windows. --- src/nvim/event/rstream.c | 4 ++-- src/nvim/event/wstream.c | 2 +- src/nvim/macros.h | 7 +++++++ src/nvim/tui/tui.c | 6 +++--- test/functional/fixtures/tty-test.c | 9 ++++++++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index e0500ba828..2fbe7f6773 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -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? diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index 320006890d..d2fb52243c 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -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); diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 0bec9af733..351fa55929 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -188,4 +188,11 @@ /// @return ((Type *)obj). #define STRUCT_CAST(Type, obj) ((Type *)(obj)) +// Type of uv_buf_t.len on Windows is ULONG, but others is size_t. +#if defined(WIN32) +# define UV_BUF_LEN(x) (ULONG)(x) +#else +# define UV_BUF_LEN(x) (x) +#endif + #endif // NVIM_MACROS_H diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2349bd2ae9..f3383eb006 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -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; } diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index edcbe23f86..9c42ca28d0 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -94,7 +94,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); From 15334dcd896812d01f81f7959a51a4c4f6929195 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:41:16 +0800 Subject: [PATCH 04/13] Fix warning unused static function --- test/functional/fixtures/tty-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 9c42ca28d0..4f0858acdb 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -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) From 5a594091dc654427cd34c3d019432ecfe77d0b64 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:42:23 +0800 Subject: [PATCH 05/13] Fix warning about unused value. --- src/nvim/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/main.c b/src/nvim/main.c index 015df5d070..80d636bb3f 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1250,12 +1250,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"); From 3632f025645bd606a61633b10f33038be54303a1 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:44:04 +0800 Subject: [PATCH 06/13] Fix warning about variable length array. --- src/nvim/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nvim/main.c b/src/nvim/main.c index 80d636bb3f..3402e2bebc 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -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; } From 43833af53c0ee5cc230dae49f69d0593ff5edf8f Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:45:49 +0800 Subject: [PATCH 07/13] Fix warning about math functions, include isnan, isinf, fpclassify. --- src/nvim/eval/encode.c | 5 +++++ src/nvim/strings.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 31779a544f..f6c42a2d3c 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -288,6 +288,11 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, : OK); } +#ifdef __MINGW32__ +# undef fpclassify +# define fpclassify __fpclassify +#endif + #define TYPVAL_ENCODE_CONV_STRING(tv, buf, len) \ do { \ const char *const buf_ = (const char *) buf; \ diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 687f734742..7ad61fd29c 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -50,6 +50,18 @@ #include "nvim/os/shell.h" #include "nvim/eval/encode.h" +/* + * Fix warning on mingw32 and mingw64 + * make isnan as _isnan + * fpclassify is used by isinf, so redefine it + */ +#ifdef __MINGW32__ +# undef fpclassify +# define fpclassify __fpclassify +# undef isnan +# define isnan _isnan +#endif + /* * Copy "string" into newly allocated memory. */ From 23102bc18e292aa8a4c3b84881723148b435f415 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:47:00 +0800 Subject: [PATCH 08/13] Fix bug, use &loop->uv replace loop. --- src/nvim/tui/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 698be02dbf..d64c630cf9 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -47,7 +47,7 @@ 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, (uv_stream_t *)&input->tty_in, 0xfff); #else From 421f2605c003c51ce25d131d444489f63a2ad928 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:48:03 +0800 Subject: [PATCH 09/13] Fix warning about NULL compare --- src/nvim/os/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index aa28b95c30..5f29a45263 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -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; From 2408a05151542da9432bd406c36f92c8bdeef1ec Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 19:54:21 +0800 Subject: [PATCH 10/13] Fix warning, read/write have unsigned int count on windows. --- src/nvim/macros.h | 7 +++++++ src/nvim/os/fs.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 351fa55929..05065499f4 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -195,4 +195,11 @@ # define UV_BUF_LEN(x) (x) #endif +// Type of bufcnt for read/write on Windows is unsigned int, not size_t. +#if defined(WIN32) +# define IO_SIZE(x) (unsigned)(x) +#else +# define IO_SIZE(x) (x) +#endif + #endif // NVIM_MACROS_H diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 5f29a45263..f3b3871aac 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -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_SIZE(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_SIZE(size - written_bytes)); if (cur_written_bytes > 0) { written_bytes += (size_t)cur_written_bytes; } From e76c6e2ee8b8a064f1f2a48e3638be6ca07f2f2a Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 20:03:01 +0800 Subject: [PATCH 11/13] Fix warning: multi-line comment [-Wcomment] use `:341,355s/: \zs.*/\=string(submatch(0))` --- src/nvim/os/pty_process_win.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index c249536536..b90578edb7 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -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; From 82adba0f2f24378b4cbd7504488c90f4260cfaf7 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 21:25:46 +0800 Subject: [PATCH 12/13] Fix for lint --- src/nvim/strings.c | 5 ----- src/nvim/tui/input.c | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 7ad61fd29c..e3f6a8cbf6 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -50,11 +50,6 @@ #include "nvim/os/shell.h" #include "nvim/eval/encode.h" -/* - * Fix warning on mingw32 and mingw64 - * make isnan as _isnan - * fpclassify is used by isinf, so redefine it - */ #ifdef __MINGW32__ # undef fpclassify # define fpclassify __fpclassify diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index d64c630cf9..b04a6ce4f9 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -49,7 +49,9 @@ void term_input_init(TermInput *input, Loop *loop) #ifdef WIN32 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, (uv_stream_t *)&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 From 10b1738f590fe08675173071b35fface324f4048 Mon Sep 17 00:00:00 2001 From: George Zhao Date: Wed, 17 Jan 2018 22:29:23 +0800 Subject: [PATCH 13/13] Fix lint error in option.c --- src/nvim/option.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/nvim/option.c b/src/nvim/option.c index d9ee8f8b94..fa2e6b169b 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -831,24 +831,26 @@ 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)) + options[opt_idx].def_val[dvi], opt_flags, 0); + } 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 { + } else { *(long *)varp = (long)(intptr_t)options[opt_idx].def_val[dvi]; - /* May also set global value for local option. */ - if (both) + // 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]; @@ -1440,20 +1442,19 @@ do_set ( * [-]0-9 set number * other error */ - ++arg; - if (nextchar == '&') + 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) + ((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) + if (p->flags & P_NUM) { return *(long *)varp == (long)(intptr_t)p->def_val[dvi]; - if (p->flags & P_BOOL) + } + 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; }