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 leadingDigits <- some digitChar
option (Nothing, [leadingDigits]) . try $ do option (Nothing, [leadingDigits]) . try $ do
firstSep <- oneOf sepChars <|> whitespaceChar firstSep <- oneOf sepChars <|> whitespaceChar
groups <- some digitChar `sepBy1` char firstSep secondGroup <- some digitChar
return (Just firstSep, leadingDigits : groups) otherGroups <- many $ try $ char firstSep *> some digitChar
return (Just firstSep, leadingDigits : secondGroup : otherGroups)
let remSepChars = maybe sepChars (`delete` sepChars) firstSep let remSepChars = maybe sepChars (`delete` sepChars) firstSep
modifier modifier

View File

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