diff options
author | Steve Bennett <steveb@workware.net.au> | 2014-01-04 10:50:37 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2014-01-15 07:21:08 +1000 |
commit | 39558d51b0f7e368eb104f86a525b63fa5475618 (patch) | |
tree | 0f2b1affb9b6e67100e1a1a8b162a2c965539f32 | |
parent | 50f7a402499cd53719c6f2e67bfe1811ddfa6f57 (diff) | |
download | jimtcl-39558d51b0f7e368eb104f86a525b63fa5475618.zip jimtcl-39558d51b0f7e368eb104f86a525b63fa5475618.tar.gz jimtcl-39558d51b0f7e368eb104f86a525b63fa5475618.tar.bz2 |
aio: simplify JimMakeChannel()
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-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 */ |