However it should wait until buffer.c is finally rewritten */
-enum { BILLION = 1000000000, LOG10_BILLION = 9 };
-
\f
/* Keyword options */
static void
code_time (struct timespec t, char const *keyword, struct xheader *xhdr)
{
- time_t s = t.tv_sec;
- int ns = t.tv_nsec;
- char sbuf[1/*"-"*/ + UINTMAX_STRSIZE_BOUND + 1/*"."*/ + LOG10_BILLION];
- char *np;
- bool negative = s < 0;
-
- if (negative && ns != 0)
- {
- s++;
- ns = BILLION - ns;
- }
-
- np = umaxtostr (negative ? - (uintmax_t) s : (uintmax_t) s, sbuf + 1);
- if (negative)
- *--np = '-';
- code_ns_fraction (ns, sbuf + UINTMAX_STRSIZE_BOUND);
- xheader_print (xhdr, keyword, np);
+ char buf[TIMESPEC_STRSIZE_BOUND];
+ xheader_print (xhdr, keyword, code_timespec (t, buf));
}
static bool
atime_coder (struct tar_stat_info const *st, char const *keyword,
struct xheader *xhdr, void *data __attribute__ ((unused)))
{
- code_time (get_stat_atime (&st->stat), keyword, xhdr);
+ code_time (st->atime, keyword, xhdr);
}
static void
{
struct timespec ts;
if (decode_time (&ts, arg, "atime"))
- set_stat_atime (&st->stat, ts);
+ st->atime = ts;
}
static void
ctime_coder (struct tar_stat_info const *st, char const *keyword,
struct xheader *xhdr, void *data __attribute__ ((unused)))
{
- code_time (get_stat_ctime (&st->stat), keyword, xhdr);
+ code_time (st->ctime, keyword, xhdr);
}
static void
{
struct timespec ts;
if (decode_time (&ts, arg, "ctime"))
- set_stat_ctime (&st->stat, ts);
+ st->ctime = ts;
}
static void
mtime_coder (struct tar_stat_info const *st, char const *keyword,
struct xheader *xhdr, void *data __attribute__ ((unused)))
{
- code_time (get_stat_mtime (&st->stat), keyword, xhdr);
+ code_time (st->mtime, keyword, xhdr);
}
static void
{
struct timespec ts;
if (decode_time (&ts, arg, "mtime"))
- set_stat_mtime (&st->stat, ts);
+ st->mtime = ts;
}
static void
{
uintmax_t u;
if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), "size"))
- st->archive_file_size = st->stat.st_size = u;
+ st->stat.st_size = u;
}
static void