From eda216fbbcfa9033e500ca628954e7e299e0b370 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Mon, 13 Jul 2020 23:00:53 +0000 Subject: [PATCH 1/2] Merged PR 4915530: Reflect OS Build fixes on top of 58f5d7c7 --- src/project.inc | 2 +- src/project.unittest.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/project.inc b/src/project.inc index fa480e3221..8a0583d9ec 100644 --- a/src/project.inc +++ b/src/project.inc @@ -8,7 +8,7 @@ # ------------------------------------- UNICODE = 1 -C_DEFINES = $(C_DEFINES) -DUNICODE -D_UNICODE +C_DEFINES = $(C_DEFINES) -DUNICODE -D_UNICODE -DFMT_HEADER_ONLY # ------------------------------------- # CRT Configuration diff --git a/src/project.unittest.inc b/src/project.unittest.inc index 13b0caa9f4..8d625b78e8 100644 --- a/src/project.unittest.inc +++ b/src/project.unittest.inc @@ -9,7 +9,7 @@ # Preprocessor Settings # ------------------------------------- -C_DEFINES = $(C_DEFINES) -DINLINE_TEST_METHOD_MARKUP -DUNIT_TESTING +C_DEFINES = $(C_DEFINES) -DINLINE_TEST_METHOD_MARKUP -DUNIT_TESTING -DFMT_HEADER_ONLY # ------------------------------------- # Program Information From b12420725f1b62890e5750856d3e52645b8d2e25 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Mon, 13 Jul 2020 23:04:32 +0000 Subject: [PATCH 2/2] Merged PR 4915574: console: switch to /Zc:wchar_t (native wchar_t) console: switch to /Zc:wchar_t (native wchar_t) This matches what we use in OpenConsole and makes {fmt} play nice. I've also removed the workaround we introduced into OutputCellIterator to work around not using /Zc:wchar_t. Fixes MSFT:27626309. Fixes GH-2673. Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_onecore_dep_uxp 1508f7c232ec58bebc37fedfdec3eb8f9bff5502 --- src/buffer/out/OutputCellIterator.cpp | 18 ++++-------------- src/buffer/out/OutputCellIterator.hpp | 3 ++- src/host/_output.cpp | 2 +- src/host/ut_host/OutputCellIteratorTests.cpp | 2 +- src/project.inc | 1 + 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/buffer/out/OutputCellIterator.cpp b/src/buffer/out/OutputCellIterator.cpp index 12ac7ad508..9b5437041b 100644 --- a/src/buffer/out/OutputCellIterator.cpp +++ b/src/buffer/out/OutputCellIterator.cpp @@ -112,26 +112,16 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text, const // - This is an iterator over legacy colors only. The text is not modified. // Arguments: // - legacyAttrs - One legacy color item per cell -// - unused - useless bool to change function signature for legacyAttrs constructor because the C++ compiler in -// razzle cannot distinguish between a std::wstring_view and a std::basic_string_view -// NOTE: This one internally casts to wchar_t because Razzle sees WORD and wchar_t as the same type -// despite that Visual Studio build can tell the difference. -#pragma warning(push) -#pragma warning(suppress : 26490) -// Suppresses reinterpret_cast. We're only doing this because Windows doesn't understand the type difference between wchar_t and DWORD. -// It is not worth trying to separate that out further or risking performance over this particular warning here. -// TODO GH 2673 - Investigate real wchar_t flag in Windows and resolve this audit issue -OutputCellIterator::OutputCellIterator(const std::basic_string_view legacyAttrs, const bool /*unused*/) noexcept : +OutputCellIterator::OutputCellIterator(const std::basic_string_view legacyAttrs) noexcept : _mode(Mode::LegacyAttr), _currentView(s_GenerateViewLegacyAttr(legacyAttrs.at(0))), - _run(std::wstring_view(reinterpret_cast(legacyAttrs.data()), legacyAttrs.size())), + _run(legacyAttrs), _attr(InvalidTextAttribute), _distance(0), _pos(0), _fillLimit(0) { } -#pragma warning(pop) // Routine Description: // - This is an iterator over legacy cell data. We will use the unicode text and the legacy color attribute. @@ -198,7 +188,7 @@ OutputCellIterator::operator bool() const noexcept } case Mode::LegacyAttr: { - return _pos < std::get(_run).length(); + return _pos < std::get>(_run).length(); } default: FAIL_FAST_HR(E_NOTIMPL); @@ -295,7 +285,7 @@ OutputCellIterator& OutputCellIterator::operator++() _pos++; if (operator bool()) { - _currentView = s_GenerateViewLegacyAttr(std::get(_run).at(_pos)); + _currentView = s_GenerateViewLegacyAttr(std::get>(_run).at(_pos)); } break; } diff --git a/src/buffer/out/OutputCellIterator.hpp b/src/buffer/out/OutputCellIterator.hpp index 02f6aefa54..0d4b866e7c 100644 --- a/src/buffer/out/OutputCellIterator.hpp +++ b/src/buffer/out/OutputCellIterator.hpp @@ -39,7 +39,7 @@ public: OutputCellIterator(const CHAR_INFO& charInfo, const size_t fillLimit = 0) noexcept; OutputCellIterator(const std::wstring_view utf16Text); OutputCellIterator(const std::wstring_view utf16Text, const TextAttribute attribute); - OutputCellIterator(const std::basic_string_view legacyAttributes, const bool unused) noexcept; + OutputCellIterator(const std::basic_string_view legacyAttributes) noexcept; OutputCellIterator(const std::basic_string_view charInfos) noexcept; OutputCellIterator(const std::basic_string_view cells); ~OutputCellIterator() = default; @@ -90,6 +90,7 @@ private: std::variant< std::wstring_view, + std::basic_string_view, std::basic_string_view, std::basic_string_view, std::monostate> diff --git a/src/host/_output.cpp b/src/host/_output.cpp index 67ad7fedf3..65413033a4 100644 --- a/src/host/_output.cpp +++ b/src/host/_output.cpp @@ -91,7 +91,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region) return E_INVALIDARG; } - const OutputCellIterator it(attrs, true); + const OutputCellIterator it(attrs); const auto done = screenInfo.Write(it, target); used = done.GetCellDistance(it); diff --git a/src/host/ut_host/OutputCellIteratorTests.cpp b/src/host/ut_host/OutputCellIteratorTests.cpp index 6f35855852..4d22fabb17 100644 --- a/src/host/ut_host/OutputCellIteratorTests.cpp +++ b/src/host/ut_host/OutputCellIteratorTests.cpp @@ -369,7 +369,7 @@ class OutputCellIteratorTests const std::vector colors{ FOREGROUND_GREEN, FOREGROUND_RED | BACKGROUND_BLUE, FOREGROUND_BLUE | FOREGROUND_INTENSITY, BACKGROUND_GREEN }; const std::basic_string_view view{ colors.data(), colors.size() }; - OutputCellIterator it(view, false); + OutputCellIterator it(view); for (const auto& color : colors) { diff --git a/src/project.inc b/src/project.inc index 8a0583d9ec..c083d8b82c 100644 --- a/src/project.inc +++ b/src/project.inc @@ -16,6 +16,7 @@ C_DEFINES = $(C_DEFINES) -DUNICODE -D_UNICODE -DFMT_HEADER_ONLY USE_UNICRT = 1 USE_MSVCRT = 1 +NO_WCHAR_T = 1 # use native wchar_t USE_STL = 1 STL_VER = STL_VER_CURRENT