sal/rtl/strtmpl.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
New commits: commit 30be686ddee70c5aa661abfc8eb2cb6f6fdc4752 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Mar 26 23:22:26 2013 +0100 Could the failing MSVC tinderbox be due to implementation-defined / ...for negative integers in < C++11? Rather unlikely, but lets see... Change-Id: I9abfcbf2c0e409fab4c77b62e5f734d3c2cc2719 diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 6859af1..455a6ae 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -941,8 +941,28 @@ namespace { bNeg = sal_False; } - const T nDiv = bNeg ? -(std::numeric_limits<T>::min()/nRadix) : (std::numeric_limits<T>::max()/nRadix); - const sal_Int16 nMod = bNeg ? -(std::numeric_limits<T>::min()%nRadix) : (std::numeric_limits<T>::max()%nRadix); + T nDiv; + sal_Int16 nMod; + if ( bNeg ) + { + nDiv = std::numeric_limits<T>::min() / nRadix; + nMod = std::numeric_limits<T>::min() % nRadix; + // Cater for C++03 implementations that round the quotient down + // instead of truncating towards zero as mandated by C++11: + if ( nMod > 0 ) + { + --nDiv; + nMod -= nRadix; + } + nDiv = -nDiv; + nMod = -nMod; + } + else + { + nDiv = std::numeric_limits<T>::max() / nRadix; + nMod = std::numeric_limits<T>::max() % nRadix; + } + while ( *pStr ) { nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits