Clean version. filterblanklines functioning now.

This commit is contained in:
Brad Arant 2024-07-11 14:37:38 -07:00
parent 632e6979ba
commit e1be28e53b
5 changed files with 20 additions and 19 deletions

16
Tag.cpp
View File

@ -43,6 +43,9 @@ namespace jet {
if(!in.ifNext("\"")) {} if(!in.ifNext("\"")) {}
} }
} }
if(variableDefined("filterblanklines")) {
filterBlankLines = variables["filterblanklines"] == "true" ? true: false;
}
if(hasContainer) { if(hasContainer) {
coreutils::Log(coreutils::LOG_DEBUG_2) << "has Container: " << hasContainer; coreutils::Log(coreutils::LOG_DEBUG_2) << "has Container: " << hasContainer;
bool hasSplitTag = splitTagName == "" ? false: true; bool hasSplitTag = splitTagName == "" ? false: true;
@ -226,14 +229,13 @@ namespace jet {
void Tag::copyContainer(coreutils::ZString &in, coreutils::MString &out) { void Tag::copyContainer(coreutils::ZString &in, coreutils::MString &out) {
while(!in.eod()) { while(!in.eod()) {
if(filterBlankLines) { if(filterBlankLines) {
in.push(); if(!in.lineIsWhitespace()) {
if(!in.eod()) { out.write(in.goeol());
in.getTokenInclude(" \t"); out.write('\n');
if(!in.ifNext("\n")) {
in.pop();
// TODO: shouod be safe to output line here.
}
} }
else {
in.goeol();
}
} }
else { else {
out.write(in.charAt(0)); out.write(in.charAt(0));

View File

@ -24,7 +24,8 @@ namespace jet {
} }
argv[ix] == NULL; argv[ix] == NULL;
pipe(fdo); pipe(fdo);
if(pid != fork()) { pid = fork();
if(pid == 0) {
close(fdo[0]); close(fdo[0]);
dup2(fdo[1], 1); dup2(fdo[1], 1);
if(variableDefined("input")) { if(variableDefined("input")) {
@ -38,7 +39,7 @@ namespace jet {
} }
close(fdi[0]); close(fdi[0]);
dup2(fdi[0], 0); dup2(fdi[0], 0);
} }
rc = execve(variables["pgm"].c_str(), argv, NULL); rc = execve(variables["pgm"].c_str(), argv, NULL);
close(fdo[1]); close(fdo[1]);
std::cout << "rc: " << rc << std::endl; std::cout << "rc: " << rc << std::endl;
@ -49,7 +50,7 @@ namespace jet {
global.variables[variables["name"]].read(fdo[0]); global.variables[variables["name"]].read(fdo[0]);
else else
out.read(fdo[0]); out.read(fdo[0]);
waitpid(pid, &status,0); waitpid(pid, &status, 0);
std::cout << "status: " << status << std::endl; std::cout << "status: " << status << std::endl;
} }

View File

@ -17,17 +17,14 @@ namespace jet {
} }
if(variableDefined(coreutils::ZString("step"))) { if(variableDefined(coreutils::ZString("step"))) {
step = variables["step"].asDouble(); step = variables["step"].asDouble();
} }
std::cout << "start: " << counter << "; end: " << end << "; step: " << step << std::endl;
for(double ix = counter; ix <= end; ix += step) { for(double ix = counter; ix <= end; ix += step) {
if(nameDefined) if(nameDefined)
variables[variables["name"]] = ix; variables[variables["name"]] = ix;
processContainer(container); processContainer(container);
container.reset(); container.reset();
} }
// for (auto i = variables.begin(); i != variables.end(); i++)
// std::cout << i->first << "=[" << i->second << "]" << std::endl;}
} }
} }

BIN
testjet

Binary file not shown.

View File

@ -5,7 +5,7 @@
int main(int argc, char **argv) { int main(int argc, char **argv) {
coreutils::ZString data("<jet name=\"localname\">\n" coreutils::ZString data("<jet name=\"localname\" filterblanklines=\"true\">\n"
" <html>\n" " <html>\n"
" <set name=\"ix\" value=\"1\" />\n" " <set name=\"ix\" value=\"1\" />\n"
" <set name=\"theexpr\" expr=\"true\" />\n" " <set name=\"theexpr\" expr=\"true\" />\n"
@ -29,7 +29,8 @@ int main(int argc, char **argv) {
" <for name=\"ix\" start=\"1\" end=\"5\" step=\"1\">\n" " <for name=\"ix\" start=\"1\" end=\"5\" step=\"1\">\n"
" -->#[ix]<--\n" " -->#[ix]<--\n"
" </for>\n" " </for>\n"
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" />" " <call pgm=\"/usr/bin/ls\" arg1=\"-al\" name=\"ls\" />\n"
" $[ls]\n"
" </html>\n" " </html>\n"
"</jet>\n"); "</jet>\n");
@ -50,5 +51,5 @@ int main(int argc, char **argv) {
jet::__jet *jet = new jet::__jet(data, out, global); jet::__jet *jet = new jet::__jet(data, out, global);
delete jet; delete jet;
std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl; std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl;
global.dump(); // global.dump();
} }