aboutsummaryrefslogtreecommitdiff
path: root/jim-exec.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 13:53:11 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:46 +1000
commitb149e4415f9a448740cd41e5fd2a5f065262e791 (patch)
tree8c26563d127da56135188800d5863a2137e34201 /jim-exec.c
parent289cf6dfe86b9b8a4e67b908a8bf8afc9fba76be (diff)
downloadjimtcl-b149e4415f9a448740cd41e5fd2a5f065262e791.zip
jimtcl-b149e4415f9a448740cd41e5fd2a5f065262e791.tar.gz
jimtcl-b149e4415f9a448740cd41e5fd2a5f065262e791.tar.bz2
Add Jim_SetResultFormatted() for simplied messages
Makes creating error messages much simpler Also convert a couple of long if/else to switch Also some error message improvements Also fix some memory leaks
Diffstat (limited to 'jim-exec.c')
-rw-r--r--jim-exec.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/jim-exec.c b/jim-exec.c
index ba31e08..4ad9b21 100644
--- a/jim-exec.c
+++ b/jim-exec.c
@@ -28,8 +28,7 @@
/* These two could be moved into the Tcl core */
static void Jim_SetResultErrno(Jim_Interp *interp, const char *msg)
{
- Jim_SetResultString(interp, "", 0);
- Jim_AppendStrings(interp, Jim_GetResult(interp), msg, ": ", strerror(errno), NULL);
+ Jim_SetResultFormatted(interp, "%s: %s", msg, strerror(errno));
}
static void Jim_RemoveTrailingNewline(Jim_Obj *objPtr)
@@ -572,8 +571,7 @@ Jim_CreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int **pid
}
if (i >= argc) {
- Jim_SetResultString(interp, "", 0);
- Jim_AppendStrings(interp, Jim_GetResult(interp), "can't specify \"", arg, "\" as last word in command", NULL);
+ Jim_SetResultFormatted(interp, "can't specify \"%s\" as last word in command", arg);
Jim_Free(arg_array);
return -1;
}
@@ -632,8 +630,7 @@ Jim_CreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int **pid
*/
inputId = open(input, O_RDONLY, 0);
if (inputId < 0) {
- Jim_SetResultString(interp, "", 0);
- Jim_AppendStrings(interp, Jim_GetResult(interp), "couldn't read file \"", input, "\": ", strerror(errno), NULL);
+ Jim_SetResultFormatted(interp, "couldn't read file \"%s\": %s", input, strerror(errno));
goto error;
}
}
@@ -675,8 +672,7 @@ Jim_CreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int **pid
lastOutputId = open(output, mode, 0666);
if (lastOutputId < 0) {
- Jim_SetResultString(interp, "", 0);
- Jim_AppendStrings(interp, Jim_GetResult(interp), "couldn't write file \"", output, "\": ", strerror(errno), NULL);
+ Jim_SetResultFormatted(interp, "couldn't write file \"%s\": %s", output, strerror(errno));
goto error;
}
}
@@ -718,8 +714,7 @@ Jim_CreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int **pid
errorId = open(error, mode, 0666);
if (errorId < 0) {
- Jim_SetResultString(interp, "", 0);
- Jim_AppendStrings(interp, Jim_GetResult(interp), "couldn't write file \"", error, "\": ", strerror(errno), NULL);
+ Jim_SetResultFormatted(interp, "couldn't write file \"%s\": %s", error, strerror(errno));
}
}
}