diff options
| author | Niklas Hambüchen <mail@nh2.me> | 2013-08-23 21:46:14 +0900 |
|---|---|---|
| committer | Austin Seipp <aseipp@pobox.com> | 2013-08-23 09:26:11 -0500 |
| commit | 41be8d30356d050938f61f06c56928d2c3eb2541 (patch) | |
| tree | f6993c34d77f4d9eb8cab4345eff920b2de0f1a6 /compiler/utils | |
| parent | 48d7b0e963e88101464136419705e3c9e2e947f9 (diff) | |
| download | haskell-41be8d30356d050938f61f06c56928d2c3eb2541.tar.gz | |
Fingerprint.getFileHash: Fix not reading file at all.
This lead to the stage1 compiler calculating random iface hashes.
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'compiler/utils')
| -rw-r--r-- | compiler/utils/Fingerprint.hsc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/utils/Fingerprint.hsc b/compiler/utils/Fingerprint.hsc index aad964a212..2f59f2a02b 100644 --- a/compiler/utils/Fingerprint.hsc +++ b/compiler/utils/Fingerprint.hsc @@ -20,6 +20,7 @@ module Fingerprint ( #include "md5.h" ##include "HsVersions.h" +import Control.Monad ( when ) import Numeric ( readHex ) #if __GLASGOW_HASKELL__ < 707 -- Only needed for getFileHash below. @@ -50,7 +51,10 @@ getFileHash path = withBinaryFile path ReadMode $ \h -> do fileSize <- toIntFileSize `fmap` hFileSize h - allocaBytes fileSize (\bufPtr -> fingerprintData bufPtr fileSize) + allocaBytes fileSize $ \bufPtr -> do + n <- hGetBuf h bufPtr fileSize + when (n /= fileSize) readFailedError + fingerprintData bufPtr fileSize where toIntFileSize :: Integer -> Int @@ -59,4 +63,7 @@ getFileHash path = withBinaryFile path ReadMode $ \h -> do Sorry $ "Fingerprint.getFileHash: Tried to calculate hash of file " ++ path ++ " with size > maxBound :: Int. This is not supported." | otherwise = fromIntegral size + + readFailedError = throwGhcException $ + Panic $ "Fingerprint.getFileHash: hGetBuf failed on interface file" #endif |
