X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fxheader.c;h=b8d4bfb7a7c80f40b128657eff39cb0d79554337;hb=f6458a827ae7a2c41616490f653714068072b257;hp=dadaf5430276c39ae731d1a78a24fb177d72f943;hpb=040b5ab5f969f9ee6c69a54bc284e2ff57b86556;p=chaz%2Ftar diff --git a/src/xheader.c b/src/xheader.c index dadaf54..b8d4bfb 100644 --- a/src/xheader.c +++ b/src/xheader.c @@ -28,13 +28,6 @@ #include -#if !HAVE_DECL_STRTOIMAX && !defined strtoimax -intmax_t strtoimax (); -#endif -#if !HAVE_DECL_STRTOUMAX && !defined strtoumax -uintmax_t strtoumax (); -#endif - static bool xheader_protected_pattern_p (char const *pattern); static bool xheader_protected_keyword_p (char const *keyword); static void xheader_set_single_keyword (char *) __attribute__ ((noreturn)); @@ -57,8 +50,6 @@ static size_t global_header_count; However it should wait until buffer.c is finally rewritten */ -enum { BILLION = 1000000000, LOG10_BILLION = 9 }; - /* Keyword options */ @@ -747,23 +738,8 @@ decode_string (char **string, char const *arg) 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 @@ -900,7 +876,7 @@ static void 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 @@ -908,7 +884,7 @@ atime_decoder (struct tar_stat_info *st, char const *arg) { struct timespec ts; if (decode_time (&ts, arg, "atime")) - set_stat_atime (&st->stat, ts); + st->atime = ts; } static void @@ -956,7 +932,7 @@ 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 @@ -964,14 +940,14 @@ ctime_decoder (struct tar_stat_info *st, char const *arg) { 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 @@ -979,7 +955,7 @@ mtime_decoder (struct tar_stat_info *st, char const *arg) { struct timespec ts; if (decode_time (&ts, arg, "mtime")) - set_stat_mtime (&st->stat, ts); + st->mtime = ts; } static void @@ -1009,7 +985,7 @@ size_decoder (struct tar_stat_info *st, char const *arg) { 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