diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-12 13:45:47 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-09-12 13:45:47 +0000 |
commit | 6ba4a6f86811eaa264734012694f5181b00f9abe (patch) | |
tree | 3ff17696c33d43734f8a528c036a403231867e39 /src | |
parent | d229a8b84880dddc05267798795ea29c50af28bd (diff) | |
download | execline-6ba4a6f86811eaa264734012694f5181b00f9abe.tar.xz |
posixify eltest for time checks
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/execline/eltest.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/execline/eltest.c b/src/execline/eltest.c index 34321c5..d49539d 100644 --- a/src/execline/eltest.c +++ b/src/execline/eltest.c @@ -7,8 +7,10 @@ #include <regex.h> #include <skalibs/posixplz.h> +#include <skalibs/stat.h> #include <skalibs/types.h> #include <skalibs/strerr.h> +#include <skalibs/djbtime.h> #include <skalibs/djbunix.h> enum eltest_opnum_e @@ -360,7 +362,7 @@ static int eltest_run (struct eltest_node_s const *tree, unsigned int root) { struct stat st ; if (stat(tree[tree[root].arg1].data, &st) == -1) return 0 ; - return (st.st_mtime > st.st_atime) ; + return timespec_cmp(&st.ST_MTIM, &st.ST_ATIM) > 0 ; } case T_EUID : { @@ -385,14 +387,14 @@ static int eltest_run (struct eltest_node_s const *tree, unsigned int root) struct stat st1, st2 ; if (stat(tree[tree[root].arg1].data, &st1) == -1) return 0 ; if (stat(tree[tree[root].arg2].data, &st2) == -1) return 1 ; - return st1.st_mtime > st2.st_mtime ; + return timespec_cmp(&st1.ST_MTIM, &st2.ST_MTIM) > 0 ; } case T_OLDER : { struct stat st1, st2 ; if (stat(tree[tree[root].arg1].data, &st1) == -1) return 1 ; if (stat(tree[tree[root].arg2].data, &st2) == -1) return 0 ; - return st1.st_mtime < st2.st_mtime ; + return timespec_cmp(&st1.ST_MTIM, &st2.ST_MTIM) < 0 ; } case T_DEVINO : { |