aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-11-07 08:55:09 +1000
committerSteve Bennett <steveb@workware.net.au>2011-11-07 15:31:41 +1000
commit05e51ed5447b83badfd8ed550c7386b68eb94919 (patch)
treec0c2c87069eaf34f9d90aaa8e810b7cf8f40c4fc /jim-aio.c
parent5fe0bb5f3beedb262512a8e548bf7cc6ed9bff96 (diff)
downloadjimtcl-05e51ed5447b83badfd8ed550c7386b68eb94919.zip
jimtcl-05e51ed5447b83badfd8ed550c7386b68eb94919.tar.gz
jimtcl-05e51ed5447b83badfd8ed550c7386b68eb94919.tar.bz2
Allow building with MSVC on windows
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/jim-aio.c b/jim-aio.c
index f86bc1c..4240311 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -38,7 +38,6 @@
* official policies, either expressed or implied, of the Jim Tcl Project.
**/
-#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -52,6 +51,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <unistd.h>
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
@@ -973,6 +973,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
const char *mode;
+ const char *filename;
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "filename ?mode?");
@@ -980,7 +981,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc,
}
mode = (argc == 3) ? Jim_String(argv[2]) : "r";
- const char *filename = Jim_String(argv[1]);
+ filename = Jim_String(argv[1]);
#ifdef jim_ext_tclcompat
/* If the filename starts with '|', use popen instead */
@@ -1036,7 +1037,9 @@ static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filenam
if (fh == NULL) {
JimAioSetError(interp, filename);
- close(fd);
+ if (fd >= 0) {
+ close(fd);
+ }
Jim_DecrRefCount(interp, filename);
return JIM_ERR;
}