diff --git a/Global.cpp b/Global.cpp index 5c00fb8..e4f97c9 100644 --- a/Global.cpp +++ b/Global.cpp @@ -11,4 +11,9 @@ namespace jet { } + void Global::dump() { + for (auto i = variables.begin(); i != variables.end(); i++) + std::cout << i->first << "=[" << i->second << "]" << std::endl; + } + } diff --git a/Global.h b/Global.h index 146a4f9..15b4e20 100644 --- a/Global.h +++ b/Global.h @@ -12,6 +12,8 @@ namespace jet { Global(); virtual ~Global(); + void dump(); + std::map variables; }; diff --git a/Tag.cpp b/Tag.cpp index 239b86f..a21cb6f 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -61,11 +61,12 @@ namespace jet { } Tag::~Tag() { - if(evaluate) { - copyContainer(out, parent); - } else { - copyContainer(container, parent); - } + if(evaluate) + if(output) + copyContainer(out, parent); + else + if(output) + copyContainer(container, parent); } void Tag::parseContainer(coreutils::ZString &in) { diff --git a/Tag.h b/Tag.h index d0d54d6..9be072d 100644 --- a/Tag.h +++ b/Tag.h @@ -18,11 +18,12 @@ namespace jet { protected: bool hasContainer; - std::map variables; + std::map variables; bool variableDefined(coreutils::ZString variable); void parseContainer(coreutils::ZString &in); void copyContainer(coreutils::ZString &in, coreutils::MString &out); + bool output = true; bool evaluate = true; bool filterBlankLines = false; bool trim = false; diff --git a/__set.cpp b/__set.cpp index 48d1090..e6a4d98 100644 --- a/__set.cpp +++ b/__set.cpp @@ -4,21 +4,15 @@ namespace jet { - __set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) { - std::cout << "name: [" << variables["name"] << "]" << std::endl; - std::cout << "value: [" << variables["value"] << "]" << std::endl; - std::cout << "container: [" << container << "]" << std::endl; - std::cout << "scope: [" << variables["scope"] << "]" << std::endl; - + __set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) { + output = false; if(variables["scope"] == "local") variables[variables["name"]] = variables["value"]; - if(variables["scope"] == "global") + if(variables["scope"] == "global") global.variables[variables["name"]] = container; + + global.dump(); - std::cout << "localvar: [" << variables.size() << "]" << std::endl; - std::cout << "localvarx: [" << variables[variables["name"]] << "]" << std::endl; - std::cout << "globalvar: [" << global.variables.size() << "]" << std::endl; - std::cout << "globalvarx: [" << global.variables[variables["name"]] << "]" << std::endl; } } diff --git a/testjet b/testjet index fa2a619..91b0a14 100755 Binary files a/testjet and b/testjet differ