eval_brkt().
By SalimMeghani
- 333 reads
void eval_brkt(int *error, char *form, int *start, int *end, int *bracket, int *length)
{
int loop=0,size=0;
char *ecopy=NULL;
char *nbrac=NULL;
char *number=NULL;
//
double answer=0;
strcpy(form3,form);
while ((*bracket) && (!*error))
{
nbrac=(char *) calloc ((unsigned long)32767, sizeof(char));
number=(char * ) calloc((unsigned long) 100, sizeof(char));
ecopy=(char *) calloc((unsigned long)32767,sizeof(char));
//
size=((*end)-(*start+1))+2;
clr_str(nbrac);
strncpy(nbrac, form3+(*start+1), ((*end)-(*start+1)));
strcat(nbrac,"%");
answer = eval_form(error,nbrac);
//
if (answer<0)
{
strcpy(nbrac, "M,");
sprintf(number, "%e", -answer);
strcat(nbrac,number);
}
else
{
sprintf(number, "%e", answer);
clr_str(nbrac);
strcpy(nbrac, number);
}
if (start !=0)
{
strncpy(ecopy, form3+0, *start);
}
strcat(ecopy, nbrac);
loop=*end+1;
strcat(ecopy, form3+loop);
clr_str(form3);
strcpy(form3, ecopy);
strcat(form3, ",");
free(ecopy);
free(number);
free(nbrac);
if (*bracket)
find_brkt(error, form3, start, end, bracket, length);
}
}
- Log in to post comments