From 622161e5635a712315c0faeb1b0e7a7fec8ae505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sat, 15 Jan 2022 15:46:59 +0100 Subject: [PATCH] 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. --- data/ToArray.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/ToArray.cpp b/data/ToArray.cpp index fd7f009e5..525ddf91c 100644 --- a/data/ToArray.cpp +++ b/data/ToArray.cpp @@ -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; }