diff options
-rw-r--r-- | jim-aio.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -1067,33 +1067,32 @@ static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filenam char buf[AIO_CMD_LEN]; int OpenFlags = 0; - if (filename == NULL) { + if (fh) { filename = Jim_NewStringObj(interp, hdlfmt, -1); + OpenFlags = AIO_KEEPOPEN; } Jim_IncrRefCount(filename); if (fh == NULL) { - if (fd < 0) { - fh = fopen(Jim_String(filename), mode); - } - else { +#if !defined(JIM_ANSIC) + if (fd >= 0) { fh = fdopen(fd, mode); } - } - else { - OpenFlags = AIO_KEEPOPEN; - } + else +#endif + fh = fopen(Jim_String(filename), mode); - if (fh == NULL) { - JimAioSetError(interp, filename); + if (fh == NULL) { + JimAioSetError(interp, filename); #if !defined(JIM_ANSIC) - if (fd >= 0) { - close(fd); - } + if (fd >= 0) { + close(fd); + } #endif - Jim_DecrRefCount(interp, filename); - return JIM_ERR; + Jim_DecrRefCount(interp, filename); + return JIM_ERR; + } } /* Create the file command */ |