Variables work. Added trimline support.

This commit is contained in:
Brad Arant committed 2024-09-24 12:13:06 -07:00
1 parent 3679644f64
commit 933c400922
5 files changed
+26 -25

No files matched your search

+10 -7
View File
@@ -33,14 +33,15 @@ namespace jet {
coreutils::ZString Global::getVariable(coreutils::ZString &variable) {
if(variable.ifNext("$[")) {
coreutils::MString name;
if(variable.ifNext("!")) {
return variables[renderVariableName(variable)];
return variables[renderVariableName(name, variable)];
} if(variable.ifNext(":")) {
// TODO: should only allow CGI variable name. Allow variable substitution.
} if(variable.ifNext("@")) {
// TODO: should only allow environment variables. Allow substitution.
} else {
return variables[renderVariableName(variable)];
return variables[renderVariableName(name, variable)];
}
throw coreutils::Exception("expected variable name or type designator.");
} if(variable.ifNext("#[")) {
@@ -51,15 +52,17 @@ namespace jet {
throw coreutils::Exception("Expecting a variable initializer ('$[' or '#[').");
}
coreutils::MString Global::renderVariableName(coreutils::ZString &variable) {
coreutils::MString name = variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
coreutils::MString Global::renderVariableName(coreutils::MString &name, coreutils::ZString &variable) {
name << variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
if(variable.ifNext("]"))
return name;
if(variable.startsWith("$[")) {
name << getVariable(variable);
return name;
}
return coreutils::MString("");
if(variable.ifNext("]"))
return name;
}
renderVariableName(name, variable);
return name;
}
}