From d873084581c5c94d2a910aea8561ea1d64eeafbd Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Tue, 27 Oct 2015 21:47:36 +0000 Subject: Don't use errno constants for os_open() errors In Windows we can't assume errno will be set by calls to os_* functions, instead the return value from os_* functions can be used. This commit fixes two occurences for os_open(). 1. EFBIG is replaced with UV_EFBIG and checked against the return from os_open(). 2. EOVERFLOW does not have a corresponding libuv constant, and is not defined by open() in Windows - disabled this case with a UNIX guard, and check the return value against -EOVERFLOW (libuv errors are negative errno values in Unix). --- src/nvim/fileio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 1bee50b717..4aa4d4c399 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -578,11 +578,11 @@ readfile ( return OK; /* a new file is not an error */ } else { filemess(curbuf, sfname, (char_u *)( -# ifdef EFBIG - (errno == EFBIG) ? _("[File too big]") : -# endif -# ifdef EOVERFLOW - (errno == EOVERFLOW) ? _("[File too big]") : + (fd == UV_EFBIG) ? _("[File too big]") : +# if defined(UNIX) && defined(EOVERFLOW) + // libuv only returns -errno in Unix and in Windows open() does not + // set EOVERFLOW + (fd == -EOVERFLOW) ? _("[File too big]") : # endif _("[Permission Denied]")), 0); curbuf->b_p_ro = TRUE; /* must use "w!" now */ -- cgit