mirror of
https://https.git.savannah.gnu.org/git/findutils.git
synced 2026-01-27 01:44:23 +00:00
Fix Savannah bug #22056, -Xtime tests are off by one second (extra fix for host with sub-second timestamps).
This commit is contained in:
parent
2d5b78c0de
commit
82009477f9
@ -13,6 +13,9 @@
|
||||
is of type struct timespec, not time_t.
|
||||
(parse_used): Likewise.
|
||||
(parse_time): Likewise.
|
||||
* find/pred.c (pred_timewindow): in the COMP_EQ case, accept times
|
||||
exactly at the end of the window and do not accept times exactly
|
||||
at the start (reversing the previous treatment of the bounds).
|
||||
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Added test for
|
||||
-mtime 0; find.posix/mtime0.{exp,xo}.
|
||||
* NEWS: mention this bugfix.
|
||||
|
||||
17
find/pred.c
17
find/pred.c
@ -273,7 +273,7 @@ compare_ts(struct timespec ts1,
|
||||
* Returns true if THE_TIME is
|
||||
* COMP_GT: after the specified time
|
||||
* COMP_LT: before the specified time
|
||||
* COMP_EQ: less than WINDOW seconds after the specified time.
|
||||
* COMP_EQ: after the specified time but by not more than WINDOW seconds.
|
||||
*/
|
||||
static boolean
|
||||
pred_timewindow(struct timespec ts, struct predicate const *pred_ptr, int window)
|
||||
@ -288,8 +288,21 @@ pred_timewindow(struct timespec ts, struct predicate const *pred_ptr, int window
|
||||
|
||||
case COMP_EQ:
|
||||
{
|
||||
/* consider "find . -mtime 0".
|
||||
*
|
||||
* Here, the origin is exactly 86400 seconds before the start
|
||||
* of the program (since -daystart was not specified). This
|
||||
* function will be called with window=86400 and
|
||||
* pred_ptr->args.reftime.ts as the origin. Hence a file
|
||||
* created the instant the program starts will show a time
|
||||
* difference (value of delta) of 86400. Similarly, a file
|
||||
* created exactly 24h ago would be the newest file which was
|
||||
* _not_ created today. So, if delta is 0.0, the file
|
||||
* was not created today. If the delta is 86400, the file
|
||||
* was created this instant.
|
||||
*/
|
||||
double delta = ts_difference(ts, pred_ptr->args.reftime.ts);
|
||||
return (delta >= 0.0 && delta < window);
|
||||
return (delta > 0.0 && delta <= window);
|
||||
}
|
||||
}
|
||||
assert (0);
|
||||
|
||||
@ -78,6 +78,7 @@ find.posix/links.xo \
|
||||
find.posix/sv-bug-11175.xo \
|
||||
find.posix/sv-bug-12181.xo \
|
||||
find.posix/depth1.xo \
|
||||
find.posix/mtime0.xo \
|
||||
find.posix/sizes.xo \
|
||||
find.posix/name.xo \
|
||||
find.posix/nameslash.xo \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user