From 52343ff414f7b41e8f38e28bec3de39500b5fed2 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Wed, 22 Aug 2018 02:07:30 +0200 Subject: Fix bug on dicealias replacement (when several replacement must be done on the same command). --- dicealias.cpp | 6 ++++-- dicealias.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dicealias.cpp b/dicealias.cpp index a27919d..f514e9e 100644 --- a/dicealias.cpp +++ b/dicealias.cpp @@ -89,9 +89,11 @@ QString makeReplament(const QString& pattern, const QString& replacement, QStrin patternPosList.push_back(pos); pos+=1; } - for(auto pos : patternPosList) + + // TODO to be replace by C++14 when it is ready + for (auto i = patternPosList.rbegin(); i != patternPosList.rend(); ++i) { - cmd.replace(pos,1,replacement); + cmd.replace(*i,1,replacement); } } } diff --git a/dicealias.h b/dicealias.h index a85c9a0..8320445 100644 --- a/dicealias.h +++ b/dicealias.h @@ -37,7 +37,7 @@ public: * @param key * @param isReplace */ - DiceAlias(QString cmd, QString key, bool isReplace = true, bool isEnable = true); + DiceAlias(QString pattern, QString remplacement, bool isReplace = true, bool isEnable = true); /** * @brief ~DiceAlias */ -- cgit v1.2.3-70-g09d2