Finish converting struct variable to an opaque type. In this
[pspp] / src / ui / gui / psppire-data-store.c
index eeaf31d660548dd7922295a2dae1f25615babfb9..65a4391d224402e353648de7795607c57e03366b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <data/casefile.h>
 #include <data/case.h>
+#include <data/data-out.h>
 
 #include <gtksheet/gtksheet.h>
 #include <gtksheet/gsheetmodel.h>
@@ -441,10 +442,10 @@ psppire_data_store_insert_new_case(PsppireDataStore *ds, gint posn)
   for (v = 0 ; v < psppire_dict_get_var_cnt (ds->dict) ; ++v) 
     {
       const struct PsppireVariable *pv = psppire_dict_get_variable(ds->dict, v);
-      if (ALPHA ==  psppire_variable_get_type(pv) ) 
+      if (VAR_STRING ==  psppire_variable_get_type(pv) ) 
        continue;
 
-      case_data_rw (&cc, psppire_variable_get_fv (pv))->f = SYSMIS;
+      case_data_rw_idx (&cc, psppire_variable_get_fv (pv))->f = SYSMIS;
     }
 
   result = psppire_case_file_insert_case (ds->case_file, &cc, posn);
@@ -506,7 +507,7 @@ psppire_data_store_get_string (const GSheetModel *model, gint row, gint column)
   /* Converts binary value V into printable form in the exactly
      FP->W character in buffer S according to format specification
      FP.  No null terminator is appended to the buffer.  */
-  data_out (s->str, fp, v);
+  data_out (v, fp, s->str);
 
   text = pspp_locale_to_utf8 (s->str, fp->w, 0);
   g_string_free (s, TRUE);
@@ -529,7 +530,7 @@ psppire_data_store_clear_datum (GSheetModel *model,
 
   const gint index = psppire_variable_get_fv(pv) ;
 
-  if ( psppire_variable_get_type(pv) == NUMERIC) 
+  if ( psppire_variable_get_type(pv) == VAR_NUMERIC) 
     v.f = SYSMIS;
   else
     memcpy(v.s, "", MAX_SHORT_STRING);
@@ -568,20 +569,10 @@ psppire_data_store_set_string(GSheetModel *model,
     }
 #endif
 
-  {
-    const gint index = psppire_variable_get_fv(pv);
-
-    struct data_in d_in;
-    d_in.s = text;
-    d_in.e = text + strlen(text);
-    d_in.v = 0;
-    d_in.f1 = d_in.f2 = 0;
-    d_in.format = * psppire_variable_get_write_spec(pv);
-    d_in.flags = 0;
-
-    psppire_case_file_data_in(store->case_file, row, index, &d_in) ;
-  }
-
+  psppire_case_file_data_in (store->case_file, row,
+                             psppire_variable_get_fv (pv), ss_cstr (text),
+                             psppire_variable_get_write_spec (pv));
+  
   return TRUE;
 }