Author: faridz
Date: Tue Mar 18 07:13:51 2008
New Revision: 638379
URL: http://svn.apache.org/viewvc?rev=638379&view=rev
Log:
2008-03-18 Farid Zaripov <[EMAIL PROTECTED]>
Merged r638369 and r638370 from trunk
2008-03-18 Farid Zaripov <[EMAIL PROTECTED]>
* 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}).
2008-03-18 Farid Zaripov <[EMAIL PROTECTED]>
* src/podarray.h (_C_length): New method to calculate the length of the
pod array.
(__rw_pod_array): Use _C_length() instead of char_traits<>::length().
(acquire): Ditto.
(append): Ditto.
(assign): Ditto.
Modified:
stdcxx/branches/4.2.x/include/loc/_num_get.cc
stdcxx/branches/4.2.x/include/loc/_num_get.h
stdcxx/branches/4.2.x/include/rw/_iosfwd.h
stdcxx/branches/4.2.x/src/podarray.h
Modified: stdcxx/branches/4.2.x/include/loc/_num_get.cc
URL:
http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/loc/_num_get.cc?rev=638379&r1=638378&r2=638379&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/loc/_num_get.cc (original)
+++ stdcxx/branches/4.2.x/include/loc/_num_get.cc Tue Mar 18 07:13:51 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/branches/4.2.x/include/loc/_num_get.h
URL:
http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/loc/_num_get.h?rev=638379&r1=638378&r2=638379&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/loc/_num_get.h (original)
+++ stdcxx/branches/4.2.x/include/loc/_num_get.h Tue Mar 18 07:13:51 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/branches/4.2.x/include/rw/_iosfwd.h
URL:
http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/rw/_iosfwd.h?rev=638379&r1=638378&r2=638379&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/rw/_iosfwd.h (original)
+++ stdcxx/branches/4.2.x/include/rw/_iosfwd.h Tue Mar 18 07:13:51 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) {
Modified: stdcxx/branches/4.2.x/src/podarray.h
URL:
http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/podarray.h?rev=638379&r1=638378&r2=638379&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/src/podarray.h (original)
+++ stdcxx/branches/4.2.x/src/podarray.h Tue Mar 18 07:13:51 2008
@@ -90,7 +90,7 @@
}
_EXPLICIT __rw_pod_array (const _TypeT *__a)
- : _C_len (_STD::char_traits<_TypeT>::length (__a))
+ : _C_len (_C_length (__a))
// , _C_pbuf (_C_len < _Size ? _C_buffer : new _TypeT [_C_len + 1])
{
// initialze _C_pbuf here in order to prevent HP aCC 3.70
@@ -147,7 +147,7 @@
}
_TypeT* acquire (_TypeT *__a) {
- return acquire (__a, _STD::char_traits<_TypeT>::length (__a));
+ return acquire (__a, _C_length (__a));
}
_TypeT* release () {
@@ -168,7 +168,7 @@
__rw_pod_array& append (const _TypeT *__a) {
_RWSTD_ASSERT (__a);
- return append (__a, _STD::char_traits<_TypeT>::length (__a));
+ return append (__a, _C_length (__a));
}
__rw_pod_array& operator+= (const _TypeT *__a) {
@@ -183,7 +183,7 @@
__rw_pod_array& assign (const _TypeT *__a) {
_RWSTD_ASSERT (__a);
- return assign (__a, _STD::char_traits<_TypeT>::length (__a));
+ return assign (__a, _C_length (__a));
}
__rw_pod_array& operator= (const _TypeT *__a) {
@@ -193,6 +193,12 @@
__rw_pod_array& operator= (const __rw_pod_array &__rhs) {
return assign (__rhs._C_pbuf, __rhs._C_len);
+ }
+
+private:
+
+ static _RWSTD_SIZE_T _C_length (const _TypeT *__a) {
+ return _STD::char_traits<_TypeT>::length (__a);
}
};