From 9e56ad24e2c76728a94fdf6909329f61c0a52e63 Mon Sep 17 00:00:00 2001 From: Joseph Weston Date: Sun, 22 Jul 2018 23:03:18 +0200 Subject: [PATCH] lib: reorder code for reading include files This should be before all journal and parser state manipulations, so that those can be readily factored in a few commits time. --- hledger-lib/Hledger/Read/JournalReader.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 311020246..238f751fc 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -191,11 +191,6 @@ includedirectivep = do lift (skipSome spacenonewline) filename <- T.unpack <$> takeWhileP Nothing (/= '\n') -- don't consume newline yet - -- save parent state - parentParserState <- getParserState - parentj <- get - - let childj = newJournalWithParseStateFrom parentj parentpos <- getPosition -- read child input @@ -203,6 +198,12 @@ includedirectivep = do filepath <- lift $ expandPath curdir filename `orRethrowIOError` (show parentpos ++ " locating " ++ filename) childInput <- lift $ readFilePortably filepath `orRethrowIOError` (show parentpos ++ " reading " ++ filepath) + -- save parent state + parentParserState <- getParserState + parentj <- get + + let childj = newJournalWithParseStateFrom parentj + -- set child state setInput childInput pushPosition $ initialPos filepath