[6.0] e464a940a Move the "loop" word up to global level, so it works everywhere.
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Oct 18 09:21:05 UTC 2023
commit e464a940a444858c1e75179279990f11874a9a54
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Oct 15 08:02:29 2020 +0000
Move the "loop" word up to global level, so it works everywhere.
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index c7350df0a..c970543ec 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -306,6 +306,7 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv,
char *e, *p, *q, *f, *buf;
int nest_brace;
int tn;
+ unsigned n, m;
const struct cmds *cp;
AN(spec);
@@ -414,6 +415,24 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv,
}
}
+
+/* SECTION: loop loop
+ *
+ * loop NUMBER STRING
+ * Process STRING as a specification, NUMBER times.
+ *
+ * This works inside all specification strings
+ */
+
+ if (!strcmp(token_s[0], "loop")) {
+ n = strtoul(token_s[1], NULL, 0);
+ for (m = 0; m < n; m++) {
+ vtc_log(vl, 4, "Loop #%u", m);
+ parse_string(token_s[2], cmd, priv, vl);
+ }
+ continue;
+ }
+
for (cp = cmd; cp->name != NULL; cp++)
if (!strcmp(token_s[0], cp->name))
break;
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 0ea454a83..9cd701f8f 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -1616,29 +1616,6 @@ cmd_http_accept(CMD_ARGS)
vtc_log(vl, 3, "Accepted socket fd is %d", hp->fd);
}
-/* SECTION: client-server.spec.loop
- *
- * loop NUMBER STRING
- * Process STRING as a specification, NUMBER times.
- */
-
-static void
-cmd_http_loop(CMD_ARGS)
-{
- struct http *hp;
- unsigned n, m;
-
- CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
- AN(av[1]);
- AN(av[2]);
- AZ(av[3]);
- n = strtoul(av[1], NULL, 0);
- for (m = 1 ; m <= n; m++) {
- vtc_log(vl, 4, "Loop #%u", m);
- parse_string(av[2], cmd, hp, vl);
- }
-}
-
/* SECTION: client-server.spec.fatal
*
* fatal|non_fatal
@@ -1820,7 +1797,6 @@ const struct cmds http_cmds[] = {
/* spec */
CMD_HTTP(fatal)
- CMD_HTTP(loop)
CMD_HTTP(non_fatal)
/* body */
More information about the varnish-commit
mailing list