From: phk Date: Mon, 2 Jul 2007 13:30:06 +0000 (+0000) Subject: Improve assignments a bit X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59978bb5dc0dfc2f8b50d9549be8b6d1ebe89273;p=varnish Improve assignments a bit git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1618 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/lib/libvcl/vcc_action.c b/varnish-cache/lib/libvcl/vcc_action.c index 54f35613..7294ecba 100644 --- a/varnish-cache/lib/libvcl/vcc_action.c +++ b/varnish-cache/lib/libvcl/vcc_action.c @@ -93,6 +93,16 @@ parse_error(struct tokenlist *tl) /*--------------------------------------------------------------------*/ +static void +illegal_assignment(struct tokenlist *tl, const char *type) +{ + + vsb_printf(tl->sb, "Invalid assignment operator "); + vcc_ErrToken(tl, tl->t); + vsb_printf(tl->sb, + " only '=' is legal for %s\n", type); +} + static void parse_set(struct tokenlist *tl) { @@ -154,38 +164,31 @@ parse_set(struct tokenlist *tl) break; #if 0 /* XXX: enable if we find a legit use */ case IP: - if (tl->t->tok == '=') { - vcc_NextToken(tl); - u = vcc_vcc_IpVal(tl); - Fb(tl, 0, "= %uU; /* %u.%u.%u.%u */\n", - u, - (u >> 24) & 0xff, - (u >> 16) & 0xff, - (u >> 8) & 0xff, - u & 0xff); - break; + if (tl->t->tok != '=') { + illegal_assignment(tl, "IP numbers"); + return; } - vsb_printf(tl->sb, "Invalid assignment operator "); - vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, - " only '=' is legal for IP numbers\n"); - vcc_ErrWhere(tl, tl->t); - return; + vcc_NextToken(tl); + u = vcc_vcc_IpVal(tl); + Fb(tl, 0, "= %uU; /* %u.%u.%u.%u */\n", + u, + (u >> 24) & 0xff, + (u >> 16) & 0xff, + (u >> 8) & 0xff, + u & 0xff); + break; #endif case BACKEND: - if (tl->t->tok == '=') { - vcc_NextToken(tl); - vcc_AddRef(tl, tl->t, R_BACKEND); - Fb(tl, 0, "VGC_backend_%.*s", PF(tl->t)); - vcc_NextToken(tl); - Fb(tl, 0, ");\n"); - break; + if (tl->t->tok != '=') { + illegal_assignment(tl, "backend"); + return; } - vsb_printf(tl->sb, "Invalid assignment operator "); - vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, - " only '=' is legal for backend\n"); - vcc_ErrWhere(tl, tl->t); + vcc_NextToken(tl); + vcc_AddRef(tl, tl->t, R_BACKEND); + Fb(tl, 0, "VGC_backend_%.*s", PF(tl->t)); + vcc_NextToken(tl); + Fb(tl, 0, ");\n"); + break; return; case HASH: ExpectErr(tl, T_INCR); @@ -193,6 +196,15 @@ parse_set(struct tokenlist *tl) vcc_StringVal(tl); Fb(tl, 0, ");\n"); return; + case STRING: + if (tl->t->tok != '=') { + illegal_assignment(tl, "strings"); + return; + } + vcc_NextToken(tl); + vcc_StringVal(tl); + Fb(tl, 0, ");\n"); + break; default: vsb_printf(tl->sb, "Assignments not possible for '%s'\n", vp->name);