summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/utils/count/count.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/utils/count/count.c')
-rw-r--r--contrib/llvm/utils/count/count.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/contrib/llvm/utils/count/count.c b/contrib/llvm/utils/count/count.c
index a37e1e0..ae96791 100644
--- a/contrib/llvm/utils/count/count.c
+++ b/contrib/llvm/utils/count/count.c
@@ -26,13 +26,15 @@ int main(int argc, char **argv) {
}
NumLines = 0;
- while ((NumRead = fread(Buffer, 1, sizeof(Buffer), stdin))) {
+ 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]);
OpenPOWER on IntegriCloud