X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2FPSPP.xs;h=923a472a8434fa0a802b2d51f13778806ce8b04f;hb=84e927df0b9a1686e9ea32f3327ea04312bbc348;hp=909ffe9e5324a500ff833f09d2e11a39e22d89af;hpb=f717491d5f3adb72858b4cb0647359cb6650b862;p=pspp diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index 909ffe9e53..923a472a84 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -1,22 +1,21 @@ /* PSPP - computes sample statistics. - Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, + 2020 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 the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ - + along with this program. If not, see . */ +#undef VERSION #include /* The Gnulib "strftime" module defines my_strftime in for use by @@ -140,7 +139,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); } } @@ -158,7 +157,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); } } @@ -273,7 +272,7 @@ CODE: free (input_format); } hmap_destroy (&dict->input_formats); - dict_destroy (dict->dict); + dict_unref (dict->dict); free (dict); } @@ -411,12 +410,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); @@ -588,7 +590,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 ) @@ -647,7 +648,7 @@ CODE: swi->opened = true; swi->dict_sv = dict_sv; SvREFCNT_inc (swi->dict_sv); - + RETVAL = swi; OUTPUT: RETVAL @@ -686,7 +687,6 @@ CODE: const struct variable **vv; size_t nv; struct ccase *c; - SV *sv; if ( av_len (av_case) >= dict_get_var_cnt (swi->dict->dict)) XSRETURN_UNDEF; @@ -696,37 +696,37 @@ CODE: dict_get_vars (swi->dict->dict, &vv, &nv, 1u << DC_ORDINARY | 1u << DC_SYSTEM); - for (sv = av_shift (av_case); SvOK (sv); sv = av_shift (av_case)) - { + for (SV *sv = av_shift (av_case); SvOK (sv); sv = av_shift (av_case)) + { const struct variable *v = vv[i++]; const struct fmt_spec *ifmt = find_input_format (swi->dict, v); /* If an input format has been set, then use it. - Otherwise just convert the raw value. - */ - if ( ifmt ) + Otherwise just convert the raw value. */ + if (ifmt) { - struct substring ss = ss_cstr (SvPV_nolen (sv)); - char *error; - bool ok; - - error = data_in (ss, SvUTF8(sv) ? UTF8: "iso-8859-1", ifmt->type, - case_data_rw (c, v), var_get_width (v), - dict_get_encoding (swi->dict->dict)); - ok = error == NULL; - free (error); - - if ( !ok ) - { - RETVAL = 0; - goto finish; - } + struct substring ss = ss_cstr (SvPV_nolen (sv)); + char *error = data_in (ss, + SvUTF8(sv) ? UTF8: "iso-8859-1", + ifmt->type, + case_data_rw (c, v), + var_get_width (v), + dict_get_encoding (swi->dict->dict)); + if (error) + { + free (error); + RETVAL = 0; + SvREFCNT_dec_NN (sv); + case_unref (c); + goto finish; + } } else { - scalar_to_value (case_data_rw (c, v), sv, v); + scalar_to_value (case_data_rw (c, v), sv, v); } - } + SvREFCNT_dec_NN (sv); + } /* The remaining variables must be sysmis or blank string */ while (i < dict_get_var_cnt (swi->dict->dict)) @@ -751,7 +751,6 @@ 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, "UTF-8", fh_default_properties () ); @@ -788,7 +787,7 @@ CODE: casenumber n = casereader_get_case_cnt (sfr->reader); if (n == CASENUMBER_MAX) ret = &PL_sv_undef; - else + else ret = newSViv (n); RETVAL = ret; OUTPUT: