diff options
author | Steve Bennett <steveb@workware.net.au> | 2013-11-11 08:50:57 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-11-11 20:01:09 +1000 |
commit | 2dba052c8e456f5d4b1b77fa85f4105650f1fe38 (patch) | |
tree | 5b13befd5f634de7b7555a1a9219a73a30658c0b | |
parent | 3bc70127b4453539eee52fa7d9a30542d141b20a (diff) | |
download | jimtcl-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>
-rw-r--r-- | jim.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; |