aboutsummaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-02-10 16:37:08 +0000
committerOmar Polo <op@omarpolo.com>2021-02-10 16:37:08 +0000
commit49b73ba1ab4be9993532bdecaf14e74f45eca676 (patch)
treec79c26c3127f6de5edf1289ea7f838c25207c76c /parse.y
parent2898780aeac7ff0a456b6f380af2bc3a25a49d3b (diff)
fix "first location" bug
reported by devel at datenbrei dot de. The first location would overwrite the default value for a server, triggering the "`foo' rule specified more than once" error. This also needed a small tweak on how we match locations to avoid breaking other tests.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y19
1 files changed, 14 insertions, 5 deletions
diff --git a/parse.y b/parse.y
index def74b0..968670d 100644
--- a/parse.y
+++ b/parse.y
@@ -44,6 +44,7 @@ int check_block_code(int);
char *check_block_fmt(char*);
int check_strip_no(int);
int check_prefork_num(int);
+void advance_loc(void);
%}
@@ -140,11 +141,11 @@ locations : /* empty */
| locations location
;
-location : TLOCATION TSTRING '{' locopts '}' {
- loc->match = $2;
- if (++iloc == LOCLEN)
- errx(1, "too much location rules defined");
- loc++;
+location : TLOCATION { advance_loc(); } TSTRING '{' locopts '}' {
+ /* drop the starting '/' if any */
+ if (*$3 == '/')
+ memmove($3, $3+1, strlen($3));
+ loc->match = $3;
}
| error '}'
;
@@ -301,3 +302,11 @@ check_prefork_num(int n)
yyerror("invalid prefork number %d", n);
return n;
}
+
+void
+advance_loc(void)
+{
+ if (++iloc == LOCLEN)
+ errx(1, "too much location rules defined");
+ loc++;
+}