r1618 - trunk/varnish-cache/lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Mon Jul 2 15:30:06 CEST 2007
Author: phk
Date: 2007-07-02 15:30:06 +0200 (Mon, 02 Jul 2007)
New Revision: 1618
Modified:
trunk/varnish-cache/lib/libvcl/vcc_action.c
Log:
Improve assignments a bit
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-07-02 13:28:03 UTC (rev 1617)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2007-07-02 13:30:06 UTC (rev 1618)
@@ -94,6 +94,16 @@
/*--------------------------------------------------------------------*/
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)
{
struct var *vp;
@@ -154,38 +164,31 @@
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 @@
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);
More information about the varnish-commit
mailing list