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:
Tamás Bálint Misius
2022-01-15 15:46:59 +01:00
parent f5bc2a5f0d
commit 622161e563

View File

@@ -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;
}