X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=perl-module%2FPSPP.xs;h=25effb9216b77364c9641b0a479b397cd25dea37;hb=c9ae1257ff1983917d2d39de53c743ae72ba16ee;hp=ca3f873ae110be68520c63a09c4f4601ca623c06;hpb=f550aee00a62fe1d8baf62d83cd7efef6cc2ee92;p=pspp-builds.git diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index ca3f873a..25effb92 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -34,6 +34,7 @@ #include "minmax.h" #include #include +#include #include #include #include @@ -166,6 +167,8 @@ MODULE = PSPP MODULE = PSPP PACKAGE = PSPP +PROTOTYPES: ENABLE + void onBoot (ver) const char *ver @@ -589,7 +592,7 @@ CODE: struct file_handle *fh = fh_create_file (NULL, name, fh_default_properties () ); struct sysfile_info *sfi = xmalloc (sizeof (*sfi)); - dict_set_encoding (dict, "UTF-8"); + dict_set_encoding (dict, UTF8); sfi->writer = sfm_open_writer (fh, dict, opts); sfi->dict = dict; sfi->opened = true; @@ -654,10 +657,16 @@ CODE: if ( ifmt ) { struct substring ss = ss_cstr (SvPV_nolen (sv)); - if ( ! data_in (ss, LEGACY_NATIVE, ifmt->type, 0, 0, 0, - sfi->dict, - case_data_rw (c, v), - var_get_width (v)) ) + 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 (sfi->dict)); + ok = error == NULL; + free (error); + + if ( !ok ) { RETVAL = 0; goto finish; @@ -676,7 +685,8 @@ CODE: union value *val = case_data_rw (c, v); value_set_missing (val, var_get_width (v)); } - RETVAL = casewriter_write (sfi->writer, c); + casewriter_write (sfi->writer, c); + RETVAL = 1; finish: free (vv); OUTPUT: