fputs(_(" --sysroot <dir> use specified directory as system root\n"), out);
fputs(_(" -u, --notruncate don't truncate text in columns\n"), out);
fputs(_(" -Q, --filter <expr> apply display filter\n"), out);
- fputs(_(" --source <source> add filter by SOURCE\n"), out);
fputs(_(" --debug-filter dump the innternal data structure of filter and exit\n"), out);
fputs(USAGE_SEPARATOR, out);
xstrappend(a, b);
}
-static char * quote_filter_expr(char *expr)
-{
- char c[] = {'\0', '\0'};
- char *r = strdup("");
- while (*expr) {
- switch (*expr) {
- case '\'':
- xstrappend(&r, "\\'");
- break;
- case '"':
- xstrappend(&r, "\\\"");
- break;
- default:
- c[0] = *expr;
- xstrappend(&r, c);
- break;
- }
- expr++;
- }
- return r;
-}
-
static void append_filter_expr(char **a, const char *b, bool and)
{
if (*a == NULL) {
enum {
OPT_SYSROOT = CHAR_MAX + 1,
- OPT_SOURCE,
OPT_DEBUG_FILTER,
};
static const struct option longopts[] = {
{ "notruncate", no_argument, NULL, 'u' },
{ "sysroot", required_argument, NULL, OPT_SYSROOT },
{ "filter", required_argument, NULL, 'Q' },
- { "source", required_argument, NULL, OPT_SOURCE },
{ "debug-filter",no_argument, NULL, OPT_DEBUG_FILTER },
{ NULL, 0, NULL, 0 },
};
case 'Q':
append_filter_expr(&filter_expr, optarg, true);
break;
- case OPT_SOURCE: {
- char * quoted_source = quote_filter_expr(optarg);
- char * source_expr = NULL;
- xstrappend(&source_expr, "(SOURCE == '");
- xstrappend(&source_expr, quoted_source);
- xstrappend(&source_expr, "')");
- append_filter_expr(&filter_expr, source_expr, true);
- free(source_expr);
- free(quoted_source);
- break;
- }
case OPT_DEBUG_FILTER:
debug_filter = true;
break;