summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-12 08:47:19 +0000
committerJim Meyering <jim@meyering.net>2001-08-12 08:47:19 +0000
commit7292e5031b0a794a9f99f71c651c3718fd20323d (patch)
treecf59eeeea17a8839b59df58cbd1fb6673d265a6f /src/ls.c
parent98950444e69ca2eeeb07ab38e1b6733eca81fdd2 (diff)
downloadcoreutils-7292e5031b0a794a9f99f71c651c3718fd20323d.tar.xz
Work around non-compliant gettimeofday on Mac OS X 10.0.4,
(aka Darwin 1.3.7) that caused the date of the first file listed in long output to be the current time rather than the file's mtime. The real work is in m4/gettimeofday.m4 and the wrapper function, lib/gettimeofday.c. Include gtod.h. (main): `Call' GETTIMEOFDAY_INIT. (print_long_format): Add a comment about gettimeofday.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 5065d5686..da8d9511d 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -119,6 +119,7 @@ int wcwidth ();
#include "quotearg.h"
#include "strverscmp.h"
#include "xstrtol.h"
+#include "gtod.h"
/* Use access control lists only under all the following conditions.
Some systems (OSF4, Irix5, Irix6) have the acl function, but not
@@ -895,6 +896,8 @@ main (int argc, char **argv)
atexit (close_stdout);
+ GETTIMEOFDAY_INIT ();
+
#define N_ENTRIES(Array) (sizeof Array / sizeof *(Array))
assert (N_ENTRIES (color_indicator) + 1 == N_ENTRIES (indicator_name));
@@ -2662,7 +2665,13 @@ print_long_format (const struct fileinfo *f)
the last time we checked the clock. */
if (current_time < when
|| (current_time == when && current_time_ns < when_ns))
- get_current_time ();
+ {
+ /* Note that get_current_time calls gettimeofday which, on some non-
+ compliant systems, clobbers the buffer used for localtime's result.
+ But it's ok here, because we use a gettimeofday wrapper that
+ saves and restores the buffer around the gettimeofday call. */
+ get_current_time ();
+ }
/* Consider a time to be recent if it is within the past six
months. A Gregorian year has 365.2425 * 24 * 60 * 60 ==