Author: MartÃn Ferrari <martin.ferrari@gmail.com> Description: The return parameters handling was incorrect and resulted in weird behaviour. But it somehow passed the tests. --- a/lib/Device/Cdio/ISO9660/FS.pm +++ b/lib/Device/Cdio/ISO9660/FS.pm @@ -132,9 +132,6 @@ sub find_lsn { my @values = perliso9660::fs_find_lsn($self->{cd}, $lsn); - # Remove the two input parameters - splice(@values, 0, 2) if @values > 2; - return Device::Cdio::ISO9660::stat_array_to_href(@values); } @@ -195,9 +192,6 @@ sub readdir { my @values = perliso9660::fs_readdir($self->{cd}, $dirname); - # Remove the two input parameters - splice(@values, 0, 2) if @values > 2; - my @result = (); while (@values) { push @result, Device::Cdio::ISO9660::stat_array_to_href(@values); @@ -310,9 +304,6 @@ sub stat { @values = perliso9660::fs_stat($self->{cd}, $path); } - # Remove the input parameters - splice(@values, 0, 2) if @values > 2; - return undef if !@values; return Device::Cdio::ISO9660::stat_array_to_href(@values); } --- a/lib/Device/Cdio/ISO9660/IFS.pm +++ b/lib/Device/Cdio/ISO9660/IFS.pm @@ -489,9 +489,6 @@ sub readdir { my @values = perliso9660::ifs_readdir($self->{iso9660}, $dirname); - # Remove the two input parameters - splice(@values, 0, 2) if @values > 2; - my @result = (); while (@values) { push @result, Device::Cdio::ISO9660::stat_array_to_href(@values); @@ -625,9 +622,6 @@ sub stat { @values = perliso9660::ifs_stat($self->{iso9660}, $path); } - # Remove the input parameters - splice(@values, 0, 2) if @values > 2; - return undef if !@values; return Device::Cdio::ISO9660::stat_array_to_href(@values); } --- a/perliso9660.swg +++ b/perliso9660.swg @@ -116,12 +116,11 @@ typedef iso9660_stat_t IsoStat_t; PPCODE: /* Have perl compute the length of the string using strlen() */ - XPUSHs(sv_2mortal(newSVpv(p_statbuf->filename, 0))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->lsn))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->size))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->secsize))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->type))); - argvi += 7; + %append_output(sv_2mortal(newSVpv(p_statbuf->filename, 0))); + %append_output(sv_2mortal(newSViv(p_statbuf->lsn))); + %append_output(sv_2mortal(newSViv(p_statbuf->size))); + %append_output(sv_2mortal(newSViv(p_statbuf->secsize))); + %append_output(sv_2mortal(newSViv(p_statbuf->type))); free (p_statbuf); out: ; } @@ -130,30 +129,23 @@ typedef iso9660_stat_t IsoStat_t; // $1 is of type IsoStatList_t CdioList_t *p_entlist = result; CdioListNode_t *p_entnode; - unsigned int num = 0; if (!result) goto out; PPCODE: - /* Figure out how many items in the array */ - _CDIO_LIST_FOREACH (p_entnode, p_entlist) { - num +=5; - } - /* For each element in the array of strings, create a new * mortalscalar, and stuff it into the above array. */ _CDIO_LIST_FOREACH (p_entnode, p_entlist) { iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (p_entnode); /* Have perl compute the length of the string using strlen() */ - XPUSHs(sv_2mortal(newSVpv(p_statbuf->filename, 0))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->lsn))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->size))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->secsize))); - XPUSHs(sv_2mortal(newSViv(p_statbuf->type))); + %append_output(sv_2mortal(newSVpv(p_statbuf->filename, 0))); + %append_output(sv_2mortal(newSViv(p_statbuf->lsn))); + %append_output(sv_2mortal(newSViv(p_statbuf->size))); + %append_output(sv_2mortal(newSViv(p_statbuf->secsize))); + %append_output(sv_2mortal(newSViv(p_statbuf->type))); } _cdio_list_free (p_entlist, true); - argvi += num + 2; out: ; }