pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

perl module documentation patches, segfault


From: Ben Pfaff
Subject: perl module documentation patches, segfault
Date: Sun, 01 Feb 2009 14:50:01 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

I noticed that the Perl module documentation doesn't say how to
tell how you've arrived at the end of the dictionary.  It seems
that get_var() returns undef in this case, thus:

diff --git a/perl-module/lib/PSPP.pm b/perl-module/lib/PSPP.pm
--- a/perl-module/lib/PSPP.pm
+++ b/perl-module/lib/PSPP.pm
@@ -90,6 +90,8 @@ sub new
 =head3 get_var ($idx)
 
 Returns the C<idx>th variable from the dictionary.
+Returns undef if C<idx> is greater than or equal to the number
+of variables in the dictionary.
 
 =cut
 



Second, it seems that get_next_case() does not return a plain
array but a reference to one.  I would think that a plain array
would be more "natural" Perl, but here is a documentation fix-up
in case the choice was intentional:

diff --git a/perl-module/lib/PSPP.pm b/perl-module/lib/PSPP.pm
--- a/perl-module/lib/PSPP.pm
+++ b/perl-module/lib/PSPP.pm
@@ -487,7 +489,8 @@ Returns the dictionary associated with the reader.
 =head3 get_next_case ()
 
 Retrieves the next case from the reader.
-This method returns an array of scalars, each of which are the values of 
+This method returns a reference to an array of scalars, each of which
+are the values of
 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




Finally, I was working on a script to dump out a system file as
text.  Here's what I have so far.  It works, in that it dumps the
cases, but it segfaults after it reads the last one:

    #! /usr/bin/perl

    use PSPP;

    use strict;
    use warnings;

    my $reader = PSPP::Reader->open ($ARGV[0]);
    while (my @case = @{$reader->get_next_case ()}) {
        print join (',', @case), "\n";
    }

Is there a good way to debug this?  Running gdb on perl doesn't
seem very helpful, since the backtrace is just this:

    0x080b8fe9 in Perl_pp_rv2av ()
    (gdb) bt
    #0  0x080b8fe9 in Perl_pp_rv2av ()
    #1  0x080b17a9 in Perl_runops_standard ()
    #2  0x080ac5d0 in perl_run ()
    #3  0x08063ddd in main ()
    (gdb) 

Thanks,

Ben.
-- 
"Now I have to go wash my mind out with soap."
--Derick Siddoway




reply via email to

[Prev in Thread] Current Thread [Next in Thread]