r1301 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Sun Apr 1 17:33:56 CEST 2007


Author: phk
Date: 2007-04-01 17:33:56 +0200 (Sun, 01 Apr 2007)
New Revision: 1301

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
   trunk/varnish-cache/lib/libvcl/vcc_parse.c
   trunk/varnish-cache/lib/libvcl/vcc_token.c
   trunk/varnish-cache/lib/libvcl/vcc_token_defs.h
   trunk/varnish-cache/lib/libvcl/vcc_xref.c
Log:
Remove unused METHOD token.

Improve error handling for unterminated /* ... */ comments.

Add undocumented and unsupported facility for inline C source code
in VCL programs.  The syntax is "C{ getpid(); }C" and you are on
your own if you use this.



Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2007-04-01 09:34:28 UTC (rev 1300)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2007-04-01 15:33:56 UTC (rev 1301)
@@ -268,10 +268,10 @@
 	vcl_tnames['~'] = "'~'";
 	vcl_tnames[';'] = "';'";
 	vcl_tnames[CNUM] = "CNUM";
+	vcl_tnames[CSRC] = "CSRC";
 	vcl_tnames[CSTR] = "CSTR";
 	vcl_tnames[EOI] = "EOI";
 	vcl_tnames[ID] = "ID";
-	vcl_tnames[METHOD] = "METHOD";
 	vcl_tnames[T_ACL] = "acl";
 	vcl_tnames[T_BACKEND] = "backend";
 	vcl_tnames[T_CAND] = "&&";

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2007-04-01 09:34:28 UTC (rev 1300)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2007-04-01 15:33:56 UTC (rev 1301)
@@ -97,7 +97,7 @@
 
 # Other token identifiers
 #
-set extras {ID VAR CNUM CSTR EOI METHOD}
+set extras {ID VAR CNUM CSTR EOI CSRC}
 
 #----------------------------------------------------------------------
 # Boilerplate warning for all generated files.

Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_parse.c	2007-04-01 09:34:28 UTC (rev 1300)
+++ trunk/varnish-cache/lib/libvcl/vcc_parse.c	2007-04-01 15:33:56 UTC (rev 1301)
@@ -487,6 +487,12 @@
 			tl->indent -= INDENT;
 			Fb(tl, 1, "}\n");
 			return;
+		case CSRC:
+			Fb(tl, 1, "%.*s\n",
+			    tl->t->e - (tl->t->b + 2),
+			    tl->t->b + 1);
+			vcc_NextToken(tl);
+			break;
 		case EOI:
 			vsb_printf(tl->sb,
 			    "End of input while in compound statement\n");

Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c	2007-04-01 09:34:28 UTC (rev 1300)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c	2007-04-01 15:33:56 UTC (rev 1301)
@@ -49,6 +49,8 @@
 
 	if (t->tok == EOI)
 		vsb_printf(tl->sb, "end of input");
+	else if (t->tok == CSRC)
+		vsb_printf(tl->sb, "C{ ... }C");
 	else
 		vsb_printf(tl->sb, "'%.*s'", PF(t));
 }
@@ -71,8 +73,6 @@
 
 	lin = 1;
 	pos = 0;
-	if (t->tok == METHOD)
-		return;
 	sp = t->src;
 	f = sp->name;
 	b = sp->b;
@@ -315,14 +315,18 @@
 
 		/* Skip C-style comments */
 		if (*p == '/' && p[1] == '*') {
-			p += 2;
-			for (p += 2; p < sp->e; p++) {
-				if (*p == '*' && p[1] == '/') {
-					p += 2;
+			for (q += 2; q < sp->e; q++) {
+				if (*q == '*' && q[1] == '/') {
+					p = q + 2;
 					break;
 				}
 			}
-			continue;
+			if (q < sp->e)
+				continue;
+			vcc_AddToken(tl, EOI, p, p + 2);
+			vsb_printf(tl->sb, "Unterminated /* ... */ comment, starting at\n");
+			vcc_ErrWhere(tl, tl->t);
+			return;
 		}
 
 		/* Skip C++-style comments */
@@ -332,6 +336,25 @@
 			continue;
 		}
 
+		/* Recognize inline C-code */
+		if (*p == 'C' && p[1] == '{') {
+			for (q = p + 2; q < sp->e; q++) {
+				if (*q == '}' && q[1] == 'C') {
+					vcc_AddToken(tl, CSRC, p, q + 2);
+					p = q + 2;
+					break;
+				}
+			}
+			if (q < sp->e)
+				continue;
+			vcc_AddToken(tl, EOI, p, p + 2);
+			vsb_printf(tl->sb,
+			    "Unterminated inline C source, starting at\n");
+			vcc_ErrWhere(tl, tl->t);
+			return;
+		}
+	
+
 		/* Match for the fixed tokens (see token.tcl) */
 		u = vcl_fixed_token(p, &q);
 		if (u != 0) {

Modified: trunk/varnish-cache/lib/libvcl/vcc_token_defs.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token_defs.h	2007-04-01 09:34:28 UTC (rev 1300)
+++ trunk/varnish-cache/lib/libvcl/vcc_token_defs.h	2007-04-01 15:33:56 UTC (rev 1301)
@@ -34,4 +34,4 @@
 #define CNUM 152
 #define CSTR 153
 #define EOI 154
-#define METHOD 155
+#define CSRC 155

Modified: trunk/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_xref.c	2007-04-01 09:34:28 UTC (rev 1300)
+++ trunk/varnish-cache/lib/libvcl/vcc_xref.c	2007-04-01 15:33:56 UTC (rev 1301)
@@ -149,11 +149,6 @@
 		nerr++;
 
 		type = vcc_typename(tl, r);
-		if (r->defcnt == 0 && r->name->tok == METHOD) {
-			vsb_printf(tl->sb,
-			    "No definition for method %.*s\n", PF(r->name));
-			continue;
-		}
 
 		if (r->defcnt == 0) {
 			vsb_printf(tl->sb,




More information about the varnish-commit mailing list