r3235 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Mon Sep 29 10:11:06 CEST 2008


Author: phk
Date: 2008-09-29 10:11:06 +0200 (Mon, 29 Sep 2008)
New Revision: 3235

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
   trunk/varnish-cache/lib/libvcl/vcc_token.c
Log:
Split vcc_Coord() function out from vcc_ErrWhere(), to give a set
of source coordinates in human readable form in a vsb.



Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2008-09-29 07:32:26 UTC (rev 3234)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2008-09-29 08:11:06 UTC (rev 3235)
@@ -203,6 +203,7 @@
 void vcc_ExpectedStringval(struct tokenlist *tl);
 
 /* vcc_token.c */
+void vcc_Coord(const struct tokenlist *tl, struct vsb *vsb, const struct token *t);
 void vcc_ErrToken(const struct tokenlist *tl, const struct token *t);
 void vcc_ErrWhere(struct tokenlist *tl, const struct token *t);
 void vcc__Expect(struct tokenlist *tl, unsigned tok, int line);

Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c	2008-09-29 07:32:26 UTC (rev 3234)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c	2008-09-29 08:11:06 UTC (rev 3235)
@@ -68,32 +68,52 @@
 	tl->err = 1;
 }
 
-void
-vcc_ErrWhere(struct tokenlist *tl, const struct token *t)
+static void
+vcc_icoord(struct vsb *vsb, const struct token *t, const char **ll)
 {
-	unsigned lin, pos, x, y;
-	const char *p, *l, *f, *b, *e;
+	unsigned lin, pos;
+	const char *p, *b;
 	struct source *sp;
 
 	lin = 1;
 	pos = 0;
 	sp = t->src;
-	f = sp->name;
 	b = sp->b;
-	e = sp->e;
-	for (l = p = b; p < t->b; p++) {
+	for (p = b; p < t->b; p++) {
 		if (*p == '\n') {
 			lin++;
 			pos = 0;
-			l = p + 1;
+			if (ll != NULL)
+				*ll = p + 1;
 		} else if (*p == '\t') {
 			pos &= ~7;
 			pos += 8;
 		} else
 			pos++;
 	}
-	vsb_printf(tl->sb, "(%s Line %d Pos %d)\n", f, lin, pos + 1);
+	vsb_printf(vsb, "(%s Line %d Pos %d)", sp->name, lin, pos + 1);
+}
+
+void
+vcc_Coord(const struct tokenlist *tl, struct vsb *vsb, const struct token *t)
+{
+
+	if (t == NULL)
+		t = tl->t;
+	vcc_icoord(vsb, t, NULL);
+}
+
+void
+vcc_ErrWhere(struct tokenlist *tl, const struct token *t)
+{
+	unsigned x, y;
+	const char *p, *l, *e;
+
+	vcc_icoord(tl->sb, t, &l);
+	vsb_printf(tl->sb, "\n");
+	
 	x = y = 0;
+	e = t->src->e;
 	for (p = l; p < e && *p != '\n'; p++) {
 		if (*p == '\t') {
 			y &= ~7;




More information about the varnish-commit mailing list