packages feed

hsini 0.5.1.3 → 0.5.2

raw patch · 3 files changed

+32/−13 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

hsini.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name:          hsini-version:       0.5.1.3+version:       0.5.2 synopsis:      ini configuration files description:   Library for reading and writing configuration files in INI format (see <https://en.wikipedia.org/wiki/INI_file>).
src/Data/Ini/Reader/Internals.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ImportQualifiedPost #-}  {- | Module    : Data.Ini.Reader.Internals@@ -9,11 +10,21 @@ -} module Data.Ini.Reader.Internals where -import Control.Monad.Except-import Control.Monad.State-import qualified Data.ByteString as BS-import Text.Parsec as P-import Text.Parsec.String+import Control.Monad.Except (MonadError (throwError), liftM)+import Control.Monad.State (evalState, get, put)+import Data.ByteString qualified as BS+import Text.Parsec as P (+    anyChar,+    char,+    choice,+    many,+    many1,+    manyTill,+    newline,+    noneOf,+    oneOf,+ )+import Text.Parsec.String (Parser)  import Data.Ini import Data.Ini.Types@@ -45,10 +56,10 @@          -- merge together OptionL and subsequent OptionContL items         mergeOptions [] = return []-        mergeOptions (s@(SectionL _) : ifs) = (s :) `liftM` mergeOptions ifs-        mergeOptions (CommentL : ifs) = (CommentL :) `liftM` mergeOptions ifs-        mergeOptions (OptionL on ov : OptionContL ov2 : ifs) = mergeOptions $ (OptionL on (ov ++ ov2)) : ifs-        mergeOptions (o@(OptionL on ov) : ifs) = (o :) `liftM` mergeOptions ifs+        mergeOptions (s@(SectionL _) : ifs) = (s :) `fmap` mergeOptions ifs+        mergeOptions (CommentL : ifs) = (CommentL :) `fmap` mergeOptions ifs+        mergeOptions (OptionL on ov : OptionContL ov2 : ifs) = mergeOptions $ OptionL on (ov ++ ov2) : ifs+        mergeOptions (o@(OptionL on ov) : ifs) = (o :) `fmap` mergeOptions ifs         mergeOptions _ = throwError $ IniSyntaxError "Syntax error in INI file."          -- build the configuration from a [IniFile]@@ -59,7 +70,7 @@             let na = setOption sn on ov a             buildit na is      in-        mergeOptions fIfs >>= (\is -> return . fst $ runState (buildit emptyConfig is) "default")+        mergeOptions fIfs >>= \is -> return $ evalState (buildit emptyConfig is) "default"  -- | Consumer of whitespace \"@ \t@\". eatWhiteSpace :: Parser String@@ -91,9 +102,10 @@ optLineParser :: Parser IniFile optLineParser =     let-        validOptNameChrs = ['a' .. 'z'] ++ ['A' .. 'Z'] ++ ['0' .. '9'] ++ "_-/@"+        validOptNameChrs = ['a' .. 'z'] ++ ['A' .. 'Z'] ++ ['0' .. '9'] ++ "_-/@ "      in         do+            eatWhiteSpace             on <- many1 $ oneOf validOptNameChrs             eatWhiteSpace             char '='
tst/ReaderI.hs view
@@ -124,6 +124,13 @@      in         expected @=? actual +case_optLineParserAllowedChars6 =+    let+        expected = Right $ OptionL "foo bar" "baz"+        actual = p2E optLineParser "optLine" "foo bar=baz\n"+     in+        expected @=? actual+ case_optLineParserDisallowedChars1 =     let         expected = Left "bad"@@ -134,7 +141,7 @@ case_optLineParserDropSpace =     let         expected = Right $ OptionL "foo" "bar"-        actual = p2E optLineParser "optLine" "foo\t \t=\t \t bar\n"+        actual = p2E optLineParser "optLine" " \tfoo\t \t=\t \t bar\n"      in         expected @=? actual