Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: magthe/hsini
base: fbdc67abe3
...
head fork: magthe/hsini
compare: d6c0f07198
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 15, 2012
@adimit adimit Allow for comments to start with semicolons.
This is pretty common, and I was surprised when it didn't work. A test
case for the new comment style is also added.
59e7770
@magthe Bumping dependency on base.
Signed-off-by: Magnus Therning <magnus@therning.org>
836dcb2
@magthe Allowing digits in option names.
Influenced by a patch from aleks.dimitrov@gmail.com.

Signed-off-by: Magnus Therning <magnus@therning.org>
c255a45
@magthe Allowing underbars in section and option names.
Inspired by patches from aleks.dimitrov@gmail.com.

Signed-off-by: Magnus Therning <magnus@therning.org>
d6c0f07
Showing with 20 additions and 15 deletions.
  1. +1 −1  hsini.cabal
  2. +3 −3 src/Data/Ini/Reader/Internals.hs
  3. +16 −11 tst/ReaderI.hs
View
2  hsini.cabal
@@ -21,7 +21,7 @@ flag Test
library
hs-source-dirs : src
- build-depends : base ==4.3.*, bytestring ==0.9.*, containers ==0.4.*, mtl ==2.0.*, parsec ==3.1.*
+ build-depends : base >=4.3 && < 4.6, bytestring ==0.9.*, containers ==0.4.*, mtl ==2.0.*, parsec ==3.1.*
exposed-modules : Data.Ini Data.Ini.Types Data.Ini.Reader
other-modules : Data.Ini.Reader.Internals
View
6 src/Data/Ini/Reader/Internals.hs
@@ -71,7 +71,7 @@ eatWhiteSpace = many $ oneOf " \t"
-- surrounded by any number of white space characters (see 'eatWhiteSpace').
secParser :: Parser IniFile
secParser = let
- validSecNameChrs = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ "-/@"
+ validSecNameChrs = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ "_-/@"
in do
char '['
eatWhiteSpace
@@ -87,7 +87,7 @@ secParser = let
-- space characters (see 'eatWhiteSpace').
optLineParser :: Parser IniFile
optLineParser = let
- validOptNameChrs = ['a'..'z'] ++ ['A'..'Z'] ++ "-/@"
+ validOptNameChrs = ['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'] ++ "_-/@"
in do
on <- many1 $ oneOf validOptNameChrs
eatWhiteSpace
@@ -114,7 +114,7 @@ optContParser = do
noiseParser :: Parser IniFile
noiseParser = let
commentP = do
- char '#'
+ oneOf "#;"
manyTill anyChar newline
emptyL = newline >> return ""
in choice [commentP, emptyL] >> return CommentL
View
27 tst/ReaderI.hs
@@ -40,12 +40,12 @@ case_secParserAllowedChars4 = let
actual = p2E secParser "sec" "[foo123]\n"
in expected @=? actual
-case_secParserDisallowedChars1 = let
- expected = Left "bad"
+case_secParserAllowedChars5 = let
+ expected = Right $ SectionL "_foo"
actual = p2E secParser "sec" "[_foo]\n"
in expected @=? actual
-case_secParserDisallowedChars2 = let
+case_secParserDisallowedChars1 = let
expected = Left "bad"
actual = p2E secParser "sec" "[foo.bar]\n"
in expected @=? actual
@@ -76,17 +76,17 @@ case_optLineParserAllowedChars3 = let
actual = p2E optLineParser "optLine" "foo@/foo-=bar\n"
in expected @=? actual
-case_optLineParserDisallowedChars1 = let
- expected = Left "bad"
- actual = p2E optLineParser "optLine" "foo_=bar\n"
+case_optLineParserAllowedChars4 = let
+ expected = Right $ OptionL "foo123" "bar"
+ actual = p2E optLineParser "optLine" "foo123=bar\n"
in expected @=? actual
-case_optLineParserDisallowedChars2 = let
- expected = Left "bad"
- actual = p2E optLineParser "optLine" "foo666=bar\n"
+case_optLineParserAllowedChars5 = let
+ expected = Right $ OptionL "_foo" "bar"
+ actual = p2E optLineParser "optLine" "_foo=bar\n"
in expected @=? actual
-case_optLineParserDisallowedChars3 = let
+case_optLineParserDisallowedChars1 = let
expected = Left "bad"
actual = p2E optLineParser "optLine" "foo.bar=baz\n"
in expected @=? actual
@@ -123,11 +123,16 @@ case_noiseParserEmptyLine = let
actual = p2E noiseParser "noise" "\n"
in expected @=? actual
-case_noiseParserComment = let
+case_noiseParserComment1 = let
expected = Right CommentL
actual = p2E noiseParser "noise" "# a comment\n"
in expected @=? actual
+case_noiseParserComment2 = let
+ expected = Right CommentL
+ actual = p2E noiseParser "noise" "; another comment\n"
+ in expected @=? actual
+
case_noiseParserNonEmpty = let
expected = Left "bad"
actual = p2E noiseParser "noise" " \n"

No commit comments for this range

Something went wrong with that request. Please try again.