aboutsummaryrefslogtreecommitdiff
path: root/jim-exec.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2014-09-18 07:23:38 +1000
committerSteve Bennett <steveb@workware.net.au>2014-09-18 07:23:38 +1000
commit17231d101cea87ed72c29b661d47a24f6c7e8d92 (patch)
tree0a6cd22e77714f892d650e8c1969e920bc5eadf5 /jim-exec.c
parenteff75a2ecc134c54cb6524f09144acaa2b3624aa (diff)
downloadjimtcl-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.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/jim-exec.c b/jim-exec.c
index e952ee7..47b327a 100644
--- a/jim-exec.c
+++ b/jim-exec.c
@@ -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;
}