summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorAugust Sodora <augsod@gmail.com>2012-01-09 00:33:45 -0500
committerAugust Sodora <augsod@gmail.com>2012-01-09 00:54:30 -0500
commit28f16e4c2580e07ce05244d2b0672e5ef9e57ace (patch)
treeb394b2e47ec58f712021c7a27849811a4531eff1 /basic
parented5b6ace8974e37f51f915d731d3b71dffdc8b49 (diff)
Only set bSpaces once here
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/scanner.cxx39
1 files changed, 26 insertions, 13 deletions
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 0c359c5c7d3a..23599d4f95fe 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -234,8 +234,12 @@ bool SbiScanner::NextSym()
nOldCol1 = nOldCol2 = 0;
}
- while(nCol < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[nCol]))
- ++pLine, ++nCol, bSpaces = true;
+ if(nCol < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[nCol]))
+ {
+ bSpaces = true;
+ while(nCol < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[nCol]))
+ ++pLine, ++nCol;
+ }
nCol1 = nCol;
@@ -257,20 +261,24 @@ bool SbiScanner::NextSym()
if(nCol < aLine.getLength() && (theBasicCharClass::get().isAlpha(aLine[nCol], bCompatible) || aLine[nCol] == '_'))
{
// if there's nothing behind '_' , it's the end of a line!
- if( *pLine == '_' && !*(pLine+1) )
- { ++pLine;
- goto eoln; }
+ if(nCol + 1 == aLine.getLength() && aLine[nCol] == '_')
+ {
+ // Note that nCol is not incremented here...
+ ++pLine;
+ goto eoln;
+ }
+
bSymbol = true;
scanAlphanumeric();
// Special handling for "go to"
- if( bCompatible && *pLine && aSym.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("go") ) )
+ if(nCol < aLine.getLength() && bCompatible && aSym.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("go")))
scanGoto();
// replace closing '_' by space when end of line is following
// (wrong line continuation otherwise)
- if( !*pLine && *(pLine-1) == '_' )
+ if(nCol == aLine.getLength() && aLine[nCol - 1] == '_' )
{
// We are going to modify a potentially shared string, so force
// a copy, so that aSym is not modified by the following operation
@@ -280,17 +288,22 @@ bool SbiScanner::NextSym()
// HACK: modifying a potentially shared string here!
*((sal_Unicode*)(pLine-1)) = ' ';
}
+
// type recognition?
// don't test the exclamation mark
// if there's a symbol behind it
- else if( *pLine != '!' || !theBasicCharClass::get().isAlpha( pLine[ 1 ], bCompatible ) )
+ else if((nCol >= aLine.getLength() || aLine[nCol] != '!') ||
+ (nCol + 1 >= aLine.getLength() || !theBasicCharClass::get().isAlpha(aLine[nCol + 1], bCompatible)))
{
- SbxDataType t = GetSuffixType( *pLine );
- if( t != SbxVARIANT )
+ if(nCol < aLine.getLength())
{
- eScanType = t;
- ++pLine;
- ++nCol;
+ SbxDataType t = GetSuffixType( *pLine );
+ if( t != SbxVARIANT )
+ {
+ eScanType = t;
+ ++pLine;
+ ++nCol;
+ }
}
}
}