aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2014-01-04 10:50:37 +1000
committerSteve Bennett <steveb@workware.net.au>2014-01-15 07:21:08 +1000
commit39558d51b0f7e368eb104f86a525b63fa5475618 (patch)
tree0f2b1affb9b6e67100e1a1a8b162a2c965539f32 /jim-aio.c
parent50f7a402499cd53719c6f2e67bfe1811ddfa6f57 (diff)
downloadjimtcl-39558d51b0f7e368eb104f86a525b63fa5475618.zip
jimtcl-39558d51b0f7e368eb104f86a525b63fa5475618.tar.gz
jimtcl-39558d51b0f7e368eb104f86a525b63fa5475618.tar.bz2
aio: simplify JimMakeChannel()
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/jim-aio.c b/jim-aio.c
index 833a44c..294aab5 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -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 */