]> git.tdb.fi Git - builder.git/commitdiff
Fix check for appending pattern suffix
authorMikko Rasa <tdb@tdb.fi>
Mon, 3 Jun 2019 11:59:04 +0000 (14:59 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 3 Jun 2019 11:59:04 +0000 (14:59 +0300)
If the body is too short to already contain the suffix, it should be
added.

source/pattern.cpp

index 51ca9c6f1c94830967ed1f7c2a5a210b9b20c243..91929f62b0c85a541361af63bc3102b9641d1eba 100644 (file)
@@ -17,7 +17,7 @@ string Pattern::apply(const string &body) const
        string result = body;
        if(body.compare(0, prefix.size(), prefix))
                result = prefix+result;
-       if(body.size()>suffix.size() && body.compare(body.size()-suffix.size(), suffix.size(), suffix))
+       if(body.size()<=suffix.size() || body.compare(body.size()-suffix.size(), suffix.size(), suffix))
                result += suffix;
        return result;
 }