Convert to new cabal and bytestring interfaces

darcs-hash:20071210234921-a4fee-251367abbc4d99d72f425b2d1b69ce2c36f32572
This commit is contained in:
Henning Guenther 2007-12-10 15:49:21 -08:00
parent 5b02009636
commit 7e291fcefe
5 changed files with 137 additions and 100 deletions

View File

@ -20,7 +20,13 @@ import Data.Array(array)
import Data.ByteString (ByteString,unfoldrN,unfoldr,length,index,unpack) import Data.ByteString (ByteString,unfoldrN,unfoldr,length,index,unpack)
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
import Data.Encoding.Helper.Template import Data.Encoding.Helper.Template
#if __GLASGOW_HASKELL__>=608
import Data.ByteString.Unsafe(unsafeIndex)
#else
import Data.ByteString.Base(unsafeIndex) import Data.ByteString.Base(unsafeIndex)
#endif
import Data.Map (Map,fromList,lookup) import Data.Map (Map,fromList,lookup)
import Data.Char(chr) import Data.Char(chr)
import Data.Maybe(mapMaybe) import Data.Maybe(mapMaybe)

View File

@ -13,7 +13,12 @@ import Data.Bits
import Data.Encoding.Base import Data.Encoding.Base
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
#if __GLASGOW_HASKELL__>=608
import Data.ByteString.Unsafe (unsafeIndex)
#else
import Data.ByteString.Base (unsafeIndex) import Data.ByteString.Base (unsafeIndex)
#endif
import Data.Encoding.GB18030Data import Data.Encoding.GB18030Data

File diff suppressed because one or more lines are too long

View File

@ -63,7 +63,16 @@ createModuleFromFile name str = createModule (readDecodeTable name str)
createModule :: [(Char,[Word8])] -> [(Char,Char)] -> [(Int,Int)] -> String createModule :: [(Char,[Word8])] -> [(Char,Char)] -> [(Int,Int)] -> String
createModule mp ranges rranges = unlines $ createModule mp ranges rranges = unlines $
["module Data.Encoding.GB18030Data where","","import Data.ByteString.Base"] ["{-# OPTIONS -fglasgow-exts #-}"
,"module Data.Encoding.GB18030Data where"
,""
,"import Data.ByteString(ByteString)"
,"#if __GLASGOW_HASKELL__>=608"
,"import Data.ByteString.Unsafe(unsafePackAddressLen)"
,"#else"
,"import Data.ByteString.Base(unsafePackAddressLen)"
,"#endif"
,"import System.IO.Unsafe(unsafePerformIO)"]
++ (createAddrVars "arr" (map (uncurry $ createAddr mp) ranges)) ++ (createAddrVars "arr" (map (uncurry $ createAddr mp) ranges))
++ (createAddrVars "rarr" (map (uncurry $ createRAddr4 mp) rranges)) ++ (createAddrVars "rarr" (map (uncurry $ createRAddr4 mp) rranges))
++ (createAddrVar "rrarr" (createRAddr2 mp)) ++ (createAddrVar "rrarr" (createRAddr2 mp))
@ -76,7 +85,7 @@ createAddrVar :: String -> [Word8] -> [String]
createAddrVar name cont = createAddrVar name cont =
["" [""
,name++" :: ByteString" ,name++" :: ByteString"
,name++" = unsafePackAddress "++show (length cont)++" \""++addr cont++"\"#" ,name++" = unsafePerformIO $ unsafePackAddressLen "++show (length cont)++" \""++addr cont++"\"#"
] ]
createAddr :: [(Char,[Word8])] -> Char -> Char -> [Word8] createAddr :: [(Char,[Word8])] -> Char -> Char -> [Word8]

View File

@ -1,5 +1,5 @@
Name: encoding Name: encoding
Version: 0.2 Version: 0.3
Author: Henning Günther Author: Henning Günther
Maintainer: h.guenther@tu-bs.de Maintainer: h.guenther@tu-bs.de
License: BSD3 License: BSD3
@ -9,8 +9,45 @@ Description:
Haskell has excellect handling of unicode, the Char type covers all unicode chars. Unfortunatly, there's no possibility to read or write something to the outer world in an encoding other than ascii due to the lack of support for encodings. This library should help with that. Haskell has excellect handling of unicode, the Char type covers all unicode chars. Unfortunatly, there's no possibility to read or write something to the outer world in an encoding other than ascii due to the lack of support for encodings. This library should help with that.
Category: Codec Category: Codec
Homepage: http://code.haskell.org/encoding/ Homepage: http://code.haskell.org/encoding/
Build-Depends: base, template-haskell Cabal-Version: >=1.2
Extensions: TemplateHaskell,CPP,ExistentialQuantification Extra-Source-Files:
8859-2.TXT
8859-3.TXT
8859-4.TXT
8859-5.TXT
8859-6.TXT
8859-7.TXT
8859-8.TXT
8859-9.TXT
8859-10.TXT
8859-11.TXT
8859-13.TXT
8859-14.TXT
8859-15.TXT
8859-16.TXT
CP1250.TXT
CP1251.TXT
CP1252.TXT
CP1253.TXT
CP1254.TXT
CP1255.TXT
CP1256.TXT
CP1257.TXT
CP1258.TXT
gb-18030-2000.xml
system_encoding.h
create_gb18030_data.sh
NEWS
Flag splitBase
description: Choose the new smaller, split-up base package.
Library
if flag(splitBase)
Build-Depends: bytestring, base >= 3, template-haskell, containers, array
else
Build-Depends: base < 3, template-haskell
Extensions: TemplateHaskell,CPP,ExistentialQuantification,ForeignFunctionInterface
C-Sources: system_encoding.c C-Sources: system_encoding.c
Include-Dirs: . Include-Dirs: .
Install-Includes: system_encoding.h Install-Includes: system_encoding.h
@ -52,31 +89,4 @@ Other-Modules:
Data.Encoding.Base Data.Encoding.Base
Data.Encoding.GB18030Data Data.Encoding.GB18030Data
Data.Encoding.Helper.Template Data.Encoding.Helper.Template
Extra-Source-Files:
8859-2.TXT
8859-3.TXT
8859-4.TXT
8859-5.TXT
8859-6.TXT
8859-7.TXT
8859-8.TXT
8859-9.TXT
8859-10.TXT
8859-11.TXT
8859-13.TXT
8859-14.TXT
8859-15.TXT
8859-16.TXT
CP1250.TXT
CP1251.TXT
CP1252.TXT
CP1253.TXT
CP1254.TXT
CP1255.TXT
CP1256.TXT
CP1257.TXT
CP1258.TXT
gb-18030-2000.xml
system_encoding.h
create_gb18030_data.sh
NEWS