about summary refs log tree commit diff
path: root/Src/cond.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2007-11-01 17:57:57 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2007-11-01 17:57:57 +0000
commitfe5390a04ce44daf1604298756d772b2ce12b268 (patch)
tree1c13e446cacb0e9462c07e5de027a181b592ea8f /Src/cond.c
parent8d956e9bcb8fe5aa3ca92e3c856b26800af11ff5 (diff)
downloadzsh-fe5390a04ce44daf1604298756d772b2ce12b268.tar.gz
zsh-fe5390a04ce44daf1604298756d772b2ce12b268.tar.xz
zsh-fe5390a04ce44daf1604298756d772b2ce12b268.zip
24050: handle nanosecond resolution timestamps on systems that support them
Diffstat (limited to 'Src/cond.c')
-rw-r--r--Src/cond.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Src/cond.c b/Src/cond.c
index a38df6fb7..cabe64446 100644
--- a/Src/cond.c
+++ b/Src/cond.c
@@ -344,19 +344,39 @@ evalcond(Estate state, char *fromtest)
     case 'G':
 	return !((st = getstat(left)) && st->st_gid == getegid());
     case 'N':
+#if defined(GET_ST_MTIME_NSEC) && defined(GET_ST_ATIME_NSEC)
+	if (!(st = getstat(left)))
+	    return 1;
+        return (st->st_atime == st->st_mtime) ?
+        	GET_ST_ATIME_NSEC(*st) > GET_ST_MTIME_NSEC(*st) :
+        	st->st_atime > st->st_mtime;
+#else
 	return !((st = getstat(left)) && st->st_atime <= st->st_mtime);
+#endif
     case 't':
 	return !isatty(mathevali(left));
     case COND_NT:
     case COND_OT:
 	{
 	    time_t a;
+#ifdef GET_ST_MTIME_NSEC
+	    long nsecs;
+#endif
 
 	    if (!(st = getstat(left)))
 		return 1;
 	    a = st->st_mtime;
+#ifdef GET_ST_MTIME_NSEC
+	    nsecs = GET_ST_MTIME_NSEC(*st);
+#endif
 	    if (!(st = getstat(right)))
 		return 1;
+#ifdef GET_ST_MTIME_NSEC
+	    if (a == st->st_mtime) {
+                return !((ctype == COND_NT) ? nsecs > GET_ST_MTIME_NSEC(*st) :
+                        nsecs < GET_ST_MTIME_NSEC(*st));
+	    }
+#endif
 	    return !((ctype == COND_NT) ? a > st->st_mtime : a < st->st_mtime);
 	}
     case COND_EF: