diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-09-11 16:33:16 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-09-11 16:33:16 +0900 |
commit | a7984ad9b84f94b50454ad7acd20d5dcacdd6b12 (patch) | |
tree | 643f618d175143ec55343b552a50bb64b9d3617c /strutil.cc | |
parent | 36b6582e5690f473f8ebbd6e255df92b955c696e (diff) | |
download | kati-a7984ad9b84f94b50454ad7acd20d5dcacdd6b12.tar.gz |
[C++] Correct the implementation of $*
Diffstat (limited to 'strutil.cc')
-rw-r--r-- | strutil.cc | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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) { |