diff --git a/Tag.cpp b/Tag.cpp index cc0fc8f..2ee6005 100644 --- a/Tag.cpp +++ b/Tag.cpp @@ -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,14 +229,13 @@ 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 { out.write(in.charAt(0)); diff --git a/__call.cpp b/__call.cpp index 8ea5711..89b2650 100644 --- a/__call.cpp +++ b/__call.cpp @@ -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")) { @@ -38,7 +39,7 @@ namespace jet { } close(fdi[0]); dup2(fdi[0], 0); - } + } rc = execve(variables["pgm"].c_str(), argv, NULL); close(fdo[1]); std::cout << "rc: " << rc << std::endl; @@ -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; } diff --git a/__for.cpp b/__for.cpp index 9ef4b13..29d0a41 100644 --- a/__for.cpp +++ b/__for.cpp @@ -17,17 +17,14 @@ 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;} - + } } } diff --git a/testjet b/testjet index d437d02..ca0ed2b 100755 Binary files a/testjet and b/testjet differ diff --git a/testjet.cpp b/testjet.cpp index a76a73d..7de6f2e 100644 --- a/testjet.cpp +++ b/testjet.cpp @@ -5,7 +5,7 @@ int main(int argc, char **argv) { - coreutils::ZString data("\n" + coreutils::ZString data("\n" " \n" " \n" " \n" @@ -29,7 +29,8 @@ int main(int argc, char **argv) { " \n" " -->#[ix]<--\n" " \n" - " " + " \n" + " $[ls]\n" " \n" "\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(); }