fix bracket evaluation
[calc.git] / workspace.c
index 26bbe8abcbcd70fb2f30d79a2e1f9d06249fbc85..eca1bf2bb182178bba5cd3372a3e0dbc9e3f45cc 100644 (file)
@@ -1,7 +1,6 @@
 #include <malloc.h>
 #include <stdio.h>
 
-#include "argument.h"
 #include "debug.h"
 #include "element.h"
 #include "parser.h"
@@ -23,8 +22,13 @@ workspace_t *alloc_ws ()
 workspace_t *backup_ws (workspace_t *ws)
 {
     ws->answer = answer;
-    ws->argument = copy_tab (argument);
+    if (ws->stack) {
+        free_tab (ws->stack);
+    }
     ws->stack = copy_tab (stack);
+    if (ws->storage) {
+        free_tab (ws->storage);
+    }
     ws->storage = copy_tab (storage);
     return ws;
 }
@@ -35,11 +39,6 @@ workspace_t *clean_ws (workspace_t *ws)
 {
     ws->answer = 0;
 
-    if (ws->argument) {
-        free_tab (ws->argument);
-        ws->argument = NULL;
-    }
-
     ws->id = 0;
 
     if (ws->root) {
@@ -81,11 +80,6 @@ void restore_ws (workspace_t *ws)
 {
     answer = ws->answer;
 
-    if (argument) {
-        free_tab (argument);
-    }
-    argument = copy_tab (ws->argument);
-
     if (stack) {
         free_tab (stack);
     }