Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ tests\GH_005768_pow_accuracy
tests\GH_005780_non_ascii_locales
tests\GH_005800_stable_sort_large_alignment
tests\GH_005968_headers_provide_begin_end
tests\GH_006130_time_get_do_get_format
tests\LWG2381_num_get_floating_point
tests\LWG2510_tag_classes
tests\LWG2597_complex_branch_cut
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/GH_006130_time_get_do_get_format/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_matrix.lst
22 changes: 22 additions & 0 deletions tests/std/tests/GH_006130_time_get_do_get_format/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
Comment thread
mirion-dev marked this conversation as resolved.
Outdated
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cassert>
#include <ctime>
#include <iomanip>
#include <sstream>

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