[master] 5a77330d9 libvcc: Fix STRING/STRANDS comparison without STRING folding
Nils Goroll
nils.goroll at uplex.de
Fri Aug 16 10:42:05 UTC 2024
commit 5a77330d95602171afdf81ea63c9266349224e40
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Aug 1 10:58:17 2024 +0200
libvcc: Fix STRING/STRANDS comparison without STRING folding
Fixes #4146
Reverts 42a7ecdd97a65a3f60408809e726e4160857fb26
Reverts the code change from b77b709510f1e1ff4792ac9bc9c3836d1a5249ec
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index afff5ce9d..cd4b03c2f 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -81,6 +81,13 @@ vcc_utype(vcc_type_t t)
return (t->name);
}
+static vcc_type_t
+vcc_stringstype(vcc_type_t t)
+{
+ return (t->stringform ? STRINGS : t);
+}
+
+
static void vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt);
static void vcc_expr_cor(struct vcc *tl, struct expr **e, vcc_type_t fmt);
static void vcc_expr_typecheck(struct vcc *tl, struct expr **e, vcc_type_t fmt,
@@ -1100,10 +1107,6 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt)
return;
}
}
-
- /* No concatenation, finalize string. */
- if ((*e)->fmt->stringform)
- vcc_expr_tostring(tl, e);
}
/*--------------------------------------------------------------------
@@ -1196,7 +1199,7 @@ cmp_string(struct vcc *tl, struct expr **e, const struct cmps *cp)
vcc_NextToken(tl);
vcc_expr_add(tl, &e2, STRINGS);
ERRCHK(tl);
- if (e2->fmt != STRINGS) {
+ if (vcc_stringstype(e2->fmt) != STRINGS) {
VSB_printf(tl->sb,
"Comparison of different types: %s '%.*s' %s\n",
vcc_utype((*e)->fmt), PF(tk), vcc_utype(e2->fmt));
@@ -1272,7 +1275,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, vcc_type_t fmt)
for (cp = vcc_cmps; cp->fmt != VOID; cp++) {
if (tl->t->tok != cp->token)
continue;
- if ((*e)->fmt != cp->fmt)
+ if (vcc_stringstype((*e)->fmt) != cp->fmt)
continue;
AN(cp->func);
cp->func(tl, e, cp);
More information about the varnish-commit
mailing list