From ed01e57b2310580f52f9103b5c97cd4e51c5fc7f Mon Sep 17 00:00:00 2001 From: Dmitry Astapov Date: Mon, 22 Jun 2020 18:12:10 +0100 Subject: [PATCH] lib: tabular rules separator cannot be space --- hledger-lib/Hledger/Read/CsvReader.hs | 2 +- tests/csv.test | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Read/CsvReader.hs b/hledger-lib/Hledger/Read/CsvReader.hs index 58cd0b758..3b95edbda 100644 --- a/hledger-lib/Hledger/Read/CsvReader.hs +++ b/hledger-lib/Hledger/Read/CsvReader.hs @@ -569,7 +569,7 @@ conditionaltablep = do lift $ dbgparse 8 "trying conditionaltablep" start <- getOffset string "if" - sep <- lift $ satisfy (not.isAlphaNum) + sep <- lift $ satisfy (\c -> not (isAlphaNum c || isSpace c)) fields <- journalfieldnamep `sepBy1` (char sep) newline body <- flip manyTill (lift eolof) $ do diff --git a/tests/csv.test b/tests/csv.test index ac2685b4e..61092157e 100644 --- a/tests/csv.test +++ b/tests/csv.test @@ -857,6 +857,31 @@ $ ./csvtest.sh >=0 +# 43. Attempt to use space as a separator in the tabular rules +< +10/2009/09,Flubber Co,50 +10/2009/09,Blubber Co,150 + +RULES +fields date, description, amount +date-format %d/%Y/%m +currency $ +account1 assets:myacct +if account2 comment +%amount 150 acct2 +%description Flubber acct +$ ./csvtest.sh +>2 +hledger: user error (input.rules:5:1: + | +5 | if account2 comment + | ^ +start of conditional block found, but no assignment rules afterward +(assignment rules in a conditional block should be indented) + +) +>=1 + ## . #<