packages feed

haskeline 0.6.1.3 → 0.6.1.5

raw patch · 5 files changed

+45/−27 lines, 5 filesdep ~unixsetup-changed

Dependency ranges changed: unix

Files

Setup.hs view
@@ -7,6 +7,9 @@ import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Utils +import Distribution.Simple.PackageIndex+import qualified Distribution.InstalledPackageInfo as Installed+ import System.IO import System.Exit import System.Directory@@ -24,8 +27,7 @@             postConf = \args flags pkgDescr lbi -> do                             let Just lib = library pkgDescr                             let bi = libBuildInfo lib-                            bi' <- maybeSetLibiconv flags bi-                                                        (withPrograms lbi)+                            bi' <- maybeSetLibiconv flags bi lbi                             let pkgDescr' = pkgDescr {                                                 library = Just lib {                                                     libBuildInfo = bi'}}@@ -33,31 +35,31 @@             }  -- Test whether compiling a c program that links against libiconv needs -liconv.-maybeSetLibiconv :: ConfigFlags -> BuildInfo -> ProgramConfiguration -> IO BuildInfo-maybeSetLibiconv flags bi progConf = do+maybeSetLibiconv :: ConfigFlags -> BuildInfo -> LocalBuildInfo -> IO BuildInfo+maybeSetLibiconv flags bi lbi = do+    let biWithIconv = addIconv bi     let verb = fromFlag (configVerbosity flags)     if hasFlagSet flags (FlagName "libiconv")         then do             putStrLn "Using -liconv."             writeBuildInfo "iconv"-            return bi+            return biWithIconv         else do     putStr "checking whether to use -liconv... "     hFlush stdout-    worksWithout <- tryCompile iconv_prog bi progConf verb+    worksWithout <- tryCompile iconv_prog bi lbi verb     if worksWithout         then do             putStrLn "not needed."             writeBuildInfo ""             return bi         else do-    let newBI = addIconv bi-    worksWith <- tryCompile iconv_prog newBI progConf verb+    worksWith <- tryCompile iconv_prog biWithIconv lbi verb     if worksWith         then do             putStrLn "using -liconv."             writeBuildInfo "iconv"-            return newBI+            return biWithIconv         else error "Unable to link against the iconv library."   where     -- Cabal (at least 1.6.0.1) won't parse an empty buildinfo file.@@ -67,27 +69,31 @@ hasFlagSet :: ConfigFlags -> FlagName -> Bool hasFlagSet cflags flag = Just True == lookup flag (configConfigurationsFlags cflags) -tryCompile :: String -> BuildInfo -> ProgramConfiguration -> Verbosity -> IO Bool-tryCompile program bi progConf verb = handle processExit $ handle processException $ do+tryCompile :: String -> BuildInfo -> LocalBuildInfo -> Verbosity -> IO Bool+tryCompile program bi lbi verb = handle processExit $ handle processException $ do     tempDir <- getTemporaryDirectory     withTempFile tempDir ".c" $ \fname h -> do         hPutStr h program         hClose h         -- TODO take verbosity from the args.-        rawSystemProgramStdoutConf verb gccProgram progConf (fname : args)+        rawSystemProgramStdoutConf verb gccProgram (withPrograms lbi) (fname : args)         return True   where     processException :: IOException -> IO Bool     processException e = return False     processExit = return . (==ExitSuccess)-    args = concat [ []-                  , ccOptions bi+    -- Mimicing Distribution.Simple.Configure+    deps = topologicalOrder (installedPkgs lbi)+    args = concat+                  [ ccOptions bi                   , cppOptions bi                   , ldOptions bi                   -- --extra-include-dirs and --extra-lib-dirs are included                   -- in the below fields.-                  , map ("-I" ++) (includeDirs bi)-                  , map ("-L" ++) (extraLibDirs bi)+                  -- Also sometimes a dependency like rts points to a nonstandard+                  -- include/lib directory where iconv can be found. +                  , map ("-I" ++) (includeDirs bi ++ concatMap Installed.includeDirs deps)+                  , map ("-L" ++) (extraLibDirs bi ++ concatMap Installed.libraryDirs deps)                   , map ("-l" ++) (extraLibs bi)                   ] 
System/Console/Haskeline/Backend/IConv.hsc view
@@ -18,6 +18,7 @@ #endif import qualified Data.ByteString as B import qualified Data.ByteString.UTF8 as UTF8+import Data.Maybe (fromMaybe)  #include <locale.h> #include <langinfo.h>@@ -26,20 +27,30 @@ openEncoder :: String -> IO (String -> IO ByteString) openEncoder codeset = do     encodeT <- iconvOpen codeset "UTF-8"-    return $ simpleIConv encodeT . UTF8.fromString+    return $ simpleIConv dropUTF8Char encodeT . UTF8.fromString  openDecoder :: String -> IO (ByteString -> IO String) openDecoder codeset = do     decodeT <- iconvOpen "UTF-8" codeset-    return $ fmap UTF8.toString . simpleIConv decodeT+    return $ fmap UTF8.toString . simpleIConv (B.drop 1) decodeT +dropUTF8Char :: ByteString -> ByteString+dropUTF8Char = fromMaybe B.empty . fmap snd . UTF8.uncons++replacement :: Word8+replacement = toEnum (fromEnum '?')+ -- handle errors by dropping unuseable chars.-simpleIConv :: IConvT -> ByteString -> IO ByteString-simpleIConv t bs = do+simpleIConv :: (ByteString -> ByteString) -> IConvT -> ByteString -> IO ByteString+simpleIConv dropper t bs = do     (cs,result) <- iconv t bs     case result of-        Invalid rest    -> fmap (cs `append`) $ simpleIConv t (B.drop 1 rest)+        Invalid rest    -> continueOnError cs rest+        Incomplete rest -> continueOnError cs rest         _               -> return cs+  where+    continueOnError cs rest = fmap ((cs `append`) . (replacement `B.cons`))+                                $ simpleIConv dropper t (dropper rest)  openPartialDecoder :: String -> IO (ByteString -> IO (String, Result)) openPartialDecoder codeset = do
System/Console/Haskeline/Backend/Posix.hsc view
@@ -211,9 +211,9 @@         Incomplete rest -> do                     extra <- B.hGetNonBlocking stdin 1                     if B.null extra-                        then return cs -- ignore the incomplete shift sequence-                                       -- since no more input is available.+                        then return (cs ++ "?")                         else fmap (cs ++) $ convert decoder (rest `B.append` extra)+        Invalid rest -> fmap ((cs ++) . ('?':)) $ convert decoder (B.drop 1 rest)         _ -> return cs  -- NOTE: relys on getChar reading only 8 bytes.@@ -222,7 +222,7 @@     b <- getChar     cs <- convert decoder (Char8.pack [b])     case cs of-        [] -> getMultiByteChar decoder+        [] -> return '?' -- shouldn't happen, but doesn't hurt to be careful.         (c:_) -> return c  
System/Console/Haskeline/Backend/Win32.hsc view
@@ -149,9 +149,10 @@ data Coord = Coord {coordX, coordY :: Int}
                 deriving Show
                 
+#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
 instance Storable Coord where
     sizeOf _ = (#size COORD)
-    alignment = undefined -- ???
+    alignment _ = (#alignment COORD)
     peek p = do
         x :: CShort <- (#peek COORD, X) p
         y :: CShort <- (#peek COORD, Y) p
haskeline.cabal view
@@ -1,6 +1,6 @@ Name:           haskeline Cabal-Version:  >=1.6-Version:        0.6.1.3+Version:        0.6.1.5 Category:       User Interfaces License:        BSD3 License-File:   LICENSE@@ -81,7 +81,7 @@         install-includes: win_console.h         cpp-options: -DMINGW     } else {-        Build-depends: unix>=2.1 && < 2.4+        Build-depends: unix>=2.0 && < 2.4                         -- unix-2.3 doesn't build on ghc-6.8.1 or earlier         c-sources: cbits/h_iconv.c         includes: h_iconv.h