summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-06-27 19:16:55 -0400
committerTavian Barnes <tavianator@tavianator.com>2019-06-27 19:16:55 -0400
commitce677576f1f7f971f45a5a08c044df1a916b004c (patch)
tree543ed2ed8414c78fbf2fd0b33db3933d989ad4cf
parent86da865d82a977c4db084327274912d228f2e9f5 (diff)
downloadbfs-ce677576f1f7f971f45a5a08c044df1a916b004c.tar.xz
parse: Add costs for -*able tests
-rw-r--r--parse.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index 131ab0a..fbc987c 100644
--- a/parse.c
+++ b/parse.c
@@ -987,9 +987,25 @@ static struct expr *parse_xargs_safe(struct parser_state *state, int arg1, int a
*/
static struct expr *parse_access(struct parser_state *state, int flag, int arg2) {
struct expr *expr = parse_nullary_test(state, eval_access);
- if (expr) {
- expr->idata = flag;
+ if (!expr) {
+ return NULL;
}
+
+ expr->idata = flag;
+ expr->cost = STAT_COST;
+
+ switch (flag) {
+ case R_OK:
+ expr->probability = 0.99;
+ break;
+ case W_OK:
+ expr->probability = 0.8;
+ break;
+ case X_OK:
+ expr->probability = 0.2;
+ break;
+ }
+
return expr;
}