PsppireValueEntry: Clear the entry, when the underlying model changes.
[pspp] / src / data / ods-reader.c
index 9bbfb479e2b9e8d02c1b6642e6ad81193b3a1e3c..9c165f9c92e30bd305a233f7b8bf4e4e57e2a50d 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011, 2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -127,7 +127,7 @@ ods_file_casereader_destroy (struct casereader *reader UNUSED, void *r_)
     xmlFreeTextReader (r->xtr);
 
   if ( ! ds_is_empty (&r->ods_errs))
-    msg (ME, ds_cstr (&r->ods_errs));
+    msg (ME, "%s", ds_cstr (&r->ods_errs));
 
   ds_destroy (&r->ods_errs);
 
@@ -324,11 +324,11 @@ convert_xml_to_value (struct ccase *c, const struct variable *var,
       text =
         xmv->value ? CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text);
 
-      data_in (ss_cstr (text), "UTF-8",
-              fmt->type,
-              v,
-              var_get_width (var),
-              "UTF-8");
+      free (data_in (ss_cstr (text), "UTF-8",
+                     fmt->type,
+                     v,
+                     var_get_width (var),
+                     "UTF-8"));
     }
 }
 
@@ -411,8 +411,10 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
   /* If CELLRANGE was given, then we know how many variables should be read */
   if ( r->stop_col != -1 )
     {
+      assert (var_spec == NULL);
       n_var_specs =  r->stop_col - r->start_col + 1;
       var_spec = xrealloc (var_spec, sizeof (*var_spec) * n_var_specs);
+      memset (var_spec, '\0', sizeof (*var_spec) * n_var_specs);
     }
 
 
@@ -460,7 +462,7 @@ ods_open_reader (struct spreadsheet_read_info *gri, struct dictionary **dict)
                  var_spec = xrealloc (var_spec, sizeof (*var_spec) * (idx + 1));
 
                  /* xrealloc (unlike realloc) doesn't initialise its memory to 0 */
-                 memset (var_spec + n_var_specs * sizeof (*var_spec),
+                 memset (var_spec + n_var_specs,
                          0, 
                          (n_var_specs - idx + 1) * sizeof (*var_spec));
                  n_var_specs = idx + 1;