[master] 1a02b4744 Add a vcc_IsFlagRaw() for when the tokens are not on tl->tokens.

Poul-Henning Kamp phk at FreeBSD.org
Tue Apr 13 17:23:05 UTC 2021


commit 1a02b4744f3b3777c800ced3d74c5b21f316abd0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 13 17:20:08 2021 +0000

    Add a vcc_IsFlagRaw() for when the tokens are not on tl->tokens.

diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 995399ab6..7d01ae9c8 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -432,6 +432,7 @@ void vcc_ByteVal(struct vcc *, double *);
 void vcc_Duration(struct vcc *tl, double *);
 unsigned vcc_UintVal(struct vcc *tl);
 int vcc_IsFlag(struct vcc *tl);
+int vcc_IsFlagRaw(struct vcc *, const struct token *, const struct token *);
 
 /* vcc_var.c */
 sym_wildcard_t vcc_Var_Wildcard;
diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c
index 6ecee46fb..d60d932cd 100644
--- a/lib/libvcc/vcc_utils.c
+++ b/lib/libvcc/vcc_utils.c
@@ -361,18 +361,27 @@ vcc_ByteVal(struct vcc *tl, double *d)
 /*--------------------------------------------------------------------*/
 
 int
-vcc_IsFlag(struct vcc *tl)
+vcc_IsFlagRaw(struct vcc *tl, const struct token *t1, const struct token *t2)
 {
-	struct token *sign;
 
-	if (tl->t->tok != '-' && tl->t->tok != '+')
+	if (t1->tok != '-' && t1->tok != '+')
 		return (-1);
-	sign = tl->t;
-	vcc_NextToken(tl);
-	if (tl->t->b != sign->e) {
+	if (t2->b != t1->e) {
 		VSB_cat(tl->sb, "Expected a flag at:\n");
-		vcc_ErrWhere(tl, sign);
+		vcc_ErrWhere(tl, t1);
 		return (-1);
 	}
-	return (sign->tok == '+' ? 1 : 0);
+	return (t1->tok == '+' ? 1 : 0);
+}
+
+int
+vcc_IsFlag(struct vcc *tl)
+{
+	int retval;
+
+
+	retval = vcc_IsFlagRaw(tl, tl->t, VTAILQ_NEXT(tl->t, list));
+	if (retval >= 0)
+		vcc_NextToken(tl);
+	return (retval);
 }


More information about the varnish-commit mailing list