diff options
author | Omar Polo <op@omarpolo.com> | 2021-02-10 16:37:08 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-02-10 16:37:08 +0000 |
commit | 49b73ba1ab4be9993532bdecaf14e74f45eca676 (patch) | |
tree | c79c26c3127f6de5edf1289ea7f838c25207c76c /parse.y | |
parent | 2898780aeac7ff0a456b6f380af2bc3a25a49d3b (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.y | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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++; +} |