diff --git a/Global.cpp b/Global.cpp index 3cc227e..7f51b76 100644 --- a/Global.cpp +++ b/Global.cpp @@ -37,22 +37,22 @@ namespace jet { sessions.erase(sessionId); } - coreutils::ZString Global::getVariable(coreutils::ZString &variable, std::map &variables) { + coreutils::ZString Global::getVariable(coreutils::ZString &variable, std::map &lvariables) { if(variable.ifNext("$[")) { coreutils::MString name; coreutils::MString modifier; if(variable.ifNext("!")) { - renderVariableName(variable, name, modifier, variables); + renderVariableName(variable, name, modifier, lvariables); return variables[name]; } if(variable.ifNext(":")) { // TODO: should only allow CGI variable name. Allow variable substitution. } if(variable.ifNext("@")) { // TODO: should only allow session variables. Allow substitution. } if(variable.ifNext("%")) { - renderVariableName(variable, name, modifier, variables); + renderVariableName(variable, name, modifier, lvariables); return getenv(name.c_str()); } else { - renderVariableName(variable, name, modifier, variables); + renderVariableName(variable, name, modifier, lvariables); name.split("."); if(name.getList().size() == 1) return variables[name[0]]; @@ -60,25 +60,26 @@ namespace jet { } throw coreutils::Exception("expected variable name or type designator."); } if(variable.ifNext("#[")) { - // TODO: this local variable type has no special naming conventions. We - // just need to do nested variable substitution for the entry. - + coreutils::MString name; + coreutils::MString modifier; + renderVariableName(variable, name, modifier, lvariables); + return lvariables[name]; } throw coreutils::Exception("Expecting a variable initializer ('$[' or '#[')."); } - void Global::renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map &variables) { + void Global::renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map &lvariables) { while(!variable.ifNext("]")) { name << variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); if(variable.ifNext(";")) { - renderVariableName(variable, modifier, modifier, variables); + renderVariableName(variable, modifier, modifier, lvariables); return; } else if(variable.startsWith("$[")) { - name << getVariable(variable, variables); + name << getVariable(variable, lvariables); } else if(variable.startsWith("#[")) { - name << getVariable(variable, variables); + name << getVariable(variable, lvariables); } } return; diff --git a/Global.h b/Global.h index 4b03cca..fcea707 100644 --- a/Global.h +++ b/Global.h @@ -18,8 +18,8 @@ namespace jet { bool sessionExists(coreutils::MString sessionId); void addSession(coreutils::MString sessionId, __mysql *mysql); void removeSession(coreutils::MString sessionId); - coreutils::ZString getVariable(coreutils::ZString &variable, std::map &variables); - void renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map &variables); + coreutils::ZString getVariable(coreutils::ZString &variable, std::map &lvariables); + void renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier, std::map &lvariables); __mysql * getSession(coreutils::MString sessionId); coreutils::ZString getSessionVariable(coreutils::MString &splitName); void outputHeaders(); diff --git a/jet-2.0 b/jet-2.0 index b1ecff4..50831b3 100755 Binary files a/jet-2.0 and b/jet-2.0 differ diff --git a/testjet.jet b/testjet.jet index f1c97cf..78fbacd 100755 --- a/testjet.jet +++ b/testjet.jet @@ -10,7 +10,7 @@ $[modified1] --- $[nonexistant] - $[$HOME] + $[%HOME] select * from testdata