[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - formula/inc formula/source sc/inc sc/source

Eike Rathke erack at redhat.com
Mon Jul 1 22:31:23 PDT 2013


 formula/inc/formula/FormulaCompiler.hxx     |    4 ++--
 formula/source/core/api/FormulaCompiler.cxx |   14 +++++++-------
 formula/source/core/api/token.cxx           |   11 +++++------
 sc/inc/compiler.hxx                         |    4 +---
 sc/source/core/tool/token.cxx               |    2 +-
 5 files changed, 16 insertions(+), 19 deletions(-)

New commits:
commit a19db54f78720dc8200b3504e84cd19d445f4d18
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 1 23:54:28 2013 +0200

    resolved fdo#35411 redefined MAXCODE 512 to FORMULA_MAXTOKENS 8192
    
    Also renamed MAXJUMPCOUNT to FORMULA_MAXJUMPCOUNT but without changing
    the value as the runtime array size of ocChose depends on it, should be
    changed before.
    
    Eliminated the duplicated and error causing redefinition of both in
    sc/inc/compiler.hxx
    
    Change-Id: I0e87d1439c9564a4f475fcb2870ab51c3b586942
    (cherry picked from commit 9c1ca6dca3b553c302a635357e33591605343b99)
    Reviewed-on: https://gerrit.libreoffice.org/4668
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx
index 85295b2..01bf38d 100644
--- a/formula/inc/formula/FormulaCompiler.hxx
+++ b/formula/inc/formula/FormulaCompiler.hxx
@@ -36,8 +36,8 @@
 #include "formula/ExternalReferenceHelper.hxx"
 
 
-#define MAXJUMPCOUNT 32     /* maximum number of jumps (ocChose) */
-#define MAXCODE      512    /* maximum number of tokens in formula */
+#define FORMULA_MAXJUMPCOUNT    32  /* maximum number of jumps (ocChose) */
+#define FORMULA_MAXTOKENS     8192  /* maximum number of tokens in formula */
 
 
 namespace com { namespace sun { namespace star {
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 16b3fd5..5d38e6e 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1194,7 +1194,7 @@ void FormulaCompiler::Factor()
                     pFacToken->GetJump()[ 0 ] = 3;  // if, else, behind
                     break;
                 case ocChose:
-                    pFacToken->GetJump()[ 0 ] = MAXJUMPCOUNT+1;
+                    pFacToken->GetJump()[ 0 ] = FORMULA_MAXJUMPCOUNT + 1;
                     break;
                 case ocIfError:
                 case ocIfNA:
@@ -1224,7 +1224,7 @@ void FormulaCompiler::Factor()
                     nJumpMax = 3;
                     break;
                 case ocChose:
-                    nJumpMax = MAXJUMPCOUNT;
+                    nJumpMax = FORMULA_MAXJUMPCOUNT;
                     break;
                 case ocIfError:
                 case ocIfNA:
@@ -1235,7 +1235,7 @@ void FormulaCompiler::Factor()
                     SAL_WARN( "formula.core", "FormulaCompiler::Factor: forgot to add a jump max case?");
             }
             short nJumpCount = 0;
-            while ( (nJumpCount < (MAXJUMPCOUNT - 1)) && (eOp == ocSep)
+            while ( (nJumpCount < (FORMULA_MAXJUMPCOUNT - 1)) && (eOp == ocSep)
                     && (!pArr->GetCodeError() || bIgnoreErrors) )
             {
                 if ( ++nJumpCount <= nJumpMax )
@@ -1261,7 +1261,7 @@ void FormulaCompiler::Factor()
                         bLimitOk = (nJumpCount <= 3);
                         break;
                     case ocChose:
-                        bLimitOk = (nJumpCount < MAXJUMPCOUNT); /* TODO: check, really <, not <=? */
+                        bLimitOk = (nJumpCount < FORMULA_MAXJUMPCOUNT); /* TODO: check, really <, not <=? */
                         break;
                     case ocIfError:
                     case ocIfNA:
@@ -1545,7 +1545,7 @@ bool FormulaCompiler::CompileTokenArray()
         pArr->nRefs = 0;    // count from start
         pArr->DelRPN();
         pStack = NULL;
-        FormulaToken* pData[ MAXCODE ];
+        FormulaToken* pData[ FORMULA_MAXTOKENS ];
         pCode = pData;
         bool bWasForced = pArr->IsRecalcModeForced();
         if ( bWasForced )
@@ -1950,9 +1950,9 @@ OpCode FormulaCompiler::NextToken()
 }
 void FormulaCompiler::PutCode( FormulaTokenRef& p )
 {
-    if( pc >= MAXCODE-1 )
+    if( pc >= FORMULA_MAXTOKENS - 1 )
     {
-        if ( pc == MAXCODE-1 )
+        if ( pc == FORMULA_MAXTOKENS - 1 )
         {
             p = new FormulaByteToken( ocStop );
             p->IncRef();
diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index f6110e7c..480ee67 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -29,7 +29,6 @@
 #include "formula/tokenarray.hxx"
 #include "formula/FormulaCompiler.hxx"
 #include <formula/compiler.hrc>
-#define MAXJUMPCOUNT 32     /* maximum number of jumps (ocChose) */
 
 namespace formula
 {
@@ -716,8 +715,8 @@ FormulaToken* FormulaTokenArray::MergeArray( )
 FormulaToken* FormulaTokenArray::Add( FormulaToken* t )
 {
     if( !pCode )
-        pCode = new FormulaToken*[ MAXCODE ];
-    if( nLen < MAXCODE-1 )
+        pCode = new FormulaToken*[ FORMULA_MAXTOKENS ];
+    if( nLen < FORMULA_MAXTOKENS - 1 )
     {
         pCode[ nLen++ ] = t;
         if( t->GetOpCode() == ocPush
@@ -731,7 +730,7 @@ FormulaToken* FormulaTokenArray::Add( FormulaToken* t )
     else
     {
         t->Delete();
-        if ( nLen == MAXCODE-1 )
+        if ( nLen == FORMULA_MAXTOKENS - 1 )
         {
             t = new FormulaByteToken( ocStop );
             pCode[ nLen++ ] = t;
@@ -1183,11 +1182,11 @@ FormulaToken* FormulaTokenArray::AddOpCode( OpCode eOp )
         case ocIfNA:
         case ocChose:
             {
-                short nJump[MAXJUMPCOUNT + 1];
+                short nJump[FORMULA_MAXJUMPCOUNT + 1];
                 if ( eOp == ocIf )
                     nJump[ 0 ] = 3;
                 else if ( eOp == ocChose )
-                    nJump[ 0 ] = MAXJUMPCOUNT + 1;
+                    nJump[ 0 ] = FORMULA_MAXJUMPCOUNT + 1;
                 else
                     nJump[ 0 ] = 2;
                 pRet = new FormulaJumpToken( eOp, (short*)nJump );
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 10af901..9fe9820 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -42,9 +42,7 @@
 
 // constants and data types also for external modules (ScInterpreter et al)
 
-#define MAXCODE      512    /* maximum number of tokens in formula */
 #define MAXSTRLEN    1024   /* maximum length of input string of one symbol */
-#define MAXJUMPCOUNT 32     /* maximum number of jumps (ocChose) */
 
 // flag values of CharTable
 #define SC_COMPILER_C_ILLEGAL         0x00000000
@@ -146,7 +144,7 @@ public:
         ScMatrix*    pMat;
         sal_uInt16   nError;
         sal_Unicode  cStr[ MAXSTRLEN+1 ];   // string (up to 255 characters + 0)
-        short        nJump[MAXJUMPCOUNT+1]; // If/Chose token
+        short        nJump[ FORMULA_MAXJUMPCOUNT + 1 ];     // If/Chose token
     };
 
                 //! other members not initialized
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 8e8c329..697420d 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -136,7 +136,7 @@ void ScRawToken::SetOpCode( OpCode e )
             break;
         case ocChose:
             eType = svJump;
-            nJump[ 0 ] = MAXJUMPCOUNT+1;
+            nJump[ 0 ] = FORMULA_MAXJUMPCOUNT + 1;
             break;
         case ocMissing:
             eType = svMissing;


More information about the Libreoffice-commits mailing list