diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2016-07-29 09:16:34 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-07-29 18:32:11 +0000 |
commit | e43e2886effea42658f4bc3b69f46cc70c9251e0 (patch) | |
tree | 96102bfe83d9ceab5b9381c51576119542873501 | |
parent | e36c10ed168e886a27de8ec1d69452807fd73924 (diff) |
tdf#97831 follow up : remove unused arguments from stack
Intention:
Make e.g. [1+SWITCH(1;1;1;6)] work. Without this fix, the result is
7 but should be 2.
Reviewed-on: https://gerrit.libreoffice.org/27664
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 3ee2cae3a36e5d052e02c3f7b226dc3b79bd2ebc)
Conflicts:
sc/qa/unit/data/functions/fods/Functions_Excel_2016.fods
Change-Id: I2a72e458e5458c02c3ce2f4214b86ba13f7b1d11
Reviewed-on: https://gerrit.libreoffice.org/27697
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sc/source/core/tool/interpr8.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx index b62fb59cde30..972b125267c0 100644 --- a/sc/source/core/tool/interpr8.cxx +++ b/sc/source/core/tool/interpr8.cxx @@ -1897,7 +1897,15 @@ void ScInterpreter::ScIfs_MS() //push result : FormulaTokenRef xToken( PopToken() ); if ( xToken ) + { + // Remove unused arguments of IFS from the stack before pushing the result. + while ( nParamCount > 1 ) + { + Pop(); + nParamCount--; + } PushTempToken( xToken.get() ); + } else PushError( errUnknownStackVariable ); } @@ -2000,7 +2008,15 @@ void ScInterpreter::ScSwitch_MS() // push result FormulaTokenRef xToken( PopToken() ); if ( xToken ) + { + // Remove unused arguments of SWITCH from the stack before pushing the result. + while ( nParamCount > 1 ) + { + Pop(); + nParamCount--; + } PushTempToken( xToken.get() ); + } else PushError( errUnknownStackVariable ); } |