diff options
-rw-r--r-- | amount.cc | 2 | ||||
-rw-r--r-- | amount.h | 2 | ||||
-rw-r--r-- | datetime.h | 10 | ||||
-rw-r--r-- | textual.cc | 13 | ||||
-rw-r--r-- | valexpr.cc | 10 | ||||
-rw-r--r-- | valexpr.h | 1 |
6 files changed, 24 insertions, 14 deletions
@@ -1952,7 +1952,7 @@ void export_amount() ; class_< commodity_base_t::updater_t, commodity_updater_wrap, - boost::noncopyable > + boost::noncopyable > ("Updater") ; @@ -312,7 +312,7 @@ void parse_conversion(const std::string& larger, inline bool is_quote_or_paren(char * p) { return *p == '"' || *p == '{' || *p == '[' || *p == '('; -} +} inline char * scan_past_quotes_and_parens(char * expr) { @@ -107,7 +107,7 @@ class date_t char buf[64]; std::strftime(buf, 63, format.c_str(), localtime()); return buf; - } + } int year() const { return localtime()->tm_year + 1900; @@ -129,7 +129,7 @@ class date_t void write(std::ostream& out, const std::string& format = output_format) const { out << to_string(format); - } + } friend class datetime_t; friend struct interval_t; @@ -227,9 +227,9 @@ class datetime_t : public date_t }; inline long operator-(const datetime_t& left, const datetime_t& right) { - datetime_t temp(left); - temp -= right; - return temp; + std::time_t left_time(left); + std::time_t right_time(right); + return left_time - right_time; } inline datetime_t operator+(const datetime_t& left, const long seconds) { @@ -185,7 +185,8 @@ transaction_t * parse_transaction(char * line, account_t * account, unsigned long beg = (long)in.tellg(); xact->amount_expr = - parse_amount_expr(in, xact->amount, xact.get()); + parse_amount_expr(in, xact->amount, xact.get(), + PARSE_VALEXPR_NO_REDUCE); unsigned long end = (long)in.tellg(); xact->amount_expr.expr = std::string(line, beg, end - beg); @@ -492,12 +493,11 @@ bool textual_parser_t::test(std::istream& in) const } static void clock_out_from_timelog(const datetime_t& when, - account_t * account, - const char * desc, - journal_t * journal) + account_t * account, + const char * desc, + journal_t * journal) { time_entry_t event; - bool found = false; if (time_entries.size() == 1) { event = time_entries.back(); @@ -511,6 +511,8 @@ static void clock_out_from_timelog(const datetime_t& when, ("When multiple check-ins are active, checking out requires an account"); } else { + bool found = false; + for (std::list<time_entry_t>::iterator i = time_entries.begin(); i != time_entries.end(); i++) @@ -520,6 +522,7 @@ static void clock_out_from_timelog(const datetime_t& when, time_entries.erase(i); break; } + if (! found) throw new parse_error ("Timelog check-out event does not match any current check-ins"); @@ -770,8 +770,14 @@ value_expr_t * parse_value_term(std::istream& in, scope_t * scope, // the current maximum precision displayed. try { pos = (long)in.tellg(); - temp.parse(in, flags & PARSE_VALEXPR_NO_MIGRATE ? - AMOUNT_PARSE_NO_MIGRATE : 0); + + unsigned char parse_flags = 0; + if (flags & PARSE_VALEXPR_NO_MIGRATE) + parse_flags |= AMOUNT_PARSE_NO_MIGRATE; + if (flags & PARSE_VALEXPR_NO_REDUCE) + parse_flags |= AMOUNT_PARSE_NO_REDUCE; + + temp.parse(in, parse_flags); } catch (amount_error * err) { // If the amount had no commodity, it must be an unambiguous @@ -279,6 +279,7 @@ bool compute_amount(value_expr_t * expr, amount_t& amt, #define PARSE_VALEXPR_PARTIAL 0x01 #define PARSE_VALEXPR_RELAXED 0x02 #define PARSE_VALEXPR_NO_MIGRATE 0x04 +#define PARSE_VALEXPR_NO_REDUCE 0x08 value_expr_t * parse_value_expr(std::istream& in, scope_t * scope = NULL, |