r1388 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Wed May 9 09:59:22 CEST 2007


Author: phk
Date: 2007-05-09 09:59:22 +0200 (Wed, 09 May 2007)
New Revision: 1388

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
Log:
Sanitize generation of white-space in generated C code.

(It is my intent that the compiled-to C-source should have sensible
readability)



Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2007-05-06 18:57:26 UTC (rev 1387)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2007-05-09 07:59:22 UTC (rev 1388)
@@ -134,7 +134,7 @@
 	va_list ap;
 
 	if (indent)
-		vsb_printf(tl->fh, "%*.*s", tl->indent, tl->indent, "");
+		vsb_printf(tl->fh, "%*.*s", tl->hindent, tl->hindent, "");
 	va_start(ap, fmt);
 	vsb_vprintf(tl->fh, fmt, ap);
 	va_end(ap);
@@ -171,7 +171,7 @@
 	va_list ap;
 
 	if (indent)
-		vsb_printf(tl->fi, "%*.*s", tl->indent, tl->indent, "");
+		vsb_printf(tl->fi, "%*.*s", tl->iindent, tl->iindent, "");
 	va_start(ap, fmt);
 	vsb_vprintf(tl->fi, fmt, ap);
 	va_end(ap);
@@ -183,7 +183,7 @@
 	va_list ap;
 
 	if (indent)
-		vsb_printf(tl->ff, "%*.*s", tl->indent, tl->indent, "");
+		vsb_printf(tl->ff, "%*.*s", tl->findent, tl->findent, "");
 	va_start(ap, fmt);
 	vsb_vprintf(tl->ff, fmt, ap);
 	va_end(ap);
@@ -301,8 +301,8 @@
 	struct source *sp;
 	const char *p;
 
-	Fh(tl, 0, "#define VGC_NREFS %u\n", tl->cnt + 1);
-	Fc(tl, 0, "static struct vrt_ref VGC_ref[VGC_NREFS] = {\n");
+	Fh(tl, 0, "\n#define VGC_NREFS %u\n", tl->cnt + 1);
+	Fc(tl, 0, "\nstatic struct vrt_ref VGC_ref[VGC_NREFS] = {\n");
 	lin = 1;
 	pos = 0;
 	sp = 0;
@@ -590,7 +590,8 @@
 	tl->sb = sb;
 
 	vcl_output_lang_h(tl->fh);
-	Fh(tl, 0, "extern struct VCL_conf VCL_conf;\n");
+	Fh(tl, 0, "\n/* ---===### VCC generated below here ###===---*/\n");
+	Fh(tl, 0, "\nextern struct VCL_conf VCL_conf;\n");
 
 	Fi(tl, 0, "\tVRT_alloc_backends(&VCL_conf);\n");
 
@@ -639,14 +640,14 @@
 
 	/* Emit method functions */
 	for (i = 0; i < N_METHODS; i++) {
-		Fc(tl, 1, "static int\n");
+		Fc(tl, 1, "\nstatic int\n");
 		Fc(tl, 1, "VGC_function_%s (struct sess *sp)\n",
 		    method_tab[i].name);
 		vsb_finish(tl->fm[i]);
 		/* XXX: check vsb_overflowed ? */
 		Fc(tl, 1, "{\n");
 		Fc(tl, 1, "%s", vsb_data(tl->fm[i]));
-		Fc(tl, 1, "}\n\n");
+		Fc(tl, 1, "}\n");
 	}
 
 	LocTable(tl);

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2007-05-06 18:57:26 UTC (rev 1387)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2007-05-09 07:59:22 UTC (rev 1388)
@@ -67,6 +67,9 @@
 	struct source		*src;
 	struct token		*t;
 	int			indent;
+	int			hindent;
+	int			iindent;
+	int			findent;
 	unsigned		cnt;
 	struct vsb		*fc, *fh, *fi, *ff, *fb;
 	struct vsb		*fm[N_METHODS];




More information about the varnish-commit mailing list