diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2015-08-21 11:13:28 -0700 |
|---|---|---|
| committer | Dan Willemsen <dwillemsen@google.com> | 2015-08-25 13:25:21 -0700 |
| commit | e6f6858860e28b4336ae5d64d42b5080a6fbe4c1 (patch) | |
| tree | 9a6f05480920bd82fd412ecd2e122b7f59994389 /strutil.cc | |
| parent | fcd7a98b3008c518a063140530366fc1ef57c0f1 (diff) | |
[C++] Fix newlines in $(info/warning/error)
Change-Id: Ia20a1ef563a6871ed843b9388fe27e87b8bd7020
Diffstat (limited to 'strutil.cc')
| -rw-r--r-- | strutil.cc | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -427,3 +427,24 @@ string ConcatDir(StringPiece b, StringPiece n) { NormalizePath(&r); return r; } + +string EchoEscape(const string str) { + const char *in = str.c_str(); + string buf; + for (; *in; in++) { + switch(*in) { + case '\\': + buf += "\\\\\\\\"; + break; + case '\n': + buf += "\\n"; + break; + case '"': + buf += "\\\""; + break; + default: + buf += *in; + } + } + return buf; +} |
