Skip to content

Commit afdff6e

Browse files
committed
cache_ban: refactor: split out ban_add_spec
Just moving code, no change
1 parent 145b38a commit afdff6e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

bin/varnishd/cache/cache_ban_build.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,20 @@ ban_parse_oper(const char *p)
225225
/*--------------------------------------------------------------------
226226
* Add a (and'ed) test-condition to a ban
227227
*/
228+
static const char *
229+
ban_add_spec(struct ban_proto *bp, const struct pvar *pv, int op, const char *a3)
230+
{
231+
232+
assert(! BANS_HAS_ARG2_DOUBLE(pv->tag));
233+
234+
ban_add_lump(bp, a3, strlen(a3) + 1);
235+
VSB_putc(bp->vsb, op);
236+
237+
if (! BANS_HAS_ARG2_SPEC(op))
238+
return (NULL);
239+
240+
return (ban_parse_regexp(bp, a3));
241+
}
228242

229243
const char *
230244
BAN_AddTest(struct ban_proto *bp,
@@ -274,17 +288,8 @@ BAN_AddTest(struct ban_proto *bp,
274288
"expected conditional (%s) got \"%s\"",
275289
arg_operhelp[BAN_ARGIDX(pv->tag)], a2));
276290

277-
if ((pv->flag & BANS_FLAG_DURATION) == 0) {
278-
assert(! BANS_HAS_ARG2_DOUBLE(pv->tag));
279-
280-
ban_add_lump(bp, a3, strlen(a3) + 1);
281-
VSB_putc(bp->vsb, op);
282-
283-
if (! BANS_HAS_ARG2_SPEC(op))
284-
return (NULL);
285-
286-
return (ban_parse_regexp(bp, a3));
287-
}
291+
if ((pv->flag & BANS_FLAG_DURATION) == 0)
292+
return (ban_add_spec(bp, pv, op, a3));
288293

289294
assert(pv->flag & BANS_FLAG_DURATION);
290295
assert(BANS_HAS_ARG2_DOUBLE(pv->tag));

0 commit comments

Comments
 (0)