From a69f6e185adabf42cc310375b5b57d7dda52397c Mon Sep 17 00:00:00 2001 From: K900 Date: Tue, 26 Mar 2024 10:55:15 +0300 Subject: [PATCH] build-remote: fix format string shenanigans HintFmt(string) invokes the HintFmt("%s", literal) constructor, which is not what we want here. Add a constructor with a proper name and call that. Next step: rename all the other ones to HintFmt::literal(string). Fixes: https://git.lix.systems/lix-project/lix/issues/178 Change-Id: If52d2eb8864ceb8663e05992e9d1fffef573d6b8 --- src/build-remote/build-remote.cc | 2 +- src/libutil/fmt.hh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index 04aade9db..e2ada70cd 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -202,7 +202,7 @@ static int main_build_remote(int argc, char * * argv) else drvstr = ""; - auto error = HintFmt(errorText); + auto error = HintFmt::fromFormatString(errorText); error % drvstr % neededSystem diff --git a/src/libutil/fmt.hh b/src/libutil/fmt.hh index 75354a07c..84a3e3e11 100644 --- a/src/libutil/fmt.hh +++ b/src/libutil/fmt.hh @@ -141,6 +141,10 @@ public: : HintFmt("%s", Uncolored(literal)) { } + static HintFmt fromFormatString(const std::string & format) { + return HintFmt(boost::format(format)); + } + /** * Interpolate the given arguments into the format string. */