dc: fix EOF handling in case of last line being incomplete
This wasn't working correctly: $ echo -ne '10 20+p' | dc 30 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -1425,6 +1425,8 @@ static BcStatus bc_read_line(BcVec *vec)
|
|||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
if (ferror(stdin))
|
if (ferror(stdin))
|
||||||
quit(); // this emits error message
|
quit(); // this emits error message
|
||||||
|
// If we had some input before EOF, do not report EOF yet:
|
||||||
|
if (vec->len == 0)
|
||||||
s = BC_STATUS_EOF;
|
s = BC_STATUS_EOF;
|
||||||
// Note: EOF does not append '\n', therefore:
|
// Note: EOF does not append '\n', therefore:
|
||||||
// printf 'print 123\n' | bc - works
|
// printf 'print 123\n' | bc - works
|
||||||
|
Reference in New Issue
Block a user