mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-17 07:58:56 +08:00
locale.cc (locale::locale(const char* __name)): Consolidate name setting.
2000-09-15 Benjamin Kosnik <bkoz@purist.soma.redhat.com> * src/locale.cc (locale::locale(const char* __name)): Consolidate name setting. Add checks for NULL __name pointers. Remove calls to _S_initialize() as initial locale initialization can either be assumed, or needs to be made consistent throughout locale constructors. (locale::locale(const locale& __other, const char* __name, category __cat): Add checks for NULL name. Add checks for assignment to self. * src/localename.cc (locale::_Impl:: _Impl(const _Impl& __other, const string& __name, category __cat, size_t __refs)): Set correct name, has_name values. * testsuite/22_locale/ctor_copy_dtor.cc (test01): More tests. * docs/22_locale/locale.html: New file, more unfinished docs... From-SVN: r36451
This commit is contained in:
parent
04807c2864
commit
d9fbca261e
@ -1,3 +1,19 @@
|
||||
2000-09-15 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
|
||||
|
||||
* src/locale.cc (locale::locale(const char* __name)): Consolidate
|
||||
name setting. Add checks for NULL __name pointers. Remove calls to
|
||||
_S_initialize() as initial locale initialization can either be
|
||||
assumed, or needs to be made consistent throughout locale
|
||||
constructors.
|
||||
(locale::locale(const locale& __other, const char* __name,
|
||||
category __cat): Add checks for NULL name. Add checks for
|
||||
assignment to self.
|
||||
* src/localename.cc (locale::_Impl:: _Impl(const _Impl& __other,
|
||||
const string& __name, category __cat, size_t __refs)): Set correct
|
||||
name, has_name values.
|
||||
* testsuite/22_locale/ctor_copy_dtor.cc (test01): More tests.
|
||||
* docs/22_locale/locale.html: New file, more unfinished docs...
|
||||
|
||||
2000-09-14 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
|
||||
|
||||
* src/locale.cc (locale::name()): Implement.
|
||||
|
@ -554,20 +554,32 @@ namespace std {
|
||||
|
||||
locale::locale(const char* __name)
|
||||
{
|
||||
_S_initialize();
|
||||
if (strcmp(__name, "C") == 0 || strcmp(__name, "POSIX") == 0)
|
||||
(_M_impl = _S_classic)->_M_add_reference();
|
||||
else
|
||||
if (__name)
|
||||
{
|
||||
if (strcmp(__name, "C") == 0 || strcmp(__name, "POSIX") == 0)
|
||||
(_M_impl = _S_classic)->_M_add_reference();
|
||||
// Might throw:
|
||||
_M_impl = new _Impl(*_S_classic, __name, all, 1);
|
||||
_M_impl->_M_has_name = true;
|
||||
else
|
||||
_M_impl = new _Impl(*_S_classic, __name, all, 1);
|
||||
}
|
||||
else
|
||||
throw runtime_error("attempt to create named locale from NULL name");
|
||||
}
|
||||
|
||||
locale::locale(const locale& __other, const char* __name, category __cat)
|
||||
: _M_impl(new _Impl(*__other._M_impl, __name, _S_normalize_category(__cat), 1))
|
||||
{ }
|
||||
{
|
||||
if (__name)
|
||||
{
|
||||
if (__other.name() == __name)
|
||||
(_M_impl = __other._M_impl)->_M_add_reference();
|
||||
// Might throw:
|
||||
else
|
||||
_M_impl = new _Impl(*__other._M_impl, __name,
|
||||
_S_normalize_category(__cat), 1);
|
||||
}
|
||||
else
|
||||
throw runtime_error("attempt to create locale from NULL named locale");
|
||||
}
|
||||
|
||||
bool
|
||||
locale::operator==(const locale& __rhs) const throw()
|
||||
|
@ -92,7 +92,7 @@ namespace std {
|
||||
: _M_references(__refs - 1)
|
||||
// , _M_facets(other._M_facets)
|
||||
// , _M_category_names(other._M_category_names)
|
||||
, _M_has_name(__other._M_has_name), _M_name(__other._M_name)
|
||||
, _M_has_name(__name != "*"), _M_name(__name)
|
||||
{
|
||||
#if 1
|
||||
typedef vector<facet*, allocator<facet*> > __vec_facet;
|
||||
|
@ -63,7 +63,7 @@ void test01()
|
||||
locale loc07("");
|
||||
VERIFY (loc07 != loc01);
|
||||
VERIFY (loc07 != loc02);
|
||||
VERIFY (loc06.name() == "");
|
||||
VERIFY (loc07.name() == "");
|
||||
try
|
||||
{ locale loc08(static_cast<const char*>(NULL)); }
|
||||
catch(runtime_error& obj)
|
||||
@ -73,6 +73,29 @@ void test01()
|
||||
|
||||
// 4
|
||||
// locale(const locale& other, const char* std_name, category)
|
||||
locale loc09(loc06, "C", locale::ctype);
|
||||
VERIFY (loc09.name() == "fr_FR");
|
||||
VERIFY (loc09 != loc01);
|
||||
VERIFY (loc09 != loc06);
|
||||
// XXX somehow check that the ctype, codecvt facets have "C" locale bits...
|
||||
|
||||
locale loc10(loc02, "C", locale::ctype);
|
||||
VERIFY (loc10.name() == "*");
|
||||
VERIFY (loc10 != loc01); // As not named, even tho facets same...
|
||||
VERIFY (loc10 != loc02);
|
||||
// XXX somehow check that the ctype, codecvt facets have "C" locale bits...
|
||||
|
||||
locale loc11(loc01, "C", locale::ctype);
|
||||
VERIFY (loc11.name() == "C");
|
||||
VERIFY (loc11 == loc01);
|
||||
// XXX somehow check that the ctype, codecvt facets have "C" locale bits...
|
||||
|
||||
try
|
||||
{ locale loc12(loc01, static_cast<const char*>(NULL), locale::ctype); }
|
||||
catch(runtime_error& obj)
|
||||
{ VERIFY (true); }
|
||||
catch(...)
|
||||
{ VERIFY (false); }
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user