diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-09-11 09:40:05 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-09-11 09:40:05 +0200 |
commit | 5a16bda0fa232eaaf3a497f569939a4f1bcf727f (patch) | |
tree | 56d3f38d68d934a299374d1c0baed36f3442c5f7 /xsd/xsd/xsd.cxx | |
parent | 0d9c416f2e8452a1f4d1c38727f81c420a4f5cd0 (diff) |
Recognize --file-list value `-` as request to write to stdout
Diffstat (limited to 'xsd/xsd/xsd.cxx')
-rw-r--r-- | xsd/xsd/xsd.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
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&) |