[master] 79b6333 Use VSL_List2Tags in -ix option processing
Martin Blix Grydeland
martin at varnish-cache.org
Tue Oct 1 14:48:18 CEST 2013
commit 79b633308d440b60484de6a14227ba3f71f147c9
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue Sep 24 13:03:58 2013 +0200
Use VSL_List2Tags in -ix option processing
diff --git a/include/vapi/vapi_options.h b/include/vapi/vapi_options.h
index df3dc83..6eceaf6 100644
--- a/include/vapi/vapi_options.h
+++ b/include/vapi/vapi_options.h
@@ -66,8 +66,9 @@
)
#define VSL_OPT_i \
- VOPT("i:", "[-i tag]", "Include tag", \
- "Include log records of this tag in output. Multiple -i" \
+ VOPT("i:", "[-i taglist]", "Include tags", \
+ "Include log records of these tags in output. Taglist is" \
+ " a comma-separated list of tag globs. Multiple -i" \
" options may be given.\n" \
"\n" \
VSL_iI_PS \
@@ -109,9 +110,10 @@
)
#define VSL_OPT_x \
- VOPT("x:", "[-x tag]", "Exclude tag", \
- "Exclude log records of this tag in output. Multiple -x" \
- " options may be given." \
+ VOPT("x:", "[-x taglist]", "Exclude tags", \
+ "Exclude log records of these tags in output. Taglist is" \
+ " a comma-separated list of tag globs. Multiple -x" \
+ " options may be given.\n" \
)
#define VSL_OPT_X \
diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c
index efc2eb8..b32a470 100644
--- a/lib/libvarnishapi/vsl_arg.c
+++ b/lib/libvarnishapi/vsl_arg.c
@@ -212,42 +212,40 @@ VSLQ_Name2Grouping(const char *name, int l)
return (n);
}
+static void
+vsl_vbm_bitset(int bit, void *priv)
+{
+
+ vbit_set((struct vbitmap *)priv, bit);
+}
+
+static void
+vsl_vbm_bitclr(int bit, void *priv)
+{
+
+ vbit_clr((struct vbitmap *)priv, bit);
+}
+
static int
vsl_ix_arg(struct VSL_data *vsl, int opt, const char *arg)
{
- int i, l;
- const char *b, *e;
+ int i;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
vsl->flags |= F_SEEN_ixIX;
- for (b = arg; *b; b = e) {
- while (isspace(*b))
- b++;
- e = strchr(b, ',');
- if (e == NULL)
- e = strchr(b, '\0');
- l = e - b;
- if (*e == ',')
- e++;
- while (isspace(b[l - 1]))
- l--;
- i = VSL_Name2Tag(b, l);
- if (i >= 0) {
- if (opt == 'x')
- vbit_set(vsl->vbm_supress, i);
- else
- vbit_clr(vsl->vbm_supress, i);
- } else if (i == -2) {
- return (vsl_diag(vsl,
- "-%c: \"%*.*s\" matches multiple tags\n",
- (char)opt, l, l, b));
- } else {
- return (vsl_diag(vsl,
- "-%c: Could not match \"%*.*s\" to any tag\n",
- (char)opt, l, l, b));
- }
- }
+ i = VSL_List2Tags(arg, -1, opt == 'x' ? vsl_vbm_bitset : vsl_vbm_bitclr,
+ vsl->vbm_supress);
+ if (i == -1)
+ return (vsl_diag(vsl, "-%c: \"%s\" matches zero tags",
+ (char)opt, arg));
+ else if (i == -2)
+ return (vsl_diag(vsl, "-%c: \"%s\" is ambiguous",
+ (char)opt, arg));
+ else if (i == -3)
+ return (vsl_diag(vsl, "-%c: Syntax error in \"%s\"",
+ (char)opt, arg));
+
return (1);
}
More information about the varnish-commit
mailing list