[commit: base] encoding: Bug fixes to Windows code path (5579a1c)
Ian Lynagh
igloo at earth.li
Wed Apr 6 23:38:16 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : encoding
http://hackage.haskell.org/trac/ghc/changeset/5579a1c42e0d56aa11bfca72b76d0b1fd332f926
>---------------------------------------------------------------
commit 5579a1c42e0d56aa11bfca72b76d0b1fd332f926
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date: Tue Apr 5 09:32:38 2011 +0100
Bug fixes to Windows code path
>---------------------------------------------------------------
GHC/IO/Encoding/CodePage.hs | 2 +-
GHC/Windows.hs | 6 ++++++
System/Environment.hs | 12 ++++++------
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/GHC/IO/Encoding/CodePage.hs b/GHC/IO/Encoding/CodePage.hs
index 412c1b3..d9ec11b 100644
--- a/GHC/IO/Encoding/CodePage.hs
+++ b/GHC/IO/Encoding/CodePage.hs
@@ -125,7 +125,7 @@ encodeToSingleByte cfm CompactArray { encoderMax = maxChar,
| otherwise = do
(c,ir') <- readCharBuf iraw ir
case lookupCompact maxChar indices values c of
- Nothing -> invalid ir'
+ Nothing -> invalid c ir'
Just 0 | c /= '\0' -> invalid c ir'
Just b -> do
writeWord8Buf oraw ow b
diff --git a/GHC/Windows.hs b/GHC/Windows.hs
index 7f3b30a..2a74a5f 100644
--- a/GHC/Windows.hs
+++ b/GHC/Windows.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude, ForeignFunctionInterface #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.Windows
@@ -18,7 +19,12 @@
module GHC.Windows where
+import GHC.Base
+import GHC.Ptr
+
import Data.Word
+
+import Foreign.C.Error (throwErrno)
import Foreign.C.Types
diff --git a/System/Environment.hs b/System/Environment.hs
index 19f2f1a..67ad1ef 100644
--- a/System/Environment.hs
+++ b/System/Environment.hs
@@ -130,17 +130,17 @@ getEnv :: String -> IO String
#ifdef mingw32_HOST_OS
getEnv name = withCWString name $ \s -> do
size <- c_GetEnvironmentVariable s nullPtr 0
- try_size size
+ try_size s size
where
- try_size size = allocaArray size $ \p_value -> do
+ try_size s size = allocaArray (fromIntegral size) $ \p_value -> do
res <- c_GetEnvironmentVariable s p_value size
case res of
0 -> throwGetLastError "getEnv"
- _ | res > size -> try_size res -- Rare: size increased between calls to GetEnvironmentVariable
- | otherwise -> peekCWString size
+ _ | res > size -> try_size s res -- Rare: size increased between calls to GetEnvironmentVariable
+ | otherwise -> peekCWString p_value
foreign import stdcall unsafe "windows.h GetEnvironmentVariableW"
- c_GetEnvironmentVariable :: LPTSTR -> LPTSTR -> DWORD -> IO LPTSTR
+ c_GetEnvironmentVariable :: LPTSTR -> LPTSTR -> DWORD -> IO DWORD
#else
getEnv name =
withCString name $ \s -> do
@@ -231,7 +231,7 @@ getEnvironment = bracket c_GetEnvironmentStrings c_FreeEnvironmentStrings $ \pBl
if done then return pBlock'
else do
c <- peek pBlock'
- seekNull pBlock' (c == 0)
+ seekNull pBlock' (c == (0 :: Word8 ))
foreign import stdcall unsafe "windows.h GetEnvironmentStringsW"
c_GetEnvironmentStrings :: IO (Ptr CWchar)
More information about the Cvs-libraries
mailing list