9c69a45888
2010-09-15 Paolo Carlini <paolo.carlini@oracle.com> * doc/xml/manual/prerequisites.xml: Update "C" library locale information prerequisites. 2010-09-15 François Dumont <francois.cppdevs@free.fr> * testsuite/lib/libstdc++.exp, dg-options.exp ([check_v3_target_namedlocale]): Take the name of the required locale. * testsuite/27_io/objects/wchar_t/9520.cc, 11.cc, 13.cc, 10.cc, 12.cc: Specify locale name to check. * testsuite/27_io/basic_streambuf/imbue/wchar_t/9322.cc, 13007-1.cc, 13007-2.cc: Likewise. * testsuite/27_io/basic_streambuf/imbue/char/9322.cc, 13007-1.cc, 13007-2.cc: Likewise. * testsuite/27_io/basic_ios/copyfmt/char/2.cc: Likewise. * testsuite/27_io/basic_stringbuf/imbue/wchar_t/9322.cc: Likewise. * testsuite/27_io/basic_stringbuf/imbue/char/9322.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/2.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/2.cc: Likewise. * testsuite/27_io/basic_filebuf/seekoff/wchar_t/1.cc, 2.cc: Likewise. * testsuite/27_io/basic_filebuf/imbue/wchar_t/13171-3.cc, 9322.cc, 13582-2.cc, 2.cc, 13582-3.cc, 12868.cc, 14975-2.cc, 13007.cc: Likewise. * testsuite/27_io/basic_filebuf/imbue/char/13171-2.cc, 13171-4.cc, 9322.cc, 13582-2.cc, 2.cc, 14975-1.cc, 13007.cc, 13171-1.cc: Likewise. * testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc, 11305-2.cc, 11305-3.cc, 11305-4.cc: Likewise. * testsuite/27_io/basic_filebuf/underflow/wchar_t/9520.cc, 1.cc, 2.cc, 3.cc, 11389-1.cc, 4.cc, 11389-2.cc, 5.cc, 11389-3.cc, 11389-4.cc: Likewise. * testsuite/27_io/basic_filebuf/seekpos/wchar_t/9874.cc: Likewise. * testsuite/27_io/manipulators/extended/put_money/wchar_t/1.cc: Likewise. * testsuite/27_io/manipulators/extended/put_money/char/1.cc: Likewise. * testsuite/27_io/manipulators/extended/get_money/wchar_t/1.cc: Likewise. * testsuite/27_io/manipulators/extended/get_money/char/1.cc: Likewise. * testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc: Likewise. * testsuite/22_locale/money_put/put/wchar_t/1.cc, 2.cc, 3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/money_put/put/char/1.cc, 2.cc, 3.cc, 9780-3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/facet/2.cc: Likewise. * testsuite/22_locale/collate/hash/wchar_t/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/collate/hash/char/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/collate/compare/wchar_t/1.cc, 2.cc, 3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/collate/compare/char/1.cc, 2.cc, 3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/collate/transform/wchar_t/2.cc, 3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/collate/transform/char/2.cc, 3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/cons/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/to/wchar_t/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/to/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/scan/wchar_t/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/scan/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/widen/wchar_t/2.cc, 3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/widen/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/narrow/wchar_t/3.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/narrow/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/ctype/is/wchar_t/2.cc,wrapped_locale.cc, wrapped_env.cc: Likewise * testsuite/22_locale/ctype/is/char/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_put/put/wchar_t/2.cc, 3.cc, 4.cc, 6.cc, 7.cc, 8.cc, wrapped_env.cc, wrapped_locale.cc, 17038.cc: Likewise. * testsuite/22_locale/time_put/put/char/2.cc, 3.cc, 4.cc, 6.cc, 9780-1.cc, 7.cc, 8.cc, wrapped_env.cc, wrapped_locale.cc, 17038.cc: Likewise. * testsuite/22_locale/money_get/get/wchar_t/1.cc, 2.cc, 3.cc, 4.cc, wrapped_env.cc, 10.cc, 11528.cc, wrapped_locale.cc, 11.cc, 12.cc, 13.cc, 15.cc, 16.cc, 17.cc, 18.cc: Likewise. * testsuite/22_locale/money_get/get/char/1.cc, 2.cc, 3.cc, 4.cc, wrapped_env.cc, 10.cc, 11528.cc, wrapped_locale.cc, 11.cc, 12.cc, 13.cc, 15.cc, 16.cc, 17.cc, 18.cc: Likewise * testsuite/22_locale/num_put/put/wchar_t/1.cc, 3.cc, 5.cc, wrapped_env.cc, 20914.cc, wrapped_locale.cc, 20909.cc: Likewise. * testsuite/22_locale/num_put/put/char/1.cc, 3.cc, 5.cc, 9780-2.cc, wrapped_env.cc, 20914.cc, wrapped_locale.cc, 20909.cc: Likewise. * testsuite/22_locale/codecvt/unshift/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/unshift/char/wrapped_locale.cc, wrapped_env.cc: Likewise. testsuite/22_locale/codecvt/length/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, 7.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/length/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/always_noconv/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/always_noconv/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/encoding/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/encoding/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/in/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, 7.cc, 8.cc, 9.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/in/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/max_length/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/max_length/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/out/wchar_t/2.cc, wrapped_locale.cc, 3.cc, 4.cc, 7.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/codecvt/out/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/moneypunct_byname/named_equivalence.cc: Likewise. * testsuite/22_locale/time_get/get_year/wchar_t/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_year/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_monthname/wchar_t/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_monthname/char/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/date_order/wchar_t/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/date_order/char/wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_weekday/wchar_t/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_weekday/char/2.cc, 38081-1.cc, wrapped_locale.cc, 38081-2.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_date/wchar_t/12750.cc, 26701.cc, 2.cc, wrapped_locale.cc, 4.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_date/char/12750.cc, 26701.cc, 2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_time/wchar_t/1.cc, 2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/time_get/get_time/char/1.cc, 2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/num_get/get/wchar_t/1.cc, 3.cc, 5.cc, 6.cc, 9.cc, wrapped_env.cc, wrapped_locale.cc: Likewise. * testsuite/22_locale/num_get/get/char/1.cc, 3.cc, 5.cc, 6.cc, 9.cc, wrapped_env.cc, wrapped_locale.cc: Likewise. * testsuite/22_locale/locale/cons/38368.cc, 2.cc, 4.cc, 5.cc, 7.cc, 12658_thread-1.cc, 12658_thread-2.cc, 40184.cc, 29217.cc, 38365.cc: Likewise. * testsuite/22_locale/locale/global_locale_objects/14071.cc, 2.cc: Likewise. * testsuite/22_locale/moneypunct/40712.cc: Likewise. * testsuite/22_locale/moneypunct/members/wchar_t/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/moneypunct/members/char/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/messages_byname/named_equivalence.cc: Likewise. * testsuite/22_locale/numpunct_byname/named_equivalence.cc: Likewise. * testsuite/22_locale/messages/members/char/1.cc, 2.cc, wrapped_locale.cc, 3.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/numpunct/members/wchar_t/2.cc, wrapped_locale.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/numpunct/members/char/2.cc, wrapped_locale.cc, 3.cc, wrapped_env.cc: Likewise. * testsuite/22_locale/collate_byname/named_equivalence.cc: Likewise. From-SVN: r164300
205 lines
6.9 KiB
C++
205 lines
6.9 KiB
C++
// { dg-require-namedlocale "en_PH" }
|
|
// { dg-require-namedlocale "de_DE" }
|
|
// { dg-require-namedlocale "it_IT" }
|
|
|
|
// 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
|
|
|
|
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
|
|
// Free Software Foundation
|
|
//
|
|
// 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/>.
|
|
|
|
// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
|
|
|
|
#include <cwchar> // for mbstate_t
|
|
#include <cstring>
|
|
#include <cstdlib>
|
|
#include <locale>
|
|
#include <stdexcept>
|
|
#include <testsuite_hooks.h>
|
|
|
|
// More tests for locale("") == POSIX locale::name.
|
|
void test04()
|
|
{
|
|
bool test __attribute__((unused)) = true;
|
|
using namespace std;
|
|
|
|
#ifdef _GLIBCXX_HAVE_SETENV
|
|
|
|
const char* LANG_orig = getenv("LANG") ? strdup(getenv("LANG")) : "";
|
|
const char* LC_ALL_orig = getenv("LC_ALL") ? strdup(getenv("LC_ALL")) : "";
|
|
const char* LC_CTYPE_orig =
|
|
getenv("LC_CTYPE") ? strdup(getenv("LC_CTYPE")) : "";
|
|
const char* LC_NUMERIC_orig =
|
|
getenv("LC_NUMERIC") ? strdup(getenv("LC_NUMERIC")) : "";
|
|
const char* LC_TIME_orig =
|
|
getenv("LC_TIME") ? strdup(getenv("LC_TIME")) : "";
|
|
const char* LC_COLLATE_orig =
|
|
getenv("LC_COLLATE") ? strdup(getenv("LC_COLLATE")) : "";
|
|
const char* LC_MONETARY_orig =
|
|
getenv("LC_MONETARY") ? strdup(getenv("LC_MONETARY")) : "";
|
|
const char* LC_MESSAGES_orig =
|
|
getenv("LC_MESSAGES") ? strdup(getenv("LC_MESSAGES")) : "";
|
|
#if _GLIBCXX_NUM_CATEGORIES
|
|
const char* LC_PAPER_orig =
|
|
getenv("LC_PAPER") ? strdup(getenv("LC_PAPER")) : "";
|
|
const char* LC_NAME_orig =
|
|
getenv("LC_NAME") ? strdup(getenv("LC_NAME")) : "";
|
|
const char* LC_ADDRESS_orig =
|
|
getenv("LC_ADDRESS") ? strdup(getenv("LC_ADDRESS")) : "";
|
|
const char* LC_TELEPHONE_orig =
|
|
getenv("LC_TELEPHONE") ? strdup(getenv("LC_TELEPHONE")) : "";
|
|
const char* LC_MEASUREMENT_orig =
|
|
getenv("LC_MEASUREMENT") ? strdup(getenv("LC_MEASUREMENT")) : "";
|
|
const char* LC_IDENTIFICATION_orig =
|
|
getenv("LC_IDENTIFICATION") ? strdup(getenv("LC_IDENTIFICATION")) : "";
|
|
#endif
|
|
|
|
// Check that a "POSIX" LC_ALL is equivalent to "C".
|
|
if (!setenv("LC_ALL", "POSIX", 1))
|
|
{
|
|
locale loc = locale("");
|
|
VERIFY( loc.name() == "C" );
|
|
}
|
|
setenv("LC_ALL", "", 1);
|
|
|
|
// Check that a "en_PH" LC_ALL is equivalent to "en_PH".
|
|
if (!setenv("LC_ALL", "en_PH", 1))
|
|
{
|
|
locale loc = locale("");
|
|
VERIFY( loc.name() == "en_PH" );
|
|
}
|
|
setenv("LC_ALL", "", 1);
|
|
|
|
// Explicit check that LC_ALL sets regardless of LC_* and LANG.
|
|
if (!setenv("LANG", "es_MX", 1) && !setenv("LC_COLLATE", "de_DE", 1))
|
|
{
|
|
if (!setenv("LC_ALL", "en_PH", 1))
|
|
{
|
|
locale loc = locale("");
|
|
VERIFY( loc.name() == "en_PH" );
|
|
}
|
|
setenv("LC_ALL", "", 1);
|
|
setenv("LANG", LANG_orig ? LANG_orig : "", 1);
|
|
setenv("LC_COLLATE", LC_COLLATE_orig ? LC_COLLATE_orig : "", 1);
|
|
}
|
|
|
|
// NB: LANG checks all LC_* macro settings. As such, all LC_* macros
|
|
// must be cleared for these tests, and then restored.
|
|
setenv("LC_ALL", "", 1);
|
|
setenv("LC_CTYPE", "", 1);
|
|
setenv("LC_NUMERIC", "", 1);
|
|
setenv("LC_TIME", "", 1);
|
|
setenv("LC_COLLATE", "", 1);
|
|
setenv("LC_MONETARY", "", 1);
|
|
setenv("LC_MESSAGES", "", 1);
|
|
#if _GLIBCXX_NUM_CATEGORIES
|
|
setenv("LC_PAPER", "", 1);
|
|
setenv("LC_NAME", "", 1);
|
|
setenv("LC_ADDRESS", "", 1);
|
|
setenv("LC_TELEPHONE", "", 1);
|
|
setenv("LC_MEASUREMENT", "", 1);
|
|
setenv("LC_IDENTIFICATION", "", 1);
|
|
#endif
|
|
|
|
// Check the default set by LANG.
|
|
if (!setenv("LANG", "fr_FR", 1))
|
|
{
|
|
locale loc = locale("");
|
|
VERIFY( loc.name() == "fr_FR" );
|
|
}
|
|
|
|
// Check that a "POSIX" LANG is equivalent to "C".
|
|
if (!setenv("LANG", "POSIX", 1))
|
|
{
|
|
locale loc("");
|
|
VERIFY( loc.name() == "C" );
|
|
}
|
|
|
|
// Setting a category in the "C" default.
|
|
if (!setenv("LC_COLLATE", "de_DE", 1))
|
|
{
|
|
locale loc = locale("");
|
|
|
|
#if _GLIBCXX_NUM_CATEGORIES
|
|
VERIFY( loc.name() == "LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;"
|
|
"LC_COLLATE=de_DE;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;"
|
|
"LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;"
|
|
"LC_IDENTIFICATION=C" );
|
|
#else
|
|
VERIFY( loc.name() == "LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;"
|
|
"LC_COLLATE=de_DE;LC_MONETARY=C;LC_MESSAGES=C" );
|
|
#endif
|
|
}
|
|
|
|
// Changing the LANG default while LC_COLLATE is set.
|
|
if (!setenv("LANG", "fr_FR", 1))
|
|
{
|
|
locale loc = locale("");
|
|
#if _GLIBCXX_NUM_CATEGORIES
|
|
VERIFY( loc.name() == "LC_CTYPE=fr_FR;LC_NUMERIC=fr_FR;"
|
|
"LC_TIME=fr_FR;LC_COLLATE=de_DE;LC_MONETARY=fr_FR;"
|
|
"LC_MESSAGES=fr_FR;LC_PAPER=fr_FR;LC_NAME=fr_FR;"
|
|
"LC_ADDRESS=fr_FR;LC_TELEPHONE=fr_FR;LC_MEASUREMENT=fr_FR;"
|
|
"LC_IDENTIFICATION=fr_FR" );
|
|
#else
|
|
VERIFY( loc.name() == "LC_CTYPE=fr_FR;LC_NUMERIC=fr_FR;"
|
|
"LC_TIME=fr_FR;LC_COLLATE=de_DE;LC_MONETARY=fr_FR;"
|
|
"LC_MESSAGES=fr_FR" );
|
|
#endif
|
|
}
|
|
|
|
// Changing another (C only) category.
|
|
#if _GLIBCXX_NUM_CATEGORIES
|
|
if (!setenv("LC_IDENTIFICATION", "it_IT", 1))
|
|
{
|
|
locale loc = locale("");
|
|
VERIFY( loc.name() == "LC_CTYPE=fr_FR;LC_NUMERIC=fr_FR;"
|
|
"LC_TIME=fr_FR;LC_COLLATE=de_DE;LC_MONETARY=fr_FR;"
|
|
"LC_MESSAGES=fr_FR;LC_PAPER=fr_FR;LC_NAME=fr_FR;"
|
|
"LC_ADDRESS=fr_FR;LC_TELEPHONE=fr_FR;LC_MEASUREMENT=fr_FR;"
|
|
"LC_IDENTIFICATION=it_IT" );
|
|
}
|
|
#endif
|
|
|
|
// Restore the environment.
|
|
setenv("LANG", LANG_orig ? LANG_orig : "", 1);
|
|
setenv("LC_ALL", LC_ALL_orig ? LC_ALL_orig : "", 1);
|
|
setenv("LC_CTYPE", LC_CTYPE_orig ? LC_CTYPE_orig : "", 1);
|
|
setenv("LC_NUMERIC", LC_NUMERIC_orig ? LC_NUMERIC_orig : "", 1);
|
|
setenv("LC_TIME", LC_TIME_orig ? LC_TIME_orig : "", 1);
|
|
setenv("LC_COLLATE", LC_COLLATE_orig ? LC_COLLATE_orig : "", 1);
|
|
setenv("LC_MONETARY", LC_MONETARY_orig ? LC_MONETARY_orig : "", 1);
|
|
setenv("LC_MESSAGES", LC_MESSAGES_orig ? LC_MESSAGES_orig : "", 1);
|
|
#if _GLIBCXX_NUM_CATEGORIES
|
|
setenv("LC_PAPER", LC_PAPER_orig ? LC_PAPER_orig : "", 1);
|
|
setenv("LC_NAME", LC_NAME_orig ? LC_NAME_orig : "", 1);
|
|
setenv("LC_ADDRESS", LC_ADDRESS_orig ? LC_ADDRESS_orig : "", 1);
|
|
setenv("LC_TELEPHONE", LC_TELEPHONE_orig ? LC_TELEPHONE_orig : "", 1);
|
|
setenv("LC_MEASUREMENT", LC_MEASUREMENT_orig ? LC_MEASUREMENT_orig : "", 1);
|
|
setenv("LC_IDENTIFICATION",
|
|
LC_IDENTIFICATION_orig ? LC_IDENTIFICATION_orig : "", 1);
|
|
#endif
|
|
|
|
#endif
|
|
}
|
|
|
|
int main()
|
|
{
|
|
test04();
|
|
return 0;
|
|
}
|