Fix extra fread after EOF, non-wires-crossed version.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105270 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-06-01 14:09:29 +00:00
parent 11fe24624a
commit c6e1f67b17

View File

@ -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]);