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

add macro for old and new utf8-string #10

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
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: haskell
before_install:
env:
- GHCVER=7.4.2 CABALVER=1.18
- GHCVER=7.6.3 CABALVER=1.18
- GHCVER=7.8.4 CABALVER=1.18
- GHCVER=7.10.1 CABALVER=1.22
- GHCVER=head CABALVER=head

matrix:
allow_failures:
- env: GHCVER=7.10.1 CABALVER=1.22
- env: GHCVER=head CABALVER=head
- env: GHCVER=7.4.2 CABALVER=1.18

before_install:
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.cabal/bin:$PATH
- cabal --version

install:
- cabal update
# - cabal install alex happy
- cabal install --only-dependencies --enable-tests

script:
# - cabal configure --enable-tests --enable-library-coverage || cabal configure --enable-tests --enable-coverage
- cabal configure --enable-tests
- cabal build
- cabal test

#after_script:
# - cabal install hpc-coveralls
# - hpc-coveralls --exclude-dir=test test
14 changes: 13 additions & 1 deletion Text/Feed/Import.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
--------------------------------------------------------------------
-- |
-- Module : Text.Feed.Import
Expand Down Expand Up @@ -32,13 +33,24 @@ import Text.XML.Light.Lexer ( XmlSource )

import Control.Monad

#if MIN_VERSION_utf8_string(1,0,0)
import Codec.Binary.UTF8.String (decodeString)
import System.IO (IOMode(..), hGetContents, openBinaryFile )
utf8readFile :: FilePath -> IO String
utf8readFile fp = fmap decodeString (hGetContents =<< openBinaryFile fp ReadMode)
#else
import System.IO.UTF8 as UTF8 ( readFile )
utf8readFile :: FilePath -> IO String
utf8readFile = UTF8.readFile
#endif



-- | 'parseFeedFromFile fp' reads in the contents of the file at @fp@;
-- the assumed encoding is UTF-8.
parseFeedFromFile :: FilePath -> IO Feed
parseFeedFromFile fp = do
ls <- UTF8.readFile fp
ls <- utf8readFile fp
case parseFeedString ls of
Nothing -> fail ("parseFeedFromFile: not a well-formed XML content in: " ++ fp)
Just f -> return f
Expand Down
2 changes: 1 addition & 1 deletion feed.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: feed
Version: 0.3.9.2
Version: 0.3.9.3
License: BSD3
License-file: LICENSE
Category: Text
Expand Down