diff options
-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 | } |