summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amount.cc2
-rw-r--r--amount.h2
-rw-r--r--datetime.h10
-rw-r--r--textual.cc13
-rw-r--r--valexpr.cc10
-rw-r--r--valexpr.h1
6 files changed, 24 insertions, 14 deletions
diff --git a/amount.cc b/amount.cc
index 841b83ab..948c1738 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1952,7 +1952,7 @@ void export_amount()
;
class_< commodity_base_t::updater_t, commodity_updater_wrap,
- boost::noncopyable >
+ boost::noncopyable >
("Updater")
;
diff --git a/amount.h b/amount.h
index d40f8f3a..7513c72d 100644
--- a/amount.h
+++ b/amount.h
@@ -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)
{
diff --git a/datetime.h b/datetime.h
index 45bd4921..8a5c5fc5 100644
--- a/datetime.h
+++ b/datetime.h
@@ -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) {
diff --git a/textual.cc b/textual.cc
index 6fdde631..37cf911e 100644
--- a/textual.cc
+++ b/textual.cc
@@ -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");
diff --git a/valexpr.cc b/valexpr.cc
index 64da351c..d1cc9322 100644
--- a/valexpr.cc
+++ b/valexpr.cc
@@ -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
diff --git a/valexpr.h b/valexpr.h
index 02e564d2..f0c1ed24 100644
--- a/valexpr.h
+++ b/valexpr.h
@@ -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,