aboutsummaryrefslogtreecommitdiff
path: root/strutil.cc
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-09-11 16:33:16 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-09-11 16:33:16 +0900
commita7984ad9b84f94b50454ad7acd20d5dcacdd6b12 (patch)
tree643f618d175143ec55343b552a50bb64b9d3617c /strutil.cc
parent36b6582e5690f473f8ebbd6e255df92b955c696e (diff)
downloadkati-a7984ad9b84f94b50454ad7acd20d5dcacdd6b12.tar.gz
[C++] Correct the implementation of $*
Diffstat (limited to 'strutil.cc')
-rw-r--r--strutil.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/strutil.cc b/strutil.cc
index defb292..09deaf4 100644
--- a/strutil.cc
+++ b/strutil.cc
@@ -150,6 +150,13 @@ bool Pattern::MatchImpl(StringPiece str) const {
HasSuffix(str, pat_.substr(percent_index_ + 1)));
}
+StringPiece Pattern::Stem(StringPiece str) const {
+ if (!Match(str))
+ return "";
+ return str.substr(percent_index_,
+ str.size() - (pat_.size() - percent_index_ - 1));
+}
+
void Pattern::AppendSubst(StringPiece str, StringPiece subst,
string* out) const {
if (percent_index_ == string::npos) {