Fix boolalpha extraction to be case-sensitive again #1543
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1541.
_Getloctxt()
is a non-member function template. We can change its signature because it's header-only. (I verified withdumpbin /exports
that it isn't exported from the DLL. It's called by separately compiled virtual member functions, which is totally fine. As an aside, this means that the__CRTDECL
is unnecessary; I will consider a global cleanup later.)For clarity, I'm introducing
enum class _Case_sensitive
(asbool
arguments are generally unreadable) and making it mandatory (no default argument).As a targeted cleanup, because I'm already changing the signature (and this is always called with template argument deduction), I'm reordering the template parameters to match the function parameters.
The core fix is a multi-line conditional expression, but due to the naming I believe it's readable. This seemed less invasive than restructuring the control flow. (I also felt that testing this at runtime was okay, compared to templating on
_Case_sensitive
and usingif constexpr
.)Then we need to change all callsites (not searching for these is what led to the regression; a useful lesson).
boolalpha
must be case-sensitive, but all of the<xloctime>
calls are correctly case-insensitive. (Future cleanup:":AM:am:PM:pm"
is an unnecessary relic now that_Getloctxt()
handles lowercase, uppercase, and mixed case.)Finally, I'm adding the test case that I developed, which is expressed with my new favorite technique, static tables.