mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Use ParseIdentifier instead of ParseToken with "PRESERVE"
to avoid creating illegal variable names.
This commit is contained in:
22
src/var.c
22
src/var.c
@@ -560,6 +560,7 @@ Var *FindVar(char const *str, int create)
|
|||||||
v->v.type = INT_TYPE;
|
v->v.type = INT_TYPE;
|
||||||
v->v.v.val = 0;
|
v->v.v.val = 0;
|
||||||
v->preserve = 0;
|
v->preserve = 0;
|
||||||
|
v->is_constant = 1;
|
||||||
v->filename = "";
|
v->filename = "";
|
||||||
v->lineno = 0;
|
v->lineno = 0;
|
||||||
StrnCpy(v->name, str, VAR_NAME_LEN);
|
StrnCpy(v->name, str, VAR_NAME_LEN);
|
||||||
@@ -660,7 +661,10 @@ int DoSet (Parser *p)
|
|||||||
Var *var;
|
Var *var;
|
||||||
|
|
||||||
r = ParseIdentifier(p, &buf);
|
r = ParseIdentifier(p, &buf);
|
||||||
if (r) return r;
|
if (r) {
|
||||||
|
DBufFree(&buf);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
if (ignoring) {
|
if (ignoring) {
|
||||||
/* We're only here to mark a variable as non-const */
|
/* We're only here to mark a variable as non-const */
|
||||||
@@ -907,7 +911,6 @@ int PreserveVar(char const *name)
|
|||||||
v = FindVar(name, 1);
|
v = FindVar(name, 1);
|
||||||
if (!v) return E_NO_MEM;
|
if (!v) return E_NO_MEM;
|
||||||
v->preserve = 1;
|
v->preserve = 1;
|
||||||
|
|
||||||
/* Assume we're gonna use the variable */
|
/* Assume we're gonna use the variable */
|
||||||
v->used_since_set = 1;
|
v->used_since_set = 1;
|
||||||
return OK;
|
return OK;
|
||||||
@@ -925,11 +928,10 @@ int DoPreserve (Parser *p)
|
|||||||
DynamicBuffer buf;
|
DynamicBuffer buf;
|
||||||
DBufInit(&buf);
|
DBufInit(&buf);
|
||||||
|
|
||||||
r = ParseToken(p, &buf);
|
r = ParseIdentifier(p, &buf);
|
||||||
if (r) return r;
|
if (r) {
|
||||||
if (!DBufLen(&buf)) {
|
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return E_EOLN;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = PreserveVar(DBufValue(&buf));
|
r = PreserveVar(DBufValue(&buf));
|
||||||
@@ -938,12 +940,14 @@ int DoPreserve (Parser *p)
|
|||||||
|
|
||||||
/* Keep going... */
|
/* Keep going... */
|
||||||
while(1) {
|
while(1) {
|
||||||
r = ParseToken(p, &buf);
|
r = ParseIdentifier(p, &buf);
|
||||||
if (r) return r;
|
if (r == E_EOLN) {
|
||||||
if (!DBufLen(&buf)) {
|
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
if (r) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
r = PreserveVar(DBufValue(&buf));
|
r = PreserveVar(DBufValue(&buf));
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
|
|||||||
Reference in New Issue
Block a user