summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Mallet <anthony.mallet@laas.fr>2022-10-05 16:12:10 +0200
committerAnthony Mallet <anthony.mallet@laas.fr>2022-10-05 16:12:10 +0200
commitae70a219159e37f1300ed2ddb446d45387c44d7a (patch)
tree250ab1f17d57e9693a5be012e050045be62d980d
parentb1653defa7fb98624fa346c7f9d616be4a5640d6 (diff)
downloadeltclsh-ae70a219159e37f1300ed2ddb446d45387c44d7a.tar.gz
Fix off-by-one in brace parsing functionHEADmaster
Prevent from assigning the end of a token beyond the current line. From Arvid Björkengren, thanks! While here, don't raise an error in case of missing close brace and just consider the partial token as a regular text token.
-rw-r--r--src/parse.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/parse.c b/src/parse.c
index 16ec073..a6b6545 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
- * Copyright (C) 2001,1998,2017 LAAS/CNRS
+ * Copyright (c) 1998,2022 by Scriptics Corporation.
+ * Copyright (C) 2001,1998,2017,1998,2022 LAAS/CNRS
*
* This file contains procedures that parse Tcl scripts. They do so in a
* general-purpose fashion that can be used for many different purposes,
@@ -1011,10 +1011,10 @@ parseBraces(string, numBytes, parsePtr, termPtr)
}
if (*src == '}') {
level--;
+ src++;
if (level == 0) {
break;
}
- src++;
} else if (*src == '{') {
level++;
src++;
@@ -1054,8 +1054,6 @@ parseBraces(string, numBytes, parsePtr, termPtr)
src += length;
}
} else if (src == end) {
- parsePtr->errorType = TCL_PARSE_MISSING_BRACE;
- parsePtr->incomplete = 1;
break;
} else {
src++;
@@ -1078,7 +1076,7 @@ parseBraces(string, numBytes, parsePtr, termPtr)
parsePtr->numTokens++;
}
if (termPtr != NULL) {
- *termPtr = src+1;
+ *termPtr = src;
}
return TCL_OK;
}