Fixed a bug with getline() failing at the EOF.
authorFrancois Fleuret <francois@fleuret.org>
Sat, 28 Mar 2009 22:38:50 +0000 (23:38 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Sat, 28 Mar 2009 22:38:50 +0000 (23:38 +0100)
selector.cc

index f5b9d2d..3f8aba7 100644 (file)
@@ -544,14 +544,14 @@ int main(int argc, char **argv) {
 
     file.getline(raw_line, buffer_size);
 
-    if(file.fail()) {
-      cerr << "Line too long." << endl;
-      cerr << raw_line << endl;
-      exit(1);
-    }
-
     if(raw_line[0]) {
 
+      if(file.fail()) {
+        cerr << "Line too long:" << endl;
+        cerr << raw_line << endl;
+        exit(1);
+      }
+
       char *s, *t;
       const char *u;