summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-10-21 18:08:49 +0200
committerJan Holesovsky <kendy@suse.cz>2011-10-21 18:08:49 +0200
commit548fc5db7c39f62d99b1c0a9e4348972ff72545e (patch)
tree2b300f3d8a123027a881c111df5d898e26a8d8d2 /basic
parent48e2a853b9106033094d2fd917dbf14ada5abdc0 (diff)
A small cleanup after the String -> OUString conversion.
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/scanner.cxx32
1 files changed, 12 insertions, 20 deletions
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 0211b75292b2..91f4a04e6e52 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -267,15 +267,13 @@ sal_Bool SbiScanner::NextSym()
// (wrong line continuation otherwise)
if( !bUsedForHilite && !*pLine && *(pLine-1) == '_' )
{
- *((sal_Unicode*)(pLine-1)) = ' '; // cast because of const
+ // We are going to modify a potentially shared string, so force
+ // a copy, so that aSym is not modified by the following operation
+ ::rtl::OUString aSymCopy( aSym.getStr(), aSym.getLength() );
+ aSym = aSymCopy;
- ::rtl::OUStringBuffer aLineBuf(aLine);
- aLineBuf[nCol - 1] = ' '; // just to keep pLine and aLine in sync
- aLine = aLineBuf.makeStringAndClear();
-
- ::rtl::OUStringBuffer aSymBuf(aSym);
- aSymBuf[aSymBuf.getLength() - 1] = '_'; // to match behavior from back when GetBufferAccess was used
- aSym = aSymBuf.makeStringAndClear();
+ // HACK: modifying a potentially shared string here!
+ *((sal_Unicode*)(pLine-1)) = ' ';
}
// type recognition?
// don't test the exclamation mark
@@ -457,20 +455,14 @@ sal_Bool SbiScanner::NextSym()
else
aSym = aLine.copy( n, nCol - n - 1 );
// get out duplicate string delimiters
- String s( cSep );
- s += cSep;
- sal_Int32 nIdx = 0;
- do
+ ::rtl::OUStringBuffer aSymBuf;
+ for ( sal_Int32 i = 0, len = aSym.getLength(); i < len; ++i )
{
- nIdx = aSym.indexOf( s, nIdx );
- if( nIdx < 0 )
- break;
- ::rtl::OUStringBuffer aSymBuf( aSym );
- aSymBuf.remove( nIdx, 1 );
- aSym = aSymBuf.makeStringAndClear();
- nIdx++;
+ aSymBuf.append( aSym[i] );
+ if ( aSym[i] == cSep && ( i+1 < len ) && aSym[i+1] == cSep )
+ ++i;
}
- while( true );
+ aSym = aSymBuf.makeStringAndClear();
if( cSep != ']' )
eScanType = ( cSep == '#' ) ? SbxDATE : SbxSTRING;
}