projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9a23b07
)
dc: fix EOF handling in case of last line being incomplete
author
Denys Vlasenko
<vda.linux@googlemail.com>
Wed, 12 Dec 2018 20:56:06 +0000
(21:56 +0100)
committer
Denys Vlasenko
<vda.linux@googlemail.com>
Wed, 12 Dec 2018 20:56:06 +0000
(21:56 +0100)
This wasn't working correctly:
$ echo -ne '10 20+p' | dc
30
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c
patch
|
blob
|
history
diff --git
a/miscutils/bc.c
b/miscutils/bc.c
index 3d26c39a7c09dd4146a59d4add63f3887c5dceb1..9cc29f0ea22a39235bea357e19f3b5b5adcbb335 100644
(file)
--- a/
miscutils/bc.c
+++ b/
miscutils/bc.c
@@
-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)