Skip to content

Commit

Permalink
Macports for icu and ghc memcpy deprecation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebeaumont committed Oct 24, 2024
1 parent 32a90ab commit 81fa10e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
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

0 comments on commit 81fa10e

Please sign in to comment.