stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r638369 - in /stdcxx/trunk/include: loc/_num_get.cc loc/_num_get.h rw/_iosfwd.h
Date Tue, 18 Mar 2008 14:09:17 GMT
Author: faridz
Date: Tue Mar 18 07:09:17 2008
New Revision: 638369

URL: http://svn.apache.org/viewvc?rev=638369&view=rev
Log:
2008-03-18  Farid Zaripov  <farid_zaripov@epam.com>

	* include/loc/_num_get.cc (num_get::get): Code checking for overflow moved from here...
	* include/loc/num_get.h (_rw_check_overflow_{short|int}): ... to here.
	* include/rw/_iosfwd.h: Added new define _RWSTD_FMTFLAGS (used in _rw_check_overflow_{short|int}).

Modified:
    stdcxx/trunk/include/loc/_num_get.cc
    stdcxx/trunk/include/loc/_num_get.h
    stdcxx/trunk/include/rw/_iosfwd.h

Modified: stdcxx/trunk/include/loc/_num_get.cc
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/loc/_num_get.cc?rev=638369&r1=638368&r2=638369&view=diff
==============================================================================
--- stdcxx/trunk/include/loc/_num_get.cc (original)
+++ stdcxx/trunk/include/loc/_num_get.cc Tue Mar 18 07:09:17 2008
@@ -76,34 +76,7 @@
     long __tmp = __val;
 
     __begin = do_get (__begin, __end, __flags, __err, __tmp);
-
-    long __shrt_min;
-    long __shrt_max;
-
-    if (   __tmp < 0
-        || (__flags.flags () & _RWSTD_IOS_BASEFIELD) == _RWSTD_IOS_DEC) {
-        // decimal parsing overflows outside the range below
-        __shrt_max = long (_RWSTD_SHRT_MAX);
-        __shrt_min = long (_RWSTD_SHRT_MIN);
-    }
-    else {
-        // other than decimal parsing overflows outside the range below
-        // (unreliable if basefield is 0 and the sequence is decimal)
-        __shrt_max = long (_RWSTD_USHRT_MAX);
-        __shrt_min = long (_RWSTD_USHRT_MIN);
-    }
-
-    // lwg issue 23: check for overflow
-    if (__tmp < __shrt_min) {
-        __err |= _RW::__rw_failbit;
-        __val  = short (_RWSTD_SHRT_MIN);
-    }
-    else if (__tmp > __shrt_max) {
-        __err |= _RW::__rw_failbit;
-        __val  = short (_RWSTD_SHRT_MAX);
-    }
-    else
-        __val = _RWSTD_STATIC_CAST (short, __tmp);
+    __val = __rw_check_overflow_short (__tmp, __flags.flags (), __err);
 
     return __begin;
 }
@@ -122,39 +95,7 @@
     long __tmp = long (__val);
 
     __begin = do_get (__begin, __end, __flags, __err, __tmp);
-
-#if _RWSTD_INT_MAX < _RWSTD_LONG_MAX
-
-    long __int_min;
-    long __int_max;
-
-    if (   __tmp < 0
-        || (__flags.flags () & _RWSTD_IOS_BASEFIELD) == _RWSTD_IOS_DEC) {
-        // decimal parsing overflows outside the range below
-        __int_max = long (_RWSTD_INT_MAX);
-        __int_min = long (_RWSTD_INT_MIN);
-    }
-    else {
-        // other than decimal parsing overflows outside the range below
-        // (unreliable if basefield is 0 and the sequence is decimal)
-        __int_max = long (_RWSTD_UINT_MAX);
-        __int_min = long (_RWSTD_UINT_MIN);
-    }
-
-    // lwg issue 23: check for overflow
-    if (__tmp < __int_min) {
-        __err |= _RW::__rw_failbit;
-        __val  = _RWSTD_INT_MIN;
-    }
-    else if (__tmp > __int_max) {
-        __err |= _RW::__rw_failbit;
-        __val  = _RWSTD_INT_MAX;
-    }
-    else
-
-#endif   // _RWSTD_INT_MAX < _RWSTD_LONG_MAX
-
-        __val = _RWSTD_STATIC_CAST (int, __tmp);
+    __val = __rw_check_overflow_int (__tmp, __flags.flags (), __err);
 
     return __begin;
 }

Modified: stdcxx/trunk/include/loc/_num_get.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/loc/_num_get.h?rev=638369&r1=638368&r2=638369&view=diff
==============================================================================
--- stdcxx/trunk/include/loc/_num_get.h (original)
+++ stdcxx/trunk/include/loc/_num_get.h Tue Mar 18 07:09:17 2008
@@ -259,6 +259,87 @@
 }   // namespace std
 
 
+_RWSTD_NAMESPACE (__rw) { 
+
+inline short
+__rw_check_overflow_short (long __lval, _RWSTD_FMTFLAGS __flags,
+                           _RWSTD_IOSTATE &__err)
+{
+#if _RWSTD_SHRT_MAX < _RWSTD_LONG_MAX
+
+    long __shrt_min;
+    long __shrt_max;
+
+    if (   __lval < 0
+        || (__flags & _RW::__rw_basefield) == _RW::__rw_dec) {
+        // decimal parsing overflows outside the range below
+        __shrt_max = long (_RWSTD_SHRT_MAX);
+        __shrt_min = long (_RWSTD_SHRT_MIN);
+    }
+    else {
+        // other than decimal parsing overflows outside the range below
+        // (unreliable if basefield is 0 and the sequence is decimal)
+        __shrt_max = long (_RWSTD_USHRT_MAX);
+        __shrt_min = long (_RWSTD_USHRT_MIN);
+    }
+
+    // lwg issue 23: check for overflow
+    if (__lval < __shrt_min) {
+        __err |= _RW::__rw_failbit;
+        return short (_RWSTD_SHRT_MIN);
+    }
+    else if (__lval > __shrt_max) {
+        __err |= _RW::__rw_failbit;
+        return short (_RWSTD_SHRT_MAX);
+    }
+    else
+
+#endif   // _RWSTD_SHRT_MAX < _RWSTD_LONG_MAX
+
+        return _RWSTD_STATIC_CAST (short, __lval);
+}
+
+inline int
+__rw_check_overflow_int (long __lval, _RWSTD_FMTFLAGS __flags,
+                         _RWSTD_IOSTATE &__err)
+{
+#if _RWSTD_INT_MAX < _RWSTD_LONG_MAX
+
+    long __int_min;
+    long __int_max;
+
+    if (   __lval < 0
+        || (__flags & _RW::__rw_basefield) == _RW::__rw_dec) {
+        // decimal parsing overflows outside the range below
+        __int_max = long (_RWSTD_INT_MAX);
+        __int_min = long (_RWSTD_INT_MIN);
+    }
+    else {
+        // other than decimal parsing overflows outside the range below
+        // (unreliable if basefield is 0 and the sequence is decimal)
+        __int_max = long (_RWSTD_UINT_MAX);
+        __int_min = long (_RWSTD_UINT_MIN);
+    }
+
+    // lwg issue 23: check for overflow
+    if (__lval < __int_min) {
+        __err |= _RW::__rw_failbit;
+        return int (_RWSTD_INT_MIN);
+    }
+    else if (__lval > __int_max) {
+        __err |= _RW::__rw_failbit;
+        return = int (_RWSTD_INT_MAX);
+    }
+    else
+
+#endif   // _RWSTD_INT_MAX < _RWSTD_LONG_MAX
+
+        return _RWSTD_STATIC_CAST (int, __lval);
+}
+
+}   // namespace __rw
+
+
 #if _RWSTD_DEFINE_TEMPLATE_FIRST (_NUM_GET)
 #  include <loc/_num_get.cc>
 #endif   // _RWSTD_DEFINE_TEMPLATE_FIRST (_NUM_GET)

Modified: stdcxx/trunk/include/rw/_iosfwd.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_iosfwd.h?rev=638369&r1=638368&r2=638369&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_iosfwd.h (original)
+++ stdcxx/trunk/include/rw/_iosfwd.h Tue Mar 18 07:09:17 2008
@@ -88,7 +88,8 @@
 
 
 // used in money_get and num_get facets
-#define _RWSTD_IOSTATE _RWSTD_BITMASK_ENUM (_RW::__rw_iostate)
+#define _RWSTD_IOSTATE  _RWSTD_BITMASK_ENUM (_RW::__rw_iostate)
+#define _RWSTD_FMTFLAGS _RWSTD_BITMASK_ENUM (_RW::__rw_fmtflags)
 
 
 _RWSTD_NAMESPACE (__rw) {



Mime
View raw message