diff --git a/linenoise-ng b/linenoise-ng index 3d3d594..6a37ee0 160000 --- a/linenoise-ng +++ b/linenoise-ng @@ -1 +1 @@ -Subproject commit 3d3d594caf15b75517d9baea1f1860978cad771a +Subproject commit 6a37ee0e9f117bb9950159545ecdbdbba41799bf diff --git a/src/rpn-test-framework.cpp b/src/rpn-test-framework.cpp index fecaf7a..47f3cc4 100644 --- a/src/rpn-test-framework.cpp +++ b/src/rpn-test-framework.cpp @@ -1,10 +1,21 @@ -#include -using namespace std; - #include "escape.h" #include "program.hpp" #include "version.h" +static void _findAndReplaceAll(std::string & data, std::string toSearch, std::string replaceStr) +{ + // Get the first occurrence + size_t pos = data.find(toSearch); + // Repeat till end is reached + while( pos != std::string::npos) + { + // Replace this occurrence of Sub String + data.replace(pos, toSearch.size(), replaceStr); + // Get the next occurrence from the current position + pos =data.find(toSearch, pos + replaceStr.size()); + } +} + /// @brief write stack in a string, each entry separated between commas /// /// @param stack_is the output string @@ -232,7 +243,7 @@ void program::test(string test_filename, int& total_tests, int& total_tests_fail failed = true; } else { // parse entry and run line - entry = regex_replace(entry, regex("`"), ""); + _findAndReplaceAll(entry, "`", ""); if (!entry.empty()) { program prog(stk, hp); ret = prog.parse(entry);