about summary refs log tree commit diff stats
path: root/092persist.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 /092persist.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 '092persist.cc')
-rw-r--r--092persist.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/092persist.cc b/092persist.cc
index 774ce08f..e0201cd0 100644
--- a/092persist.cc
+++ b/092persist.cc
@@ -57,7 +57,7 @@ string slurp(const string& filename) {
   if (!fin) return result.str();  // don't bother checking errno
   const int N = 1024;
   char buf[N];
-  while (!fin.eof()) {
+  while (has_data(fin)) {
     bzero(buf, N);
     fin.read(buf, N-1);  // leave at least one null
     result << buf;