Browse Source

lsfd: (filter) give a name to a constant

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
pull/1487/head
Masatake YAMATO 10 months ago
parent
commit
87ffe87ffc
  1. 2
      misc-utils/lsfd-filter.c
  2. 8
      misc-utils/lsfd-filter.h
  3. 2
      misc-utils/lsfd.c

2
misc-utils/lsfd-filter.c

@ -692,7 +692,7 @@ static struct node *dparser_compile1(struct parser *parser, struct node *last)
switch (t->type) {
case TOKEN_NAME: {
int col_id = parser->column_name_to_id(t->val.str, parser->data);
if (col_id == -1) {
if (col_id == LSFD_FILTER_UNKNOWN_COL_ID) {
snprintf(parser->errmsg, ERRMSG_LEN,
_("error: no such column: %s"), t->val.str);
token_free(t);

8
misc-utils/lsfd-filter.h

@ -14,8 +14,16 @@
#include <stdio.h>
#include <stdbool.h>
#define LSFD_FILTER_UNKNOWN_COL_ID -1
struct lsfd_filter;
/*
* @column_name_to_id: a function converting a column name to its id.
*
* @column_name_to_id should return LSFD_FILTER_UNKNOWN_COL_ID if
* an unknown column name is given.
*/
struct lsfd_filter *lsfd_filter_new(const char *const expr, struct libscols_table *tb,
int ncols,
int (*column_name_to_id)(const char *, void *),

2
misc-utils/lsfd.c

@ -203,7 +203,7 @@ static int column_name_to_id(const char *name, size_t namesz)
}
warnx(_("unknown column: %s"), name);
return -1;
return LSFD_FILTER_UNKNOWN_COL_ID;
}
static int column_name_to_id_cb(const char *name, void *data __attribute__((__unused__)))

Loading…
Cancel
Save