using nonstd::string_view;
static const char VERSION_TEXT[] =
- R"(%s version %s
+ R"({} version {}
Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2020 Joel Rosdahl and other contributors
print_included_files(const Context& ctx, FILE* fp)
{
for (const auto& item : ctx.included_files) {
- fprintf(fp, "%s\n", item.first.c_str());
+ fmt::print(fp, "{}\n", item.first);
}
}
return;
}
if (max_files != 0) {
- fprintf(f, "max_files = %u\n", max_files);
+ fmt::print(f, "max_files = {}\n", max_files);
config.set_max_files(max_files);
}
if (max_size != 0) {
std::string size = Util::format_parsable_size_with_suffix(max_size);
- fprintf(f, "max_size = %s\n", size.c_str());
+ fmt::print(f, "max_size = {}\n", size);
config.set_max_size(max_size);
}
fclose(f);
clean_old(
ctx, [&](double progress) { progress_bar.update(progress); }, seconds);
if (isatty(STDOUT_FILENO)) {
- printf("\n");
+ fmt::print("\n");
}
break;
}
clean_up_all(ctx.config,
[&](double progress) { progress_bar.update(progress); });
if (isatty(STDOUT_FILENO)) {
- printf("\n");
+ fmt::print("\n");
}
break;
}
ProgressBar progress_bar("Clearing...");
wipe_all(ctx, [&](double progress) { progress_bar.update(progress); });
if (isatty(STDOUT_FILENO)) {
- printf("\n");
+ fmt::print("\n");
}
break;
}
Config::set_value_in_file(
ctx.config.primary_config_path(), "max_files", arg);
if (files == 0) {
- printf("Unset cache file limit\n");
+ fmt::print("Unset cache file limit\n");
} else {
fmt::print("Set cache file limit to {}\n", files);
}
Config::set_value_in_file(
ctx.config.primary_config_path(), "max_size", arg);
if (size == 0) {
- printf("Unset cache size limit\n");
+ fmt::print("Unset cache size limit\n");
} else {
fmt::print("Set cache size limit to {}\n",
Util::format_human_readable_size(size));
break;
case 'V': // --version
- fprintf(stdout, VERSION_TEXT, MYNAME, CCACHE_VERSION);
+ fmt::print(VERSION_TEXT, MYNAME, CCACHE_VERSION);
exit(EXIT_SUCCESS);
case 'x': // --show-compression
case 'z': // --zero-stats
stats_zero(ctx);
- printf("Statistics zeroed\n");
+ fmt::print("Statistics zeroed\n");
break;
default:
#include "compopt.hpp"
+#include "third_party/fmt/core.h"
+
// The option it too hard to handle at all.
#define TOO_HARD (1 << 0)
{
for (size_t i = 0; i < ARRAY_SIZE(compopts); i++) {
if (compopts[i].type & TOO_HARD && compopts[i].type & TAKES_CONCAT_ARG) {
- fprintf(stderr,
- "type (TOO_HARD | TAKES_CONCAT_ARG) not allowed, used by %s\n",
- compopts[i].name);
+ fmt::print(stderr,
+ "type (TOO_HARD | TAKES_CONCAT_ARG) not allowed, used by {}\n",
+ compopts[i].name);
return false;
}
}
if (strcmp(compopts[i - 1].name, compopts[i].name) >= 0) {
- fprintf(stderr,
- "compopt_verify_sortedness: %s >= %s\n",
- compopts[i - 1].name,
- compopts[i].name);
+ fmt::print(stderr,
+ "compopt_verify_sortedness: {} >= {}\n",
+ compopts[i - 1].name,
+ compopts[i].name);
return false;
}
}