[libcxx] Fix the ctype `is` (pointer version) function for Windows
authorMartin Storsjö <martin@martin.st>
Fri, 21 Jan 2022 23:21:31 +0000 (23:21 +0000)
committerMartin Storsjö <martin@martin.st>
Fri, 4 Mar 2022 22:47:19 +0000 (00:47 +0200)
commit45415ef91be5311939dfb0bf11a87b1722f68d02
treea569cf98f6eea9f3b59d60d67daf25b6aae1473a
parent3347e7d40fd83ae762dcdb7c6161550e4190d6cf
[libcxx] Fix the ctype `is` (pointer version) function for Windows

Previously, this test snippet would report incorrect information:

    F::mask m;
    std::wstring in(L"\u00DA"); // LATIN CAPITAL LETTER U WITH ACUTE
    f.is(in.data(), in.data() + 1, &m);
    // m & F::lower would be set

The single-character version of the `is` function wasn't
affected by this issue though.

Define `_LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA` for Windows,
as the `alpha` / `_ALPHA` constant is a mask consisting of
multiple bits set, which avoids setting `alpha` whenver any
of the bits is set, in the `do_is` implementation.

On Windows, with the "C" locale, wchars are classified according
to their Unicode interpretation, just as in the en_US.UTF-8 locale on
all platforms.

Due to the differing classification of some characters, the
`scan_is` and `scan_not` tests are quite annoying to fix, thus just
ifdef out some of the tests for the "C" locale there - the code gets
tested with the more standard en_US.UTF-8 locale anyway.

Differential Revision: https://reviews.llvm.org/D120796
libcxx/include/__locale
libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp