1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 23:48:30 +02:00

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.
This commit is contained in:
Misa 2021-02-07 13:19:33 -08:00 committed by Ethan Lee
parent 4728f64e3a
commit adbae16666

View File

@ -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)
{