Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stl/inc/xloctime
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ protected:
}
break;

case '%':
if (_First == _Last || _Ctype_fac.narrow(*_First) != '%') {
_State |= ios_base::failbit;
} else {
++_First;
}
break;

default:
_State |= ios_base::failbit; // unknown specifier
break;
Expand Down
19 changes: 19 additions & 0 deletions tests/std/tests/Dev11_0836436_get_time/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void test_gh_2618();
void test_gh_2848();
void test_gh_4820();
void test_gh_4882();
void test_gh_6130();

int main() {
assert(read_hour("12 AM") == 0);
Expand Down Expand Up @@ -160,6 +161,7 @@ int main() {
test_gh_2848();
test_gh_4820();
test_gh_4882();
test_gh_6130();
}

typedef istreambuf_iterator<char> Iter;
Expand Down Expand Up @@ -961,3 +963,20 @@ void test_gh_4882() {
fieldValidation(testData.field, testData.hi, testData.fmt);
}
}

void test_gh_6130() {
// GH-6130 <xloctime>: time_get::do_get doesn't parse a literal %
{
tm t{};
stringstream ss{"%"};
ss >> get_time(&t, "%%");
assert(!ss.fail() && ss.eof());
}

{
tm t{};
stringstream ss{"% "};
ss >> get_time(&t, "%%");
assert(!ss.fail() && ss.tellg() == 1);
}
}