Clean up some uses of String::substr

Cases where the end position is either equvalent to the default or past
the end of the string.
This commit is contained in:
A Thousand Ships 2025-02-26 11:41:11 +01:00
parent f2cc3f1275
commit 5113022dfe
No known key found for this signature in database
GPG key ID: DEFC5A5B1306947D
54 changed files with 123 additions and 123 deletions

View file

@ -235,7 +235,7 @@ Vector<Vector<String>> get_extractable_message_list() {
list.push_back(msgs);
}
msg_context = "";
l = l.substr(7, l.length()).strip_edges();
l = l.substr(7).strip_edges();
status = STATUS_READING_CONTEXT;
entered_context = true;
}
@ -244,7 +244,7 @@ Vector<Vector<String>> get_extractable_message_list() {
if (status != STATUS_READING_ID) {
ERR_FAIL_V_MSG(Vector<Vector<String>>(), "Unexpected 'msgid_plural', was expecting 'msgid' before 'msgid_plural' while parsing: " + path + ":" + itos(line));
}
l = l.substr(12, l.length()).strip_edges();
l = l.substr(12).strip_edges();
status = STATUS_READING_PLURAL;
} else if (l.begins_with("msgid")) {
ERR_FAIL_COND_V_MSG(status == STATUS_READING_ID, Vector<Vector<String>>(), "Unexpected 'msgid', was expecting 'msgstr' while parsing: " + path + ":" + itos(line));
@ -257,7 +257,7 @@ Vector<Vector<String>> get_extractable_message_list() {
list.push_back(msgs);
}
l = l.substr(5, l.length()).strip_edges();
l = l.substr(5).strip_edges();
status = STATUS_READING_ID;
// If we did not encounter msgctxt, we reset context to empty to reset it.
if (!entered_context) {
@ -271,11 +271,11 @@ Vector<Vector<String>> get_extractable_message_list() {
if (l.begins_with("msgstr[")) {
ERR_FAIL_COND_V_MSG(status != STATUS_READING_PLURAL, Vector<Vector<String>>(),
"Unexpected 'msgstr[]', was expecting 'msgid_plural' before 'msgstr[]' while parsing: " + path + ":" + itos(line));
l = l.substr(9, l.length()).strip_edges();
l = l.substr(9).strip_edges();
} else if (l.begins_with("msgstr")) {
ERR_FAIL_COND_V_MSG(status != STATUS_READING_ID, Vector<Vector<String>>(),
"Unexpected 'msgstr', was expecting 'msgid' before 'msgstr' while parsing: " + path + ":" + itos(line));
l = l.substr(6, l.length()).strip_edges();
l = l.substr(6).strip_edges();
status = STATUS_READING_STRING;
}
@ -286,7 +286,7 @@ Vector<Vector<String>> get_extractable_message_list() {
ERR_FAIL_COND_V_MSG(!l.begins_with("\"") || status == STATUS_NONE, Vector<Vector<String>>(), "Invalid line '" + l + "' while parsing: " + path + ":" + itos(line));
l = l.substr(1, l.length());
l = l.substr(1);
// Find final quote, ignoring escaped ones (\").
// The escape_next logic is necessary to properly parse things like \\"
// where the backslash is the one being escaped, not the quote.