locale_facets.h (__num_base::_S_scale_hex): Add.
authorBenjamin Kosnik <bkoz@redhat.com>
Mon, 10 Dec 2001 08:41:03 +0000 (08:41 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Mon, 10 Dec 2001 08:41:03 +0000 (08:41 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.h
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/src/locale.cc
libstdc++-v3/testsuite/27_io/istream_extractor_arith.cc
libstdc++-v3/testsuite/testsuite_hooks.h

index 71848d1041aeb44df9032d28a4c020a9b3f21773..e2d7b7e9840d3536294e0696fd20aa2ae8eac6f9 100644 (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>
 
index 27bd5b15ac7ac48723389f79689bf335e65c083e..a992c455093863b227e5fb46078ed61c42d0bd3a 100644 (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>
index 51bc9edb5dc4e1c5a68f53dfedd6bdb7674dad9e..5f22cde02a223210ba9ba2a0d7761c9341779060 100644 (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;
 
index 2a16a3aeed21499a69a0969ae79350062bcf607c..92a8a5c09807d96d170a98c56b55ae9ca6bcdb36 100644 (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[] =
index 9a8537e82f837c225d96b05e9fd92a2a123f0af0..83b93025226b00f84521c19647a9846c98f48ba2 100644 (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;
 }
 
index f8bb87b175e2af3a33b7333e76fac333c46bd44b..b7e96cb2cf05b10d9baaa5ae9d3a6851c4771e75 100644 (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>