Hmm, so I took a look here and the following diff seems to compile (almost):
0diff --git a/src/tinyformat.h b/src/tinyformat.h
1index f536306375..079b0ccbff 100644
2--- a/src/tinyformat.h
3+++ b/src/tinyformat.h
4@@ -142,6 +142,7 @@ namespace tfm = tinyformat;
5 //------------------------------------------------------------------------------
6 // Implementation details.
7 #include <algorithm>
8+#include <concepts> // Added for Bitcoin Core
9 #include <iostream>
10 #include <sstream>
11 #include <stdexcept> // Added for Bitcoin Core
12@@ -1056,7 +1057,7 @@ inline void vformat(std::ostream& out, const char* fmt, FormatListRef list)
13
14 /// Format list of arguments to the stream according to given format string.
15 template<typename... Args>
16-void format(std::ostream& out, const char* fmt, const Args&... args)
17+void format_raw(std::ostream& out, const char* fmt, const Args&... args) // Renamed for Bitcoin Core
18 {
19 vformat(out, fmt, makeFormatList(args...));
20 }
21@@ -1064,24 +1065,24 @@ void format(std::ostream& out, const char* fmt, const Args&... args)
22 /// Format list of arguments according to the given format string and return
23 /// the result as a string.
24 template<typename... Args>
25-std::string format(const char* fmt, const Args&... args)
26+std::string format_raw(const char* fmt, const Args&... args) // Renamed for Bitcoin Core
27 {
28 std::ostringstream oss;
29- format(oss, fmt, args...);
30+ format_raw(oss, fmt, args...);
31 return oss.str();
32 }
33
34 /// Format list of arguments to std::cout, according to the given format string
35 template<typename... Args>
36-void printf(const char* fmt, const Args&... args)
37+void printf_raw(const char* fmt, const Args&... args) // Renamed for Bitcoin Core
38 {
39- format(std::cout, fmt, args...);
40+ format_raw(std::cout, fmt, args...);
41 }
42
43 template<typename... Args>
44-void printfln(const char* fmt, const Args&... args)
45+void printfln_raw(const char* fmt, const Args&... args) // Renamed for Bitcoin Core
46 {
47- format(std::cout, fmt, args...);
48+ format_raw(std::cout, fmt, args...);
49 std::cout << '\n';
50 }
51
52@@ -1146,11 +1147,12 @@ TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_FUNCS)
53 #endif
54
55 // Added for Bitcoin Core
56-template<typename... Args>
57-std::string format(const std::string &fmt, const Args&... args)
58+template <typename String, typename... Args>
59+ requires std::same_as<String, std::string>
60+std::string format(const String& fmt, const Args&... args)
61 {
62 std::ostringstream oss;
63- format(oss, fmt.c_str(), args...);
64+ format_raw(oss, fmt.c_str(), args...);
65 return oss.str();
66 }
67
68@@ -1160,4 +1162,6 @@ std::string format(const std::string &fmt, const Args&... args)
69 /** Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for details) */
70 #define strprintf tfm::format
71
72+#include <util/string.h> // Added for Bitcoin Core
73+
74 #endif // TINYFORMAT_H_INCLUDED
75diff --git a/src/util/string.h b/src/util/string.h
76index c5183d6c80..5a9b55602f 100644
77--- a/src/util/string.h
78+++ b/src/util/string.h
79@@ -239,7 +239,12 @@ namespace tinyformat {
80 template <typename... Args>
81 std::string format(util::ConstevalFormatString<sizeof...(Args)> fmt, const Args&... args)
82 {
83- return format(fmt.fmt, args...);
84+ return tfm::format_raw(fmt.fmt, args...);
85+}
86+template <typename... Args>
87+void format(std::ostream& out, util::ConstevalFormatString<sizeof...(Args)> fmt, const Args&... args)
88+{
89+ tfm::format_raw(out, fmt.fmt, args...);
90 }
91 } // namespace tinyformat
92
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.