Hmm, so I took a look here and the following diff seems to compile (almost):
<details><summary>a diff</summary>
diff --git a/src/tinyformat.h b/src/tinyformat.h
index f536306375..079b0ccbff 100644
--- a/src/tinyformat.h
+++ b/src/tinyformat.h
@@ -142,6 +142,7 @@ namespace tfm = tinyformat;
//------------------------------------------------------------------------------
// Implementation details.
#include <algorithm>
+#include <concepts> // Added for Bitcoin Core
#include <iostream>
#include <sstream>
#include <stdexcept> // Added for Bitcoin Core
@@ -1056,7 +1057,7 @@ inline void vformat(std::ostream& out, const char* fmt, FormatListRef list)
/// Format list of arguments to the stream according to given format string.
template<typename... Args>
-void format(std::ostream& out, const char* fmt, const Args&... args)
+void format_raw(std::ostream& out, const char* fmt, const Args&... args) // Renamed for Bitcoin Core
{
vformat(out, fmt, makeFormatList(args...));
}
@@ -1064,24 +1065,24 @@ void format(std::ostream& out, const char* fmt, const Args&... args)
/// Format list of arguments according to the given format string and return
/// the result as a string.
template<typename... Args>
-std::string format(const char* fmt, const Args&... args)
+std::string format_raw(const char* fmt, const Args&... args) // Renamed for Bitcoin Core
{
std::ostringstream oss;
- format(oss, fmt, args...);
+ format_raw(oss, fmt, args...);
return oss.str();
}
/// Format list of arguments to std::cout, according to the given format string
template<typename... Args>
-void printf(const char* fmt, const Args&... args)
+void printf_raw(const char* fmt, const Args&... args) // Renamed for Bitcoin Core
{
- format(std::cout, fmt, args...);
+ format_raw(std::cout, fmt, args...);
}
template<typename... Args>
-void printfln(const char* fmt, const Args&... args)
+void printfln_raw(const char* fmt, const Args&... args) // Renamed for Bitcoin Core
{
- format(std::cout, fmt, args...);
+ format_raw(std::cout, fmt, args...);
std::cout << '\n';
}
@@ -1146,11 +1147,12 @@ TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_FUNCS)
#endif
// Added for Bitcoin Core
-template<typename... Args>
-std::string format(const std::string &fmt, const Args&... args)
+template <typename String, typename... Args>
+ requires std::same_as<String, std::string>
+std::string format(const String& fmt, const Args&... args)
{
std::ostringstream oss;
- format(oss, fmt.c_str(), args...);
+ format_raw(oss, fmt.c_str(), args...);
return oss.str();
}
@@ -1160,4 +1162,6 @@ std::string format(const std::string &fmt, const Args&... args)
/** Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for details) */
#define strprintf tfm::format
+#include <util/string.h> // Added for Bitcoin Core
+
#endif // TINYFORMAT_H_INCLUDED
diff --git a/src/util/string.h b/src/util/string.h
index c5183d6c80..5a9b55602f 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -239,7 +239,12 @@ namespace tinyformat {
template <typename... Args>
std::string format(util::ConstevalFormatString<sizeof...(Args)> fmt, const Args&... args)
{
- return format(fmt.fmt, args...);
+ return tfm::format_raw(fmt.fmt, args...);
+}
+template <typename... Args>
+void format(std::ostream& out, util::ConstevalFormatString<sizeof...(Args)> fmt, const Args&... args)
+{
+ tfm::format_raw(out, fmt.fmt, args...);
}
} // namespace tinyformat
</details>
The problem is that %*s are actually used in bitcoin-cli. However, in an unspecified form (%*s can not be used after using positional specifiers). I am not sure if it is worth it to change the format strings, or to adjust the consteval parser. So an easy fix would be to just call the unchecked c-string functions in bitcoin-cli, which I think is fine.