From adbae16666c1a7d8c2b9540e1b6f2a218cab7470 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 7 Feb 2021 13:19:33 -0800 Subject: [PATCH] Clean up script header check in editorclass::load() The previous person who wrote this (a girl named Misa) clearly didn't understand the reason why you couldn't compare line[line.length()-1] directly to a string literal. It's because the former is a char, and the latter is a pointer to a char. Both are ints, so it compiles fine, but it doesn't do what you want it to. Why not just make the latter a char instead of a string literal? Well, because you can, but also I clearly didn't think this through earlier, so that's why I didn't do it in the first place. But this is fixed now. --- desktop_version/src/editor.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index e6958683..45b0709a 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -1878,14 +1878,7 @@ bool editorclass::load(std::string& _path) { std::string& line = values[i]; - //Comparing line[line.length()-1] directly to a string literal is UB - //Workaround: assign line[line.length()-1] to a string first - std::string temp; - if(line.length()) - { - temp = line[line.length()-1]; - } - if(temp == ":") + if(line.length() && line[line.length() - 1] == ':') { if(headerfound) {