Commit 0479a462 by Benjamin Kosnik Committed by Benjamin Kosnik

locale_facets.tcc (_S_build_float_format): Move ...



2000-08-31  Benjamin Kosnik  <bkoz@cygnus.com>

	* bits/locale_facets.tcc (_S_build_float_format): Move ...
	* src/locale.cc: Here.
	* bits/locale_facets.tcc (num_get::_M_extract): Clean up generic
	definition. Move specialization to ...
	* src/locale.cc: Here.
	* bits/locale_facets.tcc: Move _Format_cache specializations to ...
	* src/locale.cc: Here.
	* bits/locale_facets.tcc: Move use_facet<ctype> specializations to ...
	* src/locale.cc: Here.

	* bits/std_locale.h: Note that locale_facets.tcc should be
	included here, for standards conformance. It may increase
	compile times though. For the time being, enable.
	* testsuite/22_locale/facet.cc: New file, some parts commented out
	for the time being.

	* mkcheck.in: Append total time to test summary file.

	* bits/sbuf_iter.h : Formatting tweaks.

	Clean up static const data member definitions.
	* src/locale.cc: Add definitions for all missing locale,
	locale::_Imp, and locale::id static data members.
	(ctype<char>): Add table_size define.
	(money_base): Add _S_default_pattern, uglify.
	* bits/localefwd.h: Add definitions for static members of _Count_ones.
	* bits/locale_facets.h: Tweaks.
	* bits/locale_facets.tcc: Tweaks.
	* bits/string.tcc: Add definition for npos.
	* bits/ios_base.h: Tweaks.
	* bits/ios_base.h (ios_base::Init::_M_ios_base_init): Change to
	_S_ios_base_init.
	* src/ios.cc: And here. Add _S_local_words definition.
	Add definitions for __ios_flags const static data.
	* src/codecvt.cc: Same for __enc_traits.
	* src/locale-inst.cc: Remove money_base data member definition
	here.

From-SVN: r36093
parent b3e45cb1
2000-08-31 Benjamin Kosnik <bkoz@cygnus.com>
* bits/locale_facets.tcc (_S_build_float_format): Move ...
* src/locale.cc: Here.
* bits/locale_facets.tcc (num_get::_M_extract): Clean up generic
definition. Move specialization to ...
* src/locale.cc: Here.
* bits/locale_facets.tcc: Move _Format_cache specializations to ...
* src/locale.cc: Here.
* bits/locale_facets.tcc: Move use_facet<ctype> specializations to ...
* src/locale.cc: Here.
* bits/std_locale.h: Note that locale_facets.tcc should be
included here, for standards conformance. It may increase
compile times though. For the time being, enable.
* testsuite/22_locale/facet.cc: New file, some parts commented out
for the time being.
* mkcheck.in: Append total time to test summary file.
* bits/sbuf_iter.h : Formatting tweaks.
Clean up static const data member definitions.
* src/locale.cc: Add definitions for all missing locale,
locale::_Imp, and locale::id static data members.
(ctype<char>): Add table_size define.
(money_base): Add _S_default_pattern, uglify.
* bits/localefwd.h: Add definitions for static members of _Count_ones.
* bits/locale_facets.h: Tweaks.
* bits/locale_facets.tcc: Tweaks.
* bits/string.tcc: Add definition for npos.
* bits/ios_base.h: Tweaks.
* bits/ios_base.h (ios_base::Init::_M_ios_base_init): Change to
_S_ios_base_init.
* src/ios.cc: And here. Add _S_local_words definition.
Add definitions for __ios_flags const static data.
* src/codecvt.cc: Same for __enc_traits.
* src/locale-inst.cc: Remove money_base data member definition
here.
2000-08-30 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/22_locale/ctype_wchar_t_members.cc (test01): New file.
......
......@@ -294,7 +294,7 @@ namespace std {
Init();
~Init();
private:
static int _M_ios_base_init;
static int _S_ios_base_init;
filebuf* _M_cout;
filebuf* _M_cin;
filebuf* _M_cerr;
......
......@@ -755,6 +755,7 @@ namespace std
get(iter_type __in, iter_type __end, ios_base& __io,
ios_base::iostate& __err, void*& __v) const
{ return do_get(__in, __end, __io, __err, __v); }
static locale::id id;
protected:
......@@ -762,7 +763,8 @@ namespace std
// This consolidates the extraction, storage and
// error-processing parts of the do_get(...) overloaded member
// functions. NB: this is specialized for char.
// functions.
// NB: This is specialized for char.
void
_M_extract(iter_type __beg, iter_type __end, ios_base& __io,
ios_base::iostate& __err, char* __xtrc,
......@@ -1454,7 +1456,7 @@ namespace std
enum part { none, space, symbol, sign, value };
struct pattern { char field[4]; };
static const pattern __default_pattern;
static const pattern _S_default_pattern;
};
template<typename _CharT>
......@@ -1513,16 +1515,11 @@ namespace std
virtual pattern
do_pos_format() const
{
return money_base::__default_pattern;
}
{ return money_base::_S_default_pattern; }
virtual pattern
do_neg_format() const
{
return money_base::__default_pattern;
}
{ return money_base::_S_default_pattern; }
};
template<typename _CharT, bool _Intl>
......
......@@ -45,23 +45,32 @@ namespace std
// _Count_ones: compile-time computation of number of 1-bits in a value N
// This takes only 5 (or 6) instantiations, doing recursive descent
// in parallel -- ncm
template<unsigned _Num, int _Shift = (sizeof(unsigned) * CHAR_BIT)/2,
unsigned _Mask = (~0u >> _Shift) >
template<unsigned int _Num, int _Shift = (sizeof(unsigned) * CHAR_BIT)/2,
unsigned int _Mask = (~0u >> _Shift) >
struct _Count_ones;
template<unsigned _Num, unsigned _Mask>
struct _Count_ones<_Num,0,_Mask>
{ static const unsigned _S_count = _Num; };
template<unsigned int _Num, unsigned int _Mask>
struct _Count_ones<_Num, 0, _Mask>
{ static const unsigned int _S_count = _Num; };
template<unsigned _Num, int _Shift, unsigned _Mask>
template<unsigned int _Num, unsigned int _Mask>
const unsigned int _Count_ones<_Num, 0, _Mask>::_S_count;
template<unsigned int _Num, int _Shift, unsigned int _Mask>
struct _Count_ones
{
static const unsigned _S_halfcount =
static const unsigned int _S_halfcount =
_Count_ones<_Num, _Shift/2, (_Mask^((~_Mask)>>(_Shift/2))) >::_S_count;
static const unsigned _S_count
static const unsigned int _S_count
= (_S_halfcount&_Mask) + ((_S_halfcount>>_Shift)&_Mask);
};
template<unsigned int _Num, int _Shift, unsigned int _Mask>
const unsigned int _Count_ones<_Num, _Shift, _Mask>::_S_count;
template<unsigned int _Num, int _Shift, unsigned int _Mask>
const unsigned int _Count_ones<_Num, _Shift, _Mask>::_S_halfcount;
// 22.1.1 Locale
template<typename _Tp> class allocator;
template<typename _Tp, typename _Alloc> class vector;
......
......@@ -38,7 +38,7 @@ namespace std
template<typename _CharT, typename _Traits>
class ostreambuf_iterator
#if 0 // XXX this is standard:
: public iterator<output_iterator_tag,_CharT,void,void,void>
: public iterator<output_iterator_tag, _CharT, void, void, void>
#else
: public output_iterator
#endif
......
......@@ -36,6 +36,7 @@
#include <bits/localefwd.h>
#include <bits/locale_facets.h>
#include <bits/locale_facets.tcc>
#include <bits/codecvt.h>
#endif
......
......@@ -53,6 +53,17 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>::
_Rep::_S_max_size = (((npos - sizeof(_Rep))/sizeof(_CharT)) - 1) / 4;
template<typename _CharT, typename _Traits, typename _Alloc>
const basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::npos;
// Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
// at static init time (before static ctors are run).
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::_S_empty_rep_storage[
(sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)];
// NB: This is the special case for Input Iterators, used in
// istreambuf_iterators, etc.
// Input Iterators have a cost structure very different from
......@@ -396,13 +407,6 @@ namespace std
return 2 * (__s <= 16 ? 16 : __s) < __r;
}
// Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
// at static init time (before static ctors are run).
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::_S_empty_rep_storage[
(sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)];
template<typename _CharT, typename _Traits, typename _Alloc>
void
basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c)
......
......@@ -31,6 +31,9 @@
namespace std {
// Definitions for static const data members of __enc_traits.
const int __enc_traits::_S_max_size;
// codecvt<char, char, mbstate_t> required specialization
locale::id codecvt<char, char, mbstate_t>::id;
......
// Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-1999 Free Software Foundation, Inc.
// Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
//
// 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
......@@ -37,7 +37,38 @@
namespace std {
// Out-of-line definitions for static const ios_base members.
// Definitions for static const data members of __ios_flags.
const __ios_flags::__int_type __ios_flags::_S_boolalpha;
const __ios_flags::__int_type __ios_flags::_S_dec;
const __ios_flags::__int_type __ios_flags::_S_fixed;
const __ios_flags::__int_type __ios_flags::_S_hex;
const __ios_flags::__int_type __ios_flags::_S_internal;
const __ios_flags::__int_type __ios_flags::_S_left;
const __ios_flags::__int_type __ios_flags::_S_oct;
const __ios_flags::__int_type __ios_flags::_S_right;
const __ios_flags::__int_type __ios_flags::_S_scientific;
const __ios_flags::__int_type __ios_flags::_S_showbase;
const __ios_flags::__int_type __ios_flags::_S_showpoint;
const __ios_flags::__int_type __ios_flags::_S_showpos;
const __ios_flags::__int_type __ios_flags::_S_skipws;
const __ios_flags::__int_type __ios_flags::_S_unitbuf;
const __ios_flags::__int_type __ios_flags::_S_uppercase;
const __ios_flags::__int_type __ios_flags::_S_adjustfield;
const __ios_flags::__int_type __ios_flags::_S_basefield;
const __ios_flags::__int_type __ios_flags::_S_floatfield;
const __ios_flags::__int_type __ios_flags::_S_badbit;
const __ios_flags::__int_type __ios_flags::_S_eofbit;
const __ios_flags::__int_type __ios_flags::_S_failbit;
const __ios_flags::__int_type __ios_flags::_S_app;
const __ios_flags::__int_type __ios_flags::_S_ate;
const __ios_flags::__int_type __ios_flags::_S_bin;
const __ios_flags::__int_type __ios_flags::_S_in;
const __ios_flags::__int_type __ios_flags::_S_out;
const __ios_flags::__int_type __ios_flags::_S_trunc;
// Definitions for static const members of ios_base.
const ios_base::fmtflags ios_base::boolalpha;
const ios_base::fmtflags ios_base::dec;
const ios_base::fmtflags ios_base::fixed;
......@@ -73,17 +104,19 @@ namespace std {
const ios_base::seekdir ios_base::cur;
const ios_base::seekdir ios_base::end;
int ios_base::Init::_S_ios_base_init = 0;
const int ios_base::_S_local_words;
ios_base::failure::failure(const string& __str)
{
strncpy(_M_name, __str.c_str(), _M_bufsize);
_M_name[_M_bufsize - 1] = '\0';
}
int ios_base::Init::_M_ios_base_init = 0;
ios_base::Init::Init()
{
if (++_M_ios_base_init == 1)
if (++_S_ios_base_init == 1)
{
// NB: std_iostream.h creates the four standard files with
// default buffers. At this point, we swap out the default
......@@ -124,7 +157,7 @@ namespace std {
ios_base::Init::~Init()
{
if (--_M_ios_base_init == 0)
if (--_S_ios_base_init == 0)
{
cout.flush();
cerr.flush();
......
......@@ -50,10 +50,6 @@ namespace std {
typedef istreambuf_iterator<wchar_t, char_traits<wchar_t> > wibuf_iterator;
// moneypunct, money_get, and money_put
const money_base::pattern
money_base::__default_pattern = {{symbol, sign, none, value}};
template class moneypunct<char, false>;
template class moneypunct<char, true>;
template class moneypunct_byname<char, false>;
......
// 2000-08-31 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2000 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 22.1.1.1.2 - class locale::facet [lib.locale.facet]
#include <locale>
#include <iterator>
#include <debug_assert.h>
// 1 a class if a facet if it is publicly derived from another facet
class gnu_input_iterator: public std::iterator<std::input_iterator_tag, char>
{
value_type it;
public:
gnu_input_iterator(value_type orig): it(orig) { }
value_type
operator*() const { return it; }
reference
operator++(){ return ++it; }
reference
operator++(int){ ++it; return it; }
};
bool
operator==(const gnu_input_iterator& lhs, const gnu_input_iterator& rhs)
{ return true; }
bool
operator!=(const gnu_input_iterator& lhs, const gnu_input_iterator& rhs)
{ return true; }
class gnu_output_iterator: public std::iterator<std::output_iterator_tag, char>
{
value_type it;
public:
gnu_output_iterator(value_type orig): it(orig) { }
value_type
operator*(){ return it; }
gnu_output_iterator&
operator=(value_type obj){ it = obj; return *this; }
reference
operator++(){ return ++it; }
reference
operator++(int){ ++it; return it; }
};
class gnu_collate: public std::collate<char> { };
class gnu_ctype: public std::ctype<char> { };
class gnu_codecvt: public std::codecvt<char, char, mbstate_t> { };
class gnu_moneypunct: public std::moneypunct<char> { };
class gnu_moneypunct_true: public std::moneypunct<char, true> { };
class gnu_money_get: public std::money_get<char> { };
class gnu_money_put: public std::money_put<char> { };
class gnu_numpunct: public std::numpunct<char> { };
class gnu_num_get: public std::num_get<char> { };
class gnu_num_put: public std::num_put<char> { };
class gnu_time_get: public std::time_get<char> { };
class gnu_time_put: public std::time_put<char> { };
class gnu_messages: public std::messages<char> { };
class gnu_collate_byname: public std::collate_byname<char>
{
public:
explicit
gnu_collate_byname(const char* c, size_t refs = 0)
: std::collate_byname<char>(c, refs) { }
};
class gnu_ctype_byname: public std::ctype_byname<char>
{
public:
explicit
gnu_ctype_byname(const char* c, size_t refs = 0)
: std::ctype_byname<char>(c, refs) { }
};
class gnu_moneypunct_byname_true: public std::moneypunct_byname<char, true>
{
public:
explicit
gnu_moneypunct_byname_true(const char* c, size_t refs = 0)
: std::moneypunct_byname<char, true>(c, refs) { }
};
class gnu_moneypunct_byname_false: public std::moneypunct_byname<char, false>
{
public:
explicit
gnu_moneypunct_byname_false(const char* c, size_t refs = 0)
: std::moneypunct_byname<char, false>(c, refs) { }
};
class gnu_money_get_in: public std::money_get<char, gnu_input_iterator>
{
public:
explicit
gnu_money_get_in(size_t refs = 0)
: std::money_get<char, gnu_input_iterator>(refs) { }
};
class gnu_money_put_out: public std::money_put<char, gnu_output_iterator>
{
public:
explicit
gnu_money_put_out(size_t refs = 0)
: std::money_put<char, gnu_output_iterator>(refs) { }
};
class gnu_numpunct_byname: public std::numpunct_byname<char>
{
public:
explicit
gnu_numpunct_byname(const char* c, size_t refs = 0)
: std::numpunct_byname<char>(c, refs) { }
};
class gnu_num_get_in: public std::num_get<char, gnu_input_iterator>
{
public:
explicit
gnu_num_get_in(size_t refs = 0)
: std::num_get<char, gnu_input_iterator>(refs) { }
};
class gnu_num_put_out: public std::num_put<char, gnu_output_iterator>
{
public:
explicit
gnu_num_put_out(size_t refs = 0)
: std::num_put<char, gnu_output_iterator>(refs) { }
};
class gnu_time_get_byname: public std::time_get_byname<char>
{
public:
explicit
gnu_time_get_byname(const char* c, size_t refs = 0)
: std::time_get_byname<char>(c, refs) { }
};
class gnu_time_get_in: public std::time_get<char, gnu_input_iterator>
{
public:
explicit
gnu_time_get_in(size_t refs = 0)
: std::time_get<char, gnu_input_iterator>(refs) { }
};
class gnu_time_put_byname: public std::time_put_byname<char>
{
public:
explicit
gnu_time_put_byname(const char* c, size_t refs = 0)
: std::time_put_byname<char>(c, refs) { }
};
class gnu_time_put_out: public std::time_put<char, gnu_output_iterator>
{
public:
explicit
gnu_time_put_out(size_t refs = 0)
: std::time_put<char, gnu_output_iterator>(refs) { }
};
class gnu_messages_byname: public std::messages_byname<char>
{
public:
explicit
gnu_messages_byname(const char* c, size_t refs = 0)
: std::messages_byname<char>(c, refs) { }
};
// 2 or if it is a class deerived from locale:;facet and containing a
// publicly-accessible declaration as follows:
class gnu_facet: public std::locale::facet
{
public:
static std::locale::id id;
};
std::locale::id gnu_facet::id;
void test01()
{
// 1
gnu_collate obj01;
gnu_ctype obj02;
gnu_codecvt obj03;
gnu_moneypunct obj04;
gnu_moneypunct_true obj05;
gnu_money_get obj06;
gnu_money_put obj07;
gnu_numpunct obj08;
gnu_num_get obj09;
gnu_num_put obj10;
gnu_time_get obj11;
gnu_time_put obj12;
gnu_messages obj13;
gnu_time_put_out obj14(0);
gnu_time_put_byname obj15("gnu_message_byname", 0);
gnu_time_get_in obj16(0);
gnu_time_get_byname obj17("gnu_message_byname", 0);
// gnu_num_put_out obj18(0);
// gnu_num_get_in obj19(0);
gnu_numpunct_byname obj20("gnu_message_byname", 0);
gnu_money_put_out obj21(0);
gnu_money_get_in obj22(0);
gnu_moneypunct_byname_false obj23("gnu_message_byname", 0);
gnu_moneypunct_byname_true obj24("gnu_message_byname", 0);
gnu_ctype_byname obj25("gnu_message_byname", 0);
gnu_collate_byname obj26("gnu_message_byname", 0);
gnu_messages_byname obj27("gnu_message_byname", 0);
// 2
gnu_facet obj28;
}
int main ()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment