summaryrefslogtreecommitdiff
path: root/src/pr.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-09-16 07:50:33 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-09-16 07:50:33 +0000
commit158d982669d3d05079da2b9cc8d8fcd8adf35a4b (patch)
tree038bcb1def910a55323b86f5ee12bad2839161a5 /src/pr.c
parent3ecd35f56fbb7f9b3f43cd12f862336acf7dca56 (diff)
downloadcoreutils-158d982669d3d05079da2b9cc8d8fcd8adf35a4b.tar.xz
Include stat-time.h, and use its functions instead of the obsolete
TIMESPEC_NS macro.
Diffstat (limited to 'src/pr.c')
-rw-r--r--src/pr.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/pr.c b/src/pr.c
index 67ac6fe1a..4be18e307 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -319,6 +319,7 @@
#include "inttostr.h"
#include "mbswidth.h"
#include "quote.h"
+#include "stat-time.h"
#include "stdio--.h"
#include "strftime.h"
#include "xstrtol.h"
@@ -1656,7 +1657,7 @@ init_header (char *filename, int desc)
{
char *buf = NULL;
struct stat st;
- time_t s;
+ struct timespec t;
int ns;
struct tm *tm;
@@ -1664,25 +1665,22 @@ init_header (char *filename, int desc)
if (STREQ (filename, "-"))
desc = -1;
if (0 <= desc && fstat (desc, &st) == 0)
- {
- s = st.st_mtime;
- ns = TIMESPEC_NS (st.st_mtim);
- }
+ t = get_stat_mtime (&st);
else
{
static struct timespec timespec;
if (! timespec.tv_sec)
gettime (&timespec);
- s = timespec.tv_sec;
- ns = timespec.tv_nsec;
+ t = timespec;
}
- tm = localtime (&s);
+ ns = t.tv_nsec;
+ tm = localtime (&t.tv_sec);
if (tm == NULL)
{
buf = xmalloc (INT_BUFSIZE_BOUND (long int)
+ MAX (10, INT_BUFSIZE_BOUND (int)));
- sprintf (buf, "%ld.%09d", (long int) s, ns);
+ sprintf (buf, "%ld.%09d", (long int) t.tv_sec, ns);
}
else
{