From bd8aa1c089a69e7a1598365b959aa0ed2d4184b5 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Tue, 26 Nov 2024 13:32:15 -0800 Subject: [PATCH] fixed some bugs. Added resolveContainerParent flag to resolve set container issue not reading local variables appropriately. --- Tag.cpp | 5 ++++- Tag.h | 1 + __set.cpp | 1 + jet-2.0.cpp | 1 - tests/testjet.jet | 10 +++++----- tests/testscope.jet | 7 ++----- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Tag.cpp b/Tag.cpp index ec8a17a..316e781 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -202,7 +202,10 @@ namespace jet { } } else if(in.startsWith("$[") || in.startsWith("#[")) { global.errorCursor = in.getCursor(); - out.write(global.getVariable(in, variables)); + if(resolveContainerParent) + out.write(global.getVariable(in, parent->variables)); + else + out.write(global.getVariable(in, variables)); } else { out.write(in.nextChar()); } diff --git a/Tag.h b/Tag.h index cd2ed97..5bb67dc 100644 --- a/Tag.h +++ b/Tag.h @@ -40,6 +40,7 @@ namespace jet { bool filterBlankLines = false; bool trimLines = false; bool cleanWhitespace = false; + bool resolveContainerParent = false; private: bool containerOnly = false; diff --git a/__set.cpp b/__set.cpp index c7e2114..78cbea1 100644 --- a/__set.cpp +++ b/__set.cpp @@ -8,6 +8,7 @@ namespace jet { __set::__set(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) { output = false; + resolveContainerParent = true; if(!variableDefined("name")) throw coreutils::Exception("set tag must have name defined."); if(!variableDefined("expr") && variableDefined("value") && hasContainer) diff --git a/jet-2.0.cpp b/jet-2.0.cpp index 0da4518..8ceffe6 100644 --- a/jet-2.0.cpp +++ b/jet-2.0.cpp @@ -16,7 +16,6 @@ int main(int argc, char **argv, char **envp) { try { coreutils::MString out; - data.reset(); global.errorCursor = data.getCursor(); jet::__jet *jet = new jet::__jet(data, out, global, NULL); delete jet; diff --git a/tests/testjet.jet b/tests/testjet.jet index e8bfaaf..e16fcdd 100755 --- a/tests/testjet.jet +++ b/tests/testjet.jet @@ -3,7 +3,7 @@
This is a comment and should not show up in the output. - --- + ---#[name1] $[modified1;tohex] @@ -23,8 +23,8 @@ - - $[$nested] + + $[nested] 0123456789 lefty=[$[lefty]] @@ -34,8 +34,8 @@ 5*3($[multiplication]) 5/3($[division]) - this is the value store in #[name]. - this is the value store in #[name]. + this is the value store in #[name1]. + this is the value store in #[name1]. another container value include: $[include] diff --git a/tests/testscope.jet b/tests/testscope.jet index c3064c8..3dcf55b 100755 --- a/tests/testscope.jet +++ b/tests/testscope.jet @@ -1,8 +1,5 @@ #!../jet-2.0 - - #[testvar] - - -->#[ix]<-- - + + $[x] $[x]