diff --git a/date.h b/date.h index 704dae2..186420d 100644 --- a/date.h +++ b/date.h @@ -4149,7 +4149,7 @@ parse(std::basic_istream& is, auto e = b + format.size(); auto command = false; auto modified = false; - for (; i < e; ++i) + for (; i < e && 0 == (err & ios_base::failbit); ++i) { switch (*i) { @@ -4166,11 +4166,21 @@ parse(std::basic_istream& is, if (command && !modified) { f.get(is, 0, is, err, &tm, b, i-1); + if (err & ios_base::failbit) + { + command = modified = false; + break; // break the switch/case + } b = i+1; if (*i == 'T') { const CharT hm[] = {'%', 'H', ':', '%', 'M', ':'}; f.get(is, 0, is, err, &tm, hm, hm+6); + if (err & ios_base::failbit) + { + command = modified = false; + break; // break the switch/case + } } if (ratio_less>::value) { @@ -4302,6 +4312,8 @@ parse(std::basic_istream& is, } is.setstate(err); } + else + is.setstate(ios_base::failbit); } } // namespace detail