Fixed a bug causing pspp to crash when computed variables had no format
[pspp-builds.git] / src / compute.c
index ff127e359f7e984f51075e9117700ddad54bf3c9..d26bf1ed2dd441d8f1406353b75b29b4105d227b 100644 (file)
 #include <assert.h>
 #include <stdlib.h>
 #include "alloc.h"
-#include "approx.h"
 #include "command.h"
 #include "error.h"
 #include "expr.h"
 #include "lexer.h"
+#include "misc.h"
 #include "str.h"
 #include "var.h"
 
@@ -397,11 +397,20 @@ lvalue_finalize (struct lvalue *lvalue,
     {
       compute->variable = dict_lookup_var (default_dict, lvalue->var_name);
       if (compute->variable == NULL)
-        compute->variable = dict_create_var_assert (default_dict,
-                                                    lvalue->var_name, 0);
+       {
+         struct fmt_spec input_spec = { 0,8,2 };
+         compute->variable = dict_create_var_assert (default_dict,
+                                                     lvalue->var_name, 0);
+
+                 convert_fmt_ItoO (&input_spec, &compute->variable->print);
+         compute->variable->write = compute->variable->print;
+       }
+
       compute->fv = compute->variable->fv;
       compute->width = compute->variable->width;
 
+      
+
       /* Goofy behavior, but compatible: Turn off LEAVE. */
       if (dict_class_from_id (compute->variable->name) != DC_SCRATCH)
         compute->variable->reinit = 1;