diff options
m--------- | lib/cppunit | 0 | ||||
m--------- | lib/libofx | 0 | ||||
-rw-r--r-- | src/session.cc | 18 |
3 files changed, 17 insertions, 1 deletions
diff --git a/lib/cppunit b/lib/cppunit -Subproject 1f41e59a4dae47720d0aacb422548b45be0daa1 +Subproject fccfbd741a0fd974945bb259854768cc70258f0 diff --git a/lib/libofx b/lib/libofx -Subproject 699016bfd00e2be7f13120f314a4f976eeacadd +Subproject 31ab2c052edb3e72fc1fda385d6d118c479407f diff --git a/src/session.cc b/src/session.cc index 113aeda0..fa61e08b 100644 --- a/src/session.cc +++ b/src/session.cc @@ -216,7 +216,23 @@ std::size_t session_t::read_data(journal_t& journal, if (data_file == "-") { use_cache = false; journal.sources.push_back("/dev/stdin"); - entry_count += read_journal(journal, std::cin, "/dev/stdin", acct); + + // To avoid problems with stdin and pipes, etc., we read the entire + // file in beforehand into a memory buffer, and then parcel it out + // from there. + std::ostringstream buffer; + + while (std::cin.good() && ! std::cin.eof()) { + static char line[8192]; + std::cin.read(line, 8192); + std::streamsize count = std::cin.gcount(); + buffer.write(line, count); + } + buffer.flush(); + + std::istringstream buf_in(buffer.str()); + + entry_count += read_journal(journal, buf_in, "/dev/stdin", acct); } else if (exists(data_file)) { entry_count += read_journal(journal, data_file, acct); |