Fucked up variable handling trying to improve things with a modifier.
This commit is contained in:
1 parent
d561a65f9d
commit
4972799e7a
5 files changed
+40
-18
No files matched your search
+19
-15
@@ -40,20 +40,25 @@ namespace jet {
|
||||
coreutils::ZString Global::getVariable(coreutils::ZString &variable) {
|
||||
if(variable.ifNext("$[")) {
|
||||
coreutils::MString name;
|
||||
coreutils::MString modifier;
|
||||
if(variable.ifNext("!")) {
|
||||
return variables[renderVariableName(name, variable)];
|
||||
return variables[renderVariableName(variable, name, modifier)];
|
||||
} if(variable.ifNext(":")) {
|
||||
// TODO: should only allow CGI variable name. Allow variable substitution.
|
||||
} if(variable.ifNext("@")) {
|
||||
// TODO: should only allow environment variables. Allow substitution.
|
||||
} if(variable.ifNext("$")) {
|
||||
return getenv(renderVariableName(name, variable).c_str());
|
||||
return getenv(renderVariableName(variable, name, modifier).c_str());
|
||||
} else {
|
||||
coreutils::MString splitName = renderVariableName(name, variable);
|
||||
splitName.split(".");
|
||||
if(splitName.getList().size() == 1)
|
||||
return variables[splitName[0]];
|
||||
return getSessionVariable(splitName);
|
||||
renderVariableName(variable, name, modifier);
|
||||
if(!variable.ifNext("]")) {
|
||||
std::cout << "unparsed: " << variable.unparsed() << std::endl;
|
||||
throw coreutils::Exception("expecting ] to close variable name.");
|
||||
}
|
||||
name.split(".");
|
||||
if(name.getList().size() == 1)
|
||||
return variables[name[0]];
|
||||
return getSessionVariable(name);
|
||||
}
|
||||
throw coreutils::Exception("expected variable name or type designator.");
|
||||
} if(variable.ifNext("#[")) {
|
||||
@@ -64,16 +69,15 @@ namespace jet {
|
||||
throw coreutils::Exception("Expecting a variable initializer ('$[' or '#[').");
|
||||
}
|
||||
|
||||
coreutils::MString Global::renderVariableName(coreutils::MString &name, coreutils::ZString &variable) {
|
||||
coreutils::MString Global::renderVariableName(coreutils::ZString &variable, coreutils::MString &name, coreutils::MString &modifier) {
|
||||
name << variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
||||
if(variable.ifNext("]"))
|
||||
return name;
|
||||
if(variable.startsWith("$[")) {
|
||||
if(variable.ifNext("]"));
|
||||
else if(variable.ifNext(";")) {
|
||||
modifier = renderVariableName(variable, modifier, modifier);
|
||||
}
|
||||
else if(variable.startsWith("$[")) {
|
||||
name << getVariable(variable);
|
||||
if(variable.ifNext("]"))
|
||||
return name;
|
||||
}
|
||||
renderVariableName(name, variable);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user