locale_facets.h (__num_base::_S_scale_hex): Add.

2001-12-09  Benjamin Kosnik  <bkoz@redhat.com>
	    Philip Martin <pmartin@uklinux.net>

	* include/bits/locale_facets.h (__num_base::_S_scale_hex): Add.
	(__num_base::_S_scale_oct): Add.
	* src/locale.cc: Add definitions.
	* testsuite/27_io/istream_extractor_arith.cc (main): Call test13.

	* testsuite/testsuite_hooks.h: Remove duplicate VERIFY define.

Co-Authored-By: Philip Martin <pmartin@uklinux.net>

From-SVN: r47837
This commit is contained in:
Benjamin Kosnik 2001-12-10 08:41:03 +00:00 committed by Benjamin Kosnik
parent d4197a152d
commit 2a74463013
6 changed files with 29 additions and 7 deletions

View File

@ -1,3 +1,13 @@
2001-12-09 Benjamin Kosnik <bkoz@redhat.com>
Philip Martin <pmartin@uklinux.net>
* include/bits/locale_facets.h (__num_base::_S_scale_hex): Add.
(__num_base::_S_scale_oct): Add.
* src/locale.cc: Add definitions.
* testsuite/27_io/istream_extractor_arith.cc (main): Call test13.
* testsuite/testsuite_hooks.h: Remove duplicate VERIFY define.
2001-12-07 Nathan Myers <ncm@cantrip.org>
Loren Rittle <ljrittle@acm.org>

View File

@ -439,6 +439,12 @@ namespace std
// Construct and return valid scanf format for integer types.
static void
_S_format_int(const ios_base& __io, char* __fptr, char __mod, char __modl);
// Used to establish gating factor for base 16 input.
static const double _S_scale_hex;
// Used to establish gating factor for base 8 input.
static const double _S_scale_oct;
};
template<typename _CharT>

View File

@ -35,7 +35,7 @@
#include <bits/std_cerrno.h>
#include <bits/std_clocale.h> // For localeconv
#include <bits/std_cstdlib.h> // For strof, strtold
#include <bits/std_cmath.h> // For ceil
#include <bits/std_cmath.h> // For ceil
#include <bits/std_limits.h> // For numeric_limits
#include <bits/std_memory.h> // For auto_ptr
#include <bits/streambuf_iterator.h> // For streambuf_iterators
@ -299,11 +299,13 @@ namespace std
// Figure out the maximum number of digits that can be extracted
// for the given type, using the determined base.
int __max_digits;
if (__base != 10)
__max_digits = static_cast<int>(ceil(__max * log(10.0)
/log(static_cast<double>(__base))));
else
if (__base == 10)
__max_digits = __max;
else if (__base == 16)
__max_digits = static_cast<int>(ceil(__max * _S_scale_hex));
else if (__base == 8)
__max_digits = static_cast<int>(ceil(__max * _S_scale_oct));
// Add in what's already been extracted.
__max_digits += __pos;

View File

@ -76,6 +76,10 @@ namespace std
const char __num_base::_S_atoms[] = "0123456789eEabcdfABCDF";
const double __num_base::_S_scale_hex = log(10.0)/log(16.0);
const double __num_base::_S_scale_oct = log(10.0)/log(8.0);
// Definitions for static const data members of locale::_Impl
const locale::id* const
locale::_Impl::_S_id_ctype[] =

View File

@ -579,7 +579,7 @@ void test13()
digits += '1';
istringstream iss2(digits);
iss2 >> i;
VERIFY( iss2.good() );
VERIFY( !iss2.fail() );
digits += '1';
i = 0;
@ -604,6 +604,7 @@ int main()
test11();
test12();
test13();
return 0;
}

View File

@ -49,7 +49,6 @@
# define VERIFY(fn) assert(fn)
#else
# define VERIFY(fn) test &= (fn)
# define VERIFY(fn) fn
#endif
#include <bits/c++config.h>