From: Eduardo Ramos Testillano Date: Tue, 4 Apr 2017 00:35:50 +0000 (+0200) Subject: Fix bug with position values after replace X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=ab5e2bb5ee931f510aa443d9109d46aaf2cdedc2;p=anna.git Fix bug with position values after replace --- diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 5ae6f87..1633e5c 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -2297,27 +2297,21 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons throw anna::RuntimeException(e.what(), ANNA_FILE_LOCATION); } */ - std::string::size_type pos = 0u; - std::string::size_type pos_hbh_1, pos_hbh_2; - std::string::size_type pos_ete_1, pos_ete_2; + std::string::size_type pos, pos_1, pos_2; - pos = regexp.find("hop-by-hop-id=", pos); + pos = regexp.find("hop-by-hop-id=", 0u); pos = regexp.find("\"", pos); - pos_hbh_1 = pos; + pos_1 = pos; pos = regexp.find("\"", pos+1); - pos_hbh_2 = pos; + pos_2 = pos; + regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+"); - pos = regexp.find("end-to-end-id=", pos); + pos = regexp.find("end-to-end-id=", 0u); pos = regexp.find("\"", pos); - pos_ete_1 = pos; + pos_1 = pos; pos = regexp.find("\"", pos+1); - pos_ete_2 = pos; - - std::string hbh = regexp.substr(pos_hbh_1 + 1, pos_hbh_2 - pos_hbh_1 - 1); - std::string ete = regexp.substr(pos_ete_1 + 1, pos_ete_2 - pos_ete_1 - 1); - - regexp.replace(pos_hbh_1 + 1, pos_hbh_2 - pos_hbh_1 - 1, "[0-9]+"); - regexp.replace(pos_ete_1 + 1, pos_ete_2 - pos_ete_1 - 1, "[0-9]+"); + pos_2 = pos; + regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+"); //regexp.insert(0, "^"); //regexp += "$";