s, s, len);
* (v-> s + len) = ' 0';> t ype = TOK_STRING;> error = NULL;
} parser_value_free (ParserVal * v)
{_value_delete (v);
} parser_value_copy (ParserVal * from_v, ParserVal * to_v)
{
* to_v = * from_v; (from_v-> type! = TOK_STRING) return; _t len ​​= min (parser_strlen (from_v-> s), MAX_TOKEN_LEN); _v-> s = ( char *) calloc (len + 1, sizeof (char)); (len) (to_v-> s, from_v-> s, len);
* (to_v-> s + len) = ' 0';
} parser_value_delete (ParserVal * v)
{(v-> type == TOK_STRING)
{
/* Free string value */(v-> s) free (v-> s);> s = NULL;
}
/* Free error */(v-> error) free (v-> error);> error = NULL;
/* it keep the type.
*/
} do_sqrt (ParserVal * v, int arg_count)
{
/* Return sqrt (v [0]) in v [0] */[0]. d = sqrt (v [0]. d);
} do_abs (ParserVal * v, int arg_count)
{
/* Return abs (v [0]) in v [0]. */[0]. D = fabs (v [0]. D);
} do_exp (ParserVal * v, int arg_count)
{
/* Return exp (v [0]) in v [0]. */[0]. D = exp (v [0]. D);
} do_ln (ParserVal * v, int arg_count)
{
/* Return log (v [0]) in v [0]. */[0]. D = log (v [0]. D);
} do_pow (ParserVal * v, int arg_count)
{
/* Return pow (v [0], v [1]) in v [0]. */[0]. D = pow (v [0]. D, v [1]. D);
} do_integer (ParserVal * v, int arg_count)
{
/* Return integer (whole part of) v [0] in v [0]. */(V [0]. D, & v [0]. D/* int part * /);
} do_fraction (ParserVal * v, int arg_count)
{
/* Return fraction (decimal part of) v [0] in v [0]. */Int_part; [0]. D/* fraction */= modf (v [0]. D, & int_part);
} do_round (ParserVal * v, int arg_count)
{
/* Round v [0] to nearest n decimal. n = {0 ... 10}. [1] contains n. Returns the rounded value in v [0]. p align="justify"> */
/* TODO: Find a better way to do this! */Char buf [MAX_NUMERIC_LEN]; char format [MAX_NUMERIC_LEN];
sprintf (format, "%%.% df", (int) v [1]. d); (buf, format, v [0]. d);
v [0]. d = atof (buf);
} * lookup_builtin_function (char * name)
{i; (i = 0; i