aboutsummaryrefslogtreecommitdiff
path: root/jim.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-11-16 22:09:31 +1000
committerSteve Bennett <steveb@workware.net.au>2020-11-16 22:09:31 +1000
commit7eb4881306eb10000657a6b020f12002d30943d1 (patch)
treea7170dc4c461d5aeb750151cf08fd221f0a47ae7 /jim.c
parent19a8dacce565dc286ad9d3950d0f669f3058673d (diff)
downloadjimtcl-7eb4881306eb10000657a6b020f12002d30943d1.zip
jimtcl-7eb4881306eb10000657a6b020f12002d30943d1.tar.gz
jimtcl-7eb4881306eb10000657a6b020f12002d30943d1.tar.bz2
expr: TIP 582 - comments in expressions
Add support for comments in expressions Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r--jim.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/jim.c b/jim.c
index c253f5c..684905f 100644
--- a/jim.c
+++ b/jim.c
@@ -8810,13 +8810,22 @@ static const struct Jim_ExprOperator Jim_ExprOperators[] = {
static int JimParseExpression(struct JimParserCtx *pc)
{
- /* Discard spaces and quoted newline */
- while (isspace(UCHAR(*pc->p)) || (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) {
- if (*pc->p == '\n') {
- pc->linenr++;
+ while (1) {
+ /* Discard spaces and quoted newline */
+ while (isspace(UCHAR(*pc->p)) || (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) {
+ if (*pc->p == '\n') {
+ pc->linenr++;
+ }
+ pc->p++;
+ pc->len--;
}
- pc->p++;
- pc->len--;
+ /* Discard comments */
+ if (*pc->p == '#') {
+ JimParseComment(pc);
+ /* Go back to discarding white space */
+ continue;
+ }
+ break;
}
/* Common case */