summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-05-10 12:10:16 -0700
committerPaul Smith <psmith@gnu.org>2023-05-14 18:26:35 -0400
commitc85b71a39620b41c764a58b1595fc1021545665a (patch)
treed4bb82c03dc5bda644cc7bb7d02659be998060b2
parent032f784601219474ac2a31d61caa071665451933 (diff)
downloadmake-git-master.tar.gz
make -p now uses consistent timestamp formatHEADmaster
* NEWS: mention this. * src/main.c (safer_ctime, time_now): Remove. (print_data_base): Use file_timestamp_sprintf to format timestamps.
-rw-r--r--NEWS5
-rw-r--r--src/main.c51
2 files changed, 11 insertions, 45 deletions
diff --git a/NEWS b/NEWS
index 295a2a4e..16348d67 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,11 @@ which is contained in this distribution as the file doc/make.texi.
See the README file and the GNU Make manual for instructions for
reporting bugs.
+* 'make --print-data-base' (or 'make -p') now outputs time of day
+ using the same form as for file timestamps, e.g., "2023-05-10
+ 10:43:57.570558743". Previously it used the form "Wed May 10
+ 10:43:57 2023", which has less detail and is harder to compare.
+
Version 4.5 (26 Feb 2023)
diff --git a/src/main.c b/src/main.c
index d22d170a..39e511ff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3720,57 +3720,18 @@ print_version (void)
printed_version = 1;
}
-/* Like ctime, except do not have undefined behavior with timestamps
- out of ctime range. */
-static char const *
-safer_ctime (time_t *t)
-{
- struct tm *tm = localtime (t);
- if (tm && -999 - 1900 <= tm->tm_year && tm->tm_year <= 9999 - 1900)
- return ctime (t);
- else
- return "(time out of range)\n";
-}
-
-static time_t
-time_now (void)
-{
- /* Use an algorithm like file_timestamp_now's, extracting just the
- seconds part of the timestamp. This avoids a race that would
- generate output that incorrectly makes it look like the system
- clock jumped backwards on platforms like GNU/Linux where the
- 'time' function does not use the CLOCK_REALTIME clock and the two
- clocks can disagree in their seconds component. */
-#if FILE_TIMESTAMP_HI_RES
-# if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
- {
- struct timespec timespec;
- if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
- return timespec.tv_sec;
- }
-# endif
-# if HAVE_GETTIMEOFDAY
- {
- struct timeval timeval;
- if (gettimeofday (&timeval, 0) == 0)
- return timeval.tv_sec;
- }
-# endif
-#endif
-
- return time ((time_t *) 0);
-}
-
/* Print a bunch of information about this and that. */
static void
print_data_base (void)
{
- time_t when = time_now ();
+ int resolution;
+ char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
+ file_timestamp_sprintf (buf, file_timestamp_now (&resolution));
print_version ();
- printf (_("\n# Make data base, printed on %s"), safer_ctime (&when));
+ printf (_("\n# Make data base, printed on %s\n"), buf);
print_variable_data_base ();
print_dir_data_base ();
@@ -3779,8 +3740,8 @@ print_data_base (void)
print_vpath_data_base ();
strcache_print_stats ("#");
- when = time_now ();
- printf (_("\n# Finished Make data base on %s\n"), safer_ctime (&when));
+ file_timestamp_sprintf (buf, file_timestamp_now (&resolution));
+ printf (_("\n# Finished Make data base on %s\n\n"), buf);
}
static void