Commit c8bdf13d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

The compiler should not care about field order in director decls.



git-svn-id: http://www.varnish-cache.org/svn/trunk@3060 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent ce7806e8
......@@ -12,7 +12,7 @@ server s1 {
varnish v1 -vcl+backend {
director foo random {
{ .backend = s1; .weight = 1; }
{ .backend = s1; .weight = 1; }
{ .weight = 1; .backend = s1; }
}
sub vcl_recv {
......
......@@ -56,6 +56,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
int nbh, nelem;
struct fld_spec *fs;
unsigned u;
const char *first;
fs = vcc_FldSpec(tl, "!backend", "!weight", NULL);
......@@ -64,6 +65,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
PF(t_dir));
for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */
first = "";
t_be = tl->t;
vcc_ResetFldSpec(fs);
nbh = -1;
......@@ -78,7 +80,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
if (vcc_IdIs(t_field, "backend")) {
vcc_ParseBackendHost(tl, &nbh,
t_dir, t_policy, nelem);
Fc(tl, 0, " .host = &bh_%d,", nbh);
Fc(tl, 0, "%s .host = &bh_%d", first, nbh);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "weight")) {
ExpectErr(tl, CNUM);
......@@ -92,13 +94,14 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
vcc_ErrWhere(tl, tl->t);
return;
}
Fc(tl, 0, " .weight = %u", u);
Fc(tl, 0, "%s .weight = %u", first, u);
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
} else {
ErrInternal(tl);
}
first = ", ";
}
vcc_FieldsOk(tl, fs);
if (tl->err) {
......
......@@ -54,6 +54,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
struct token *t_field, *t_be;
int nbh, nelem;
struct fld_spec *fs;
const char *first;
fs = vcc_FldSpec(tl, "!backend", NULL);
......@@ -62,6 +63,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
PF(t_dir));
for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */
first = "";
t_be = tl->t;
vcc_ResetFldSpec(fs);
nbh = -1;
......@@ -76,11 +78,12 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
if (vcc_IdIs(t_field, "backend")) {
vcc_ParseBackendHost(tl, &nbh,
t_dir, t_policy, nelem);
Fc(tl, 0, " .host = &bh_%d,", nbh);
Fc(tl, 0, "%s .host = &bh_%d", first, nbh);
ERRCHK(tl);
} else {
ErrInternal(tl);
}
first = ", ";
}
vcc_FieldsOk(tl, fs);
if (tl->err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment