]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Work around non-compliant gettimeofday on Mac OS X 10.0.4,
authorJim Meyering <jim@meyering.net>
Sun, 12 Aug 2001 08:47:19 +0000 (08:47 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 12 Aug 2001 08:47:19 +0000 (08:47 +0000)
(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.

src/ls.c

index 5065d56860c65484189c943ea25944e2177327ec..da8d9511da593438b52d90f7da5a15d98ed68fbf 100644 (file)
--- 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 ==