treewide: Remove uses of FMT_COMPILE

We can use stdplus::strCat which takes even less code space.

Change-Id: I91185afa7f5d9041ca7477eb19d5d53755ed329d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/config_parser.cpp b/src/config_parser.cpp
index afa563a..8c84e95 100644
--- a/src/config_parser.cpp
+++ b/src/config_parser.cpp
@@ -1,6 +1,5 @@
 #include "config_parser.hpp"
 
-#include <fmt/compile.h>
 #include <fmt/format.h>
 
 #include <stdplus/exception.hpp>
@@ -8,6 +7,7 @@
 #include <stdplus/fd/create.hpp>
 #include <stdplus/fd/fmt.hpp>
 #include <stdplus/fd/line.hpp>
+#include <stdplus/str/cat.hpp>
 
 #include <functional>
 #include <iterator>
@@ -47,12 +47,12 @@
 
 fs::path pathForIntfConf(const fs::path& dir, std::string_view intf)
 {
-    return dir / fmt::format(FMT_COMPILE("00-bmc-{}.network"), intf);
+    return dir / stdplus::strCat("00-bmc-"sv, intf, ".network"sv);
 }
 
 fs::path pathForIntfDev(const fs::path& dir, std::string_view intf)
 {
-    return dir / fmt::format(FMT_COMPILE("{}.netdev"), intf);
+    return dir / stdplus::strCat(intf, ".netdev"sv);
 }
 
 const std::string*
@@ -90,7 +90,7 @@
         if (c == '\n' || c == '=')
         {
             throw std::invalid_argument(
-                fmt::format(FMT_COMPILE("Invalid Config Key: {}"), s));
+                stdplus::strCat("Invalid Config Key: "sv, s));
         }
     }
 }
@@ -102,7 +102,7 @@
         if (c == '\n' || c == ']')
         {
             throw std::invalid_argument(
-                fmt::format(FMT_COMPILE("Invalid Config Section: {}"), s));
+                stdplus::strCat("Invalid Config Section: "sv, s));
         }
     }
 }
@@ -114,7 +114,7 @@
         if (c == '\n')
         {
             throw std::invalid_argument(
-                fmt::format(FMT_COMPILE("Invalid Config Value: {}"), s));
+                stdplus::strCat("Invalid Config Value: "sv, s));
         }
     }
 }
@@ -287,12 +287,12 @@
     {
         for (const auto& map : maps)
         {
-            out.append(FMT_COMPILE("[{}]\n"), section.get());
+            out.appends("["sv, section.get(), "]\n"sv);
             for (const auto& [key, vals] : map)
             {
                 for (const auto& val : vals)
                 {
-                    out.append(FMT_COMPILE("{}={}\n"), key.get(), val.get());
+                    out.appends(key.get(), "="sv, val.get(), "\n"sv);
                 }
             }
         }
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index b3b9bb7..11485b9 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -1,4 +1,3 @@
-#include "config.h"
 
 #include "ethernet_interface.hpp"
 
@@ -7,7 +6,6 @@
 #include "system_queries.hpp"
 #include "util.hpp"
 
-#include <fmt/compile.h>
 #include <fmt/format.h>
 #include <linux/rtnetlink.h>
 #include <net/if.h>
@@ -16,6 +14,7 @@
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/lg2.hpp>
 #include <stdplus/raw.hpp>
+#include <stdplus/str/cat.hpp>
 #include <stdplus/zstring.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
@@ -66,7 +65,7 @@
 
 static std::string makeObjPath(std::string_view root, std::string_view intf)
 {
-    auto ret = fmt::format(FMT_COMPILE("{}/{}"), root, intf);
+    auto ret = stdplus::strCat(root, "/"sv, intf);
     std::replace(ret.begin() + ret.size() - intf.size(), ret.end(), '.', '_');
     return ret;
 }
@@ -578,7 +577,7 @@
 ObjectPath EthernetInterface::createVLAN(uint16_t id)
 {
     auto idStr = stdplus::toStr(id);
-    auto intfName = fmt::format(FMT_COMPILE("{}.{}"), interfaceName(), idStr);
+    auto intfName = stdplus::strCat(interfaceName(), "."sv, idStr);
     if (manager.get().interfaces.find(intfName) !=
         manager.get().interfaces.end())
     {
diff --git a/src/util.cpp b/src/util.cpp
index b04cfd6..3e1916a 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -5,13 +5,13 @@
 #include "config_parser.hpp"
 #include "types.hpp"
 
-#include <fmt/compile.h>
-#include <fmt/format.h>
 #include <sys/wait.h>
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/lg2.hpp>
 #include <stdplus/numeric/str.hpp>
+#include <stdplus/str/buf.hpp>
+#include <stdplus/str/cat.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #include <cctype>
@@ -30,7 +30,7 @@
 namespace internal
 {
 
-void executeCommandinChildProcess(stdplus::const_zstring path, char** args)
+void executeCommandinChildProcess(stdplus::zstring_view path, char** args)
 {
     using namespace std::string_literals;
     pid_t pid = fork();
@@ -60,11 +60,11 @@
 
         if (status < 0)
         {
-            fmt::memory_buffer buf;
-            fmt::format_to(fmt::appender(buf), "`{}`", path);
+            stdplus::StrBuf buf;
+            stdplus::strAppend(buf, "`"sv, path, "`"sv);
             for (size_t i = 0; args[i] != nullptr; ++i)
             {
-                fmt::format_to(fmt::appender(buf), " `{}`", args[i]);
+                stdplus::strAppend(buf, " `"sv, args[i], "`"sv);
             }
             buf.push_back('\0');
             lg2::error("Unable to execute the command {CMD}: {STATUS}", "CMD",
@@ -145,7 +145,8 @@
     {
         return "ethaddr";
     }
-    return fmt::format(FMT_COMPILE("eth{}addr"), idx);
+    stdplus::ToStrHandle<stdplus::IntToStr<10, unsigned>> tsh;
+    return stdplus::strCat("eth"sv, tsh(idx), "addr"sv);
 }
 
 static std::optional<DHCPVal> systemdParseDHCP(std::string_view str)
diff --git a/src/util.hpp b/src/util.hpp
index abfd8eb..a1742fa 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -2,7 +2,7 @@
 #include "types.hpp"
 
 #include <stdplus/raw.hpp>
-#include <stdplus/zstring.hpp>
+#include <stdplus/zstring_view.hpp>
 
 #include <optional>
 #include <string>
@@ -70,7 +70,7 @@
  * @param[in] path - path of the binary file which needs to be execeuted.
  * @param[in] args - arguments of the command.
  */
-void executeCommandinChildProcess(stdplus::const_zstring path, char** args);
+void executeCommandinChildProcess(stdplus::zstring_view path, char** args);
 
 /** @brief Get ignored interfaces from environment */
 std::string_view getIgnoredInterfacesEnv();
@@ -89,7 +89,7 @@
  * @param[in] tArgs - arguments of the command.
  */
 template <typename... ArgTypes>
-void execute(stdplus::const_zstring path, ArgTypes&&... tArgs)
+void execute(stdplus::zstring_view path, ArgTypes&&... tArgs)
 {
     using expandType = char*[];
 
diff --git a/test/test_config_parser.cpp b/test/test_config_parser.cpp
index 779f561..d666502 100644
--- a/test/test_config_parser.cpp
+++ b/test/test_config_parser.cpp
@@ -1,7 +1,5 @@
 #include "config_parser.hpp"
 
-#include <fmt/compile.h>
-
 #include <phosphor-logging/elog-errors.hpp>
 #include <stdplus/fd/atomic.hpp>
 #include <stdplus/fd/fmt.hpp>
@@ -24,6 +22,7 @@
 {
 
 using testing::ElementsAre;
+using std::literals::string_view_literals::operator""sv;
 
 TEST(TestConvert, iCaseEq)
 {
@@ -184,13 +183,15 @@
     stdplus::fd::AtomicWriter file(fmt::format("{}/tmp.XXXXXX", CaseTmpDir()),
                                    0600);
     stdplus::fd::FormatBuffer out(file);
+    std::string obj(500, 'a');
+    std::string kv(500 * 70, 'b');
     for (size_t i = 0; i < 500; ++i)
     {
-        out.append(FMT_COMPILE("[{:a>{}}]\n"), "", i + 1);
+        out.appends("["sv, std::string_view{obj}.substr(0, i + 1), "[\n"sv);
         for (size_t j = 0; j < 70; j++)
         {
-            const size_t es = i * 70 + j + 1;
-            out.append(FMT_COMPILE("{:b>{}}={:c>{}}\n"), "", es, "", es);
+            auto sv = std::string_view(kv).substr(0, i * 70 + j + 1);
+            out.appends(sv, "="sv, sv, "\n"sv);
         }
     }
     out.flush();