295 |
|
errno = 0; |
296 |
|
d = pow(evalue(ep1), evalue(ep1->sibling)); |
297 |
|
#ifdef isnan |
298 |
< |
if (errno == 0) |
298 |
> |
if (errno == 0) { |
299 |
|
if (isnan(d)) |
300 |
|
errno = EDOM; |
301 |
|
else if (isinf(d)) |
302 |
|
errno = ERANGE; |
303 |
+ |
} |
304 |
|
#endif |
305 |
|
if (errno == EDOM || errno == ERANGE) { |
306 |
|
wputs("Illegal power\n"); |
620 |
|
EPNODE *ep3 = ep1->sibling; |
621 |
|
if (ep1->type == NUM && ep3->type == NUM) { |
622 |
|
ep2 = rconst(ep2); |
623 |
< |
} else if (ep3->type == NUM && ep3->v.num == 0) { |
624 |
< |
if (ep2->type == '/') |
625 |
< |
syntax("divide by zero constant"); |
626 |
< |
ep1->sibling = NULL; /* (E2 * 0) */ |
627 |
< |
epfree(ep2); |
628 |
< |
ep2 = ep3; |
623 |
> |
} else if (ep3->type == NUM) { |
624 |
> |
if (ep2->type == '/') { |
625 |
> |
if (ep3->v.num == 0) |
626 |
> |
syntax("divide by zero constant"); |
627 |
> |
ep2->type = '*'; /* for speed */ |
628 |
> |
ep3->v.num = 1./ep3->v.num; |
629 |
> |
} else if (ep3->v.num == 0) { |
630 |
> |
ep1->sibling = NULL; /* (E2 * 0) */ |
631 |
> |
epfree(ep2); |
632 |
> |
ep2 = ep3; |
633 |
> |
} |
634 |
|
} else if (ep1->type == NUM && ep1->v.num == 0) { |
635 |
|
epfree(ep3); /* (0 * E3) or (0 / E3) */ |
636 |
|
ep1->sibling = NULL; |