aboutsummaryrefslogtreecommitdiff
path: root/jim.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2013-11-11 08:50:57 +1000
committerSteve Bennett <steveb@workware.net.au>2013-11-11 20:01:09 +1000
commit2dba052c8e456f5d4b1b77fa85f4105650f1fe38 (patch)
tree5b13befd5f634de7b7555a1a9219a73a30658c0b /jim.c
parent3bc70127b4453539eee52fa7d9a30542d141b20a (diff)
downloadjimtcl-2dba052c8e456f5d4b1b77fa85f4105650f1fe38.zip
jimtcl-2dba052c8e456f5d4b1b77fa85f4105650f1fe38.tar.gz
jimtcl-2dba052c8e456f5d4b1b77fa85f4105650f1fe38.tar.bz2
Consider scripts with trailing backslash as unfinished
From the interactive prompt. Reported-by: Sergei Gavrikov <sergei.gavrikov@gmail.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r--jim.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/jim.c b/jim.c
index 1e26b38..8a776e4 100644
--- a/jim.c
+++ b/jim.c
@@ -1729,6 +1729,11 @@ static int JimParseStr(struct JimParserCtx *pc)
pc->p++;
pc->len--;
}
+ else if (pc->len == 1) {
+ /* End of script with trailing backslash */
+ pc->missing = '\\';
+ pc->missingline = pc->tline;
+ }
break;
case '(':
/* If the following token is not '$' just keep going */
@@ -2050,6 +2055,7 @@ static Jim_Obj *JimParserGetTokenObj(Jim_Interp *interp, struct JimParserCtx *pc
* '{' on scripts incomplete missing one or more '}' to be balanced.
* '[' on scripts incomplete missing one or more ']' to be balanced.
* '"' on scripts incomplete missing a '"' char.
+ * '\\' on scripts with a trailing backslash.
*
* If the script is complete, 1 is returned, otherwise 0.
*/
@@ -3613,7 +3619,8 @@ static int SetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr, struct J
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
}
- if (result && parser.missing != ' ') {
+ /* Note that we accept a trailing backslash without error */
+ if (result && parser.missing != ' ' && parser.missing != '\\') {
ScriptTokenListFree(&tokenlist);
result->missing = parser.missing;
result->line = parser.missingline;