diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-16 09:40:36 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-16 09:40:36 +0200 |
commit | 1113961dde21ce73c1543ca466913d9e17d06c1b (patch) | |
tree | 2956a47d072fd613c05d2a31f4f363addc64e8f5 | |
parent | abe248b20880d4d3831ba0a188f69d4a8126498a (diff) | |
download | busybox-w32-1113961dde21ce73c1543ca466913d9e17d06c1b.tar.gz busybox-w32-1113961dde21ce73c1543ca466913d9e17d06c1b.tar.bz2 busybox-w32-1113961dde21ce73c1543ca466913d9e17d06c1b.zip |
dc: make 4 % 0 emit error messgaes and set result to 0
function old new delta
mod 105 136 +31
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/dc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/miscutils/dc.c b/miscutils/dc.c index 5119c1383..5aef64b60 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
@@ -94,13 +94,18 @@ static void mod(void) | |||
94 | { | 94 | { |
95 | data_t d = pop(); | 95 | data_t d = pop(); |
96 | 96 | ||
97 | //if (d == 0) { | 97 | /* compat with dc (GNU bc 1.07.1) 1.4.1: |
98 | // bb_error_msg("remainder by zero"); | 98 | * $ dc -e '4 0 % p' |
99 | // pop(); | 99 | * dc: remainder by zero |
100 | // push(0); | 100 | * 0 |
101 | // return; | 101 | */ |
102 | //} | 102 | if (d == 0) { |
103 | //^^^^ without this, we simply get SIGFPE and die | 103 | bb_error_msg("remainder by zero"); |
104 | pop(); | ||
105 | push(0); | ||
106 | return; | ||
107 | } | ||
108 | /* ^^^^ without this, we simply get SIGFPE and die */ | ||
104 | 109 | ||
105 | push((data_t) pop() % d); | 110 | push((data_t) pop() % d); |
106 | } | 111 | } |