diff options
author | Paul Smith <psmith@gnu.org> | 2000-07-07 17:34:56 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2000-07-07 17:34:56 +0000 |
commit | 3c132f10f39f1675607d50f5c75669ec64e13bb5 (patch) | |
tree | 6a749a7c51472ff1f41aaa1cb6eb3a2dcaac9f70 /file.c | |
parent | 88187d9f4b963227e72a46848826eab93545da6e (diff) | |
download | gunmake-3c132f10f39f1675607d50f5c75669ec64e13bb5.tar.gz |
* Minor code cleanups
* Fix for PR/1811, from Paul Eggert.
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -580,11 +580,12 @@ file_timestamp_cons (fname, s, ns) return ts; } -/* Get and print file timestamps. */ - +/* Return the current time as a file timestamp, setting *RESOLUTION to + its resolution. */ FILE_TIMESTAMP -file_timestamp_now () +file_timestamp_now (int *resolution) { + int r; time_t s; int ns; @@ -598,6 +599,7 @@ file_timestamp_now () struct timespec timespec; if (clock_gettime (CLOCK_REALTIME, ×pec) == 0) { + r = 1; s = timespec.tv_sec; ns = timespec.tv_nsec; goto got_time; @@ -609,6 +611,7 @@ file_timestamp_now () struct timeval timeval; if (gettimeofday (&timeval, 0) == 0) { + r = 1000; s = timeval.tv_sec; ns = timeval.tv_usec * 1000; goto got_time; @@ -617,13 +620,17 @@ file_timestamp_now () #endif } + r = 1000000000; s = time ((time_t *) 0); ns = 0; got_time: + *resolution = r; return file_timestamp_cons (0, s, ns); } +/* Place into the buffer P a printable representation of the file + timestamp TS. */ void file_timestamp_sprintf (p, ts) char *p; @@ -647,7 +654,7 @@ file_timestamp_sprintf (p, ts) applies only to local times, whereas this timestamp might come from a remote filesystem. So removing trailing zeros is the best guess that we can do. */ - sprintf (p, ".%09ld", (long) FILE_TIMESTAMP_NS (ts)); + sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts)); p += strlen (p) - 1; while (*p == '0') p--; |