From 080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 10 Mar 2012 02:27:33 -0600 Subject: Added syntactic sugar for lot pricing: {{$500.00}} --- src/annotate.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/annotate.cc') diff --git a/src/annotate.cc b/src/annotate.cc index 1140bf0a..d2c7f983 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -88,6 +88,12 @@ void annotation_t::parse(std::istream& in) throw_(amount_error, _("Commodity specifies more than one price")); in.get(c); + c = static_cast(in.peek()); + if (c == '{') { + in.get(c); + add_flags(ANNOTATION_PRICE_NOT_PER_UNIT); + } + c = peek_next_nonws(in); if (c == '=') { in.get(c); @@ -95,10 +101,18 @@ void annotation_t::parse(std::istream& in) } READ_INTO(in, buf, 255, c, c != '}'); - if (c == '}') + if (c == '}') { in.get(c); - else - throw_(amount_error, _("Commodity price lacks closing brace")); + if (has_flags(ANNOTATION_PRICE_NOT_PER_UNIT)) { + c = static_cast(in.peek()); + if (c != '}') + throw_(amount_error, _("Commodity lot price lacks double closing brace")); + else + in.get(c); + } + } else { + throw_(amount_error, _("Commodity lot price lacks closing brace")); + } amount_t temp; temp.parse(buf, PARSE_NO_MIGRATE); -- cgit v1.2.3