replace boost::ifind_first with std::ranges::search
Use a custom case-insensitive search to remove Boost dependency and
reduce compilation memory usage, keeping original string replacement
behavior.
Change-Id: I5778b208dfdb0082515e92f7bda335beb94c21cb
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/src/utils.cpp b/src/utils.cpp
index 4a35756..d5eb30b 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -4,7 +4,6 @@
 #include "utils.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/find.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/container/flat_map.hpp>
@@ -12,9 +11,14 @@
 #include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus/match.hpp>
 
+#include <algorithm>
+#include <cctype>
 #include <filesystem>
 #include <map>
+#include <ranges>
 #include <regex>
+#include <string_view>
+#include <utility>
 
 namespace fs = std::filesystem;
 
@@ -176,3 +180,34 @@
 {
     return std::visit(MatchProbeForwarder(probe), dbusValue);
 }
+
+inline char asciiToLower(char c)
+{
+    // Converts a character to lower case without relying on std::locale
+    if ('A' <= c && c <= 'Z')
+    {
+        c -= static_cast<char>('A' - 'a');
+    }
+    return c;
+}
+
+std::pair<FirstIndex, LastIndex> iFindFirst(std::string_view str,
+                                            std::string_view sub)
+{
+    if (sub.empty())
+    {
+        return {std::string_view::npos, std::string_view::npos};
+    }
+    auto result = std::ranges::search(str, sub, [](char a, char b) {
+        return asciiToLower(a) == asciiToLower(b);
+    });
+
+    if (!result.empty())
+    {
+        size_t start = static_cast<size_t>(
+            std::ranges::distance(str.begin(), result.begin()));
+        return {start, start + sub.size()};
+    }
+
+    return {std::string_view::npos, std::string_view::npos};
+}