X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=perl-module%2FPSPP.xs;h=46e9ba132d094fe446444d1ba4a047793cce0881;hb=facd7a838036eed0166478e34f601d9c7d97a88a;hp=8800d0bdf4e0e87cbba8f89ec872029181395f59;hpb=facb4a1ad3c9e8b2cdf55824680eed2afb91aebe;p=pspp diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index 8800d0bdf4..46e9ba132d 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -1,5 +1,6 @@ /* 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 @@ -221,7 +222,7 @@ CODE: union value uv; char *s; make_value_from_scalar (&uv, val, var); - s = data_out (&uv, var_get_encoding (var), fmt); + s = data_out (&uv, var_get_encoding (var), fmt, settings_get_fmt_settings ()); value_destroy (&uv, var_get_width (var)); ret = newSVpv (s, fmt->w); free (s); @@ -376,7 +377,7 @@ CODE: struct input_format *input_format; struct variable *v; - op_fmt = fmt_for_output_from_input (&ip_fmt); + op_fmt = fmt_for_output_from_input (&ip_fmt, settings_get_fmt_settings ()); v = dict_create_var (dict->dict, name, fmt_is_string (op_fmt.type) ? op_fmt.w : 0); if ( NULL == v ) @@ -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,38 @@ 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, + settings_get_fmt_settings (), + 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))