summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-09-12 13:45:47 +0000
committerLaurent Bercot <ska@appnovation.com>2023-09-12 13:45:47 +0000
commit6ba4a6f86811eaa264734012694f5181b00f9abe (patch)
tree3ff17696c33d43734f8a528c036a403231867e39
parentd229a8b84880dddc05267798795ea29c50af28bd (diff)
downloadexecline-6ba4a6f86811eaa264734012694f5181b00f9abe.tar.xz
posixify eltest for time checks
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/execline/eltest.c8
-rwxr-xr-xtools/gen-multicall.sh2
2 files changed, 7 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 :
{
diff --git a/tools/gen-multicall.sh b/tools/gen-multicall.sh
index fc702ba..959d87b 100755
--- a/tools/gen-multicall.sh
+++ b/tools/gen-multicall.sh
@@ -17,6 +17,8 @@ cat <<EOF
#include <execline/execline.h>
#include "exlsn.h"
+#include <skalibs/posixishard.h>
+
typedef int main_func (int, char **, char const *const *) ;
typedef main_func *main_func_ref ;