int pathcmp(const char *a, const char *b);
void safe_fprintf(FILE * ARCHIVE_RESTRICT, const char * ARCHIVE_RESTRICT fmt, ...) __LA_PRINTF(2, 3);
void set_chdir(struct bsdtar *, const char *newdir);
-const char *tar_i64toa(int64_t);
void tar_mode_c(struct bsdtar *bsdtar);
void tar_mode_r(struct bsdtar *bsdtar);
void tar_mode_t(struct bsdtar *bsdtar);
else
compression = (int)((uncomp - comp) * 100 / uncomp);
fprintf(stderr,
- "In: %s bytes, compression %d%%;",
- tar_i64toa(comp), compression);
- fprintf(stderr, " Out: %d files, %s bytes\n",
- archive_file_count(a), tar_i64toa(uncomp));
+ "In: %ju bytes, compression %d%%;",
+ (uintmax_t)comp, compression);
+ fprintf(stderr, " Out: %d files, %ju bytes\n",
+ archive_file_count(a), (uintmax_t)uncomp);
}
if (entry != NULL) {
safe_fprintf(stderr, "Current: %s",
archive_entry_pathname(entry));
- fprintf(stderr, " (%s bytes)\n",
- tar_i64toa(archive_entry_size(entry)));
+ fprintf(stderr, " (%jd bytes)\n",
+ (intmax_t)archive_entry_size(entry));
}
}
archive_entry_set_mtime(entry, bsdtar->mtime, 0);
}
-/*
- * It would be nice to just use printf() for formatting large numbers,
- * but the compatibility problems are quite a headache. Hence the
- * following simple utility function.
- */
-const char *
-tar_i64toa(int64_t n0)
-{
- static char buff[24];
- uint64_t n = n0 < 0 ? -n0 : n0;
- char *p = buff + sizeof(buff);
-
- *--p = '\0';
- do {
- *--p = '0' + (int)(n % 10);
- } while (n /= 10);
- if (n0 < 0)
- *--p = '-';
- return p;
-}
-
/*
* Like strcmp(), but try to be a little more aware of the fact that
* we're comparing two paths. Right now, it just handles leading
(unsigned long)archive_entry_rdevminor(entry));
p = tmp;
} else {
- p = tar_i64toa(archive_entry_size(entry));
+ snprintf(tmp, sizeof(tmp), "%jd",
+ (intmax_t)archive_entry_size(entry));
+ p = tmp;
}
if (w + strlen(p) >= bsdtar->gs_width)
bsdtar->gs_width = w + strlen(p) + 1;
bsdtar->diskreader = NULL;
if (bsdtar->flags & OPTFLAG_TOTALS) {
- fprintf(stderr, "Total bytes written: %s\n",
- tar_i64toa(archive_filter_bytes(a, -1)));
+ fprintf(stderr, "Total bytes written: %jd\n",
+ (intmax_t)archive_filter_bytes(a, -1));
}
archive_write_free(a);
fprintf(stderr, "\n");
comp = archive_filter_bytes(a, -1);
uncomp = archive_filter_bytes(a, 0);
- fprintf(stderr, "In: %d files, %s bytes;",
- archive_file_count(a), tar_i64toa(uncomp));
+ fprintf(stderr, "In: %d files, %ju bytes;",
+ archive_file_count(a), (uintmax_t)uncomp);
if (comp >= uncomp)
compression = 0;
else
compression = (int)((uncomp - comp) * 100 / uncomp);
fprintf(stderr,
- " Out: %s bytes, compression %d%%\n",
- tar_i64toa(comp), compression);
- /* Can't have two calls to tar_i64toa() pending, so split the output. */
- safe_fprintf(stderr, "Current: %s (%s",
+ " Out: %ju bytes, compression %d%%\n",
+ (uintmax_t)comp, compression);
+ safe_fprintf(stderr, "Current: %s (%jd",
archive_entry_pathname(entry),
- tar_i64toa(progress));
- fprintf(stderr, "/%s bytes)\n",
- tar_i64toa(archive_entry_size(entry)));
+ (intmax_t)progress);
+ fprintf(stderr, "/%jd bytes)\n",
+ (intmax_t)archive_entry_size(entry));
}
static void