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

This commit is contained in:
Brad Arant committed 2024-10-31 16:05:46 -07:00
1 parent bff2b4d2c5
commit 527e8bf778
4 files changed
+11 -8

No files matched your search

+6 -6
View File
@@ -75,12 +75,12 @@ namespace jet {
renderVariableName(variable, modifier, modifier, lvariables);
return;
}
else if(variable.startsWith("$[")) {
name << getVariable(variable, lvariables);
}
else if(variable.startsWith("#[")) {
name << getVariable(variable, lvariables);
}
else if(variable.startsWith("$[") || variable.startsWith("#["))
name << getVariable(variable, lvariables);
else if(variable.ifNext("]"))
return;
else if(!variable.ifNextInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"))
throw coreutils::Exception("invalid variable name.");
}
return;
}
+2
View File
@@ -14,6 +14,8 @@ namespace jet {
if(hasContainer)
throw coreutils::Exception("read tag does not have a container.");
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);
close(fd);
}
+2 -2
View File
@@ -1,4 +1,4 @@
#!./jet-2.0
#!../jet-2.0
<jet cgi="true" name1="localname" filterblanklines="true" trimlines="true">
<header name="Content-Type" value="text/html" />
<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" />
$[rc]
$[ls]
<read file="compile" name="file" />
<read file="../compile" name="file" />
$[filex]
<whiledir path="." filename="file" fullpath="fullpath" filenamenoextension="noext" sort="true">
$[file] $[fullpath] $[noext]
+1
View File
@@ -6,6 +6,7 @@
<set name="1var1" value="This is another test" />
<set name="var1var" value="Yet another test" />
<set name="var11" value="it seems to work." />
$[$test]
$[$[ix]var$[ix]]
$[var$[ix]]
$[var$[ix]var]