mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-28 10:20:04 +02:00
Fix ToArray duplicating the last byte of its input
Apparently, you have to read() before you check status bits. Who woulda thunk. This never manifested because all the files we ever embedded this way ended in a newline. I needed a report from someone who uses a text editor that doesn't ensure this.
This commit is contained in:
@@ -20,6 +20,8 @@ int main(int argc, char *argv[])
|
||||
auto dataLen = 0U;
|
||||
while (true)
|
||||
{
|
||||
char ch;
|
||||
inputAny.read(&ch, 1);
|
||||
if (inputAny.eof())
|
||||
{
|
||||
break;
|
||||
@@ -28,8 +30,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
char ch;
|
||||
inputAny.read(&ch, 1);
|
||||
outputCpp << (unsigned int)(unsigned char)(ch) << ", ";
|
||||
dataLen += 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user