From e9f0dc8bb94c7590891a5c1dc0e1a431a2ed52a3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 23 Sep 2004 01:52:47 -0400 Subject: fix to date mask parsing; put in a safety cutoffs when asserts are enabled --- datetime.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'datetime.cc') diff --git a/datetime.cc b/datetime.cc index 0d39d3b3..70b36279 100644 --- a/datetime.cc +++ b/datetime.cc @@ -47,8 +47,17 @@ std::time_t interval_t::first(const std::time_t moment) } std::time_t temp; - while (std::difftime(moment, temp = increment(quant)) > 0) +#if DEBUG_LEVEL >= RELEASE + int cutoff = 10000; +#endif + while (std::difftime(moment, temp = increment(quant)) > 0) { + if (quant == temp) + break; quant = temp; +#if DEBUG_LEVEL >= RELEASE + assert(--cutoff > 0); +#endif + } } return quant; @@ -90,7 +99,8 @@ static void parse_inclusion_specifier(const std::string& word, struct std::tm when; if (! parse_date_mask(word.c_str(), &when)) - throw interval_expr_error("Could not parse 'in' date mask"); + throw interval_expr_error(std::string("Could not parse date mask: ") + + word); when.tm_hour = 0; when.tm_min = 0; -- cgit v1.2.3