X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2Fcount%2Fcount.c;h=ae96791ae497361dd4059c507ad9e037b1001ba3;hb=566fb9fe3ed767be7218fb1608ec6a284067d3b0;hp=13250198b9e4d7d29262a8c0ab643f85e020e134;hpb=b6bd72ee7c426f066ffb6e80734cfe1bc43c2cce;p=oota-llvm.git diff --git a/utils/count/count.c b/utils/count/count.c index 13250198b9e..ae96791ae49 100644 --- a/utils/count/count.c +++ b/utils/count/count.c @@ -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]);