aboutsummaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-06-29 16:35:06 +0000
committerOmar Polo <op@omarpolo.com>2021-06-29 16:35:06 +0000
commitbfb076ed7ee61a93cc6ae701b07c3d3bc7a006aa (patch)
tree03e11975a298247a687748679c0b7ec3b6b432cf /parse.y
parent7252049dd77e4927049f698d06d7ebc8fbc3e3df (diff)
don't expand macros inside the quotes
Now that we have this auto concat string thingy, macros can simply expand to standalone strings in place, as single words. Forgot to point it out in previous commits, but now we can cert = "/etc/keys" server "foo" { cert $cert "/foo.crt" ... }
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y11
1 files changed, 5 insertions, 6 deletions
diff --git a/parse.y b/parse.y
index 9b9b9df..02ab827 100644
--- a/parse.y
+++ b/parse.y
@@ -416,7 +416,6 @@ repeat:
goto eof;
}
-top:
/* parsing next word */
for (;; c = getc(yyfp), yylval.colno++) {
switch (c) {
@@ -433,7 +432,7 @@ top:
/* expand macros in-place */
case '$':
- if (!escape) {
+ if (!escape && !quotes) {
v = p;
while (1) {
if ((c = getc(yyfp)) == EOF) {
@@ -449,24 +448,24 @@ top:
continue;
}
*p = 0;
- ungetc(c, yyfp);
break;
}
p = v;
if ((val = symget(p)) == NULL) {
yyerror("macro '%s' not defined", v);
- goto top;
+ return TERR;
}
len = strlen(val);
if (p + len >= ebuf - 1) {
yyerror("after macro-expansion, "
"string too long");
- goto top;
+ return TERR;
}
*p = '\0';
strlcat(p, val, ebuf - p);
p += len;
- goto top;
+ nonkw = 1;
+ goto eow;
}
break;
case '\n':