mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-18 06:12:20 -05:00
Fix find newline looping to have additional break early cases (#4614)
This commit is contained in:
parent
b442c15322
commit
9b169af3f5
@ -376,10 +376,15 @@ static size_t NextLineLength(const std::string* textStr, const size_t lastNewlin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
|
size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
|
||||||
size_t newLine = str.find(NEWLINE()[0], lastNewline);
|
size_t newLine = str.find(NEWLINE()[0], lastNewline);
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
|
// Bail out early
|
||||||
|
if (newLine == std::string::npos) {
|
||||||
|
return newLine;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
done = true;
|
done = true;
|
||||||
if (newLine != 0) {
|
if (newLine != 0) {
|
||||||
@ -420,12 +425,13 @@ size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
|
|||||||
}
|
}
|
||||||
if (!done) {
|
if (!done) {
|
||||||
newLine = str.find(NEWLINE()[0], newLine + 1);
|
newLine = str.find(NEWLINE()[0], newLine + 1);
|
||||||
if (newLine != std::string::npos){
|
if (newLine == std::string::npos) {
|
||||||
// if we reach the end of the string, quit now to save a loop
|
// if we reach the end of the string, quit now to save a loop
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
|
|
||||||
return newLine;
|
return newLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user