diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-01 14:09:29 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-01 14:09:29 +0000 |
commit | c6e1f67b17b4cb9d707af1245c1ecf00f91f23c0 (patch) | |
tree | a1903fb4ccca267050dfcdbc9c589166db956f65 /utils/count | |
parent | 11fe24624a307575eec82e9825ab8ba5435024a5 (diff) | |
download | external_llvm-c6e1f67b17b4cb9d707af1245c1ecf00f91f23c0.tar.gz external_llvm-c6e1f67b17b4cb9d707af1245c1ecf00f91f23c0.tar.bz2 external_llvm-c6e1f67b17b4cb9d707af1245c1ecf00f91f23c0.zip |
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
Diffstat (limited to 'utils/count')
-rw-r--r-- | utils/count/count.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/utils/count/count.c b/utils/count/count.c index a37e1e0b25..ae96791ae4 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))) { + 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]); |