/* PSPP - computes sample statistics.
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
- 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 <http://www.gnu.org/licenses/>. */
+#undef VERSION
#include <config.h>
/* The Gnulib "strftime" module defines my_strftime in <config.h> for use by
#include "ppport.h"
#include "minmax.h"
+#include <libpspp/hmap.h>
+#include <libpspp/hash-functions.h>
#include <libpspp/message.h>
#include <libpspp/version.h>
#include <libpspp/i18n.h>
#include <data/identifier.h>
#include <data/settings.h>
#include <data/sys-file-writer.h>
-#include <data/sys-file-reader.h>
#include <data/value.h>
#include <data/vardict.h>
#include <data/value-labels.h>
/* 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;
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);
}
}
else
{
int width = var_get_width (var);
- return newSVpvn (value_str (val, width), width);
+ return newSVpvn (val->s, width);
}
}
free (input_format);
}
hmap_destroy (&dict->input_formats);
- dict_destroy (dict->dict);
+ dict_unref (dict->dict);
free (dict);
}
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);
struct variable *var;
char *label
CODE:
- var_set_label (var, label, false);
+ var_set_label (var, label);
void
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 )
opts.create_writeable = readonly ? ! SvIV (*readonly) : true;
opts.compression = (compress && SvIV (*compress)
- ? SFM_COMP_SIMPLE
- : SFM_COMP_NONE);
+ ? 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;
swi->opened = true;
swi->dict_sv = dict_sv;
SvREFCNT_inc (swi->dict_sv);
-
+
RETVAL = swi;
OUTPUT:
RETVAL
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;
- struct sfm_reader *r;
sri = xmalloc (sizeof (*sri));
- r = sfm_open (fh);
- if (r)
- {
- sri->reader = sfm_decode (r, NULL, &dict, &sri->opts);
- if (sri->reader)
- sri->dict = create_pspp_dict (dict);
- else
- {
- free (sri);
- sri = NULL;
- }
- }
+ sri->reader = any_reader_open_and_decode (fh, NULL, &dict, &sri->opts);
+ if (sri->reader)
+ sri->dict = create_pspp_dict (dict);
else
{
free (sri);
sri = NULL;
- }
+ }
RETVAL = sri;
OUTPUT:
casenumber n = casereader_get_case_cnt (sfr->reader);
if (n == CASENUMBER_MAX)
ret = &PL_sv_undef;
- else
+ else
ret = newSViv (n);
RETVAL = ret;
OUTPUT: