summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2023-03-13 19:26:50 +0100
committerJoel Rosdahl <joel@rosdahl.net>2023-04-17 08:27:55 +0200
commite3fc28a42a8bf3305749919a22127f3a31b3eac2 (patch)
treea91ed919598b2212bfbab83b2eaf83450a20c01c
parent962f3118429517dcda790a50d26ea14102f7cf5a (diff)
downloadccache-e3fc28a42a8bf3305749919a22127f3a31b3eac2.tar.gz
fix: Make output of "ccache -k max_size" parsable
-rw-r--r--src/Config.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index 1707da01..982134e1 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -246,12 +246,6 @@ format_bool(bool value)
return value ? "true" : "false";
}
-std::string
-format_cache_size(uint64_t value, util::SizeUnitPrefixType prefix_type)
-{
- return util::format_human_readable_size(value, prefix_type);
-}
-
CompilerType
parse_compiler_type(const std::string& value)
{
@@ -791,8 +785,15 @@ Config::get_string_value(const std::string& key) const
case ConfigItem::max_files:
return FMT("{}", m_max_files);
- case ConfigItem::max_size:
- return format_cache_size(m_max_size, m_size_prefix_type);
+ case ConfigItem::max_size: {
+ auto result =
+ util::format_human_readable_size(m_max_size, m_size_prefix_type);
+ if (util::ends_with(result, " bytes")) {
+ // Special case to make the output parsable by util::parse_size.
+ result.resize(result.size() - 6);
+ }
+ return result;
+ }
case ConfigItem::msvc_dep_prefix:
return m_msvc_dep_prefix;