r5136 - trunk/varnish-cache/lib/libvcl
phk at varnish-cache.org
phk at varnish-cache.org
Thu Aug 26 17:44:18 CEST 2010
Author: phk
Date: 2010-08-26 17:44:18 +0200 (Thu, 26 Aug 2010)
New Revision: 5136
Modified:
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_expr.c
trunk/varnish-cache/lib/libvcl/vcc_types.h
Log:
More whitespace and string-casting magic.
Remove some debugging that snug into last commit
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2010-08-26 13:49:35 UTC (rev 5135)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2010-08-26 15:44:18 UTC (rev 5136)
@@ -439,7 +439,6 @@
vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
{
struct token *t_field;
- struct token *t_first;
struct token *t_host = NULL;
struct token *t_port = NULL;
struct token *t_hosthdr = NULL;
@@ -462,7 +461,6 @@
"?max_connections",
"?saintmode_threshold",
NULL);
- t_first = tl->t;
SkipToken(tl, '{');
Modified: trunk/varnish-cache/lib/libvcl/vcc_expr.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_expr.c 2010-08-26 13:49:35 UTC (rev 5135)
+++ trunk/varnish-cache/lib/libvcl/vcc_expr.c 2010-08-26 15:44:18 UTC (rev 5136)
@@ -225,7 +225,6 @@
vsb_delete(e->vsb);
FREE_OBJ(e);
}
-
/*--------------------------------------------------------------------
* We want to get the indentation right in the emitted C code so we have
* to represent it symbolically until we are ready to render.
@@ -247,40 +246,12 @@
* XXX: check line lengths in edit, should pass indent in for this
*/
-static void
-vcc_show(const char *p)
-{
-
- fprintf(stderr, "<");
- for (; *p; p++) {
- if (*p == '\n')
- fprintf(stderr, "\\n");
- else if (*p == '\v')
- fprintf(stderr, "\\v");
- else
- fprintf(stderr, "%c", *p);
- }
- fprintf(stderr, ">\n");
-}
-
-
static struct expr *
vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, struct expr *e2)
{
struct expr *e;
int nl = 1;
- fprintf(stderr, "EDIT:");
- vcc_show(p);
- if (e1 != NULL) {
- fprintf(stderr, "E1:");
- vcc_show(vsb_data(e1->vsb));
- }
- if (e2 != NULL) {
- fprintf(stderr, "E2:");
- vcc_show(vsb_data(e2->vsb));
- }
-
e = vcc_new_expr();
while (*p != '\0') {
if (*p == '\n') {
@@ -320,8 +291,6 @@
vcc_delete_expr(e1);
vcc_delete_expr(e2);
e->fmt = fmt;
- fprintf(stderr, "RESULT:");
- vcc_show(vsb_data(e->vsb));
return (e);
}
@@ -337,17 +306,20 @@
for (i = 0; i < ind; i++)
vsb_cat(d, " ");
- for (p = vsb_data(e1->vsb); *p != '\0'; p++) {
+ p = vsb_data(e1->vsb);
+ while (*p != '\0') {
if (*p == '\n') {
vsb_putc(d, '\n');
if (p[1] != '\0') {
for (i = 0; i < ind; i++)
vsb_cat(d, " ");
}
+ p++;
continue;
}
if (*p != '\v') {
vsb_putc(d, *p);
+ p++;
continue;
}
p++;
@@ -357,6 +329,7 @@
default:
assert(__LINE__ == 0);
}
+ p++;
}
}
@@ -364,6 +337,30 @@
*/
static void
+vcc_expr_tostring(struct expr **e, enum var_type fmt)
+{
+ const char *p;
+
+ AN(fmt == STRING || fmt == STRING_LIST);
+
+ p = NULL;
+ switch((*e)->fmt) {
+ case BACKEND: p = "VRT_backend_string(sp, \v1)"; break;
+ case INT: p = "VRT_int_string(sp, \v1)"; break;
+ case IP: p = "VRT_IP_string(sp, \v1)"; break;
+ case TIME: p = "VRT_time_string(sp, \v1)"; break;
+ case DURATION: p = "VRT_double_string(sp, \v1)"; break;
+ /* XXX: should have "s" suffix ? */
+ default: break;
+ }
+ if (p != NULL)
+ *e = vcc_expr_edit(fmt, p, *e, NULL);
+}
+
+/*--------------------------------------------------------------------
+ */
+
+static void
hack_regsub(struct vcc *tl, struct expr **e, int all)
{
struct expr *e2;
@@ -391,14 +388,14 @@
/*--------------------------------------------------------------------
* SYNTAX:
- * Expr5:
+ * Expr4:
* '(' Expr0 ')'
* CNUM
* CSTR
*/
static void
-vcc_expr5(struct vcc *tl, struct expr **e, enum var_type fmt)
+vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
{
struct expr *e1, *e2;
const struct symbol *sym;
@@ -502,34 +499,6 @@
}
/*--------------------------------------------------------------------
- */
-static void
-vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
-{
- const char *p;
-
- *e = NULL;
- vcc_expr5(tl, e, fmt);
- ERRCHK(tl);
- if (fmt == STRING || fmt == STRING_LIST) {
- p = NULL;
- switch((*e)->fmt) {
- case BACKEND: p = "VRT_backend_string(sp, \v1)"; break;
- case INT: p = "VRT_int_string(sp, \v1)"; break;
- case IP: p = "VRT_IP_string(sp, \v1)"; break;
- case TIME: p = "VRT_time_string(sp, \v1)"; break;
- case DURATION: p = "VRT_double_string(sp, \v1)"; break;
- /* XXX: should have "s" suffix ? */
- default: break;
- }
- if (p != NULL) {
- *e = vcc_expr_edit(fmt, p, *e, NULL);
- return;
- }
- }
-}
-
-/*--------------------------------------------------------------------
* SYNTAX:
* Expr3:
* Expr4 { {'*'|'/'} Expr4 } *
@@ -577,6 +546,7 @@
{
struct expr *e2;
enum var_type f2;
+ struct token *tk;
*e = NULL;
vcc_expr_mul(tl, e, fmt);
@@ -584,11 +554,13 @@
f2 = (*e)->fmt;
if (fmt == STRING_LIST && f2 == STRING) {
- if (f2 == STRING)
- (*e)->fmt = STRING_LIST;
+ (*e)->fmt = STRING_LIST;
while (tl->t->tok == '+') {
vcc_NextToken(tl);
vcc_expr_mul(tl, &e2, STRING);
+ if (e2->fmt != STRING && e2->fmt != STRING_LIST)
+ vcc_expr_tostring(&e2, f2);
+ assert(e2->fmt == STRING || e2->fmt == STRING_LIST);
*e = vcc_expr_edit(STRING_LIST, "\v1,\n\v2", *e, e2);
}
return;
@@ -599,7 +571,10 @@
while (tl->t->tok == '+') {
vcc_NextToken(tl);
vcc_expr_mul(tl, &e2, STRING);
- assert(e2->fmt == STRING);
+ if (e2->fmt != STRING && e2->fmt != STRING_LIST)
+ vcc_expr_tostring(&e2, f2);
+
+ assert(e2->fmt == STRING || e2->fmt == STRING_LIST);
*e = vcc_expr_edit(STRING, "\v1,\n\v2", *e, e2);
}
*e = vcc_expr_edit(STRING, "\v1, vrt_magic_string_end)",
@@ -616,11 +591,12 @@
}
while (tl->t->tok == '+' || tl->t->tok == '-') {
+ tk = tl->t;
vcc_NextToken(tl);
vcc_expr_mul(tl, &e2, f2);
assert(e2->fmt == f2);
ERRCHK(tl);
- if (tl->t->tok == '+')
+ if (tk->tok == '+')
*e = vcc_expr_edit(f2, "(\v1+\v2)", *e, e2);
else
*e = vcc_expr_edit(f2, "(\v1-\v2)", *e, e2);
@@ -756,12 +732,6 @@
break;
}
}
- if (fmt == VOID || fmt != (*e)->fmt) {
- vsb_printf(tl->sb, "WANT: %s has %s next %.*s (%s)\n",
- vcc_Type(fmt), vcc_Type((*e)->fmt),
- PF(tl->t), vsb_data((*e)->vsb));
- tl->err = 1;
- }
}
/*--------------------------------------------------------------------
@@ -804,14 +774,18 @@
*e = NULL;
vcc_expr_cand(tl, e, fmt);
ERRCHK(tl);
- if ((*e)->fmt != BOOL)
+ if (fmt == STRING || fmt == STRING_LIST)
+ vcc_expr_tostring(e, fmt);
+ if ((*e)->fmt != BOOL || tl->t->tok != T_COR)
return;
+ *e = vcc_expr_edit(BOOL, "(\v+\n\v1", *e, NULL);
while (tl->t->tok == T_COR) {
vcc_NextToken(tl);
vcc_expr_cand(tl, &e2, fmt);
ERRCHK(tl);
- *e = vcc_expr_edit(BOOL, "(\v1||\v2)", *e, e2);
+ *e = vcc_expr_edit(BOOL, "\v1\v-\n||\v+\n\v2", *e, e2);
}
+ *e = vcc_expr_edit(BOOL, "\v1\v-\n)", *e, NULL);
}
/*--------------------------------------------------------------------
Modified: trunk/varnish-cache/lib/libvcl/vcc_types.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_types.h 2010-08-26 13:49:35 UTC (rev 5135)
+++ trunk/varnish-cache/lib/libvcl/vcc_types.h 2010-08-26 15:44:18 UTC (rev 5136)
@@ -28,6 +28,7 @@
* $Id$
*/
+/*lint -save -e525 -e539 */
VCC_TYPE(VOID)
VCC_TYPE(BACKEND)
VCC_TYPE(BOOL)
@@ -39,3 +40,4 @@
VCC_TYPE(IP)
VCC_TYPE(HEADER)
VCC_TYPE(REAL)
+/*lint -restore */
More information about the varnish-commit
mailing list