diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-17 01:21:00 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-17 01:21:00 -0800 |
commit | 08cf048f2a8ed0fa096f2c82e147b61ffc480e2a (patch) | |
tree | 80493ca241c9172e21df76cedb98312af6de8113 /010vm.cc | |
parent | 21c277062ef151ad86e2003ad0e2bfb09f3d4c2d (diff) | |
download | mu-08cf048f2a8ed0fa096f2c82e147b61ffc480e2a.tar.gz |
2454
Another gotcha uncovered in the process of sorting out the previous commit: I keep using eof() but forgetting that there are two other states an istream can get into. Just never use eof().
Diffstat (limited to '010vm.cc')
-rw-r--r-- | 010vm.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/010vm.cc b/010vm.cc index 016d3ad6..fcd72be2 100644 --- a/010vm.cc +++ b/010vm.cc @@ -236,7 +236,7 @@ reagent::reagent(string s) :original_string(s), value(0), initialized(false), ty istringstream in(s); in >> std::noskipws; // properties - while (!in.eof()) { + while (has_data(in)) { istringstream row(slurp_until(in, '/')); row >> std::noskipws; string key = slurp_until(row, ':'); @@ -261,7 +261,7 @@ reagent::reagent(string s) :original_string(s), value(0), initialized(false), ty string_tree* parse_property_list(istream& in) { skip_whitespace(in); - if (in.eof()) return NULL; + if (!has_data(in)) return NULL; string_tree* result = new string_tree(slurp_until(in, ':')); result->right = parse_property_list(in); return result; @@ -539,7 +539,7 @@ void dump(const string_tree* x, ostream& out) { } void skip_whitespace(istream& in) { - while (!in.eof() && isspace(in.peek()) && in.peek() != '\n') { + while (in && isspace(in.peek()) && in.peek() != '\n') { in.get(); } } |