diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ctx.c | 5 | ||||
-rw-r--r-- | src/ctx.h | 4 | ||||
-rw-r--r-- | src/eval.c | 2 | ||||
-rw-r--r-- | src/parse.c | 10 |
4 files changed, 12 insertions, 9 deletions
@@ -23,6 +23,7 @@ #include "pwcache.h" #include "stat.h" #include "trie.h" +#include "xtime.h" #include <assert.h> #include <errno.h> #include <limits.h> @@ -109,6 +110,10 @@ struct bfs_ctx *bfs_ctx_new(void) { goto fail; } + if (xgettime(&ctx->now) != 0) { + goto fail; + } + return ctx; fail: @@ -26,6 +26,7 @@ #include <stdbool.h> #include <stddef.h> #include <sys/resource.h> +#include <time.h> /** * Various debugging flags. @@ -127,6 +128,9 @@ struct bfs_ctx { rlim_t nofile_soft; /** The initial RLIMIT_NOFILE hard limit. */ rlim_t nofile_hard; + + /** The current time. */ + struct timespec now; }; /** @@ -708,7 +708,7 @@ bool eval_fls(const struct bfs_expr *expr, struct bfs_eval *state) { } time_t time = statbuf->mtime.tv_sec; - time_t now = expr->reftime.tv_sec; + time_t now = ctx->now.tv_sec; time_t six_months_ago = now - 6*30*24*60*60; time_t tomorrow = now + 24*60*60; struct tm tm; diff --git a/src/parse.c b/src/parse.c index fc30cd2..a1e32fd 100644 --- a/src/parse.c +++ b/src/parse.c @@ -284,7 +284,7 @@ struct parser_state { /** An "-ok"-type expression, if any. */ const struct bfs_expr *ok_expr; - /** The current time. */ + /** The current time (maybe modified by -daystart). */ struct timespec now; }; @@ -1527,7 +1527,6 @@ static struct bfs_expr *parse_fls(struct parser_state *state, int arg1, int arg2 expr_set_always_true(expr); expr->cost = PRINT_COST; - expr->reftime = state->now; return expr; fail: @@ -1772,7 +1771,6 @@ static struct bfs_expr *parse_ls(struct parser_state *state, int arg1, int arg2) } init_print_expr(state, expr); - expr->reftime = state->now; return expr; } @@ -3892,6 +3890,7 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) { .files0_arg = NULL, .files0_stdin_arg = NULL, .ok_expr = NULL, + .now = ctx->now, }; if (strcmp(xbasename(state.command), "find") == 0) { @@ -3899,11 +3898,6 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) { ctx->strategy = BFTW_DFS; } - if (xgettime(&state.now) != 0) { - parse_perror(&state, "xgettime()"); - goto fail; - } - ctx->exclude = &bfs_false; ctx->expr = parse_whole_expr(&state); if (!ctx->expr) { |