Skip to content
Merged
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
14 changes: 8 additions & 6 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,6 @@ std/localization/locale.categories/category.time/locale.time.get/locale.time.get
std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp FAIL
std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp FAIL

# GH-6129 <xloctime>: time_get::do_get uses the wrong format for %c and %x
# GH-6130 <xloctime>: time_get::do_get doesn't parse a literal %
std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp FAIL
std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp FAIL
std/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp FAIL

# GH-6134 <xloctime>: time_put::do_put does not match strftime for the %c and %r specifiers in the "C" locale
std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp FAIL

Expand Down Expand Up @@ -753,6 +747,14 @@ std/time/time.zone/time.zone.db/time.zone.db.tzdb/current_zone.pass.cpp FAIL
std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp FAIL
std/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp FAIL

# Assertion failed: base(i) == in+sizeof(in)/sizeof(in[0])-1
# We fixed GH-6129 "<xloctime>: time_get::do_get uses the wrong format for %c and %x",
# which created a conflict with `#ifdef _WIN32` test code commented with:
# `On Windows, the "%c" format lacks the leading week day`.
# See LWG-4541 "Unclear behavior for parsing locale-dependent format".
std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp FAIL
std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp FAIL


# *** LIKELY STL BUGS ***
# Not analyzed, likely STL bugs. Various assertions.
Expand Down
21 changes: 21 additions & 0 deletions tests/std/tests/Dev11_0836436_get_time/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void test_gh_2848();
void test_gh_4820();
void test_gh_4882();
void test_gh_6129();
void test_gh_6130();

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

typedef istreambuf_iterator<char> Iter;
Expand Down Expand Up @@ -994,3 +996,22 @@ 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{};
istringstream iss{"%"};
iss >> get_time(&t, "%%");
assert(!iss.fail());
assert(iss.eof());
}

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