PSPP::Reader::get_next_case() was documented to return a list,
but actually it returned a reference to a list. This commit
changes the behavior to match the documentation.
This also fixes the behavior on reading past the end of the file.
Previously this was documented to return undef but caused a
segfault in practice. Now it returns an empty list.
Also increase PSPP version number from 0.7.1 to 0.7.2 at John
Darrington's request, to alert users of the previous version of
the Perl interface.
dnl Initialize.
AC_PREREQ(2.60)
dnl Initialize.
AC_PREREQ(2.60)
-AC_INIT([pspp],[0.7.1],[bug-gnu-pspp@gnu.org])
+AC_INIT([pspp],[0.7.2],[bug-gnu-pspp@gnu.org])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE
get_next_case (sfr)
struct sysreader_info *sfr;
get_next_case (sfr)
struct sysreader_info *sfr;
- if (! (c = casereader_read (sfr->reader)))
- {
- RETVAL = 0;
- }
- else
+ if (c = casereader_read (sfr->reader))
- AV *av_case = (AV *) sv_2mortal ((SV *) newAV());
+ EXTEND (SP, dict_get_var_cnt (sfr->dict));
for (v = 0; v < dict_get_var_cnt (sfr->dict); ++v )
{
const struct variable *var = dict_get_var (sfr->dict, v);
const union value *val = case_data (c, var);
for (v = 0; v < dict_get_var_cnt (sfr->dict); ++v )
{
const struct variable *var = dict_get_var (sfr->dict, v);
const union value *val = case_data (c, var);
- av_push (av_case, value_to_scalar (val, var));
+ PUSHs (sv_2mortal (value_to_scalar (val, var)));
- RETVAL = newRV ((SV *) av_case);
the data in the system file.
The first call to C<get_next_case> after C<open> has been called retrieves
the first case in the system file. Each subsequent call retrieves the next
the data in the system file.
The first call to C<get_next_case> after C<open> has been called retrieves
the first case in the system file. Each subsequent call retrieves the next
-case. If there are no more cases to be read, the function returns undef.
+case. If there are no more cases to be read, the function returns an empty
+list.
If the case contains system missing values, these values are set to the
empty string.
If the case contains system missing values, these values are set to the
empty string.
print MYFILE "$_ => $vl->{$_}\n" for keys %$vl;
}
print MYFILE "$_ => $vl->{$_}\n" for keys %$vl;
}
- while (my $c = $sf->get_next_case () )
+ while (my @c = $sf->get_next_case () )
{
for ($v = 0; $v < $dict->get_var_cnt(); $v++)
{
{
for ($v = 0; $v < $dict->get_var_cnt(); $v++)
{
- print MYFILE "val$v: \"@$c[$v]\"\n";
+ print MYFILE "val$v: \"$c[$v]\"\n";
my $output = PSPP::Sysfile->new ("$tempdir/out.sav", $dict);
my $output = PSPP::Sysfile->new ("$tempdir/out.sav", $dict);
- while (my $c = $input->get_next_case () )
+ while (my (@c) = $input->get_next_case () )
- $output->append_case ($c);
+ $output->append_case (\@c);
my $dict = $sf->get_dict ();
my $dict = $sf->get_dict ();
- my $c = $sf->get_next_case ();
+ my (@c) = $sf->get_next_case ();
my $var = $dict->get_var (0);
my $var = $dict->get_var (0);
my $formatted = PSPP::format_value ($val, $var);
my $str = gmtime ($val - PSPP::PERL_EPOCH);
print "Formatted string is \"$formatted\"\n";
my $formatted = PSPP::format_value ($val, $var);
my $str = gmtime ($val - PSPP::PERL_EPOCH);
print "Formatted string is \"$formatted\"\n";
my $dict = $sf->get_dict ();
my $dict = $sf->get_dict ();
- my $c = $sf->get_next_case ();
+ my (@c) = $sf->get_next_case ();
my $stringvar = $dict->get_var (0);
my $numericvar = $dict->get_var (2);
my $stringvar = $dict->get_var (0);
my $numericvar = $dict->get_var (2);
ok ( !PSPP::value_is_missing ($val, $stringvar), "Missing Value Negative String");
ok ( !PSPP::value_is_missing ($val, $stringvar), "Missing Value Negative String");
ok ( !PSPP::value_is_missing ($val, $numericvar), "Missing Value Negative Num");
ok ( !PSPP::value_is_missing ($val, $numericvar), "Missing Value Negative Num");
- $c = $sf->get_next_case ();
- $c = $sf->get_next_case ();
+ @c = $sf->get_next_case ();
+ @c = $sf->get_next_case ();
ok ( PSPP::value_is_missing ($val, $stringvar), "Missing Value Positive");
ok ( PSPP::value_is_missing ($val, $stringvar), "Missing Value Positive");
- $c = $sf->get_next_case ();
- $val = @$c[2];
+ @c = $sf->get_next_case ();
+ $val = $c[2];
ok ( PSPP::value_is_missing ($val, $numericvar), "Missing Value Positive SYS");
ok ( PSPP::value_is_missing ($val, $numericvar), "Missing Value Positive SYS");
- $c = $sf->get_next_case ();
- $val = @$c[2];
+ @c = $sf->get_next_case ();
+ $val = $c[2];
ok ( PSPP::value_is_missing ($val, $numericvar), "Missing Value Positive Num");
}
ok ( PSPP::value_is_missing ($val, $numericvar), "Missing Value Positive Num");
}