summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-02-08 19:15:11 -0500
committerTavian Barnes <tavianator@tavianator.com>2017-02-08 19:31:58 -0500
commita4dcfe8b6d1eaabe172322a81721f355647257ff (patch)
tree1b9a91ed1c1bf7e92bbc55d0ce8fce685b4ca090 /eval.c
parent360bb95f1d0296efd8c784b13b05daf289336684 (diff)
downloadbfs-a4dcfe8b6d1eaabe172322a81721f355647257ff.tar.xz
Add support for -x?type with multiple types
This functionality is already part of GNU findutils git.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c30
1 files changed, 2 insertions, 28 deletions
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