about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-17 01:21:00 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-17 01:21:00 -0800
commit08cf048f2a8ed0fa096f2c82e147b61ffc480e2a (patch)
tree80493ca241c9172e21df76cedb98312af6de8113 /030container.cc
parent21c277062ef151ad86e2003ad0e2bfb09f3d4c2d (diff)
downloadmu-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 '030container.cc')
-rw-r--r--030container.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/030container.cc b/030container.cc
index 25303f39..9be42f23 100644
--- a/030container.cc
+++ b/030container.cc
@@ -415,7 +415,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) {
   recently_added_types.push_back(get(Type_ordinal, name));
   info.name = name;
   info.kind = kind;
-  while (!in.eof()) {
+  while (has_data(in)) {
     skip_whitespace_and_comments(in);
     string element = next_word(in);
     if (element == "]") break;
@@ -424,7 +424,7 @@ void insert_container(const string& command, kind_of_type kind, istream& in) {
     info.element_names.push_back(slurp_until(inner, ':'));
     trace(9993, "parse") << "  element name: " << info.element_names.back() << end();
     type_tree* new_type = NULL;
-    for (type_tree** curr_type = &new_type; !inner.eof(); curr_type = &(*curr_type)->right) {
+    for (type_tree** curr_type = &new_type; has_data(inner); curr_type = &(*curr_type)->right) {
       string type_name = slurp_until(inner, ':');
       // End insert_container Special Uses(type_name)
       if (!contains_key(Type_ordinal, type_name)