"include/vscode:/vscode.git/clone" did not exist on "f30dbe8717177da2b1745ac3b2a5d5fd7475de55"
Commit eba54290 authored by Guolin Ke's avatar Guolin Ke
Browse files

fix bug in string.split()

parent 804d3ada
......@@ -44,13 +44,17 @@ inline static std::string& RemoveQuotationSymbol(std::string& str) {
return str;
}
inline static std::vector<std::string> Split(const char* str, char delimiter) {
std::stringstream ss(str);
std::string tmp_str;
inline static std::vector<std::string> Split(const char* c_str, char delimiter) {
std::vector<std::string> ret;
while (std::getline(ss, tmp_str, delimiter)) {
ret.push_back(tmp_str);
}
std::string str(c_str);
size_t i = 0;
size_t pos = str.find(delimiter);
while (pos != std::string::npos) {
ret.push_back(str.substr(i, pos - i));
i = ++pos;
pos = str.find(delimiter, pos);
}
ret.push_back(str.substr(i));
return ret;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment