diff --git a/i18n/strings.de-DE b/i18n/strings.de-DE new file mode 100644 index 000000000..4e27cf74f --- /dev/null +++ b/i18n/strings.de-DE @@ -0,0 +1,11 @@ +# 1xx task shell +100 Unbekannter Fehler. + +# 2xx Commands +# 3xx Attributes +# 4xx Columns +# 5xx Colors +# 6xx Config +# 7xx TDB +# 8xx Reports + diff --git a/i18n/strings.es-ES b/i18n/strings.es-ES new file mode 100644 index 000000000..f9cf3ff99 --- /dev/null +++ b/i18n/strings.es-ES @@ -0,0 +1,11 @@ +# 1xx task shell +100 Error desconocido. + +# 2xx Commands +# 3xx Attributes +# 4xx Columns +# 5xx Colors +# 6xx Config +# 7xx TDB +# 8xx Reports + diff --git a/i18n/strings.fr-FR b/i18n/strings.fr-FR new file mode 100644 index 000000000..7c06146e5 --- /dev/null +++ b/i18n/strings.fr-FR @@ -0,0 +1,11 @@ +# 1xx task shell +100 Erreur inconnue. + +# 2xx Commands +# 3xx Attributes +# 4xx Columns +# 5xx Colors +# 6xx Config +# 7xx TDB +# 8xx Reports + diff --git a/i18n/strings.nl-NL b/i18n/strings.nl-NL new file mode 100644 index 000000000..bc561d5b4 --- /dev/null +++ b/i18n/strings.nl-NL @@ -0,0 +1,11 @@ +# 1xx task shell +100 Onbekende fout. + +# 2xx Commands +# 3xx Attributes +# 4xx Columns +# 5xx Colors +# 6xx Config +# 7xx TDB +# 8xx Reports + diff --git a/src/Subst.cpp b/src/Subst.cpp index 35a8bf007..ebf89e38d 100644 --- a/src/Subst.cpp +++ b/src/Subst.cpp @@ -25,7 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// -#include +#include "Subst.h" +#include "Nibbler.h" //////////////////////////////////////////////////////////////////////////////// Subst::Subst () @@ -70,36 +71,18 @@ Subst::~Subst () //////////////////////////////////////////////////////////////////////////////// bool Subst::parse (const std::string& input) { - size_t first = input.find ('/'); - if (first != std::string::npos) + Nibbler n (input); + if (n.skip ('/') && + n.getUntil ('/', mFrom) && + n.skip ('/') && + n.getUntil ('/', mTo) && + n.skip ('/')) { - size_t second = input.find ('/', first + 1); - if (second != std::string::npos) - { - size_t third = input.find ('/', second + 1); - if (third != std::string::npos) - { - if (first == 0 && - first < second && - second < third && - (third == input.length () - 1 || - third == input.length () - 2)) - { - mFrom = input.substr (first + 1, second - first - 1); - mTo = input.substr (second + 1, third - second - 1); - - mGlobal = false; - if (third == input.length () - 2 && - input.find ('g', third + 1) != std::string::npos) - mGlobal = true; - - return true; - } - } - } + mGlobal = n.skip ('g'); + return true; } - return false; + return false; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tests/subst.t.cpp b/src/tests/subst.t.cpp index 67622a873..982ef205a 100644 --- a/src/tests/subst.t.cpp +++ b/src/tests/subst.t.cpp @@ -31,7 +31,7 @@ //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (2); + UnitTest t (3); T2 task; task.set ("description", "one two three four"); @@ -65,6 +65,20 @@ int main (int argc, char** argv) t.fail ("failed to parse '/e /E /g'"); } + if (s.parse ("/from/to/g")) + { + std::string description = task.get ("description"); + std::vector annotations; + task.getAnnotations (annotations); + + s.apply (description, annotations); + t.is (description, "one two three four", "multiple word subst mismatch"); + } + else + { + t.fail ("failed to parse '/from/to/g'"); + } + return 0; }