Merge pull request #123 from kljohann/bug.788
change handling of standard input
This commit is contained in:
commit
83bd3234d3
6 changed files with 36 additions and 5 deletions
|
|
@ -84,7 +84,7 @@ string source_context(const path& file,
|
||||||
const string& prefix)
|
const string& prefix)
|
||||||
{
|
{
|
||||||
const std::streamoff len = end_pos - pos;
|
const std::streamoff len = end_pos - pos;
|
||||||
if (! len || file == path("/dev/stdin"))
|
if (! len || file.empty())
|
||||||
return _("<no source context>");
|
return _("<no source context>");
|
||||||
|
|
||||||
assert(len > 0);
|
assert(len > 0);
|
||||||
|
|
|
||||||
|
|
@ -582,8 +582,8 @@ string item_context(const item_t& item, const string& desc)
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
||||||
if (item.pos->pathname == path("/dev/stdin")) {
|
if (item.pos->pathname.empty()) {
|
||||||
out << desc << _(" from standard input:");
|
out << desc << _(" from streamed input:");
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ std::size_t session_t::read_data(const string& master_account)
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const path& pathname, HANDLER(file_).data_files) {
|
foreach (const path& pathname, HANDLER(file_).data_files) {
|
||||||
if (pathname == "-") {
|
if (pathname == "-" || pathname == "/dev/stdin") {
|
||||||
// To avoid problems with stdin and pipes, etc., we read the entire
|
// To avoid problems with stdin and pipes, etc., we read the entire
|
||||||
// file in beforehand into a memory buffer, and then parcel it out
|
// file in beforehand into a memory buffer, and then parcel it out
|
||||||
// from there.
|
// from there.
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class RegressFile(object):
|
||||||
use_stdin = False
|
use_stdin = False
|
||||||
if test['command'].find("-f ") != -1:
|
if test['command'].find("-f ") != -1:
|
||||||
test['command'] = '$ledger ' + test['command']
|
test['command'] = '$ledger ' + test['command']
|
||||||
if test['command'].find("-f - ") != -1:
|
if re.search("-f (-|/dev/stdin)(\s|$)", test['command']):
|
||||||
use_stdin = True
|
use_stdin = True
|
||||||
else:
|
else:
|
||||||
test['command'] = (('$ledger -f "%s" ' %
|
test['command'] = (('$ledger -f "%s" ' %
|
||||||
|
|
|
||||||
12
test/regress/BF3C1F82-2.test
Normal file
12
test/regress/BF3C1F82-2.test
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
; Check that include directives are relative for "-f /dev/stdin"
|
||||||
|
include non-existent-ledger-file-BF3C1F82
|
||||||
|
test -f - reg -> 1
|
||||||
|
__ERROR__
|
||||||
|
While parsing file "", line 2:
|
||||||
|
Error: File to include was not found: "./non-existent-ledger-file-BF3C1F82"
|
||||||
|
end test
|
||||||
|
test -f /dev/stdin reg -> 1
|
||||||
|
__ERROR__
|
||||||
|
While parsing file "", line 2:
|
||||||
|
Error: File to include was not found: "./non-existent-ledger-file-BF3C1F82"
|
||||||
|
end test
|
||||||
19
test/regress/BF3C1F82.test
Normal file
19
test/regress/BF3C1F82.test
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
; Check that error reporting works for "-f -"
|
||||||
|
|
||||||
|
2012/02/30 * Test
|
||||||
|
a 1
|
||||||
|
b
|
||||||
|
test -f - reg -> 1
|
||||||
|
__ERROR__
|
||||||
|
While parsing file "", line 3:
|
||||||
|
While parsing transaction:
|
||||||
|
<no source context>
|
||||||
|
Error: Day of month is not valid for year
|
||||||
|
end test
|
||||||
|
test -f /dev/stdin reg -> 1
|
||||||
|
__ERROR__
|
||||||
|
While parsing file "", line 3:
|
||||||
|
While parsing transaction:
|
||||||
|
<no source context>
|
||||||
|
Error: Day of month is not valid for year
|
||||||
|
end test
|
||||||
Loading…
Add table
Reference in a new issue