Fixed read tag to throw exception on file error unstead of looping forever.

This commit is contained in:
Brad Arant 2024-10-31 16:05:46 -07:00
parent bff2b4d2c5
commit 527e8bf778
4 changed files with 11 additions and 8 deletions

View File

@ -75,12 +75,12 @@ namespace jet {
renderVariableName(variable, modifier, modifier, lvariables); renderVariableName(variable, modifier, modifier, lvariables);
return; return;
} }
else if(variable.startsWith("$[")) { else if(variable.startsWith("$[") || variable.startsWith("#["))
name << getVariable(variable, lvariables); name << getVariable(variable, lvariables);
} else if(variable.ifNext("]"))
else if(variable.startsWith("#[")) { return;
name << getVariable(variable, lvariables); else if(!variable.ifNextInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
} throw coreutils::Exception("invalid variable name.");
} }
return; return;
} }

View File

@ -14,6 +14,8 @@ namespace jet {
if(hasContainer) if(hasContainer)
throw coreutils::Exception("read tag does not have a container."); throw coreutils::Exception("read tag does not have a container.");
fd = open(variables["file"].c_str(), O_RDONLY); fd = open(variables["file"].c_str(), O_RDONLY);
if(fd < 0)
throw coreutils::Exception("file name is not found.");
global.variables[variables["name"]].read(fd); global.variables[variables["name"]].read(fd);
close(fd); close(fd);
} }

View File

@ -1,4 +1,4 @@
#!./jet-2.0 #!../jet-2.0
<jet cgi="true" name1="localname" filterblanklines="true" trimlines="true"> <jet cgi="true" name1="localname" filterblanklines="true" trimlines="true">
<header name="Content-Type" value="text/html" /> <header name="Content-Type" value="text/html" />
<comment>This is a comment and should not show up in the output.</comment> <comment>This is a comment and should not show up in the output.</comment>
@ -54,7 +54,7 @@
<call status="rc" pgm="/usr/bin/ls" arg1="-al" name="ls" /> <call status="rc" pgm="/usr/bin/ls" arg1="-al" name="ls" />
$[rc] $[rc]
$[ls] $[ls]
<read file="compile" name="file" /> <read file="../compile" name="file" />
$[filex] $[filex]
<whiledir path="." filename="file" fullpath="fullpath" filenamenoextension="noext" sort="true"> <whiledir path="." filename="file" fullpath="fullpath" filenamenoextension="noext" sort="true">
$[file] $[fullpath] $[noext] $[file] $[fullpath] $[noext]

View File

@ -6,6 +6,7 @@
<set name="1var1" value="This is another test" /> <set name="1var1" value="This is another test" />
<set name="var1var" value="Yet another test" /> <set name="var1var" value="Yet another test" />
<set name="var11" value="it seems to work." /> <set name="var11" value="it seems to work." />
$[$test]
$[$[ix]var$[ix]] $[$[ix]var$[ix]]
$[var$[ix]] $[var$[ix]]
$[var$[ix]var] $[var$[ix]var]