From a4dcfe8b6d1eaabe172322a81721f355647257ff Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 8 Feb 2017 19:15:11 -0500 Subject: Add support for -x?type with multiple types This functionality is already part of GNU findutils git. --- eval.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 6109d44..37bea60 100644 --- a/eval.c +++ b/eval.c @@ -866,7 +866,7 @@ bool eval_sparse(const struct expr *expr, struct eval_state *state) { * -type test. */ bool eval_type(const struct expr *expr, struct eval_state *state) { - return state->ftwbuf->typeflag == expr->idata; + return state->ftwbuf->typeflag & expr->idata; } /** @@ -900,33 +900,7 @@ bool eval_xtype(const struct expr *expr, struct eval_state *state) { } } - switch ((enum bftw_typeflag)expr->idata) { - case BFTW_UNKNOWN: - case BFTW_ERROR: - break; - case BFTW_BLK: - return S_ISBLK(sb.st_mode); - case BFTW_CHR: - return S_ISCHR(sb.st_mode); - case BFTW_DIR: - return S_ISDIR(sb.st_mode); - case BFTW_DOOR: - return S_ISDOOR(sb.st_mode); - case BFTW_FIFO: - return S_ISFIFO(sb.st_mode); - case BFTW_LNK: - return S_ISLNK(sb.st_mode); - case BFTW_PORT: - return S_ISPORT(sb.st_mode); - case BFTW_REG: - return S_ISREG(sb.st_mode); - case BFTW_SOCK: - return S_ISSOCK(sb.st_mode); - case BFTW_WHT: - return S_ISWHT(sb.st_mode); - } - - return false; + return bftw_mode_to_typeflag(sb.st_mode) & expr->idata; } #if _POSIX_MONOTONIC_CLOCK > 0 -- cgit v1.2.3