diff options
author | sb <sb@openoffice.org> | 2010-09-22 15:59:47 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-09-22 15:59:47 +0200 |
commit | d4b7acc6f5e5d58103f238339f100dc1daaba43e (patch) | |
tree | 4a3402f111c25811864c4857e533db04a282a9e3 /sal | |
parent | 0166b35fc660911c02d56852fca79f89e7cede5c (diff) | |
parent | e9cece0160a22621761d27e09eb47e6095fe91ff (diff) |
sb123: merged in DEV300_m88
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/math.h | 20 | ||||
-rw-r--r-- | sal/osl/w32/signal.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/source/math.cxx | 292 | ||||
-rw-r--r-- | sal/textenc/convertadobe.tab | 2 |
4 files changed, 169 insertions, 147 deletions
diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h index 872d526b8835..985ce700b049 100644 --- a/sal/inc/rtl/math.h +++ b/sal/inc/rtl/math.h @@ -140,9 +140,8 @@ enum rtl_math_DecimalPlaces /** Conversions analogous to sprintf() using internal rounding. - +/-HUGE_VAL are converted to "1.#INF" and "-1.#INF", NAN values are - converted to "1.#NAN" and "-1.#NAN", of course using cDecSeparator instead - of '.'. + +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are + converted to "NaN". @param pResult Returns the resulting byte string. Must itself not be null, and must point @@ -216,9 +215,8 @@ void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult, /** Conversions analogous to sprintf() using internal rounding. - +/-HUGE_VAL are converted to "1.#INF" and "-1.#INF", NAN values are - converted to "1.#NAN" and "-1.#NAN", of course using cDecSeparator instead - of '.'. + +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are + converted to "NaN". @param pResult Returns the resulting Unicode string. Must itself not be null, and must @@ -296,8 +294,9 @@ void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult, Leading tabs (0x09) and spaces (0x20) are eaten. Overflow returns +/-HUGE_VAL, underflow 0. In both cases pStatus is set to rtl_math_ConversionStatus_OutOfRange, otherwise to - rtl_math_ConversionStatus_Ok. "+/-1.#INF" is recognized as +/-HUGE_VAL, - pStatus is set to rtl_math_ConversionStatus_OutOfRange. "+/-1.#NAN" is + rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are + recognized as +/-HUGE_VAL, pStatus is set to + rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are recognized and the value is set to +/-NAN, pStatus is set to rtl_math_ConversionStatus_Ok. @@ -333,8 +332,9 @@ double SAL_CALL rtl_math_stringToDouble( Leading tabs (U+0009) and spaces (U+0020) are eaten. Overflow returns +/-HUGE_VAL, underflow 0. In both cases pStatus is set to rtl_math_ConversionStatus_OutOfRange, otherwise to - rtl_math_ConversionStatus_Ok. "+/-1.#INF" is recognized as +/-HUGE_VAL, - pStatus is set to rtl_math_ConversionStatus_OutOfRange. "+/-1.#NAN" is + rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are + recognized as +/-HUGE_VAL, pStatus is set to + rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are recognized and the value is set to +/-NAN, pStatus is set to rtl_math_ConversionStatus_Ok. diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx index f893f7520d40..a74baaefc057 100644 --- a/sal/osl/w32/signal.cxx +++ b/sal/osl/w32/signal.cxx @@ -188,7 +188,7 @@ static BOOL ReportCrash( LPEXCEPTION_POINTERS lpEP ) sntprintf( szBuffer, elementsof(szBuffer), _T("%s -p %u -excp 0x%p -t %u%s"), - aPath, + static_cast<sal_Char*>( aPath ), GetCurrentProcessId(), lpEP, GetCurrentThreadId(), diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx index 7d0e3cea0c0d..d983c5726230 100644 --- a/sal/rtl/source/math.cxx +++ b/sal/rtl/source/math.cxx @@ -318,44 +318,37 @@ inline void doubleToString(StringT ** pResult, if ( rtl::math::isNan( fValue ) ) { - sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH("-1.#NAN"); + // #i112652# XMLSchema-2 + sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH("NaN"); if (pResultCapacity == 0) { pResultCapacity = &nCapacity; T::createBuffer(pResult, pResultCapacity); nResultOffset = 0; } - - if ( bSign ) - T::appendAscii(pResult, pResultCapacity, &nResultOffset, - RTL_CONSTASCII_STRINGPARAM("-")); - T::appendAscii(pResult, pResultCapacity, &nResultOffset, - RTL_CONSTASCII_STRINGPARAM("1")); - T::appendChar(pResult, pResultCapacity, &nResultOffset, cDecSeparator); T::appendAscii(pResult, pResultCapacity, &nResultOffset, - RTL_CONSTASCII_STRINGPARAM("#NAN")); + RTL_CONSTASCII_STRINGPARAM("NaN")); + return; } bool bHuge = fValue == HUGE_VAL; // g++ 3.0.1 requires it this way... if ( bHuge || rtl::math::isInf( fValue ) ) { - sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH("-1.#INF"); + // #i112652# XMLSchema-2 + sal_Int32 nCapacity = RTL_CONSTASCII_LENGTH("-INF"); if (pResultCapacity == 0) { pResultCapacity = &nCapacity; T::createBuffer(pResult, pResultCapacity); nResultOffset = 0; } - if ( bSign ) T::appendAscii(pResult, pResultCapacity, &nResultOffset, RTL_CONSTASCII_STRINGPARAM("-")); T::appendAscii(pResult, pResultCapacity, &nResultOffset, - RTL_CONSTASCII_STRINGPARAM("1")); - T::appendChar(pResult, pResultCapacity, &nResultOffset, cDecSeparator); - T::appendAscii(pResult, pResultCapacity, &nResultOffset, - RTL_CONSTASCII_STRINGPARAM("#INF")); + RTL_CONSTASCII_STRINGPARAM("INF")); + return; } @@ -736,158 +729,185 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, ++p0; } CharT const * p = p0; + bool bDone = false; - // leading zeros and group separators may be safely ignored - while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator)) - ++p; - - long nValExp = 0; // carry along exponent of mantissa - - // integer part of mantissa - for (; p != pEnd; ++p) + // #i112652# XMLSchema-2 + if (3 >= (pEnd - p)) { - CharT c = *p; - if (isDigit(c)) + if ((CharT('N') == p[0]) && (CharT('a') == p[1]) + && (CharT('N') == p[2])) { - fVal = fVal * 10.0 + static_cast< double >( c - CharT('0') ); - ++nValExp; + p += 3; + rtl::math::setNan( &fVal ); + bDone = true; + } + else if ((CharT('I') == p[0]) && (CharT('N') == p[1]) + && (CharT('F') == p[2])) + { + p += 3; + fVal = HUGE_VAL; + eStatus = rtl_math_ConversionStatus_OutOfRange; + bDone = true; } - else if (c != cGroupSeparator) - break; } - // fraction part of mantissa - if (p != pEnd && *p == cDecSeparator) + if (!bDone) // do not recognize e.g. NaN1.23 { - ++p; - double fFrac = 0.0; - long nFracExp = 0; - while (p != pEnd && *p == CharT('0')) - { - --nFracExp; + // leading zeros and group separators may be safely ignored + while (p != pEnd && (*p == CharT('0') || *p == cGroupSeparator)) ++p; - } - if ( nValExp == 0 ) - nValExp = nFracExp - 1; // no integer part => fraction exponent - // one decimal digit needs ld(10) ~= 3.32 bits - static const int nSigs = (DBL_MANT_DIG / 3) + 1; - int nDigs = 0; + + long nValExp = 0; // carry along exponent of mantissa + + // integer part of mantissa for (; p != pEnd; ++p) { CharT c = *p; - if (!isDigit(c)) - break; - if ( nDigs < nSigs ) - { // further digits (more than nSigs) don't have any significance - fFrac = fFrac * 10.0 + static_cast< double >( c - CharT('0') ); - --nFracExp; - ++nDigs; + if (isDigit(c)) + { + fVal = fVal * 10.0 + static_cast< double >( c - CharT('0') ); + ++nValExp; } + else if (c != cGroupSeparator) + break; } - if ( fFrac != 0.0 ) - fVal += rtl::math::pow10Exp( fFrac, nFracExp ); - else if ( nValExp < 0 ) - nValExp = 0; // no digit other than 0 after decimal point - } - - if ( nValExp > 0 ) - --nValExp; // started with offset +1 at the first mantissa digit - // Exponent - if (p != p0 && p != pEnd && (*p == CharT('E') || *p == CharT('e'))) - { - ++p; - bool bExpSign; - if (p != pEnd && *p == CharT('-')) + // fraction part of mantissa + if (p != pEnd && *p == cDecSeparator) { - bExpSign = true; ++p; - } - else - { - bExpSign = false; - if (p != pEnd && *p == CharT('+')) - ++p; - } - if ( fVal == 0.0 ) - { // no matter what follows, zero stays zero, but carry on the offset - while (p != pEnd && isDigit(*p)) + double fFrac = 0.0; + long nFracExp = 0; + while (p != pEnd && *p == CharT('0')) + { + --nFracExp; ++p; - } - else - { - bool bOverFlow = false; - long nExp = 0; + } + if ( nValExp == 0 ) + nValExp = nFracExp - 1; // no integer part => fraction exponent + // one decimal digit needs ld(10) ~= 3.32 bits + static const int nSigs = (DBL_MANT_DIG / 3) + 1; + int nDigs = 0; for (; p != pEnd; ++p) { CharT c = *p; if (!isDigit(c)) break; - int i = c - CharT('0'); - if ( long10Overflow( nExp, i ) ) - bOverFlow = true; - else - nExp = nExp * 10 + i; - } - if ( nExp ) - { - if ( bExpSign ) - nExp = -nExp; - long nAllExp = ( bOverFlow ? 0 : nExp + nValExp ); - if ( nAllExp > DBL_MAX_10_EXP || (bOverFlow && !bExpSign) ) - { // overflow - fVal = HUGE_VAL; - eStatus = rtl_math_ConversionStatus_OutOfRange; - } - else if ( nAllExp < DBL_MIN_10_EXP || (bOverFlow && bExpSign) ) - { // underflow - fVal = 0.0; - eStatus = rtl_math_ConversionStatus_OutOfRange; - } - else if ( nExp > DBL_MAX_10_EXP || nExp < DBL_MIN_10_EXP ) - { // compensate exponents - fVal = rtl::math::pow10Exp( fVal, -nValExp ); - fVal = rtl::math::pow10Exp( fVal, nAllExp ); + if ( nDigs < nSigs ) + { // further digits (more than nSigs) don't have any + // significance + fFrac = fFrac * 10.0 + static_cast<double>(c - CharT('0')); + --nFracExp; + ++nDigs; } - else - fVal = rtl::math::pow10Exp( fVal, nExp ); // normal } + if ( fFrac != 0.0 ) + fVal += rtl::math::pow10Exp( fFrac, nFracExp ); + else if ( nValExp < 0 ) + nValExp = 0; // no digit other than 0 after decimal point } - } - else if (p - p0 == 2 && p != pEnd && p[0] == CharT('#') - && p[-1] == cDecSeparator && p[-2] == CharT('1')) - { - if (pEnd - p >= 4 && p[1] == CharT('I') && p[2] == CharT('N') - && p[3] == CharT('F')) + + if ( nValExp > 0 ) + --nValExp; // started with offset +1 at the first mantissa digit + + // Exponent + if (p != p0 && p != pEnd && (*p == CharT('E') || *p == CharT('e'))) { - // "1.#INF", "+1.#INF", "-1.#INF" - p += 4; - fVal = HUGE_VAL; - eStatus = rtl_math_ConversionStatus_OutOfRange; - // Eat any further digits: - while (p != pEnd && isDigit(*p)) + ++p; + bool bExpSign; + if (p != pEnd && *p == CharT('-')) + { + bExpSign = true; ++p; + } + else + { + bExpSign = false; + if (p != pEnd && *p == CharT('+')) + ++p; + } + if ( fVal == 0.0 ) + { // no matter what follows, zero stays zero, but carry on the + // offset + while (p != pEnd && isDigit(*p)) + ++p; + } + else + { + bool bOverFlow = false; + long nExp = 0; + for (; p != pEnd; ++p) + { + CharT c = *p; + if (!isDigit(c)) + break; + int i = c - CharT('0'); + if ( long10Overflow( nExp, i ) ) + bOverFlow = true; + else + nExp = nExp * 10 + i; + } + if ( nExp ) + { + if ( bExpSign ) + nExp = -nExp; + long nAllExp = ( bOverFlow ? 0 : nExp + nValExp ); + if ( nAllExp > DBL_MAX_10_EXP || (bOverFlow && !bExpSign) ) + { // overflow + fVal = HUGE_VAL; + eStatus = rtl_math_ConversionStatus_OutOfRange; + } + else if ((nAllExp < DBL_MIN_10_EXP) || + (bOverFlow && bExpSign) ) + { // underflow + fVal = 0.0; + eStatus = rtl_math_ConversionStatus_OutOfRange; + } + else if ( nExp > DBL_MAX_10_EXP || nExp < DBL_MIN_10_EXP ) + { // compensate exponents + fVal = rtl::math::pow10Exp( fVal, -nValExp ); + fVal = rtl::math::pow10Exp( fVal, nAllExp ); + } + else + fVal = rtl::math::pow10Exp( fVal, nExp ); // normal + } + } } - else if (pEnd - p >= 4 && p[1] == CharT('N') && p[2] == CharT('A') - && p[3] == CharT('N')) + else if (p - p0 == 2 && p != pEnd && p[0] == CharT('#') + && p[-1] == cDecSeparator && p[-2] == CharT('1')) { - // "1.#NAN", "+1.#NAN", "-1.#NAN" - p += 4; - rtl::math::setNan( &fVal ); - if (bSign) + if (pEnd - p >= 4 && p[1] == CharT('I') && p[2] == CharT('N') + && p[3] == CharT('F')) { - union { - double sd; - sal_math_Double md; - } m; - m.sd = fVal; - m.md.w32_parts.msw |= 0x80000000; // create negative NaN - fVal = m.sd; - bSign = false; // don't negate again + // "1.#INF", "+1.#INF", "-1.#INF" + p += 4; + fVal = HUGE_VAL; + eStatus = rtl_math_ConversionStatus_OutOfRange; + // Eat any further digits: + while (p != pEnd && isDigit(*p)) + ++p; + } + else if (pEnd - p >= 4 && p[1] == CharT('N') && p[2] == CharT('A') + && p[3] == CharT('N')) + { + // "1.#NAN", "+1.#NAN", "-1.#NAN" + p += 4; + rtl::math::setNan( &fVal ); + if (bSign) + { + union { + double sd; + sal_math_Double md; + } m; + m.sd = fVal; + m.md.w32_parts.msw |= 0x80000000; // create negative NaN + fVal = m.sd; + bSign = false; // don't negate again + } + // Eat any further digits: + while (p != pEnd && isDigit(*p)) + ++p; } - // Eat any further digits: - while (p != pEnd && isDigit(*p)) - ++p; } } diff --git a/sal/textenc/convertadobe.tab b/sal/textenc/convertadobe.tab index b657256d7bfe..31ec3305933b 100644 --- a/sal/textenc/convertadobe.tab +++ b/sal/textenc/convertadobe.tab @@ -185,6 +185,7 @@ rtl::textenc::BmpUnicodeToSingleByteRange const unicodeToAdobeSymbolEncoding[] { 0x23D0, 0x23D0 - 0x23D0, 0xBE }, { 0x25CA, 0x25CA - 0x25CA, 0xE0 }, { 0x2660, 0x2660 - 0x2660, 0xAA }, { 0x2663, 0x2663 - 0x2663, 0xA7 }, { 0x2665, 0x2665 - 0x2665, 0xA9 }, { 0x2666, 0x2666 - 0x2666, 0xA8 }, + { 0xF000, 0xF0FF - 0xF000, 0x00 }, // symbol aliasing U+F0XX->S+00XX { 0xF6D9, 0xF6D9 - 0xF6D9, 0xD3 }, { 0xF6DA, 0xF6DA - 0xF6DA, 0xD2 }, { 0xF6DB, 0xF6DB - 0xF6DB, 0xD4 }, { 0xF8E5, 0xF8E5 - 0xF8E5, 0x60 }, { 0xF8E8, 0xF8EA - 0xF8E8, 0xE2 } }; @@ -251,6 +252,7 @@ rtl::textenc::BmpUnicodeToSingleByteRange const unicodeToAdobeDingbatsEncoding[] { 0x2756, 0x2756 - 0x2756, 0x76 }, { 0x2758, 0x275E - 0x2758, 0x78 }, { 0x2761, 0x2767 - 0x2761, 0xA1 }, { 0x2776, 0x2794 - 0x2776, 0xB6 }, { 0x2798, 0x27AF - 0x2798, 0xD8 }, { 0x27B1, 0x27BE - 0x27B1, 0xF1 }, + { 0xF000, 0xF0FF - 0xF000, 0x00 }, // symbol aliasing U+F0XX->S+00XX { 0xF8D7, 0xF8E4 - 0xF8D7, 0x80 }}; rtl::textenc::BmpUnicodeToSingleByteConverterData const |