1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

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

llvm-svn: 105270
This commit is contained in:
Dan Gohman 2010-06-01 14:09:29 +00:00
parent ed7364d3e1
commit 03eb68452e

View File

@ -26,13 +26,15 @@ int main(int argc, char **argv) {
} }
NumLines = 0; NumLines = 0;
while ((NumRead = fread(Buffer, 1, sizeof(Buffer), stdin))) { do {
unsigned i; unsigned i;
NumRead = fread(Buffer, 1, sizeof(Buffer), stdin);
for (i = 0; i != NumRead; ++i) for (i = 0; i != NumRead; ++i)
if (Buffer[i] == '\n') if (Buffer[i] == '\n')
++NumLines; ++NumLines;
} } while (NumRead == sizeof(Buffer));
if (!feof(stdin)) { if (!feof(stdin)) {
fprintf(stderr, "%s: error reading stdin\n", argv[0]); fprintf(stderr, "%s: error reading stdin\n", argv[0]);