*: Fix some Windows-specific warnings

Also fixed an error in path_fnamecmp().
This commit is contained in:
ZyX
2016-11-05 01:03:44 +03:00
parent 9ed9af7e11
commit 4bcee96347
10 changed files with 122 additions and 65 deletions

View File

@@ -395,10 +395,10 @@ void nvim_buf_set_lines(uint64_t channel_id,
mark_adjust((linenr_T)start, (linenr_T)(end - 1), MAXLNUM, extra);
}
changed_lines((linenr_T)start, 0, (linenr_T)end, extra);
changed_lines((linenr_T)start, 0, (linenr_T)end, (long)extra);
if (save_curbuf.br_buf == NULL) {
fix_cursor((linenr_T)start, (linenr_T)end, extra);
fix_cursor((linenr_T)start, (linenr_T)end, (linenr_T)extra);
}
end:

View File

@@ -89,7 +89,10 @@ static void on_rbuffer_nonfull(RBuffer *buf, void *data)
static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf)
{
Stream *stream = handle->data;
buf->base = rbuffer_write_ptr(stream->buffer, &buf->len);
// `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;
}
// Callback invoked by libuv after it copies the data into the buffer provided
@@ -136,7 +139,10 @@ static void fread_idle_cb(uv_idle_t *handle)
uv_fs_t req;
Stream *stream = handle->data;
stream->uvbuf.base = rbuffer_write_ptr(stream->buffer, &stream->uvbuf.len);
// `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;
// the offset argument to uv_fs_read is int64_t, could someone really try
// to read more than 9 quintillion (9e18) bytes?

View File

@@ -579,7 +579,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])
&& strchr(" *?[{`$%#", ccline.cmdbuff[s->j + 1])
== NULL
#endif
) {

View File

@@ -322,8 +322,11 @@ vim_findfile_init (
drive[0] = path[0];
drive[1] = ':';
drive[2] = NUL;
if (vim_FullName(drive, ff_expand_buffer, MAXPATHL, TRUE) == FAIL)
if (vim_FullName((const char *)drive, (char *)ff_expand_buffer, MAXPATHL,
true)
== FAIL) {
goto error_return;
}
path += 2;
} else
#endif

View File

@@ -5207,7 +5207,7 @@ void forward_slash(char_u *fname)
{
char_u *p;
if (path_with_url(fname)) {
if (path_with_url((const char *)fname)) {
return;
}
for (p = fname; *p != NUL; p++) {

View File

@@ -174,7 +174,7 @@ static char_u *skip_string(char_u *p)
char_u *paren = vim_strchr(delim, '(');
if (paren != NULL) {
ptrdiff_t delim_len = paren - delim;
const ptrdiff_t delim_len = paren - delim;
for (p += 3; *p; ++p)
if (p[0] == ')' && STRNCMP(p + 1, delim, delim_len) == 0

View File

@@ -18,6 +18,7 @@
#include "nvim/eval.h"
#include "nvim/ex_getln.h"
#include "nvim/version.h"
#include "nvim/fileio.h"
#ifdef WIN32
#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8

View File

@@ -12,8 +12,9 @@ typedef struct pty_process {
#define pty_process_spawn(job) libuv_process_spawn((LibuvProcess *)job)
#define pty_process_close(job) libuv_process_close((LibuvProcess *)job)
#define pty_process_close_master(job) libuv_process_close((LibuvProcess *)job)
#define pty_process_resize(job, width, height)
#define pty_process_teardown(loop)
#define pty_process_resize(job, width, height) ( \
(void)job, (void)width, (void)height, 0)
#define pty_process_teardown(loop) ((void)loop, 0)
static inline PtyProcess pty_process_init(Loop *loop, void *data)
{

View File

@@ -312,7 +312,7 @@ int path_fnamecmp(const char *fname1, const char *fname2)
///
/// @return 0 if they are equal, non-zero otherwise.
int path_fnamencmp(const char *const fname1, const char *const fname2,
const size_t len)
size_t len)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
#ifdef BACKSLASH_IN_FILENAME
@@ -322,16 +322,16 @@ int path_fnamencmp(const char *const fname1, const char *const fname2,
const char *p1 = fname1;
const char *p2 = fname2;
while (len > 0) {
c1 = PTR2CHAR(p1);
c2 = PTR2CHAR(p2);
if (c1 == NUL || c2 == NUL
|| (!((c1 == '/' || c1 == '\\') && (c2 == '\\' || c2 == '/')))
|| (p_fic ? (c1 != c2 && CH_FOLD(c1) != CH_FOLD(c2)) : c1 != c2)) {
c1 = PTR2CHAR((const char_u *)p1);
c2 = PTR2CHAR((const char_u *)p2);
if ((c1 == NUL || c2 == NUL
|| (!((c1 == '/' || c1 == '\\') && (c2 == '\\' || c2 == '/'))))
&& (p_fic ? (c1 != c2 && CH_FOLD(c1) != CH_FOLD(c2)) : c1 != c2)) {
break;
}
len -= MB_PTR2LEN(p1);
p1 += MB_PTR2LEN(p1);
p2 += MB_PTR2LEN(p2);
len -= MB_PTR2LEN((const char_u *)p1);
p1 += MB_PTR2LEN((const char_u *)p1);
p2 += MB_PTR2LEN((const char_u *)p2);
}
return c1 - c2;
#else
@@ -819,7 +819,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
}
STRMOVE(buf + len + 1, buf);
STRCPY(buf, curdir);
buf[len] = PATHSEP;
buf[len] = (char_u)PATHSEP;
simplify_filename(buf);
}
@@ -1333,12 +1333,12 @@ static int expand_backtick(
/// When the path looks like a URL leave it unmodified.
void slash_adjust(char_u *p)
{
if (path_with_url(p)) {
if (path_with_url((const char *)p)) {
return;
}
while (*p) {
if (*p == psepcN) {
*p = psepc;
if (*p == (char_u)psepcN) {
*p = (char_u)psepc;
}
mb_ptr_adv(p);
}