diff options
-rw-r--r-- | jim.c | 22 | ||||
-rw-r--r-- | tests/parse.test | 15 |
2 files changed, 30 insertions, 7 deletions
@@ -1732,7 +1732,6 @@ static int JimParseStr(struct JimParserCtx *pc) else if (pc->len == 1) { /* End of script with trailing backslash */ pc->missing = '\\'; - pc->missingline = pc->tline; } break; case '(': @@ -1794,13 +1793,22 @@ static int JimParseStr(struct JimParserCtx *pc) static int JimParseComment(struct JimParserCtx *pc) { while (*pc->p) { - if (*pc->p == '\n') { + if (*pc->p == '\\') { + pc->p++; + pc->len--; + if (pc->len == 0) { + pc->missing = '\\'; + return JIM_OK; + } + if (*pc->p == '\n') { + pc->linenr++; + } + } + else if (*pc->p == '\n') { + pc->p++; + pc->len--; pc->linenr++; - if (*(pc->p - 1) != '\\') { - pc->p++; - pc->len--; - return JIM_OK; - } + break; } pc->p++; pc->len--; diff --git a/tests/parse.test b/tests/parse.test index e352fc3..982c4a4 100644 --- a/tests/parse.test +++ b/tests/parse.test @@ -320,4 +320,19 @@ test parse-1.63 "unquoted dollar sign" { set x x$ } {x$} +test parse-1.64 "backslash in comment" { + set x 0 + # comment \ + incr x + incr x +} 1 + +test parse-1.65 "double backslash in comment" { + set x 0 + # comment \\ + incr x + incr x +} 2 + + testreport |