PR libstdc++/79980 fix BOM detection, maxcode checks, UCS2 handling
authorJonathan Wakely <jwakely@redhat.com>
Thu, 16 Mar 2017 15:27:51 +0000 (15:27 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 16 Mar 2017 15:27:51 +0000 (15:27 +0000)
commitbcd682e1faed71fd861518ca43235706fc39a7cd
treede8fd5a5cb199e551d99a1fede15c60f699ed6d8
parent02e12bda2df86491a5d9c7294550fd4cd4968aa1
PR libstdc++/79980 fix BOM detection, maxcode checks, UCS2 handling

PR libstdc++/79980
* include/bits/locale_conv.h (__do_str_codecvt): Set __count on
error path.
* src/c++11/codecvt.cc (operator&=, operator|=, operator~): Overloads
for manipulating codecvt_mode values.
(read_utf16_bom): Compare input to BOM constants instead of integral
constants that depend on endianness.  Take mode parameter by
reference and adjust it, to distinguish between no BOM present and
UTF-16BE BOM present.
(ucs4_in, ucs2_span, ucs4_span): Adjust calls to read_utf16_bom.
(surrogates): New enumeration type.
(utf16_in, utf16_out): Add surrogates parameter to choose between
UTF-16 and UCS2 behaviour.
(utf16_span, ucs2_span): Use std::min not std::max.
(ucs2_out): Use std::min not std::max.  Disallow surrogate pairs.
(ucs2_in): Likewise. Adjust calls to read_utf16_bom.
* testsuite/22_locale/codecvt/codecvt_utf16/79980.cc: New test.
* testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: New test.

From-SVN: r246200
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_conv.h
libstdc++-v3/src/c++11/codecvt.cc
libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc [new file with mode: 0644]