perl-module: Avoid VERSION redefinition warning from compiler.
[pspp] / perl-module / PSPP.xs
index e600f7b45d4e271d1d381e087349ec017a5f7831..74ea561170b00b3b16917aa8fe1c5a2c9fa24309 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>
@@ -46,7 +49,6 @@
 #include <data/identifier.h>
 #include <data/settings.h>
 #include <data/sys-file-writer.h>
-#include <data/sys-file-reader.h>
 #include <data/value.h>
 #include <data/vardict.h>
 #include <data/value-labels.h>
@@ -78,7 +80,7 @@ struct syswriter_info
 /*  A thin wrapper around sfm_reader */
 struct sysreader_info
 {
-  struct sfm_read_info opts;
+  struct any_read_info opts;
 
   /* A pointer to the reader. The reader is owned by the struct */
   struct casereader *reader;
@@ -633,13 +635,13 @@ INIT:
 
     opts.create_writeable = readonly ? ! SvIV (*readonly) : true;
     opts.compression = (compress && SvIV (*compress)
-                        ? SFM_COMP_SIMPLE
-                       : SFM_COMP_NONE);
+                        ? ANY_COMP_SIMPLE
+                       : ANY_COMP_NONE);
     opts.version = version ? SvIV (*version) : 3 ;
   }
 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;
@@ -753,28 +755,18 @@ 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;
- struct sfm_reader *r;
 
  sri = xmalloc (sizeof (*sri));
- r = sfm_open (fh);
- if (r)
-   {
-     sri->reader = sfm_decode (r, NULL, &dict, &sri->opts);
-     if (sri->reader)
-       sri->dict = create_pspp_dict (dict);
-     else
-       {
-        free (sri);
-        sri = NULL;
-       }
-   }
+ sri->reader = any_reader_open_and_decode (fh, NULL, &dict, &sri->opts);
+ if (sri->reader)
+   sri->dict = create_pspp_dict (dict);
  else
    {
      free (sri);
      sri = NULL;
-   } 
+   }
 
  RETVAL = sri;
  OUTPUT: