X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2FPSPP.xs;h=ba43fa58a8b33f22e1e1c356a8cb42ccced5f65a;hb=d573464ad00fdb72c27e3c36d8f862ef99249431;hp=0895f641a8577570fe5aff2a011d356fc1cf72f8;hpb=b3fcf4b1644bf4af9b5eb7b0b0f8856c51118128;p=pspp diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index 0895f641a8..ba43fa58a8 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -1,5 +1,5 @@ /* PSPP - computes sample statistics. - Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 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 @@ -17,6 +17,7 @@ 02110-1301, USA. */ +#undef VERSION #include /* The Gnulib "strftime" module defines my_strftime in for use by @@ -32,6 +33,8 @@ #include "ppport.h" #include "minmax.h" +#include +#include #include #include #include @@ -46,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -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; @@ -139,7 +141,7 @@ scalar_to_value (union value *val, SV *scalar, const struct variable *var) const char *p = SvPV (scalar, len); int width = var_get_width (var); value_set_missing (val, width); - memcpy (value_str_rw (val, width), p, len); + memcpy (val->s, p, len); } } @@ -157,7 +159,7 @@ value_to_scalar (const union value *val, const struct variable *var) else { int width = var_get_width (var); - return newSVpvn (value_str (val, width), width); + return newSVpvn (val->s, width); } } @@ -272,7 +274,7 @@ CODE: free (input_format); } hmap_destroy (&dict->input_formats); - dict_destroy (dict->dict); + dict_unref (dict->dict); free (dict); } @@ -410,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); @@ -424,7 +429,7 @@ set_label (var, label) struct variable *var; char *label CODE: - var_set_label (var, label, false); + var_set_label (var, label); void @@ -587,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 ) @@ -632,12 +636,14 @@ INIT: SV** version = hv_fetch(opt_h, "version", 7, 0); opts.create_writeable = readonly ? ! SvIV (*readonly) : true; - opts.compress = compress ? SvIV (*compress) : false; + opts.compression = (compress && SvIV (*compress) + ? 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; @@ -748,16 +754,14 @@ 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)); - sri->reader = sfm_open_reader (fh, NULL, &dict, &sri->opts); - - if ( sri->reader != NULL) + sri->reader = any_reader_open_and_decode (fh, NULL, &dict, &sri->opts); + if (sri->reader) sri->dict = create_pspp_dict (dict); else {