aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jim.c22
-rw-r--r--tests/parse.test15
2 files changed, 30 insertions, 7 deletions
diff --git a/jim.c b/jim.c
index 8a776e4..b314e1c 100644
--- a/jim.c
+++ b/jim.c
@@ -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