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:
parent
f5bc2a5f0d
commit
622161e563
@ -20,6 +20,8 @@ int main(int argc, char *argv[])
|
|||||||
auto dataLen = 0U;
|
auto dataLen = 0U;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
char ch;
|
||||||
|
inputAny.read(&ch, 1);
|
||||||
if (inputAny.eof())
|
if (inputAny.eof())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -28,8 +30,6 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
char ch;
|
|
||||||
inputAny.read(&ch, 1);
|
|
||||||
outputCpp << (unsigned int)(unsigned char)(ch) << ", ";
|
outputCpp << (unsigned int)(unsigned char)(ch) << ", ";
|
||||||
dataLen += 1;
|
dataLen += 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user