basic/source/comp/scanner.cxx | 49 +++++++++++++++++------------------------- helpcontent2 | 2 - include/rtl/character.hxx | 15 ++++++++++++ 3 files changed, 36 insertions(+), 30 deletions(-)
New commits: commit ab50e4f8e5b34b15e4f6a338fb7326035b7d3180 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Feb 9 09:56:40 2015 +0000 Updated core Project: help 1ff0bd652428824fdbd3a1650c8ec0c8ead4af4a diff --git a/helpcontent2 b/helpcontent2 index 8cc178e..1ff0bd6 160000 --- a/helpcontent2 +++ b/helpcontent2 @@ -1 +1 @@ -Subproject commit 8cc178e568781e3f4fe9a79579074532ccc00ec4 +Subproject commit 1ff0bd652428824fdbd3a1650c8ec0c8ead4af4a commit 78f25d565e1b04be257100023ad84c5259cfd9e1 Author: Arnaud Versini <arnaud.vers...@gmail.com> Date: Sun Feb 8 15:55:28 2015 +0100 Basic : Partially rewrite hex and octal constant reading. Change-Id: I42f72e7b1ca897aba71950841f90b501cf3b6dc2 Signed-off-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 41e6171..0afd5f2 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -417,17 +417,14 @@ bool SbiScanner::NextSym() else if(nCol < aLine.getLength() && aLine[nCol] == '&') { ++pLine; ++nCol; - sal_Unicode cmp1[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F', 0 }; - sal_Unicode cmp2[] = { '0', '1', '2', '3', '4', '5', '6', '7', 0 }; - sal_Unicode *cmp = cmp1; sal_Unicode base = 16; - sal_Unicode ndig = 8; - sal_Unicode xch = aLine[nCol] & 0xFF; + sal_Unicode xch = aLine[nCol]; ++pLine; ++nCol; - switch( toupper( xch ) ) + switch( rtl::toAsciiUpperCase( xch ) ) { case 'O': - cmp = cmp2; base = 8; ndig = 11; break; + base = 8; + break; case 'H': break; default : @@ -439,40 +436,34 @@ bool SbiScanner::NextSym() bNumber = true; // Hex literals are signed Integers ( as defined by basic // e.g. -2,147,483,648 through 2,147,483,647 (signed) - sal_uInt32 lu = 0; - bool bBufOverflow = false; - while(nCol < aLine.getLength() && theBasicCharClass::get().isAlphaNumeric(aLine[nCol] & 0xFF, bCompatible)) + sal_uInt64 lu = 0; + bool bOverflow = false; + while(nCol < aLine.getLength() && theBasicCharClass::get().isAlphaNumeric(aLine[nCol], bCompatible)) { - sal_Unicode ch = sal::static_int_cast< sal_Unicode >( - toupper(aLine[nCol] & 0xFF)); + sal_Unicode ch = rtl::toAsciiUpperCase(aLine[nCol]); ++pLine; ++nCol; - // from 4.1.1996: buffer full, go on scanning empty - if( (p-buf) == (BUF_SIZE-1) ) - bBufOverflow = true; - else if( OUString( cmp ).indexOf( ch ) != -1 ) - *p++ = ch; + if( ((base == 16 ) && rtl::isAsciiHexDigit( ch ) ) || + ((base == 8) && rtl::isAsciiOctalDigit( ch ))) + { + int i = ch - '0'; + if( i > 9 ) i -= 7; + lu = ( lu * base ) + i; + if( lu > SAL_MAX_UINT32 ) + { + bOverflow = true; + } + } else { aError = OUString(ch); GenError( SbERR_BAD_CHAR_IN_NUMBER ); } } - *p = 0; - for( p = buf; *p; ++p ) - { - int i = (*p & 0xFF) - '0'; - if( i > 9 ) i -= 7; - lu = ( lu * base ) + i; - if( !ndig-- ) - { - GenError( SbERR_MATH_OVERFLOW ); break; - } - } if(nCol < aLine.getLength() && aLine[nCol] == '&') ++pLine, ++nCol; sal_Int32 ls = static_cast<sal_Int32>(lu); nVal = (double) ls; eScanType = ( ls >= SbxMININT && ls <= SbxMAXINT ) ? SbxINTEGER : SbxLONG; - if( bBufOverflow ) + if( bOverflow ) GenError( SbERR_MATH_OVERFLOW ); } diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx index 87a20c2..b62f6d1 100644 --- a/include/rtl/character.hxx +++ b/include/rtl/character.hxx @@ -148,6 +148,21 @@ inline bool isAsciiHexDigit(sal_uInt32 code) return isAsciiCanonicHexDigit(code) || (code >= 'a' && code <= 'f'); } +/** Check for ASCII octal digit character. + + @param code A Unicode code point. + + @return True if code is an ASCII octal digit character (ASCII '0'--'7'). + + @since LibreOffice 4.5 + */ +inline bool isAsciiOctalDigit(sal_uInt32 code) +{ + assert(code <= 0x10FFFF); + return code >= '0' && code <= '7'; +} + + /** Convert a character, if ASCII, to upper case. @param code A Unicode code point.
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits