[SystemZ] Add test missing from r186148
[oota-llvm.git] / utils / count / count.c
index 13250198b9e4d7d29262a8c0ab643f85e020e134..ae96791ae497361dd4059c507ad9e037b1001ba3 100644 (file)
@@ -26,13 +26,15 @@ int main(int argc, char **argv) {
   }
 
   NumLines = 0;
-  while ((NumRead = fread(Buffer, 1, sizeof(Buffer), stdin)) == sizeof(Buffer)){
+  do {
     unsigned i;
 
+    NumRead = fread(Buffer, 1, sizeof(Buffer), stdin);
+
     for (i = 0; i != NumRead; ++i)
       if (Buffer[i] == '\n')
         ++NumLines;
-  }
+  } while (NumRead == sizeof(Buffer));
     
   if (!feof(stdin)) {
     fprintf(stderr, "%s: error reading stdin\n", argv[0]);