Skip to content

Commit 7a93396

Browse files
committed
Tweaked C++ BitInputStream class in case EOF is not -1.
1 parent f6744d9 commit 7a93396

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cpp/BitIoStream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ BitInputStream::BitInputStream(std::istream &in) :
1818

1919

2020
int BitInputStream::read() {
21-
if (currentByte == -1)
21+
if (currentByte == EOF)
2222
return -1;
2323
if (numBitsRemaining == 0) {
2424
currentByte = input.get(); // Note: istream.get() returns int, not char

cpp/BitIoStream.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BitInputStream final {
2323
// The underlying byte stream to read from.
2424
private: std::istream &input;
2525

26-
// Either in the range [0x00, 0xFF] if bits are available, or -1 if end of stream is reached.
26+
// Either in the range [0x00, 0xFF] if bits are available, or EOF if end of stream is reached.
2727
private: int currentByte;
2828

2929
// Number of remaining bits in the current byte, always between 0 and 7 (inclusive).

0 commit comments

Comments
 (0)