[Libreoffice-commits] core.git: sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 6 13:01:00 UTC 2018


 sc/source/core/tool/compiler.cxx |   24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

New commits:
commit df1d4bd528027c60bcab2f2e0a87303610fad326
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Aug 4 20:10:55 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Aug 6 15:00:37 2018 +0200

    ScCompiler::IsString, pass down the string length if we know it
    
    instead of making the constructor first perform strlen (normally for the
    second time).
    
    And drop an unnecessary if (.. > MAXSTRLEN) which is impossible to hit,
    since we check that before adding to this array.
    
    Change-Id: I8ef2e027fb4a22e06be81e8b5955350869599d85
    Reviewed-on: https://gerrit.libreoffice.org/58597
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 831f8ec677f1..446f1b08f86f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2703,7 +2703,7 @@ Label_MaskStateMachine:
         --nSrcPos;
     }
     if ( bAutoCorrect )
-        aCorrectedSymbol = cSymbol;
+        aCorrectedSymbol = OUString(cSymbol, pSym - cSymbol);
     if (bAutoIntersection && nSpaces > 1)
         --nSpaces;  // replace '!!' with only one space
     return nSpaces;
@@ -2996,25 +2996,17 @@ bool ScCompiler::IsValue( const OUString& rSym )
 
 bool ScCompiler::IsString()
 {
-    const sal_Unicode* p = cSymbol;
+    if ( cSymbol[0] != '"' )
+        return false;
+    const sal_Unicode* p = cSymbol+1;
     while ( *p )
         p++;
     sal_Int32 nLen = sal::static_int_cast<sal_Int32>( p - cSymbol - 1 );
-    bool bQuote = ((cSymbol[0] == '"') && (cSymbol[nLen] == '"'));
-    if ((bQuote ? nLen-2 : nLen) > MAXSTRLEN)
-    {
-        SetError(FormulaError::StringOverflow);
+    if (cSymbol[nLen] != '"')
         return false;
-    }
-    if ( bQuote )
-    {
-        cSymbol[nLen] = '\0';
-        const sal_Unicode* pStr = cSymbol+1;
-        svl::SharedString aSS = pDoc->GetSharedStringPool().intern(OUString(pStr));
-        maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
-        return true;
-    }
-    return false;
+    svl::SharedString aSS = pDoc->GetSharedStringPool().intern(OUString(cSymbol+1, nLen-1));
+    maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
+    return true;
 }
 
 bool ScCompiler::IsPredetectedErrRefReference( const OUString& rName, const OUString* pErrRef )


More information about the Libreoffice-commits mailing list