From 5a16bda0fa232eaaf3a497f569939a4f1bcf727f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Sep 2023 09:40:05 +0200 Subject: Recognize --file-list value `-` as request to write to stdout --- xsd/xsd/xsd.cxx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'xsd/xsd/xsd.cxx') diff --git a/xsd/xsd/xsd.cxx b/xsd/xsd/xsd.cxx index 0df4ea0..5a239d5 100644 --- a/xsd/xsd/xsd.cxx +++ b/xsd/xsd/xsd.cxx @@ -770,38 +770,43 @@ main (int argc, char* argv[]) try { OutputFileStream ofs; - SemanticGraph::Path path (fl); + if (fl != "-") + { + SemanticGraph::Path path (fl); - ofs.open (path.string ().c_str (), ios_base::out); + ofs.open (path.string ().c_str (), ios_base::out); - if (!ofs.is_open ()) - { - wcerr << path << ": error: unable to open in write mode" << endl; - return 1; + if (!ofs.is_open ()) + { + wcerr << path << ": error: unable to open in write mode" << endl; + return 1; + } } + std::ostream& os (ofs.is_open () ? ofs : cout); + NarrowString d (common_ops.file_list_delim ()); expand_nl (d); if (NarrowString p = common_ops.file_list_prologue ()) { expand_nl (p); - ofs << p; + os << p; } for (FileList::iterator i (file_list.begin ()), e (file_list.end ()); i != e;) { - ofs << *i; + os << *i; if (++i != e) - ofs << d; + os << d; } if (NarrowString e = common_ops.file_list_epilogue ()) { expand_nl (e); - ofs << e; + os << e; } } catch (SemanticGraph::InvalidPath const&) -- cgit v1.1