Skip to content

Commit

Permalink
fix: Made error non-fatal in case optimization done twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Feb 25, 2024
1 parent 3d3d971 commit 3eb035a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/common/calexpr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: calexpr.c,v 2.47 2024/02/25 04:11:10 greg Exp $";
static const char RCSid[] = "$Id: calexpr.c,v 2.48 2024/02/25 04:41:44 greg Exp $";
#endif
/*
* Compute data values using expression parser
Expand Down Expand Up @@ -218,17 +218,16 @@ epflatten( /* flatten hierarchies for '+', '*' */
{
EPNODE *ep;

if (epar->nkids < 0) {
eputs("Cannot flatten EPNODE array\n");
quit(1);
}
if (epar->nkids < 0) /* can't handle array allocations */
return;

for (ep = epar->v.kid; ep != NULL; ep = ep->sibling)
while (ep->type == epar->type) {
while (ep->type == epar->type && ep->nkids > 0) {
EPNODE *ep1 = ep->v.kid;
while (ep1->sibling != NULL)
ep1 = ep1->sibling;
ep1->sibling = ep->sibling;
epar->nkids += nekids(ep) - 1;
epar->nkids += ep->nkids - 1;
ep1 = ep->v.kid;
*ep = *ep1;
efree(ep1); /* not epfree()! */
Expand Down Expand Up @@ -347,16 +346,14 @@ edivi(
)
{
EPNODE *ep1 = ep->v.kid;
EPNODE *ep2 = ep1->sibling;
double d;
double den = evalue(ep1->sibling);

d = evalue(ep2);
if (d == 0.0) {
if (den == 0.0) {
wputs("Division by zero\n");
errno = ERANGE;
return(0.0);
}
return(envalue(ep1) / d);
return(envalue(ep1) / den);
}

static double
Expand Down

0 comments on commit 3eb035a

Please # to comment.