From 5eb3689c9985f28b46651f547b9b32d55b4a07b5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 22 Apr 2016 22:23:35 +0200 Subject: Handle input stream EOF --- justify.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'justify.cc') diff --git a/justify.cc b/justify.cc index 8120ded..c417dfd 100644 --- a/justify.cc +++ b/justify.cc @@ -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; -- cgit v1.2.3