Rename string_helpers file .cpp -> .cc
This commit is contained in:
parent
e1ac62edc5
commit
5deeebc38c
2 changed files with 738 additions and 728 deletions
24
src/compiler/util/string_helpers.cc
Normal file
24
src/compiler/util/string_helpers.cc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "compiler/util/string_helpers.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
using std::string;
|
||||
|
||||
namespace util {
|
||||
void str_replace(string *input, const string &search, const string &replace) {
|
||||
size_t pos = 0;
|
||||
while (1) {
|
||||
pos = input->find(search, pos);
|
||||
if (pos == string::npos) break;
|
||||
input->erase(pos, search.length());
|
||||
input->insert(pos, replace);
|
||||
pos += replace.length();
|
||||
}
|
||||
}
|
||||
|
||||
string escape_string(string input) {
|
||||
str_replace(&input, "\"", "\\\"");
|
||||
str_replace(&input, "\n", "\\n");
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue