aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2015-10-27 21:47:36 +0000
committerRui Abreu Ferreira <raf-ep@gmx.com>2015-11-25 23:16:37 +0000
commitd873084581c5c94d2a910aea8561ea1d64eeafbd (patch)
tree8f8eb05cc5ae6d4bdc2d1325a40af8c82f49fc20
parent5bc6e0dc74828064acef3bdafbf9986435edd0df (diff)
downloadrneovim-d873084581c5c94d2a910aea8561ea1d64eeafbd.tar.gz
rneovim-d873084581c5c94d2a910aea8561ea1d64eeafbd.tar.bz2
rneovim-d873084581c5c94d2a910aea8561ea1d64eeafbd.zip
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).
-rw-r--r--src/nvim/fileio.c10
1 files changed, 5 insertions, 5 deletions
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 */