diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-06-27 19:16:55 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-06-27 19:16:55 -0400 |
commit | ce677576f1f7f971f45a5a08c044df1a916b004c (patch) | |
tree | 543ed2ed8414c78fbf2fd0b33db3933d989ad4cf /parse.c | |
parent | 86da865d82a977c4db084327274912d228f2e9f5 (diff) | |
download | bfs-ce677576f1f7f971f45a5a08c044df1a916b004c.tar.xz |
parse: Add costs for -*able tests
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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; } |