Skip to content

Commit 1c5873f

Browse files
bugfix in mlml: lack of input file would cause run to exit with no output. Now output to terminal
1 parent 3861b37 commit 1c5873f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/mlml/mlml.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,13 @@ process_three_types(const double alpha,
381381
ifstream o_in(oxbs_file);
382382
if (!o_in) throw dnmt_error("failed to open input file: " + oxbs_file);
383383

384-
ofstream out(outfile);
384+
ofstream of;
385+
if (!outfile.empty()) {
386+
of.open(outfile);
387+
if (!of) throw dnmt_error("failed to open output file: " + outfile);
388+
}
389+
std::ostream out(outfile.empty() ? cout.rdbuf() : of.rdbuf());
390+
385391
ofstream out_m, out_h;
386392
if (!out_methcount_pseudo_m.empty()) {
387393
out_m.open(out_methcount_pseudo_m);
@@ -557,7 +563,13 @@ process_two_types(const double alpha,
557563
size_t &conflict_sites) {
558564
constexpr auto max_read_count = 500;
559565

560-
ofstream out(outfile);
566+
ofstream of;
567+
if (!outfile.empty()) {
568+
of.open(outfile);
569+
if (!of) throw dnmt_error("failed to open output file: " + outfile);
570+
}
571+
std::ostream out(outfile.empty() ? cout.rdbuf() : of.rdbuf());
572+
561573
ofstream out_m, out_h;
562574
if (!out_methcount_pseudo_m.empty()) {
563575
out_m.open(out_methcount_pseudo_m);

0 commit comments

Comments
 (0)