From: Mikko Rasa Date: Tue, 25 Dec 2018 11:06:30 +0000 (+0200) Subject: Don't apply parts of a pattern that are already present X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=daac042aa64e944248160c1b38b9a31e3972bb50;p=builder.git Don't apply parts of a pattern that are already present This allows naming a library component "libsomething" without the final file name having a double lib prefix. --- diff --git a/source/pattern.cpp b/source/pattern.cpp index 74c7c31..51ca9c6 100644 --- a/source/pattern.cpp +++ b/source/pattern.cpp @@ -14,7 +14,12 @@ Pattern::Pattern(const string &pat) string Pattern::apply(const string &body) const { - return prefix+body+suffix; + 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)) + result += suffix; + return result; } list Pattern::apply_list(const list &patterns, const string &body)