← Commit list

d8078a79b

Denys Vlasenko
Denys Vlasenko
2018-12-12
FAILED Duration: 85s

Subject

dc: fix EOF handling in case of last line being incomplete

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/bc.c+3 -1
@@ -1425,7 +1425,9 @@ static BcStatus bc_read_line(BcVec *vec)
if (c == EOF) {
if (ferror(stdin))
quit(); // this emits error message
- s = BC_STATUS_EOF;
+ // If we had some input before EOF, do not report EOF yet:
+ if (vec->len == 0)
+ s = BC_STATUS_EOF;
// Note: EOF does not append '\n', therefore:
// printf 'print 123\n' | bc - works
// printf 'print 123' | bc - fails (syntax error)