From: phk Date: Fri, 1 Aug 2008 12:44:53 +0000 (+0000) Subject: The compiler should not care about field order in director decls. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d259612d7682312888b1e4ec3782ec4e5af7215;p=varnish The compiler should not care about field order in director decls. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3060 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishtest/tests/v00007.vtc b/varnish-cache/bin/varnishtest/tests/v00007.vtc index 436ab099..2e1a4658 100644 --- a/varnish-cache/bin/varnishtest/tests/v00007.vtc +++ b/varnish-cache/bin/varnishtest/tests/v00007.vtc @@ -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 { diff --git a/varnish-cache/lib/libvcl/vcc_dir_random.c b/varnish-cache/lib/libvcl/vcc_dir_random.c index 43fa15f5..8f817199 100644 --- a/varnish-cache/lib/libvcl/vcc_dir_random.c +++ b/varnish-cache/lib/libvcl/vcc_dir_random.c @@ -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) { diff --git a/varnish-cache/lib/libvcl/vcc_dir_round_robin.c b/varnish-cache/lib/libvcl/vcc_dir_round_robin.c index 53edb6ca..71b5b363 100644 --- a/varnish-cache/lib/libvcl/vcc_dir_round_robin.c +++ b/varnish-cache/lib/libvcl/vcc_dir_round_robin.c @@ -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) {