Skip to content

Commit 617a3d4

Browse files
committedJun 1, 2015
Make split method static
1 parent 06a2eee commit 617a3d4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed
 

Diff for: ‎src/guiFormSpecMenu.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -236,28 +236,27 @@ GUITable* GUIFormSpecMenu::getTable(std::wstring tablename)
236236
return 0;
237237
}
238238

239-
std::vector<std::string> split(const std::string &s, char delim) {
239+
static std::vector<std::string> split(const std::string &s, char delim)
240+
{
240241
std::vector<std::string> tokens;
241242

242243
std::string current = "";
243244
bool last_was_escape = false;
244-
for(unsigned int i=0; i < s.size(); i++) {
245+
for (unsigned int i = 0; i < s.size(); i++) {
246+
char si = s.c_str()[i];
245247
if (last_was_escape) {
246248
current += '\\';
247-
current += s.c_str()[i];
249+
current += si;
248250
last_was_escape = false;
249-
}
250-
else {
251-
if (s.c_str()[i] == delim) {
251+
} else {
252+
if (si == delim) {
252253
tokens.push_back(current);
253254
current = "";
254255
last_was_escape = false;
255-
}
256-
else if (s.c_str()[i] == '\\'){
256+
} else if (si == '\\') {
257257
last_was_escape = true;
258-
}
259-
else {
260-
current += s.c_str()[i];
258+
} else {
259+
current += si;
261260
last_was_escape = false;
262261
}
263262
}

0 commit comments

Comments
 (0)
Please sign in to comment.