diff --git a/date.h b/date.h index fd4ee7f..0951199 100644 --- a/date.h +++ b/date.h @@ -5805,6 +5805,9 @@ from_stream(std::basic_istream& is, const CharT* fmt, for (++fmt; *fmt == 'n' || *fmt == 't'; ++fmt) ; --fmt; + command = nullptr; + width = -1; + modified = CharT{}; } else read(is, *fmt); diff --git a/test/date_test/parse.pass.cpp b/test/date_test/parse.pass.cpp index 05b666d..d93f394 100644 --- a/test/date_test/parse.pass.cpp +++ b/test/date_test/parse.pass.cpp @@ -728,6 +728,18 @@ test_trailing_Z() assert(input.eof()); } +void +test_leading_ws() +{ + using namespace std; + using namespace date; + istringstream in{"05/04/17 5/4/17"}; + year_month_day d1, d2; + in >> parse("%D", d1) >> parse("%n%D", d2); + assert(d1 == may/4/2017); + assert(d2 == may/4/2017); +} + int main() { @@ -756,4 +768,5 @@ main() test_z(); test_Z(); test_trailing_Z(); + test_leading_ws(); }