summaryrefslogtreecommitdiffstats
path: root/llvm/utils/count
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-06-01 14:09:29 +0000
committerDan Gohman <gohman@apple.com>2010-06-01 14:09:29 +0000
commit88337a95cae8d1d2aac1ceeb80cfc7fb54292a41 (patch)
tree50f24b923c1d84390bec1a3e2472ee2ea0776cd4 /llvm/utils/count
parent8916358f9714973fe69bd962795e391276c6e774 (diff)
downloadbcm5719-llvm-88337a95cae8d1d2aac1ceeb80cfc7fb54292a41.tar.gz
bcm5719-llvm-88337a95cae8d1d2aac1ceeb80cfc7fb54292a41.zip
Fix extra fread after EOF, non-wires-crossed version.
llvm-svn: 105270
Diffstat (limited to 'llvm/utils/count')
-rw-r--r--llvm/utils/count/count.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/utils/count/count.c b/llvm/utils/count/count.c
index a37e1e0b254..ae96791ae49 100644
--- a/llvm/utils/count/count.c
+++ b/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