From 69ce8b9a8e7060eebc3ce23c4473f4fb0eaaa711 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 10 Apr 2009 05:37:26 +0000 Subject: [PATCH] don't treat comments as part of ledger transaction descriptions --- Ledger/Parse.hs | 5 +---- Tests.hs | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Ledger/Parse.hs b/Ledger/Parse.hs index 4e3a7d95f..1f2faa5b7 100644 --- a/Ledger/Parse.hs +++ b/Ledger/Parse.hs @@ -311,10 +311,7 @@ ledgerTransaction = do date <- ledgerdate "entry" status <- ledgerstatus code <- ledgercode --- ledger treats entry comments as part of the description, we will too --- desc <- many (noneOf ";\n") "description" --- let description = reverse $ dropWhile (==' ') $ reverse desc - description <- many1 (noneOf "\n") "description" + description <- liftM rstrip (many1 (noneOf ";\n") "description") comment <- ledgercomment restofline postings <- ledgerpostings diff --git a/Tests.hs b/Tests.hs index 49d558b0d..f480d245c 100644 --- a/Tests.hs +++ b/Tests.hs @@ -564,6 +564,9 @@ tests = [ $ isLeft $ parseWithCtx ledgerTransaction "2009/1/1\n" assertBool "ledgerTransaction should require some postings" $ isLeft $ parseWithCtx ledgerTransaction "2009/1/1 a\n" + let t = parseWithCtx ledgerTransaction "2009/1/1 a ;comment\n b 1\n" + assertBool "ledgerTransaction should not include a comment in the description" + $ either (const False) ((== "a") . ltdescription) p ,"ledgerHistoricalPrice" ~: do parseWithCtx ledgerHistoricalPrice price1_str `parseis` price1