X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2FPSPP.xs;fp=perl-module%2FPSPP.xs;h=923a472a8434fa0a802b2d51f13778806ce8b04f;hb=84e927df0b9a1686e9ea32f3327ea04312bbc348;hp=8800d0bdf4e0e87cbba8f89ec872029181395f59;hpb=f8cba0fb13cceeac43fe4b15e2d5b48798ab1a6e;p=pspp diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index 8800d0bdf4..923a472a84 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 @@ -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))