diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-01-20 17:18:32 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-01-20 17:18:32 +0100 |
commit | 0daaa49586ff49584946cdf96549e1331f055103 (patch) | |
tree | adbf6bce58de5f8280ecf496728edd6f38bdfa58 | |
parent | ee84da358c27b9c0a6bbd49424bc9d04bb98d662 (diff) | |
parent | 10b1738f590fe08675173071b35fface324f4048 (diff) | |
download | rneovim-0daaa49586ff49584946cdf96549e1331f055103.tar.gz rneovim-0daaa49586ff49584946cdf96549e1331f055103.tar.bz2 rneovim-0daaa49586ff49584946cdf96549e1331f055103.zip |
Merge #7863 'mingw64: fix gcc warnings'
-rw-r--r-- | src/nvim/api/buffer.c | 6 | ||||
-rw-r--r-- | src/nvim/eval/encode.c | 5 | ||||
-rw-r--r-- | src/nvim/event/rstream.c | 4 | ||||
-rw-r--r-- | src/nvim/event/wstream.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 2 | ||||
-rw-r--r-- | src/nvim/file_search.c | 2 | ||||
-rw-r--r-- | src/nvim/macros.h | 19 | ||||
-rw-r--r-- | src/nvim/main.c | 7 | ||||
-rw-r--r-- | src/nvim/option.c | 53 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 6 | ||||
-rw-r--r-- | src/nvim/os/pty_process_win.c | 30 | ||||
-rw-r--r-- | src/nvim/path.c | 8 | ||||
-rw-r--r-- | src/nvim/strings.c | 7 | ||||
-rw-r--r-- | src/nvim/tui/input.c | 6 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 6 | ||||
-rw-r--r-- | test/functional/fixtures/tty-test.c | 11 |
17 files changed, 114 insertions, 62 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/eval/encode.c b/src/nvim/eval/encode.c index 31779a544f..9bae436e3d 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -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)) 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/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 f0185d6825..54bbe66620 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/macros.h b/src/nvim/macros.h index 26d4f74b6a..a98c1e05a0 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -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 diff --git a/src/nvim/main.c b/src/nvim/main.c index 015df5d070..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; } @@ -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"); diff --git a/src/nvim/option.c b/src/nvim/option.c index 192d2b0f78..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 { - *(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]; @@ -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; } diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index aa28b95c30..c0a97aeb34 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_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; diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 3c4839a076..b90578edb7 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, @@ -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; 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/strings.c b/src/nvim/strings.c index 687f734742..e3f6a8cbf6 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -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. */ diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 96bb692db9..b04a6ce4f9 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -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 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..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) @@ -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); |