r5132 - trunk/varnish-cache/lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Thu Aug 26 11:30:18 CEST 2010


Author: phk
Date: 2010-08-26 11:30:18 +0200 (Thu, 26 Aug 2010)
New Revision: 5132

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_action.c
   trunk/varnish-cache/lib/libvcl/vcc_expr.c
Log:
Get don't subtract when addition is required.



Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c	2010-08-26 08:48:49 UTC (rev 5131)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c	2010-08-26 09:30:18 UTC (rev 5132)
@@ -65,37 +65,25 @@
 static void
 parse_error(struct vcc *tl)
 {
-	const struct var *vp;
+	int paran = 0;
 
 	vcc_NextToken(tl);
-	if (tl->t->tok == ID) {
-		vp = vcc_FindVar(tl, tl->t, 0, "cannot be read");
-		ERRCHK(tl);
-		assert(vp != NULL);
-		if (vp->fmt == INT) {
-			Fb(tl, 1, "VRT_error(sp, %s", vp->rname);
-			vcc_NextToken(tl);
-		} else {
-			Fb(tl, 1, "VRT_error(sp, 0");
-		}
-	} else if (tl->t->tok == CNUM) {
-		Fb(tl, 1, "VRT_error(sp, %u", vcc_UintVal(tl));
-	} else
-		Fb(tl, 1, "VRT_error(sp, 0");
-	if (tl->t->tok == CSTR) {
-		Fb(tl, 0, ", %.*s", PF(tl->t));
+	if (tl->t->tok == '(') {
+		paran = 1;
 		vcc_NextToken(tl);
-	} else if (tl->t->tok == ID) {
-		Fb(tl, 0, ", ");
-		if (!vcc_StringVal(tl)) {
-			ERRCHK(tl);
-			vcc_ExpectedStringval(tl);
-			return;
-		}
+	}
+	Fb(tl, 1, "VRT_error(sp,\n");
+	vcc_Expr(tl, INT);
+	if (tl->t->tok == ',') {
+		Fb(tl, 1, ",\n");
+		vcc_NextToken(tl);
+		vcc_Expr(tl, STRING);
 	} else {
-		Fb(tl, 0, ", (const char *)0");
+		Fb(tl, 1, ", 0\n");
 	}
-	Fb(tl, 0, ");\n");
+	if (paran)
+		SkipToken(tl, ')');
+	Fb(tl, 1, ");\n");
 	Fb(tl, 1, "VRT_done(sp, VCL_RET_ERROR);\n");
 }
 

Modified: trunk/varnish-cache/lib/libvcl/vcc_expr.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_expr.c	2010-08-26 08:48:49 UTC (rev 5131)
+++ trunk/varnish-cache/lib/libvcl/vcc_expr.c	2010-08-26 09:30:18 UTC (rev 5132)
@@ -480,6 +480,7 @@
 {
 	struct expr *e2;
 	enum var_type f2, f3;
+	struct token *tk;
 
 	*e = NULL;
 	vcc_expr4(tl, e, fmt);
@@ -493,10 +494,11 @@
 		return;
 	}
 	while (tl->t->tok == '+' || tl->t->tok == '-') {
+		tk = tl->t;
 		vcc_NextToken(tl);
 		vcc_expr4(tl, &e2, f2);
 		ERRCHK(tl);
-		if (tl->t->tok == '+')
+		if (tk->tok == '+')
 			*e = vcc_expr_edit(f3, "(\v1+\v2)", *e, e2);
 		else
 			*e = vcc_expr_edit(f3, "(\v1-\v2)", *e, e2);




More information about the varnish-commit mailing list