Commit 79b63330 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Use VSL_List2Tags in -ix option processing

parent 8b66fc69
......@@ -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 \
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment