basic/inc/basrid.hxx | 6 --- basic/source/comp/scanner.cxx | 79 ++++++++++++++++++++++++------------------ basic/source/inc/scanner.hxx | 1 3 files changed, 47 insertions(+), 39 deletions(-)
New commits: commit d3a52bd7b3fe11fc6cf5f3296dd00eba524e40a0 Author: August Sodora <aug...@gmail.com> Date: Sat Jan 7 18:32:47 2012 -0500 scanner cleanup for consistency diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 7eb6fb0..25a493a 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -162,18 +162,18 @@ void SbiScanner::scanAlphanumeric() void SbiScanner::scanGoto() { - sal_Int32 nTestCol = nCol; - while(nTestCol < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[nTestCol])) - nTestCol++; + sal_Int32 n = nCol; + while(n < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[n])) + ++n; - if(nTestCol + 1 < aLine.getLength()) + if(n + 1 < aLine.getLength()) { - ::rtl::OUString aTestSym = aLine.copy(nTestCol, 2); - if(aTestSym.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("to"))) + ::rtl::OUString aTemp = aLine.copy(n, 2); + if(aTemp.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("to"))) { aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("goto")); - pLine += nTestCol + 2 - nCol; - nCol = nTestCol + 2; + pLine += n + 2 - nCol; + nCol = n + 2; } } } commit 1e04280bce397f6c4c6715ab882fa9fd8f372c09 Author: August Sodora <aug...@gmail.com> Date: Sat Jan 7 18:23:45 2012 -0500 Refactor readLine in scanner diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 1c49f98..7eb6fb0 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -178,6 +178,40 @@ void SbiScanner::scanGoto() } } +bool SbiScanner::readLine() +{ + if(nBufPos >= aBuf.getLength()) + return false; + + sal_Int32 n = nBufPos; + sal_Int32 nLen = aBuf.getLength(); + + while(n < nLen && aBuf[n] != '\r' && aBuf[n] != '\n') + ++n; + + // Trim trailing whitespace + sal_Int32 nEnd = n; + while(nBufPos < nEnd && theBasicCharClass::get().isWhitespace(aBuf[nEnd - 1])) + --nEnd; + + aLine = aBuf.copy(nBufPos, nEnd - nBufPos); + + // Fast-forward past the line ending + if(n + 1 < nLen && aBuf[n] == '\r' && aBuf[n + 1] == '\n') + n += 2; + else if(n < nLen) + n++; + + nBufPos = n; + pLine = aLine.getStr(); + + ++nLine; + nCol = nCol1 = nCol2 = 0; + nColLock = 0; + + return true; +} + bool SbiScanner::NextSym() { // memorize for the EOLN-case @@ -195,33 +229,12 @@ bool SbiScanner::NextSym() // read in line? if( !pLine ) { - sal_Int32 n = nBufPos; - sal_Int32 nLen = aBuf.getLength(); - if( nBufPos >= nLen ) + if(!readLine()) return false; - const sal_Unicode* p2 = aBuf.getStr(); - p2 += n; - while( ( n < nLen ) && ( *p2 != '\n' ) && ( *p2 != '\r' ) ) - p2++, n++; - // #163944# ignore trailing whitespace - sal_Int32 nCopyEndPos = n; - while( (nBufPos < nCopyEndPos) && theBasicCharClass::get().isWhitespace( aBuf[ nCopyEndPos - 1 ] ) ) - --nCopyEndPos; - aLine = aBuf.copy( nBufPos, nCopyEndPos - nBufPos ); - if( n < nLen ) - { - if( *p2 == '\r' && *( p2+1 ) == '\n' ) - n += 2; - else - n++; - } - nBufPos = n; - pLine = aLine.getStr(); - nOldLine = ++nLine; - nCol = nCol1 = nCol2 = nOldCol1 = nOldCol2 = 0; - nColLock = 0; - } + nOldLine = nLine; + nOldCol1 = nOldCol2 = 0; + } while( theBasicCharClass::get().isWhitespace( *pLine ) ) pLine++, nCol++, bSpaces = true; diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx index 96b0658..69c3d87 100644 --- a/basic/source/inc/scanner.hxx +++ b/basic/source/inc/scanner.hxx @@ -48,6 +48,7 @@ class SbiScanner void scanAlphanumeric(); void scanGoto(); + bool readLine(); protected: ::rtl::OUString aSym; String aError; commit db1faf486837c44a69406a53ea67f66a6fe56d34 Author: August Sodora <aug...@gmail.com> Date: Sat Jan 7 17:50:21 2012 -0500 Remove unused class SttResId diff --git a/basic/inc/basrid.hxx b/basic/inc/basrid.hxx index f79778c..ecb55fc 100644 --- a/basic/inc/basrid.hxx +++ b/basic/inc/basrid.hxx @@ -31,12 +31,6 @@ #include <tools/resid.hxx> -class SttResId : public ResId -{ - public: - SttResId( sal_uInt32 nId ); -}; - class BasResId : public ResId { public: _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits