From 33153851e9773690e6970384331f2b81c18fbcc2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 24 Feb 2013 20:04:28 +0000 Subject: [PATCH] words' on an empty string should return empty list --- hledger-lib/Hledger/Utils.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Utils.hs b/hledger-lib/Hledger/Utils.hs index a80640c7a..dd6e627ba 100644 --- a/hledger-lib/Hledger/Utils.hs +++ b/hledger-lib/Hledger/Utils.hs @@ -87,9 +87,10 @@ escapeQuotes :: String -> String escapeQuotes = regexReplace "([\"'])" "\\1" -- | Quote-aware version of words - don't split on spaces which are inside quotes. --- NB correctly handles "a'b" but not "''a''". +-- NB correctly handles "a'b" but not "''a''". Can raise an error if parsing fails. words' :: String -> [String] -words' = map stripquotes . fromparse . parsewith p +words' "" = [] +words' s = map stripquotes $ fromparse $ parsewith p s where p = do ss <- (quotedPattern <|> pattern) `sepBy` many1 spacenonewline -- eof