diff --git a/Data/Text/ICU/BiDi.hsc b/Data/Text/ICU/BiDi.hsc index 976a593..d94be7d 100644 --- a/Data/Text/ICU/BiDi.hsc +++ b/Data/Text/ICU/BiDi.hsc @@ -45,7 +45,6 @@ import Data.Text.ICU.Error.Internal (UErrorCode, handleError, handleOverflowErro import Data.Text (Text) import Data.Text.ICU.Internal (UChar, useAsUCharPtr, fromUCharPtr, newICUPtr) import Foreign.C.Types (CInt(..)) -import Data.List (foldl') import Data.Bits ((.|.)) import System.IO.Unsafe (unsafePerformIO) import Data.Traversable (for) diff --git a/Data/Text/ICU/Collate.hsc b/Data/Text/ICU/Collate.hsc index 160e3f6..d70f498 100644 --- a/Data/Text/ICU/Collate.hsc +++ b/Data/Text/ICU/Collate.hsc @@ -39,8 +39,7 @@ module Data.Text.ICU.Collate import Control.DeepSeq (NFData(..)) import Data.ByteString (empty) -import Data.ByteString.Internal (ByteString(..), create, mallocByteString, - memcpy) +import Data.ByteString.Internal (ByteString(..), create, mallocByteString) import Data.Int (Int32) import Data.Text (Text) import qualified Data.Text as T @@ -58,7 +57,7 @@ import Foreign.C.String (CString) import Foreign.C.Types (CInt(..)) import Foreign.ForeignPtr (withForeignPtr) import Foreign.Marshal.Alloc (alloca) -import Foreign.Marshal.Utils (with) +import Foreign.Marshal.Utils (with, copyBytes) import Foreign.Ptr (Ptr, nullPtr) import Foreign.Storable (peek) @@ -342,7 +341,7 @@ sortKey c t _ | i == 0 -> error "Data.Text.ICU.Collate.sortKey: internal error" | i > n -> loop i | i <= n `div` 2 -> create j $ \p -> withForeignPtr fp $ \op -> - memcpy p op (fromIntegral i) + copyBytes p op (fromIntegral i) | otherwise -> return $! PS fp 0 j loop (min (len * 4) 8) diff --git a/Data/Text/ICU/Normalize.hsc b/Data/Text/ICU/Normalize.hsc index 21c9426..1f6a5a5 100644 --- a/Data/Text/ICU/Normalize.hsc +++ b/Data/Text/ICU/Normalize.hsc @@ -48,7 +48,6 @@ import Foreign.C.Types (CInt(..)) import Foreign.Ptr (Ptr) import System.IO.Unsafe (unsafePerformIO) import Prelude hiding (compare) -import Data.List (foldl') import Data.Bits ((.|.)) -- $api diff --git a/Data/Text/ICU/Normalize2.hsc b/Data/Text/ICU/Normalize2.hsc index 7b437ea..07dbe28 100644 --- a/Data/Text/ICU/Normalize2.hsc +++ b/Data/Text/ICU/Normalize2.hsc @@ -45,7 +45,6 @@ import Foreign.C.Types (CInt(..)) import Foreign.Ptr (Ptr) import System.IO.Unsafe (unsafePerformIO) import Prelude hiding (compare) -import Data.List (foldl') import Data.Bits ((.|.)) -- $api diff --git a/Data/Text/ICU/Shape.hsc b/Data/Text/ICU/Shape.hsc index cfb4f29..89d2bc6 100644 --- a/Data/Text/ICU/Shape.hsc +++ b/Data/Text/ICU/Shape.hsc @@ -21,7 +21,6 @@ module Data.Text.ICU.Shape #include -import Data.List (foldl') import Data.Text.ICU.Error.Internal (UErrorCode, handleOverflowError) import Data.Bits ((.|.)) import Data.Int (Int32) diff --git a/Data/Text/ICU/Spoof.hsc b/Data/Text/ICU/Spoof.hsc index 2e87b50..eb97536 100644 --- a/Data/Text/ICU/Spoof.hsc +++ b/Data/Text/ICU/Spoof.hsc @@ -52,7 +52,7 @@ import Control.DeepSeq (NFData(..)) import Control.Exception (Exception, throwIO, catchJust) import Data.Bits ((.&.)) import Data.ByteString (ByteString) -import Data.ByteString.Internal (create, memcpy, toForeignPtr) +import Data.ByteString.Internal (create, toForeignPtr) import Data.ByteString.Unsafe (unsafeUseAsCStringLen) import Data.Int (Int32) import Data.List (intercalate) @@ -75,7 +75,7 @@ import Data.Text.ICU.Internal (fromUCharPtr) import Data.Typeable (Typeable) import Data.Word (Word8) import Foreign.C.String (CString, peekCString, withCString) -import Foreign.Marshal.Utils (with) +import Foreign.Marshal.Utils (with, copyBytes) import Foreign.Ptr (Ptr, nullPtr, plusPtr) import Foreign.Storable (peek) import Foreign.ForeignPtr (withForeignPtr) @@ -430,7 +430,7 @@ serialize s = withSpoof s $ \sptr -> handleOverflowError 0 (\dptr dlen -> (uspoof_serialize sptr dptr (fromIntegral dlen))) (\dptr dlen -> create (fromIntegral dlen) $ \bptr -> - memcpy dptr bptr (fromIntegral dlen)) + copyBytes dptr bptr (fromIntegral dlen)) foreign import ccall unsafe "hs_text_icu.h __hs_uspoof_open" uspoof_open :: Ptr UErrorCode -> IO (Ptr USpoof) diff --git a/cbits/text_icu.c b/cbits/text_icu.c index ec2f896..f66b093 100644 --- a/cbits/text_icu.c +++ b/cbits/text_icu.c @@ -316,7 +316,7 @@ const char *__hs_u_errorName(UErrorCode code) } -UBiDi* __hs_ubidi_open() +UBiDi* __hs_ubidi_open(void) { return ubidi_open(); } diff --git a/include/hs_text_icu.h b/include/hs_text_icu.h index 345977f..6fc3fe0 100644 --- a/include/hs_text_icu.h +++ b/include/hs_text_icu.h @@ -143,7 +143,7 @@ int32_t __hs_ucol_getSortKey(const UCollator *coll, uint8_t *result, int32_t resultLength); /* ubidi.h */ -UBiDi* __hs_ubidi_open(); +UBiDi* __hs_ubidi_open(void); UBiDi* __hs_ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *err); void __hs_ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UErrorCode *pErrorCode); diff --git a/text-icu.cabal b/text-icu.cabal index e1c4f8b..78b4e8e 100644 --- a/text-icu.cabal +++ b/text-icu.cabal @@ -69,10 +69,16 @@ tested-with: GHC == 8.0.2 flag homebrew - Description: Assume homebrew on macOS. Automatically add /usr/local/opt/ and /opt/homebrew/opt/ paths to extra-lib-dirs and include-dirs. + Description: Homebrew on macOS. Add /usr/local/opt/ and /opt/homebrew/opt/ paths to extra-lib-dirs and include-dirs. Default: True Manual: True +flag macports + Description: MacPorts on macOS. (port install icu) + Default: False + Manual: True + + library default-language: Haskell98 build-depends: @@ -134,6 +140,13 @@ library include-dirs: /usr/local/opt/icu4c/include /opt/homebrew/opt/icu4c/include + if os(darwin) && flag(macports) + extra-lib-dirs: + /opt/local/lib + include-dirs: + /opt/local/include + + extra-libraries: icuuc if os(mingw32) extra-libraries: icuin icudt icuio