Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macports for icu and ghc memcpy deprecation. #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Data/Text/ICU/BiDi.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions Data/Text/ICU/Collate.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion Data/Text/ICU/Normalize.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Data/Text/ICU/Normalize2.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Data/Text/ICU/Shape.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module Data.Text.ICU.Shape

#include <unicode/ushape.h>

import Data.List (foldl')
import Data.Text.ICU.Error.Internal (UErrorCode, handleOverflowError)
import Data.Bits ((.|.))
import Data.Int (Int32)
Expand Down
6 changes: 3 additions & 3 deletions Data/Text/ICU/Spoof.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cbits/text_icu.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const char *__hs_u_errorName(UErrorCode code)
}


UBiDi* __hs_ubidi_open()
UBiDi* __hs_ubidi_open(void)
{
return ubidi_open();
}
Expand Down
2 changes: 1 addition & 1 deletion include/hs_text_icu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion text-icu.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading