mirror of
https://github.com/HowardHinnant/date.git
synced 2025-01-14 09:47:57 +08:00
Make parse fail if fmt string is not completely consumed.
This commit is contained in:
parent
c64d69b1e1
commit
2f8997d3ed
5
date.h
5
date.h
@ -5367,9 +5367,8 @@ read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args)
|
|||||||
if (a0 != CharT{})
|
if (a0 != CharT{})
|
||||||
{
|
{
|
||||||
auto ic = is.peek();
|
auto ic = is.peek();
|
||||||
if (Traits::eq_int_type(ic, Traits::eof()))
|
if (Traits::eq_int_type(ic, Traits::eof()) ||
|
||||||
return;
|
!Traits::eq(Traits::to_char_type(ic), a0))
|
||||||
if (!Traits::eq(Traits::to_char_type(ic), a0))
|
|
||||||
{
|
{
|
||||||
is.setstate(std::ios::failbit);
|
is.setstate(std::ios::failbit);
|
||||||
return;
|
return;
|
||||||
|
@ -716,6 +716,18 @@ test_Z()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_trailing_Z()
|
||||||
|
{
|
||||||
|
std::string format = "%FT%TZ";
|
||||||
|
std::string datetime = "2017-2-15T13:13:13";
|
||||||
|
std::istringstream input(datetime);
|
||||||
|
date::sys_seconds tp;
|
||||||
|
input >> date::parse(format, tp);
|
||||||
|
assert(input.fail());
|
||||||
|
assert(input.eof());
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
@ -743,4 +755,5 @@ main()
|
|||||||
test_X();
|
test_X();
|
||||||
test_z();
|
test_z();
|
||||||
test_Z();
|
test_Z();
|
||||||
|
test_trailing_Z();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user