diff options
author | Adrian Kummerlaender | 2016-04-22 22:23:35 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2016-04-22 22:23:35 +0200 |
commit | 5eb3689c9985f28b46651f547b9b32d55b4a07b5 (patch) | |
tree | 798b747b241de9f9233fa7b5dc6ce96a2fbbcde5 | |
parent | b647d08bb19abe4d199166a05f9f14c65f5f0ed4 (diff) | |
download | justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.tar justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.tar.gz justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.tar.bz2 justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.tar.lz justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.tar.xz justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.tar.zst justify-5eb3689c9985f28b46651f547b9b32d55b4a07b5.zip |
Handle input stream EOF
-rw-r--r-- | justify.cc | 8 | ||||
-rw-r--r-- | src/line_accumulator.cc | 2 |
2 files changed, 7 insertions, 3 deletions
@@ -81,8 +81,12 @@ bool process(const boost::program_options::variables_map& variables) { justify::LineAccumulator acc{line_length, line_offset}; std::string token; - while ( std::cin >> token ) { - acc(token); + while ( std::cin.good() ) { + if ( std::cin >> token ) { + acc(token); + } else { + return true; + } } return true; diff --git a/src/line_accumulator.cc b/src/line_accumulator.cc index 4398c50..9ce389b 100644 --- a/src/line_accumulator.cc +++ b/src/line_accumulator.cc @@ -149,7 +149,7 @@ void LineAccumulator::justify() { std::for_each( indizes.begin(), indizes.begin() + this->getMissing(), - [&](std::uint8_t x) { + [&](const std::uint8_t x) { this->tokens_[x].second += 1; this->length_ += 1; } |