parseColorsStream: fix empty/white lines detection

When input line is empty, sscanf does not write a '\0' to the %s target.
Initialize its first byte to '\0' to properly detect empty lines after.

Next, we do not want to stop reading the file upon reading an empty line:
use continue instead of break.

The latter was not noticed because of the former.
This commit is contained in:
Christophe Le Roy 2016-10-08 20:11:32 +02:00
parent 5a174e7980
commit 82a19b6cae
1 changed files with 2 additions and 1 deletions

View File

@ -272,13 +272,14 @@ void TileGenerator::parseColorsStream(std::istream &in)
}
char name[64];
name[0] = '\0';
unsigned int r, g, b, a, t;
a = 255;
t = 0;
sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t);
if(strlen(name) == 0)
break;
continue;
ColorEntry color = ColorEntry(r, g, b, a, t);
m_colorMap[name] = color;
}