Commit ce3039af by Jerry Quinn Committed by Benjamin Kosnik

locale_facets.h (__num_base): Add _S_atoms_out.


2003-02-11 Jerry Quinn  <jlquinn@optonline.net>
           Benjamin Kosnik  <benjamin@redhat.com>

	* include/bits/locale_facets.h (__num_base): Add _S_atoms_out.
	Add indexes into this array.
	(__num_base::_S_atoms): To _S_atoms_in.
	(num_put::_M_insert): Rename to _M_pad.
	(num_put::_M_convert_int): Adjust remove __mod, __modl arguments.
	(num_put::_M_widen_int): Rename to _M_group_int.
	(num_put::_M_widen_float): Rename to _M_group_float.
	* include/bits/locale_facets.tcc (__int_to_char): New inline
	function and adapter functions.
	(num_put::_M_group_int): Streamline.
	(num_put::_M_group_float): Streamline.
	(num_put::_M_convert_int): Remove unused parameter names. Choose
	large enough buffer for text.  Use __int_to_char instead of
	__convert_from_v.  Formatted text is now at the end of the buffer.
	(num_put::_M_convert_float): Preliminary fixups.
	* src/locale-inst.cc (__convert_from_v<long long>): Add ifdef.
	(__int_to_char<unsigned long long>): Same.
	(__int_to_char<char, unsigned long>): New.
	(__int_to_char<char, unsigned long long>): New.
	(__int_to_char<wchar_t, unsigned long>): New.
	(__int_to_char<wchar_t, unsigned long long>): New.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>

From-SVN: r62731
parent a3259be8
2003-02-11 Jerry Quinn <jlquinn@optonline.net>
Benjamin Kosnik <benjamin@redhat.com>
* include/bits/locale_facets.h (__num_base): Add _S_atoms_out.
Add indexes into this array.
(__num_base::_S_atoms): To _S_atoms_in.
(num_put::_M_insert): Rename to _M_pad.
(num_put::_M_convert_int): Adjust remove __mod, __modl arguments.
(num_put::_M_widen_int): Rename to _M_group_int.
(num_put::_M_widen_float): Rename to _M_group_float.
* include/bits/locale_facets.tcc (__int_to_char): New inline
function and adapter functions.
(num_put::_M_group_int): Streamline.
(num_put::_M_group_float): Streamline.
(num_put::_M_convert_int): Remove unused parameter names. Choose
large enough buffer for text. Use __int_to_char instead of
__convert_from_v. Formatted text is now at the end of the buffer.
(num_put::_M_convert_float): Preliminary fixups.
* src/locale-inst.cc (__convert_from_v<long long>): Add ifdef.
(__int_to_char<unsigned long long>): Same.
(__int_to_char<char, unsigned long>): New.
(__int_to_char<char, unsigned long long>): New.
(__int_to_char<wchar_t, unsigned long>): New.
(__int_to_char<wchar_t, unsigned long long>): New.
2003-02-11 Scott Snyder <snyder@fnal.gov> 2003-02-11 Scott Snyder <snyder@fnal.gov>
PR libstdc++/9659 PR libstdc++/9659
......
...@@ -527,14 +527,37 @@ namespace std ...@@ -527,14 +527,37 @@ namespace std
// 22.2.1.5 Template class codecvt // 22.2.1.5 Template class codecvt
#include <bits/codecvt.h> #include <bits/codecvt.h>
// 22.2.2 The numeric category. // 22.2.2 The numeric category.
class __num_base class __num_base
{ {
public:
// NB: Code depends on the order of _M_atoms_out elements.
// Below are the indices into _M_atoms_out.
enum
{
_S_minus,
_S_plus,
_S_x,
_S_X,
_S_digits,
_S_digits_end = _S_digits + 16,
_S_udigits = _S_digits_end,
_S_udigits_end = _S_udigits + 16,
_S_e = _S_digits + 14, // For scientific notation, 'e'
_S_E = _S_udigits + 14 // For scientific notation, 'E'
};
// A list of valid numeric literals for output.
// This array contains the chars after having been passed through
// the current locale's ctype<_CharT>.widen().
// For the standard "C" locale, this is
// "-+xX0123456789abcdef0123456789ABCDEF".
static const char* _S_atoms_out;
protected: protected:
// String literal of acceptable (narrow) input, for num_get. // String literal of acceptable (narrow) input, for num_get.
// "0123456789eEabcdfABCDF" // "0123456789eEabcdfABCDF"
static const char _S_atoms[]; static const char* _S_atoms_in;
enum enum
{ {
...@@ -827,7 +850,6 @@ namespace std ...@@ -827,7 +850,6 @@ namespace std
// Types: // Types:
typedef _CharT char_type; typedef _CharT char_type;
typedef _OutIter iter_type; typedef _OutIter iter_type;
static locale::id id; static locale::id id;
explicit explicit
...@@ -877,22 +899,24 @@ namespace std ...@@ -877,22 +899,24 @@ namespace std
_M_convert_float(iter_type, ios_base& __io, char_type __fill, _M_convert_float(iter_type, ios_base& __io, char_type __fill,
char __mod, _ValueT __v) const; char __mod, _ValueT __v) const;
void
_M_group_float(const string& __grouping, char_type __sep,
const char_type* __p, char_type* __new, char_type* __cs,
int& __len) const;
template<typename _ValueT> template<typename _ValueT>
iter_type iter_type
_M_convert_int(iter_type, ios_base& __io, char_type __fill, _M_convert_int(iter_type, ios_base& __io, char_type __fill,
char __mod, char __modl, _ValueT __v) const; _ValueT __v) const;
iter_type
_M_widen_float(iter_type, ios_base& __io, char_type __fill, char* __cs,
int __len) const;
iter_type void
_M_widen_int(iter_type, ios_base& __io, char_type __fill, char* __cs, _M_group_int(const string& __grouping, char_type __sep,
int __len) const; ios_base& __io, char_type* __new, char_type* __cs,
int& __len) const;
iter_type void
_M_insert(iter_type, ios_base& __io, char_type __fill, _M_pad(char_type __fill, streamsize __w, ios_base& __io,
const char_type* __ws, int __len) const; char_type* __new, const char_type* __cs, int& __len) const;
virtual virtual
~num_put() { }; ~num_put() { };
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. // Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -64,26 +64,26 @@ namespace std ...@@ -64,26 +64,26 @@ namespace std
template template
ostreambuf_iterator<char> ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >:: num_put<char, ostreambuf_iterator<char> >::
_M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
long) const; long) const;
template template
ostreambuf_iterator<char> ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >:: num_put<char, ostreambuf_iterator<char> >::
_M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
unsigned long) const; unsigned long) const;
#ifdef _GLIBCPP_USE_LONG_LONG #ifdef _GLIBCPP_USE_LONG_LONG
template template
ostreambuf_iterator<char> ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >:: num_put<char, ostreambuf_iterator<char> >::
_M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
long long) const; long long) const;
template template
ostreambuf_iterator<char> ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >:: num_put<char, ostreambuf_iterator<char> >::
_M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, _M_convert_int(ostreambuf_iterator<char>, ios_base&, char,
unsigned long long) const; unsigned long long) const;
#endif #endif
...@@ -97,8 +97,8 @@ namespace std ...@@ -97,8 +97,8 @@ namespace std
ostreambuf_iterator<char> ostreambuf_iterator<char>
num_put<char, ostreambuf_iterator<char> >:: num_put<char, ostreambuf_iterator<char> >::
_M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char, _M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char,
long double) const; long double) const;
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
template class numpunct<wchar_t>; template class numpunct<wchar_t>;
template class numpunct_byname<wchar_t>; template class numpunct_byname<wchar_t>;
...@@ -108,27 +108,27 @@ namespace std ...@@ -108,27 +108,27 @@ namespace std
template template
ostreambuf_iterator<wchar_t> ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
_M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
char, long) const; long) const;
template template
ostreambuf_iterator<wchar_t> ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
_M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
char, unsigned long) const; unsigned long) const;
#ifdef _GLIBCPP_USE_LONG_LONG #ifdef _GLIBCPP_USE_LONG_LONG
template template
ostreambuf_iterator<wchar_t> ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
_M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
char, long long) const; long long) const;
template template
ostreambuf_iterator<wchar_t> ostreambuf_iterator<wchar_t>
num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: num_put<wchar_t, ostreambuf_iterator<wchar_t> >::
_M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t,
char, unsigned long long) const; unsigned long long) const;
#endif #endif
template template
...@@ -451,6 +451,7 @@ namespace std ...@@ -451,6 +451,7 @@ namespace std
__convert_from_v(char*, const int, const char*, unsigned long, __convert_from_v(char*, const int, const char*, unsigned long,
const __c_locale&, int); const __c_locale&, int);
#ifdef _GLIBCPP_USE_LONG_LONG
template template
int int
__convert_from_v(char*, const int, const char*, long long, __convert_from_v(char*, const int, const char*, long long,
...@@ -460,4 +461,31 @@ namespace std ...@@ -460,4 +461,31 @@ namespace std
int int
__convert_from_v(char*, const int, const char*, unsigned long long, __convert_from_v(char*, const int, const char*, unsigned long long,
const __c_locale&, int); const __c_locale&, int);
#endif
template
int
__int_to_char(char*, const int, unsigned long, const char*,
ios_base::fmtflags, bool);
#ifdef _GLIBCPP_USE_WCHAR_T
template
int
__int_to_char(wchar_t*, const int, unsigned long, const wchar_t*,
ios_base::fmtflags, bool);
#endif
#ifdef _GLIBCPP_USE_LONG_LONG
template
int
__int_to_char(char*, const int, unsigned long long, const char*,
ios_base::fmtflags, bool);
#ifdef _GLIBCPP_USE_WCHAR_T
template
int
__int_to_char(wchar_t*, const int, unsigned long long, const wchar_t*,
ios_base::fmtflags, bool);
#endif
#endif
} // namespace std } // namespace std
...@@ -503,7 +503,8 @@ namespace std ...@@ -503,7 +503,8 @@ namespace std
const money_base::pattern const money_base::pattern
money_base::_S_default_pattern = { {symbol, sign, none, value} }; money_base::_S_default_pattern = { {symbol, sign, none, value} };
const char __num_base::_S_atoms[] = "0123456789eEabcdfABCDF"; const char* __num_base::_S_atoms_in = "0123456789eEabcdfABCDF";
const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
// _GLIBCPP_RESOLVE_LIB_DEFECTS // _GLIBCPP_RESOLVE_LIB_DEFECTS
// According to the resolution of DR 231, about 22.2.2.2.2, p11, // According to the resolution of DR 231, about 22.2.2.2.2, p11,
......
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