From 33b4877a64014cfb19d0ef6928b1ffefe6496903 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 16 Feb 2023 00:03:17 +0100 Subject: [PATCH] test --- argument.c | 10 ++++++++-- program.c | 11 +++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/argument.c b/argument.c index bda7684..c8f345f 100644 --- a/argument.c +++ b/argument.c @@ -1,3 +1,5 @@ +#include + #include "parser.h" #include "tabular.h" @@ -21,10 +23,14 @@ double arg (int n) double def (int nbops, element_t **ops) { int i; - argument = resize_tab (argument, nbops); + tab_t *new = alloc_tab (nbops); for (i = 0; i < nbops; i++) { - set_tab (argument, i + 1, evaluate_element (ops[i], 0)); + double val = evaluate_element (ops[i], 0); + VERBOSE (DEBUG, fprintf (stdout, "arg[%d] = %g\n", i + i, val)); + set_tab (new, i + 1, val); } + free_tab (argument); + argument = new; return size_tab (argument); } diff --git a/program.c b/program.c index dc433aa..a6801f8 100644 --- a/program.c +++ b/program.c @@ -81,22 +81,25 @@ double call (int id, int nbargs, element_t **args) VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id)); return 0; } + VERBOSE (DEBUG, fprintf (stdout, "id -> n; %d -> %d\n", id, n)); - /* backup context */ - workspace_t *tmp = backup_ws (alloc_ws ()); - restore_ws (programs[n]); - /* set arguments */ free_tab (argument); argument = NULL; + VERBOSE (DEBUG, fprintf (stdout, "nbargs; %d\n", nbargs)); if (nbargs > 0) { def (nbargs, args); } + /* backup context */ + workspace_t *tmp = backup_ws (alloc_ws ()); + restore_ws (programs[n]); + /* evaluate program */ answer = 0; element_t *elements = dupelement (programs[n]->root); ret = evaluate_element (elements, 0); + VERBOSE (DEBUG, fprintf (stdout, "ret; %g\n", ret)); delelement (elements); /* clean arguments */ -- 2.30.2