lib: fix parsing of amounts with a whitespace digits separator

This commit is contained in:
awjchen 2018-05-20 16:02:59 -06:00 committed by GitHub
parent 93a2060659
commit 46aae19a54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 14 deletions

View File

@ -763,8 +763,9 @@ rawnumberp = do
leadingDigits <- some digitChar
option (Nothing, [leadingDigits]) . try $ do
firstSep <- oneOf sepChars <|> whitespaceChar
groups <- some digitChar `sepBy1` char firstSep
return (Just firstSep, leadingDigits : groups)
secondGroup <- some digitChar
otherGroups <- many $ try $ char firstSep *> some digitChar
return (Just firstSep, leadingDigits : secondGroup : otherGroups)
let remSepChars = maybe sepChars (`delete` sepChars) firstSep
modifier

View File

@ -136,17 +136,17 @@ $ hledger -f- bal -V -N
#>=1
# 11. After a space-grouped amount, a posting comment should parse.
#<
#2018-01-01
# (a) USD 1 000 ;comment
#
#$ hledger -f- print
#> // # any stdout, no stderr, 0 exit code
<
2018-01-01
(a) USD 1 000 ;comment
$ hledger -f- print
> // # any stdout, no stderr, 0 exit code
# 12. After a space-grouped amount, trailing whitespace should parse.
#<
#2018-01-01
# (a) USD 1 000
#
#$ hledger -f- print
#> // # any stdout, no stderr, 0 exit code
<
2018-01-01
(a) USD 1 000
$ hledger -f- print
> // # any stdout, no stderr, 0 exit code