As I mentioned earlier, there's a logic bug in GNU make 3.79
in the case of WINDOWS32: the code

        if (mtime > now && (((mtime % 2) == 0) && ((mtime-1) > now)))

does not warn about a future timestamp if the timestamp is odd.  I
earlier sent a patch that was combined with a lot of other stuff that
turned out to be undesirable as it missed some skews; sorry about
that.  Here's a patch that fixes just this problem, and cleans up the
code a bit so it's easier to follow.

2000-05-22  Paul Eggert  <[EMAIL PROTECTED]>

        * remake.c (f_mtime): Fix bug when handling future odd
        timestamps in the WINDOWS32 case.  Do not bother initializing
        static var to zero.  Simplify code that works around WINDOWS32
        and __MSDOS__ time skew brain damage.

===================================================================
RCS file: remake.c,v
retrieving revision 3.79
retrieving revision 3.79.0.2
diff -pu -r3.79 -r3.79.0.2
--- remake.c    2000/04/03 05:46:08     3.79
+++ remake.c    2000/05/22 16:45:52     3.79.0.2
@@ -1142,9 +1142,27 @@ f_mtime (file, search)
 
        We only need to do this once, for now. */
 
-    static FILE_TIMESTAMP now = 0;
+    static FILE_TIMESTAMP now;
+
+    FILE_TIMESTAMP adjusted_mtime = mtime;
+#ifdef WINDOWS32
+    /* FAT filesystems round time to the nearest even second!
+       Allow for any file (NTFS or FAT) to perhaps suffer from this
+       brain damage.  */
+    if ((FILE_TIMESTAMP_S (adjusted_mtime) & 1) == 0
+       && FILE_TIMESTAMP_NS (adjusted_mtime) == 0)
+      adjusted_mtime -= FILE_TIMESTAMPS_PER_S;
+#else
+#ifdef __MSDOS__
+    /* On DJGPP under Windows 98 and Windows NT, FAT filesystems can
+       set file times up to 3 seconds into the future!  The bug doesn't
+       occur in plain DOS or in Windows 95, but we play it safe.  */
+    adjusted_mtime -= 3 * FILE_TIMESTAMPS_PER_S;
+#endif
+#endif
+
     if (!clock_skew_detected
-        && mtime != (FILE_TIMESTAMP)-1 && mtime > now
+        && mtime != (FILE_TIMESTAMP)-1 && now < adjusted_mtime
         && !file->updated)
       {
        /* This file's time appears to be in the future.
@@ -1152,22 +1170,7 @@ f_mtime (file, search)
 
        now = file_timestamp_now ();
 
-#ifdef WINDOWS32
-       /*
-        * FAT filesystems round time to nearest even second(!). Just
-        * allow for any file (NTFS or FAT) to perhaps suffer from this
-        * braindamage.
-        */
-       if (mtime > now && (((mtime % 2) == 0) && ((mtime-1) > now)))
-#else
-#ifdef __MSDOS__
-       /* Scrupulous testing indicates that some Windows
-          filesystems can set file times up to 3 sec into the future!  */
-       if (mtime > now + 3)
-#else
-        if (mtime > now)
-#endif
-#endif
+       if (now < adjusted_mtime)
           {
            char mtimebuf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
            char nowbuf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];

Reply via email to