X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=main%2Fodcread.cc;h=a2a2bd57dca6ec919de8e4918e6916460049a9c0;hb=da59d5524abbb95fb4112248dea75396cd00ff6d;hp=075671fadc1c9dddb39c74cc1b81c64f9d8639ed;hpb=cf88fc04686af2b4a34f9ccebc9f517cd83be491;p=odcread.git diff --git a/main/odcread.cc b/main/odcread.cc index 075671f..a2a2bd5 100644 --- a/main/odcread.cc +++ b/main/odcread.cc @@ -1,4 +1,4 @@ -#include "main/main.ih" +#include "main/module.ih" namespace odc { class Context { @@ -147,18 +147,20 @@ namespace odc { } int main(int argc, char *argv[]) { - if (argc < 2) { - return 1; - } - // Set the locale according to the terminal's environment setlocale(LC_ALL, ""); - std::ifstream in(argv[1], std::ios::in | std::ios::binary); odc::Store* s; try { - s = odc::importDocument(in); + if (argc < 2) { + s = odc::importDocument(std::cin); + } else if (argc == 2) { + std::ifstream in(argv[1], std::ios::in | std::ios::binary); + s = odc::importDocument(in); + } else { + return 1; + } } catch (int trap) { std::cerr << "Exception in parsing file: BlackBox trap no. " << trap << std::endl; return 2; @@ -169,6 +171,10 @@ int main(int argc, char *argv[]) { // std::cout << s->toPlainText() << std::endl; // std::cout << std::endl << std::endl; + if (s == nullptr) { + return 1; + } + try { odc::MyVisitor visitor; s->accept(visitor);