perl-module: Init and destroy for long strings in set_missing_values().
[pspp] / perl-module / PSPP.xs
index 7577b7ad2c7be4d54b37fad06013aca3d6be0332..c563b40f6330785c48f42d1efa30749b8d4345a1 100644 (file)
@@ -17,6 +17,7 @@
    02110-1301, USA. */
 
 
+#undef VERSION
 #include <config.h>
 
 /* The Gnulib "strftime" module defines my_strftime in <config.h> for use by
@@ -32,6 +33,8 @@
 #include "ppport.h"
 
 #include "minmax.h"
+#include <libpspp/hmap.h>
+#include <libpspp/hash-functions.h>
 #include <libpspp/message.h>
 #include <libpspp/version.h>
 #include <libpspp/i18n.h>
@@ -271,7 +274,7 @@ CODE:
         free (input_format);
        }
      hmap_destroy (&dict->input_formats);
-     dict_destroy (dict->dict);
+     dict_unref (dict->dict);
      free (dict);
    }
 
@@ -409,12 +412,15 @@ INIT:
   croak ("No more than 3 missing values are permitted");
 
  for (i = 0; i < items - 1; ++i)
-   scalar_to_value (&val[i], ST(i+1), var);
+   make_value_from_scalar (&val[i], ST(i+1), var);
 CODE:
  struct missing_values mv;
  mv_init (&mv, var_get_width (var));
  for (i = 0 ; i < items - 1; ++i )
-   mv_add_value (&mv, &val[i]);
+   {
+     mv_add_value (&mv, &val[i]);
+     value_destroy (&val[i], var_get_width (var));
+   }
  var_set_missing_values (var, &mv);
 
 
@@ -586,7 +592,6 @@ get_value_labels (var)
 CODE:
  HV *labelhash = (HV *) sv_2mortal ((SV *) newHV());
  const struct val_lab *vl;
- struct val_labs_iterator *viter = NULL;
  const struct val_labs *labels = var_get_value_labels (var);
 
  if ( labels )
@@ -638,7 +643,7 @@ INIT:
   }
 CODE:
  struct file_handle *fh =
-  fh_create_file (NULL, name, fh_default_properties () );
+   fh_create_file (NULL, name, "UTF-8", fh_default_properties () );
  struct syswriter_info *swi = xmalloc (sizeof (*swi));
  swi->writer = sfm_open_writer (fh, dict->dict, opts);
  swi->dict = dict;
@@ -749,10 +754,9 @@ struct sysreader_info *
 pxs_open_sysfile (name)
  char * name
 CODE:
- struct casereader *reader;
  struct sysreader_info *sri = NULL;
  struct file_handle *fh =
-        fh_create_file (NULL, name, fh_default_properties () );
+   fh_create_file (NULL, name, "UTF-8", fh_default_properties () );
  struct dictionary *dict;
 
  sri = xmalloc (sizeof (*sri));