2015-11-13 15:25:48 +00:00
|
|
|
// { dg-require-namedlocale "fr_FR.ISO8859-15" }
|
re PR libstdc++/13631 (Problems in messages)
2014-12-03 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/13631
* include/bits/codecvt.h (codecvt<char, char, mbstate_t>): friend class
std::messages<char>.
(codecvt<wchar_t, char, mbstate_t>): friend class
std::messages<wchar_t>.
* config/locale/gnu/messages_member.h
(messages<char>::do_open): Specialized.
(messages<char>::do_close): Likewise.
(messages<wchar_t>::do_open): Likewise.
(messages<wchar_t>::do_close): Likewise.
* config/locale/gnu/messages_member.cc:
(messages<char>::do_open): Implement. Use bind_textdomain_codeset based
on codecvt<char, char, mbstate_t>._M_c_locale_codecvt code set. Use
internal cache to keep opened domain name with locale information.
(messages<wchar_t>::do_open): Likewise with
codecvt<wchar_t, char, mbstate_t>.
(messages<char>::do_close): Implement. Clean cache information.
(messages<wchar_t>::do_close): Likewise.
(get_glibc_msg): New. Use dgettext rather than gettext using cached
domain name associated to catalog id.
(messages<char>::do_get): Use latter.
(messages<wchar_t>::do_get): Likewise and use also cached locale
codecvt<wchar_t, char, mbstate_t> facet to convert wchar_t default
value to char and the result back to wchar_t.
* testsuite/22_locale/messages/13631.cc: New.
* testsuite/22_locale/messages/members/char/2.cc: Use also fr_FR locale
for charset conversion to get the expected accented character.
From-SVN: r218329
2014-12-03 19:47:00 +00:00
|
|
|
|
2016-01-04 15:30:50 +01:00
|
|
|
// Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
re PR libstdc++/13631 (Problems in messages)
2014-12-03 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/13631
* include/bits/codecvt.h (codecvt<char, char, mbstate_t>): friend class
std::messages<char>.
(codecvt<wchar_t, char, mbstate_t>): friend class
std::messages<wchar_t>.
* config/locale/gnu/messages_member.h
(messages<char>::do_open): Specialized.
(messages<char>::do_close): Likewise.
(messages<wchar_t>::do_open): Likewise.
(messages<wchar_t>::do_close): Likewise.
* config/locale/gnu/messages_member.cc:
(messages<char>::do_open): Implement. Use bind_textdomain_codeset based
on codecvt<char, char, mbstate_t>._M_c_locale_codecvt code set. Use
internal cache to keep opened domain name with locale information.
(messages<wchar_t>::do_open): Likewise with
codecvt<wchar_t, char, mbstate_t>.
(messages<char>::do_close): Implement. Clean cache information.
(messages<wchar_t>::do_close): Likewise.
(get_glibc_msg): New. Use dgettext rather than gettext using cached
domain name associated to catalog id.
(messages<char>::do_get): Use latter.
(messages<wchar_t>::do_get): Likewise and use also cached locale
codecvt<wchar_t, char, mbstate_t> facet to convert wchar_t default
value to char and the result back to wchar_t.
* testsuite/22_locale/messages/13631.cc: New.
* testsuite/22_locale/messages/members/char/2.cc: Use also fr_FR locale
for charset conversion to get the expected accented character.
From-SVN: r218329
2014-12-03 19:47:00 +00:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING3. If not see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#include <locale>
|
|
|
|
#include <testsuite_hooks.h>
|
|
|
|
|
|
|
|
void test01()
|
|
|
|
{
|
|
|
|
bool test __attribute__((unused)) = true;
|
|
|
|
|
|
|
|
// This is defined through CXXFLAGS in scripts/testsuite_flags[.in].
|
|
|
|
const char* dir = LOCALEDIR;
|
|
|
|
|
2015-11-13 15:25:48 +00:00
|
|
|
std::locale l(ISO_8859(15,fr_FR));
|
re PR libstdc++/13631 (Problems in messages)
2014-12-03 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/13631
* include/bits/codecvt.h (codecvt<char, char, mbstate_t>): friend class
std::messages<char>.
(codecvt<wchar_t, char, mbstate_t>): friend class
std::messages<wchar_t>.
* config/locale/gnu/messages_member.h
(messages<char>::do_open): Specialized.
(messages<char>::do_close): Likewise.
(messages<wchar_t>::do_open): Likewise.
(messages<wchar_t>::do_close): Likewise.
* config/locale/gnu/messages_member.cc:
(messages<char>::do_open): Implement. Use bind_textdomain_codeset based
on codecvt<char, char, mbstate_t>._M_c_locale_codecvt code set. Use
internal cache to keep opened domain name with locale information.
(messages<wchar_t>::do_open): Likewise with
codecvt<wchar_t, char, mbstate_t>.
(messages<char>::do_close): Implement. Clean cache information.
(messages<wchar_t>::do_close): Likewise.
(get_glibc_msg): New. Use dgettext rather than gettext using cached
domain name associated to catalog id.
(messages<char>::do_get): Use latter.
(messages<wchar_t>::do_get): Likewise and use also cached locale
codecvt<wchar_t, char, mbstate_t> facet to convert wchar_t default
value to char and the result back to wchar_t.
* testsuite/22_locale/messages/13631.cc: New.
* testsuite/22_locale/messages/members/char/2.cc: Use also fr_FR locale
for charset conversion to get the expected accented character.
From-SVN: r218329
2014-12-03 19:47:00 +00:00
|
|
|
|
|
|
|
typedef std::messages<char> messages;
|
|
|
|
|
|
|
|
const messages &msgs_facet = std::use_facet<messages>(l);
|
|
|
|
|
|
|
|
messages::catalog msgs = msgs_facet.open("libstdc++", l, dir);
|
|
|
|
VERIFY( msgs >= 0 );
|
|
|
|
|
|
|
|
const char msgid[] = "please";
|
|
|
|
std::string translation1 = msgs_facet.get(msgs, 0, 0, msgid);
|
|
|
|
|
|
|
|
// Without a real translation this test doesn't mean anything:
|
|
|
|
VERIFY( translation1 != msgid );
|
|
|
|
|
|
|
|
// Opening another catalog was enough to show the problem, even a fake
|
|
|
|
// catalog.
|
|
|
|
messages::catalog fake_msgs = msgs_facet.open("fake", l);
|
|
|
|
|
|
|
|
std::string translation2 = msgs_facet.get(msgs, 0, 0, msgid);
|
|
|
|
|
|
|
|
// Close catalogs before doing the check to avoid leaks.
|
|
|
|
msgs_facet.close(fake_msgs);
|
|
|
|
msgs_facet.close(msgs);
|
|
|
|
|
|
|
|
VERIFY( translation1 == translation2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void test02()
|
|
|
|
{
|
2015-10-03 00:43:17 +01:00
|
|
|
#ifdef _GLIBCXX_USE_WCHAR_T
|
re PR libstdc++/13631 (Problems in messages)
2014-12-03 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/13631
* include/bits/codecvt.h (codecvt<char, char, mbstate_t>): friend class
std::messages<char>.
(codecvt<wchar_t, char, mbstate_t>): friend class
std::messages<wchar_t>.
* config/locale/gnu/messages_member.h
(messages<char>::do_open): Specialized.
(messages<char>::do_close): Likewise.
(messages<wchar_t>::do_open): Likewise.
(messages<wchar_t>::do_close): Likewise.
* config/locale/gnu/messages_member.cc:
(messages<char>::do_open): Implement. Use bind_textdomain_codeset based
on codecvt<char, char, mbstate_t>._M_c_locale_codecvt code set. Use
internal cache to keep opened domain name with locale information.
(messages<wchar_t>::do_open): Likewise with
codecvt<wchar_t, char, mbstate_t>.
(messages<char>::do_close): Implement. Clean cache information.
(messages<wchar_t>::do_close): Likewise.
(get_glibc_msg): New. Use dgettext rather than gettext using cached
domain name associated to catalog id.
(messages<char>::do_get): Use latter.
(messages<wchar_t>::do_get): Likewise and use also cached locale
codecvt<wchar_t, char, mbstate_t> facet to convert wchar_t default
value to char and the result back to wchar_t.
* testsuite/22_locale/messages/13631.cc: New.
* testsuite/22_locale/messages/members/char/2.cc: Use also fr_FR locale
for charset conversion to get the expected accented character.
From-SVN: r218329
2014-12-03 19:47:00 +00:00
|
|
|
bool test __attribute__((unused)) = true;
|
|
|
|
|
|
|
|
// This is defined through CXXFLAGS in scripts/testsuite_flags[.in].
|
|
|
|
const char* dir = LOCALEDIR;
|
|
|
|
|
2015-11-13 15:25:48 +00:00
|
|
|
std::locale l(ISO_8859(15,fr_FR));
|
re PR libstdc++/13631 (Problems in messages)
2014-12-03 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/13631
* include/bits/codecvt.h (codecvt<char, char, mbstate_t>): friend class
std::messages<char>.
(codecvt<wchar_t, char, mbstate_t>): friend class
std::messages<wchar_t>.
* config/locale/gnu/messages_member.h
(messages<char>::do_open): Specialized.
(messages<char>::do_close): Likewise.
(messages<wchar_t>::do_open): Likewise.
(messages<wchar_t>::do_close): Likewise.
* config/locale/gnu/messages_member.cc:
(messages<char>::do_open): Implement. Use bind_textdomain_codeset based
on codecvt<char, char, mbstate_t>._M_c_locale_codecvt code set. Use
internal cache to keep opened domain name with locale information.
(messages<wchar_t>::do_open): Likewise with
codecvt<wchar_t, char, mbstate_t>.
(messages<char>::do_close): Implement. Clean cache information.
(messages<wchar_t>::do_close): Likewise.
(get_glibc_msg): New. Use dgettext rather than gettext using cached
domain name associated to catalog id.
(messages<char>::do_get): Use latter.
(messages<wchar_t>::do_get): Likewise and use also cached locale
codecvt<wchar_t, char, mbstate_t> facet to convert wchar_t default
value to char and the result back to wchar_t.
* testsuite/22_locale/messages/13631.cc: New.
* testsuite/22_locale/messages/members/char/2.cc: Use also fr_FR locale
for charset conversion to get the expected accented character.
From-SVN: r218329
2014-12-03 19:47:00 +00:00
|
|
|
|
|
|
|
typedef std::messages<wchar_t> messages;
|
|
|
|
|
|
|
|
const messages &msgs_facet = std::use_facet<messages>(l);
|
|
|
|
|
|
|
|
messages::catalog msgs = msgs_facet.open("libstdc++", l, dir);
|
|
|
|
VERIFY( msgs >= 0 );
|
|
|
|
|
|
|
|
const wchar_t msgid[] = L"please";
|
|
|
|
std::wstring translation1 = msgs_facet.get(msgs, 0, 0, msgid);
|
|
|
|
|
|
|
|
// Without a real translation this test doesn't mean anything:
|
|
|
|
VERIFY( !translation1.empty() );
|
|
|
|
VERIFY( translation1 != msgid );
|
|
|
|
|
|
|
|
// Opening another catalog was enough to show the problem, even a fake
|
|
|
|
// catalog.
|
|
|
|
messages::catalog fake_msgs = msgs_facet.open("fake", l);
|
|
|
|
|
|
|
|
std::wstring translation2 = msgs_facet.get(msgs, 0, 0, msgid);
|
|
|
|
|
|
|
|
// Close catalogs before doing the check to avoid leaks.
|
|
|
|
msgs_facet.close(fake_msgs);
|
|
|
|
msgs_facet.close(msgs);
|
|
|
|
|
|
|
|
VERIFY( translation1 == translation2 );
|
2015-10-03 00:43:17 +01:00
|
|
|
#endif
|
re PR libstdc++/13631 (Problems in messages)
2014-12-03 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/13631
* include/bits/codecvt.h (codecvt<char, char, mbstate_t>): friend class
std::messages<char>.
(codecvt<wchar_t, char, mbstate_t>): friend class
std::messages<wchar_t>.
* config/locale/gnu/messages_member.h
(messages<char>::do_open): Specialized.
(messages<char>::do_close): Likewise.
(messages<wchar_t>::do_open): Likewise.
(messages<wchar_t>::do_close): Likewise.
* config/locale/gnu/messages_member.cc:
(messages<char>::do_open): Implement. Use bind_textdomain_codeset based
on codecvt<char, char, mbstate_t>._M_c_locale_codecvt code set. Use
internal cache to keep opened domain name with locale information.
(messages<wchar_t>::do_open): Likewise with
codecvt<wchar_t, char, mbstate_t>.
(messages<char>::do_close): Implement. Clean cache information.
(messages<wchar_t>::do_close): Likewise.
(get_glibc_msg): New. Use dgettext rather than gettext using cached
domain name associated to catalog id.
(messages<char>::do_get): Use latter.
(messages<wchar_t>::do_get): Likewise and use also cached locale
codecvt<wchar_t, char, mbstate_t> facet to convert wchar_t default
value to char and the result back to wchar_t.
* testsuite/22_locale/messages/13631.cc: New.
* testsuite/22_locale/messages/members/char/2.cc: Use also fr_FR locale
for charset conversion to get the expected accented character.
From-SVN: r218329
2014-12-03 19:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
test01();
|
|
|
|
test02();
|
|
|
|
return 0;
|
|
|
|
}
|