Resolve outstanding stdin parsing issues by buffering the data.
This commit is contained in:
parent
8abf8baa53
commit
ebae0257fb
1 changed files with 15 additions and 10 deletions
25
parser.cc
25
parser.cc
|
|
@ -166,16 +166,21 @@ unsigned int parse_ledger_data(config_t& config,
|
||||||
"rejected cache, parsing " << config.data_file);
|
"rejected cache, parsing " << config.data_file);
|
||||||
if (config.data_file == "-") {
|
if (config.data_file == "-") {
|
||||||
config.use_cache = false;
|
config.use_cache = false;
|
||||||
journal->sources.push_back("<stdin>");
|
journal->sources.push_back("/dev/stdin");
|
||||||
#if 0
|
|
||||||
// jww (2006-03-23): Why doesn't XML work on stdin?
|
std::ostringstream buffer;
|
||||||
if (xml_parser && std::cin.peek() == '<')
|
|
||||||
entry_count += xml_parser->parse(std::cin, config, journal,
|
while (std::cin.good() && ! std::cin.eof()) {
|
||||||
acct);
|
static char line[8192];
|
||||||
else if (stdin_parser)
|
std::cin.read(line, 8192);
|
||||||
#endif
|
std::streamsize count = std::cin.gcount();
|
||||||
entry_count += stdin_parser->parse(std::cin, config,
|
buffer.write(line, count);
|
||||||
journal, acct);
|
}
|
||||||
|
buffer.flush();
|
||||||
|
|
||||||
|
std::istringstream buf_in(buffer.str());
|
||||||
|
|
||||||
|
entry_count += parse_journal(buf_in, config, journal, acct);
|
||||||
}
|
}
|
||||||
else if (access(config.data_file.c_str(), R_OK) != -1) {
|
else if (access(config.data_file.c_str(), R_OK) != -1) {
|
||||||
entry_count += parse_journal_file(config.data_file, config,
|
entry_count += parse_journal_file(config.data_file, config,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue