Stricter parsing of SET command expressions.

This commit is contained in:
Dianne Skoll
2023-12-22 14:22:54 -05:00
parent 3df2b72175
commit 32e8db322d
5 changed files with 21 additions and 2 deletions

View File

@@ -349,7 +349,9 @@ int CallUserFunc(char const *name, int nargs, ParsePtr p)
/* Skip the opening bracket, if there's one */
while (isempty(*s)) s++;
if (*s == BEG_OF_EXPR) s++;
if (*s == BEG_OF_EXPR) {
s++;
}
push_call(f->filename, f->name, f->lineno);
h = Evaluate(&s, f->locals, p);
if (h == OK) {

View File

@@ -525,7 +525,9 @@ int DoSet (Parser *p)
int r;
DynamicBuffer buf;
DynamicBuffer buf2;
DBufInit(&buf);
DBufInit(&buf2);
r = ParseIdentifier(p, &buf);
if (r) return r;
@@ -541,6 +543,13 @@ int DoSet (Parser *p)
return r;
}
r = ParseToken(p, &buf2);
if (r) return r;
if (DBufLen(&buf2)) {
DBufFree(&buf2);
return E_EXPECTING_EOL;
}
DBufFree(&buf2);
if (*DBufValue(&buf) == '$') r = SetSysVar(DBufValue(&buf)+1, &v);
else r = SetVar(DBufValue(&buf), &v);
if (buf.len > VAR_NAME_LEN) {

View File

@@ -4,7 +4,7 @@ MSG UseVTColors is: [$UseVTColors]%
MSG Use256Colors is: [$Use256Colors]%
MSG UseTrueColors is: [$UseTrueColors]%
MSG UseBGVTColors is: [$UseBGVTColors]%
set n ansicolor("")]
set n ansicolor("")
MSG This is [ansicolor(0,255,0)]green[n], [ansicolor("255 0 0")]red[n] and [ansicolor("0 0 255")]blue[n] text.%
MSG This is [ansicolor(0,0,0)][ansicolor(0,255,0,1)]black text on a green background[n]%
MSG This is [ansicolor(0,0,0,0,1)]clamped black text[n]%

View File

@@ -4833,6 +4833,11 @@ REM 2 Jan 1990 MSG ["bad_expr" * 2]
../tests/test.rem(887): Expired
SET $ParseUntriggered 1
# Should result in errors
set pqxya 1+2)
1 + 2 => 3
../tests/test.rem(891): Expecting end-of-line
# Don't want Remind to queue reminders
EXIT

View File

@@ -887,6 +887,9 @@ SET $ParseUntriggered 0
REM 2 Jan 1990 MSG ["bad_expr" * 2]
SET $ParseUntriggered 1
# Should result in errors
set pqxya 1+2)
# Don't want Remind to queue reminders
EXIT