mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
convert ASCII TABs to ASCII SPACEs
Converted all ASCII tabs to ASCII spaces using a 8 character tab stop, for all files, except for all Makefiles (plus rpm.mk). The `git diff -w` reports no changes.
This commit is contained in:
188
poly.c
188
poly.c
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
@@ -19,143 +19,143 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Under source code control: 1995/12/02 03:10:28
|
||||
* File existed as early as: 1995
|
||||
* Under source code control: 1995/12/02 03:10:28
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#include "value.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
bool
|
||||
evp(LISTELEM *cp, LISTELEM *x, VALUE *vres)
|
||||
{
|
||||
VALUE v, tmp1, tmp2;
|
||||
bool s;
|
||||
VALUE v, tmp1, tmp2;
|
||||
bool s;
|
||||
|
||||
s = false;
|
||||
while (cp) {
|
||||
if (s) {
|
||||
mulvalue(vres, &x->e_value, &tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp1;
|
||||
}
|
||||
v = cp->e_value;
|
||||
if (v.v_type == V_LIST) {
|
||||
if (evalpoly(v.v_list, x->e_next, &tmp1)) {
|
||||
if (s) {
|
||||
addvalue(&tmp1, vres, &tmp2);
|
||||
freevalue(&tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp2;
|
||||
} else {
|
||||
s = true;
|
||||
*vres = tmp1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s) {
|
||||
addvalue(&v, vres, &tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp1;
|
||||
} else {
|
||||
s = true;
|
||||
copyvalue(&v, vres);
|
||||
}
|
||||
}
|
||||
cp = cp->e_prev;
|
||||
}
|
||||
return s;
|
||||
s = false;
|
||||
while (cp) {
|
||||
if (s) {
|
||||
mulvalue(vres, &x->e_value, &tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp1;
|
||||
}
|
||||
v = cp->e_value;
|
||||
if (v.v_type == V_LIST) {
|
||||
if (evalpoly(v.v_list, x->e_next, &tmp1)) {
|
||||
if (s) {
|
||||
addvalue(&tmp1, vres, &tmp2);
|
||||
freevalue(&tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp2;
|
||||
} else {
|
||||
s = true;
|
||||
*vres = tmp1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s) {
|
||||
addvalue(&v, vres, &tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp1;
|
||||
} else {
|
||||
s = true;
|
||||
copyvalue(&v, vres);
|
||||
}
|
||||
}
|
||||
cp = cp->e_prev;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
evalpoly(LIST *clist, LISTELEM *x, VALUE *vres)
|
||||
{
|
||||
LISTELEM *cp;
|
||||
VALUE v;
|
||||
LISTELEM *cp;
|
||||
VALUE v;
|
||||
|
||||
cp = clist->l_first;
|
||||
if (cp == NULL)
|
||||
return false;
|
||||
if (x == NULL) {
|
||||
v = cp->e_value;
|
||||
if (v.v_type == V_LIST)
|
||||
return evalpoly(v.v_list, x->e_next, vres);
|
||||
copyvalue(&v, vres);
|
||||
return true;
|
||||
}
|
||||
return evp(clist->l_last, x, vres);
|
||||
cp = clist->l_first;
|
||||
if (cp == NULL)
|
||||
return false;
|
||||
if (x == NULL) {
|
||||
v = cp->e_value;
|
||||
if (v.v_type == V_LIST)
|
||||
return evalpoly(v.v_list, x->e_next, vres);
|
||||
copyvalue(&v, vres);
|
||||
return true;
|
||||
}
|
||||
return evp(clist->l_last, x, vres);
|
||||
}
|
||||
|
||||
void
|
||||
insertitems(LIST *lp1, LIST *lp2)
|
||||
{
|
||||
LISTELEM *ep;
|
||||
LISTELEM *ep;
|
||||
|
||||
for (ep = lp2->l_first; ep; ep = ep->e_next) {
|
||||
if (ep->e_value.v_type == V_LIST)
|
||||
insertitems(lp1, ep->e_value.v_list);
|
||||
else
|
||||
insertlistlast(lp1, &ep->e_value);
|
||||
}
|
||||
for (ep = lp2->l_first; ep; ep = ep->e_next) {
|
||||
if (ep->e_value.v_type == V_LIST)
|
||||
insertitems(lp1, ep->e_value.v_list);
|
||||
else
|
||||
insertlistlast(lp1, &ep->e_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long
|
||||
countlistitems(LIST *lp)
|
||||
{
|
||||
LISTELEM *ep;
|
||||
LISTELEM *ep;
|
||||
|
||||
long n = 0;
|
||||
for (ep = lp->l_first; ep; ep = ep->e_next) {
|
||||
if (ep->e_value.v_type == V_LIST)
|
||||
n += countlistitems(ep->e_value.v_list);
|
||||
else
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
long n = 0;
|
||||
for (ep = lp->l_first; ep; ep = ep->e_next) {
|
||||
if (ep->e_value.v_type == V_LIST)
|
||||
n += countlistitems(ep->e_value.v_list);
|
||||
else
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
addlistitems(LIST *lp, VALUE *vres)
|
||||
{
|
||||
LISTELEM *ep;
|
||||
VALUE tmp;
|
||||
LISTELEM *ep;
|
||||
VALUE tmp;
|
||||
|
||||
for (ep = lp->l_first; ep; ep = ep->e_next) {
|
||||
addvalue(vres, &ep->e_value, &tmp);
|
||||
freevalue(vres);
|
||||
*vres = tmp;
|
||||
if (vres->v_type < 0)
|
||||
return;
|
||||
}
|
||||
for (ep = lp->l_first; ep; ep = ep->e_next) {
|
||||
addvalue(vres, &ep->e_value, &tmp);
|
||||
freevalue(vres);
|
||||
*vres = tmp;
|
||||
if (vres->v_type < 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
addlistinv(LIST *lp, VALUE *vres)
|
||||
{
|
||||
LISTELEM *ep;
|
||||
VALUE tmp1, tmp2;
|
||||
LISTELEM *ep;
|
||||
VALUE tmp1, tmp2;
|
||||
|
||||
for (ep = lp->l_first; ep; ep = ep->e_next) {
|
||||
if (ep->e_value.v_type == V_LIST) {
|
||||
addlistinv(ep->e_value.v_list, vres);
|
||||
} else {
|
||||
invertvalue(&ep->e_value, &tmp1);
|
||||
addvalue(vres, &tmp1, &tmp2);
|
||||
freevalue(&tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp2;
|
||||
}
|
||||
if (vres->v_type < 0)
|
||||
return;
|
||||
}
|
||||
for (ep = lp->l_first; ep; ep = ep->e_next) {
|
||||
if (ep->e_value.v_type == V_LIST) {
|
||||
addlistinv(ep->e_value.v_list, vres);
|
||||
} else {
|
||||
invertvalue(&ep->e_value, &tmp1);
|
||||
addvalue(vres, &tmp1, &tmp2);
|
||||
freevalue(&tmp1);
|
||||
freevalue(vres);
|
||||
*vres = tmp2;
|
||||
}
|
||||
if (vres->v_type < 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user