From 2bea3f3d47cd6e7a1140a07a2e1b142ca645ebd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 22 May 2020 17:18:12 +0200 Subject: [PATCH] [apps/code] Fix again VariableBoxController::loadCurrentVariablesInScript --- apps/code/variable_box_controller.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index c140ca06b..5431c5ef5 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -626,18 +626,22 @@ void VariableBoxController::loadCurrentVariablesInScript(const char * scriptCont * This was found from stepping in the code and trying. */ /* TODO: Try to understand what is happening with tokenInText and * remove this trick.*/ - while (*tokenInText == ' ') { - tokenInText++; - } + const char * fixedTokenInText = tokenInText; for (int i = 0; i < 3; i++) { - if (strncmp(tokenInText, name, nameLength) != 0 && tokenInText > scriptContent) { - tokenInText--; + if (strncmp(fixedTokenInText, name, nameLength) != 0 && fixedTokenInText > scriptContent) { + fixedTokenInText--; } else { break; } } - assert(strncmp(tokenInText, name, nameLength) == 0); - addNode(nodeType, origin, tokenInText, nameLength); + if (strncmp(fixedTokenInText, name, nameLength) != 0) { + fixedTokenInText = tokenInText; + while (*fixedTokenInText == ' ') { + fixedTokenInText++; + } + } + assert(strncmp(fixedTokenInText, name, nameLength) == 0); + addNode(nodeType, origin, fixedTokenInText, nameLength); } }