diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-03-20 10:44:34 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-03-20 16:40:57 -0400 |
commit | 912d2b94cf6ff0871c07325af5ed520a2bc97722 (patch) | |
tree | c2a38bcba049dc633811cab5d80f8945a2f91ba8 /src/eval.c | |
parent | 906009bbb7a88002d0db8b7a26ad9d5b71120869 (diff) | |
download | bfs-912d2b94cf6ff0871c07325af5ed520a2bc97722.tar.xz |
Implement -limit N
Closes: https://github.com/tavianator/bfs/issues/133
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -841,6 +841,19 @@ error: } /** + * -limit action. + */ +bool eval_limit(const struct bfs_expr *expr, struct bfs_eval *state) { + long long evals = expr->evaluations + 1; + if (evals >= expr->num) { + state->action = BFTW_STOP; + state->quit = true; + } + + return true; +} + +/** * -prune action. */ bool eval_prune(const struct bfs_expr *expr, struct bfs_eval *state) { |