From 65820c9d0e90fb082e8399ad13bc654ac7c1a547 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 5 Jan 2014 17:18:16 +1000 Subject: exec: remove duplicate code Two versions of the "trim trailing space" function Signed-off-by: Steve Bennett --- jim-exec.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'jim-exec.c') diff --git a/jim-exec.c b/jim-exec.c index d298891..7d41bc9 100644 --- a/jim-exec.c +++ b/jim-exec.c @@ -166,6 +166,10 @@ static const char *JimStrError(void) return strerror(JimErrno()); } +/* + * If the last character of 'objPtr' is a newline, then remove + * the newline character. + */ static void Jim_RemoveTrailingNewline(Jim_Obj *objPtr) { int len; @@ -203,23 +207,6 @@ static int JimAppendStreamToString(Jim_Interp *interp, fdtype fd, Jim_Obj *strOb return JIM_OK; } -/* - * If the last character of the result is a newline, then remove - * the newline character (the newline would just confuse things). - * - * Note: Ideally we could do this by just reducing the length of stringrep - * by 1, but there is no API for this :-( - */ -static void JimTrimTrailingNewline(Jim_Interp *interp) -{ - int len; - const char *p = Jim_GetString(Jim_GetResult(interp), &len); - - if (len > 0 && p[len - 1] == '\n') { - Jim_SetResultString(interp, p, len - 1); - } -} - /** * Builds the environment array from $::env * @@ -1133,7 +1120,7 @@ static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, } } - JimTrimTrailingNewline(interp); + Jim_RemoveTrailingNewline(Jim_GetResult(interp)); return result; } -- cgit v1.1