mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-17 22:02:19 -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 newLine = str.find(NEWLINE()[0], lastNewline);
|
||||
bool done;
|
||||
|
||||
// Bail out early
|
||||
if (newLine == std::string::npos) {
|
||||
return newLine;
|
||||
}
|
||||
|
||||
do {
|
||||
done = true;
|
||||
if (newLine != 0) {
|
||||
@ -420,12 +425,13 @@ size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
|
||||
}
|
||||
if (!done) {
|
||||
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
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
return newLine;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user