diff options
author | Steve Bennett <steveb@workware.net.au> | 2014-09-18 07:23:38 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2014-09-18 07:23:38 +1000 |
commit | 17231d101cea87ed72c29b661d47a24f6c7e8d92 (patch) | |
tree | 0a6cd22e77714f892d650e8c1969e920bc5eadf5 /jim-exec.c | |
parent | eff75a2ecc134c54cb6524f09144acaa2b3624aa (diff) | |
download | jimtcl-17231d101cea87ed72c29b661d47a24f6c7e8d92.zip jimtcl-17231d101cea87ed72c29b661d47a24f6c7e8d92.tar.gz jimtcl-17231d101cea87ed72c29b661d47a24f6c7e8d92.tar.bz2 |
exec: simplify tempfile error msg handling
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-exec.c')
-rw-r--r-- | jim-exec.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -1578,18 +1578,16 @@ static int JimCreateTemp(Jim_Interp *interp, const char *contents, int len) { int fd = Jim_MakeTempFile(interp, NULL); - if (fd == JIM_BAD_FD) { - Jim_SetResultErrno(interp, "couldn't create temp file"); - return -1; - } - unlink(Jim_String(Jim_GetResult(interp))); - if (contents) { - if (write(fd, contents, len) != len) { - Jim_SetResultErrno(interp, "couldn't write temp file"); - close(fd); - return -1; + if (fd != JIM_BAD_FD) { + unlink(Jim_String(Jim_GetResult(interp))); + if (contents) { + if (write(fd, contents, len) != len) { + Jim_SetResultErrno(interp, "couldn't write temp file"); + close(fd); + return -1; + } + lseek(fd, 0L, SEEK_SET); } - lseek(fd, 0L, SEEK_SET); } return fd; } |