fixed some bugs. Added resolveContainerParent flag to resolve set container issue not reading local variables appropriately.

This commit is contained in:
Brad Arant 2024-11-26 13:32:15 -08:00
parent e3d788bc92
commit bd8aa1c089
6 changed files with 13 additions and 12 deletions

View File

@ -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());
}

1
Tag.h
View File

@ -40,6 +40,7 @@ namespace jet {
bool filterBlankLines = false;
bool trimLines = false;
bool cleanWhitespace = false;
bool resolveContainerParent = false;
private:
bool containerOnly = false;

View File

@ -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)

View File

@ -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;

View File

@ -3,7 +3,7 @@
<header name="Content-Type" value="text/html" />
<comment>This is a comment and should not show up in the output.</comment>
<html>
---
---#[name1]
<set name="modified1" value="ABCD" />
$[modified1;tohex]
<set name="tohex" value="tohex" />
@ -23,8 +23,8 @@
<set name="division" expr="5/3" />
<set name="divisor" value="8" />
<set name="nested" expr="(2*(4+4)/$[divisor])*32" />
<set name="error" value="$[$x]" />
$[$nested]
<set name="error" value="$[x]" />
$[nested]
<set name="numbers">0123456789</set>
<set name="lefty" expr="LEFT($[numbers],5)" />
lefty=[$[lefty]]
@ -34,8 +34,8 @@
5*3($[multiplication])
5/3($[division])
<set name="varname$[ix]" value="vardata" scope="global" />
<set name="noeval" eval="no">this is the value store in #[name].</set>
<set name="thename" eval="yes">this is the value store in #[name].</set>
<set name="noeval" eval="no">this is the value store in #[name1].</set>
<set name="thename" eval="yes">this is the value store in #[name1].</set>
<set name="newname" scope="global">another container value</set>
<include file="./testinclude.jet" />
include: $[include]

View File

@ -1,8 +1,5 @@
#!../jet-2.0
<jet cgi="true" name1="localname" filterblanklines="true" trimlines="true">
<set name="testvar" value="do you see this" scope="local" />
#[testvar]
<for name="ix" start="1" end="5" step="1">
-->#[ix]<--
</for>
<set name="x" value="#[name1]" />
$[x] $[x]
</jet>