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

14
Tag.cpp
View File

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

View File

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

View File

@ -18,16 +18,13 @@ namespace jet {
if(variableDefined(coreutils::ZString("step"))) {
step = variables["step"].asDouble();
}
std::cout << "start: " << counter << "; end: " << end << "; step: " << step << std::endl;
for(double ix = counter; ix <= end; ix += step) {
if(nameDefined)
variables[variables["name"]] = ix;
processContainer(container);
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) {
coreutils::ZString data("<jet name=\"localname\">\n"
coreutils::ZString data("<jet name=\"localname\" filterblanklines=\"true\">\n"
" <html>\n"
" <set name=\"ix\" value=\"1\" />\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"
" -->#[ix]<--\n"
" </for>\n"
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" />"
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" name=\"ls\" />\n"
" $[ls]\n"
" </html>\n"
"</jet>\n");
@ -50,5 +51,5 @@ int main(int argc, char **argv) {
jet::__jet *jet = new jet::__jet(data, out, global);
delete jet;
std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl;
global.dump();
// global.dump();
}