lib: fix parsing of amounts with a whitespace digits separator
This commit is contained in:
parent
93a2060659
commit
46aae19a54
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user