On Mon, Jun 29, 2009 at 07:13:35PM +0200, Matthias Kilian wrote: > > >Is the attacheched patch the correct way to do it? > > > > Yes, looks fine. > > After thinking a little bit about it: doesn't it need some > > #ifndef __MINGW32__ > ... > #endif > > shield to not break the windows builds?
New patch attached, it also resolves a conflict caused by the directory stuff moved do unix.
Mon Jun 29 20:36:34 CEST 2009 Matthias Kilian <[email protected]> * Add a wrapper for libiconv. New patches: [Add a wrapper for libiconv. Matthias Kilian <[email protected]>**20090629183634 Ignore-this: 23c6047c0d71b745b495cc223574a47f ] { hunk ./GHC/IO/Encoding/Iconv.hs 117 -- value -1, which is a possible return value from iconv_open. type IConv = CLong -- ToDo: (#type iconv_t) -foreign import ccall unsafe "iconv_open" - iconv_open :: CString -> CString -> IO IConv +foreign import ccall unsafe "hs_iconv_open" + hs_iconv_open :: CString -> CString -> IO IConv hunk ./GHC/IO/Encoding/Iconv.hs 120 -foreign import ccall unsafe "iconv_close" - iconv_close :: IConv -> IO CInt +foreign import ccall unsafe "hs_iconv_close" + hs_iconv_close :: IConv -> IO CInt hunk ./GHC/IO/Encoding/Iconv.hs 123 -foreign import ccall unsafe "iconv" - iconv :: IConv -> Ptr CString -> Ptr CSize -> Ptr CString -> Ptr CSize +foreign import ccall unsafe "hs_iconv" + hs_iconv :: IConv -> Ptr CString -> Ptr CSize -> Ptr CString -> Ptr CSize -> IO CSize foreign import ccall unsafe "localeEncoding" hunk ./GHC/IO/Encoding/Iconv.hs 155 newIConv from to fn = withCString from $ \ from_str -> withCString to $ \ to_str -> do - iconvt <- throwErrnoIfMinus1 "mkTextEncoding" $ iconv_open to_str from_str - let iclose = do throwErrnoIfMinus1 "Iconv.close" $ iconv_close iconvt + iconvt <- throwErrnoIfMinus1 "mkTextEncoding" $ hs_iconv_open to_str from_str + let iclose = do throwErrnoIfMinus1 "Iconv.close" $ hs_iconv_close iconvt return () return BufferCodec{ encode = fn iconvt, hunk ./GHC/IO/Encoding/Iconv.hs 188 with (poraw `plusPtr` (ow `shiftL` oscale)) $ \ p_outbuf -> do with (fromIntegral ((iw-ir) `shiftL` iscale)) $ \ p_inleft -> do with (fromIntegral ((os-ow) `shiftL` oscale)) $ \ p_outleft -> do - res <- iconv iconv_t p_inbuf p_inleft p_outbuf p_outleft + res <- hs_iconv iconv_t p_inbuf p_inleft p_outbuf p_outleft new_inleft <- peek p_inleft new_outleft <- peek p_outleft let hunk ./base.cabal 190 cbits/WCsubst.c cbits/Win32Utils.c cbits/consUtils.c + cbits/iconv.c cbits/inputReady.c cbits/selectUtils.c include-dirs: include addfile ./cbits/iconv.c hunk ./cbits/iconv.c 1 +#ifndef __MINGW32__ + +#include <stdlib.h> +#include <iconv.h> + +iconv_t hs_iconv_open(const char* tocode, + const char* fromcode) +{ + return iconv_open(tocode, fromcode); +} + +size_t hs_iconv(iconv_t cd, + const char* * inbuf, size_t * inbytesleft, + char* * outbuf, size_t * outbytesleft) +{ + return iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); +} + +int hs_iconv_close(iconv_t cd) { + return iconv_close(cd); +} + +#endif } Context: [#include <sys/times.h> if we have it (should fix build problems) Simon Marlow <[email protected]>**20090629085351 Ignore-this: a35e93b37ca9595c73460243180f4b9d ] [set binary mode for existing FDs on Windows (fixes some GHCi test failures) Simon Marlow <[email protected]>**20090626120522 Ignore-this: 580cf636e9c77d8427aff6861d089481 ] [Move directory-related stuff to the unix package Simon Marlow <[email protected]>**20090625120325 Ignore-this: b997b3cbce0a46ca87ad825bbdc0a411 now that it isn't used on Windows any more. ] [TAG 2009-06-25 Ian Lynagh <[email protected]>**20090625160056] Patch bundle hash: 4355f86b0f8f9e1b0467856c41709d81b59d14d0
_______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
