r1337 - in branches/1.0: . lib/libvcl

des at projects.linpro.no des at projects.linpro.no
Thu Apr 19 16:50:59 CEST 2007


Author: des
Date: 2007-04-19 16:50:59 +0200 (Thu, 19 Apr 2007)
New Revision: 1337

Modified:
   branches/1.0/
   branches/1.0/lib/libvcl/vcc_parse.c
Log:
 r37070 at cat (orig r1294):  phk | 2007-03-31 20:21:14 +0200
 Better syntax checking of "set" statements.
 
 Remove inapplicable comment.
 



Property changes on: branches/1.0
___________________________________________________________________
Name: svk:merge
   - d4fa192b-c00b-0410-8231-f00ffab90ce4:/trunk/varnish-cache:1293
   + d4fa192b-c00b-0410-8231-f00ffab90ce4:/trunk/varnish-cache:1294

Modified: branches/1.0/lib/libvcl/vcc_parse.c
===================================================================
--- branches/1.0/lib/libvcl/vcc_parse.c	2007-04-19 14:50:58 UTC (rev 1336)
+++ branches/1.0/lib/libvcl/vcc_parse.c	2007-04-19 14:50:59 UTC (rev 1337)
@@ -29,37 +29,6 @@
  * $Id$
  */
 
-/*
- * XXX:
- *	generate interface structure
- *
- * XXX:
- *	Better error messages, throughout.
- *	>It also accured to me that we could link the errors to the error
- *	>documentation.
- *	>
- *	>Unreferenced  function 'request_policy', first mention is
- *	>         Line 8 Pos 4
- *	>         sub request_policy {
- *	>         ----##############--
- *	>Read more about this type of error:
- *	>http://varnish/doc/error.html#Unreferenced%20function
- *	>
- *	>
- *	>         Unknown variable 'obj.bandwidth'
- *	>         At: Line 88 Pos 12
- *	>                 if (obj.bandwidth < 1 kb/h) {
- *	>         ------------#############------------
- *	>Read more about this type of error:
- *	>http://varnish/doc/error.html#Unknown%20variable
- *
- * XXX:
- *	Create proper tmp filenames for .h, .c and .o
- *
- * XXX:
- *	and all the rest...
- */
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
@@ -514,7 +483,7 @@
 {
 	unsigned a;
 	struct var *vp;
-	struct token *at;
+	struct token *at, *vt;
 
 	at = tl->t;
 	vcc_NextToken(tl);
@@ -569,6 +538,7 @@
 		return;
 	case T_SET:
 		ExpectErr(tl, VAR);
+		vt = tl->t;
 		vp = FindVar(tl, tl->t, vcc_vars);
 		ERRCHK(tl);
 		assert(vp != NULL);
@@ -582,18 +552,35 @@
 		case FLOAT:
 			if (tl->t->tok != '=')
 				Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b);
-			a = tl->t->tok;
+			at = tl->t;
 			vcc_NextToken(tl);
-			if (a == T_MUL || a == T_DIV)
+			switch (at->tok) {
+			case T_MUL:
+			case T_DIV:
 				Fb(tl, 0, "%g", DoubleVal(tl));
-			else if (vp->fmt == TIME)
-				TimeVal(tl);
-			else if (vp->fmt == SIZE)
-				SizeVal(tl);
-			else if (vp->fmt == RATE)
-				RateVal(tl);
-			else
-				Fb(tl, 0, "%g", DoubleVal(tl));
+				break;
+			case T_INCR:
+			case T_DECR:
+			case '=':
+				if (vp->fmt == TIME)
+					TimeVal(tl);
+				else if (vp->fmt == SIZE)
+					SizeVal(tl);
+				else if (vp->fmt == RATE)
+					RateVal(tl);
+				else if (vp->fmt == FLOAT)
+					Fb(tl, 0, "%g", DoubleVal(tl));
+				else {
+					vsb_printf(tl->sb, "Cannot assign this variable type.\n");
+					vcc_ErrWhere(tl, vt);
+					return;
+				}
+				break;
+			default:
+				vsb_printf(tl->sb, "Illegal assignment operator.\n");
+				vcc_ErrWhere(tl, at);
+				return;
+			}
 			Fb(tl, 0, ");\n");
 			break;
 #if 0	/* XXX: enable if we find a legit use */




More information about the varnish-commit mailing list