diff options
| author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-17 04:38:03 +0900 |
|---|---|---|
| committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-18 11:25:43 +0900 |
| commit | 810fd03ef36afedeef832c5e78171b9e26a97e00 (patch) | |
| tree | 67ce2b8a0d40af8fa42b9aecde9fc3d7c164a789 /strutil.cc | |
| parent | d4e8193c6bf264d32332a82d6ec0188c9bdac14f (diff) | |
[C++] Implement define
Diffstat (limited to 'strutil.cc')
| -rw-r--r-- | strutil.cc | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -154,3 +154,15 @@ void AppendSubstRef(StringPiece str, StringPiece pat, StringPiece subst, out->append(s.begin(), s.end()); out->append(subst.begin(), subst.end()); } + +string NoLineBreak(const string& s) { + size_t index = s.find('\n'); + if (index == string::npos) + return s; + string r = s; + while (index != string::npos) { + r = s.substr(0, index) + "\\n" + s.substr(index + 1); + index = s.find('\n', index + 2); + } + return r; +} |
