journal: really don't parse + before an amount as part of the commodity (fixes #181 harder)

This commit is contained in:
Simon Michael 2014-04-30 11:28:47 -07:00
parent 8341b4a8d3
commit 70ad5b26ff
2 changed files with 3 additions and 3 deletions

View File

@ -17,8 +17,8 @@ import Hledger.Data.Types
import Hledger.Utils import Hledger.Utils
-- characters than can't be in a non-quoted commodity symbol -- characters that may not be used in a non-quoted commodity symbol
nonsimplecommoditychars = "0123456789-.@;\n \"{}=" :: String nonsimplecommoditychars = "0123456789-+.@;\n \"{}=" :: String
quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\"" quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\""
| otherwise = s | otherwise = s

View File

@ -658,12 +658,12 @@ signp = do
leftsymbolamount :: GenParser Char JournalContext Amount leftsymbolamount :: GenParser Char JournalContext Amount
leftsymbolamount = do leftsymbolamount = do
sign <- signp sign <- signp
let applysign = if sign=="-" then negate else id
c <- commoditysymbol c <- commoditysymbol
sp <- many spacenonewline sp <- many spacenonewline
(q,prec,dec,sep,seppos) <- numberp (q,prec,dec,sep,seppos) <- numberp
let s = amountstyle{ascommodityside=L, ascommodityspaced=not $ null sp, asdecimalpoint=dec, asprecision=prec, asseparator=sep, asseparatorpositions=seppos} let s = amountstyle{ascommodityside=L, ascommodityspaced=not $ null sp, asdecimalpoint=dec, asprecision=prec, asseparator=sep, asseparatorpositions=seppos}
p <- priceamount p <- priceamount
let applysign = if sign=="-" then negate else id
return $ applysign $ Amount c q p s return $ applysign $ Amount c q p s
<?> "left-symbol amount" <?> "left-symbol amount"