From: mike Date: Wed, 14 May 2008 13:32:55 +0000 (+0000) Subject: Simpler API to record_get() no longer requires the unused by-reference parameter X-Git-Tag: cpan_1_22~2 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=beda31b7cd0715d4830891459f75f5ddff416489;p=ZOOM-Perl-moved-to-github.git Simpler API to record_get() no longer requires the unused by-reference parameter --- diff --git a/samples/net-z3950-zoom/async.pl b/samples/net-z3950-zoom/async.pl index 470cfff..3e55859 100644 --- a/samples/net-z3950-zoom/async.pl +++ b/samples/net-z3950-zoom/async.pl @@ -1,4 +1,4 @@ -# $Id: async.pl,v 1.3 2006-11-02 17:48:25 mike Exp $ +# $Id: async.pl,v 1.4 2008-05-14 13:34:00 mike Exp $ # # See ../README for a description of this program. # perl -I../../blib/lib -I../../blib/arch zoomtst3.pl [...] @@ -69,14 +69,13 @@ if ($i != 0) { # Go through all records at target $size = 10 if $size > 10; for (my $pos = 0; $pos < $size; $pos++) { - my $len = 0; # length of buffer rec print "$tname: fetching ", $pos+1, " of $size\n"; my $tmp = Net::Z3950::ZOOM::resultset_record($r[$i], $pos); if (!defined $tmp) { print "$tname: can't get record ", $pos+1, "\n"; next; } - my $rec = Net::Z3950::ZOOM::record_get($tmp, "render", $len); + my $rec = Net::Z3950::ZOOM::record_get($tmp, "render"); if (!defined $rec) { print "$tname: can't render record ", $pos+1, "\n"; next; diff --git a/samples/net-z3950-zoom/zoomtst1.pl b/samples/net-z3950-zoom/zoomtst1.pl index 47fc660..bbb7841 100644 --- a/samples/net-z3950-zoom/zoomtst1.pl +++ b/samples/net-z3950-zoom/zoomtst1.pl @@ -1,4 +1,4 @@ -# $Id: zoomtst1.pl,v 1.3 2006-11-02 17:48:25 mike Exp $ +# $Id: zoomtst1.pl,v 1.4 2008-05-14 13:34:00 mike Exp $ # # See ../README for a description of this program. # perl -I../../blib/lib -I../../blib/arch zoomtst1.pl @@ -37,8 +37,7 @@ print "Query '$query' found $n records\n"; for my $i (0..$n-1) { my $rec = Net::Z3950::ZOOM::resultset_record($rs, $i); print "=== Record ", $i+1, " of $n ===\n"; - my $dummy = 0; - print Net::Z3950::ZOOM::record_get($rec, "render", $dummy); + print Net::Z3950::ZOOM::record_get($rec, "render"); } Net::Z3950::ZOOM::resultset_destroy($rs); diff --git a/samples/net-z3950-zoom/zoomtst3.pl b/samples/net-z3950-zoom/zoomtst3.pl index 8f044f6..0525251 100644 --- a/samples/net-z3950-zoom/zoomtst3.pl +++ b/samples/net-z3950-zoom/zoomtst3.pl @@ -1,4 +1,4 @@ -# $Id: zoomtst3.pl,v 1.8 2006-11-02 17:48:25 mike Exp $ +# $Id: zoomtst3.pl,v 1.9 2008-05-14 13:34:00 mike Exp $ # # See ../README for a description of this program. # perl -I../../blib/lib -I../../blib/arch zoomtst3.pl [...] @@ -69,14 +69,13 @@ for (my $i = 0; $i < $n; $i++) { # Go through all records at target $size = 10 if $size > 10; for (my $pos = 0; $pos < $size; $pos++) { - my $len = 0; # length of buffer rec print "$tname: fetching ", $pos+1, " of $size\n"; my $tmp = Net::Z3950::ZOOM::resultset_record($r[$i], $pos); if (!defined $tmp) { print "$tname: can't get record ", $pos+1, "\n"; next; } - my $rec = Net::Z3950::ZOOM::record_get($tmp, "render", $len); + my $rec = Net::Z3950::ZOOM::record_get($tmp, "render"); if (!defined $rec) { print "$tname: can't render record ", $pos+1, "\n"; next; diff --git a/t/1-Net-Z3950-ZOOM.t b/t/1-Net-Z3950-ZOOM.t index bab5712..d530145 100644 --- a/t/1-Net-Z3950-ZOOM.t +++ b/t/1-Net-Z3950-ZOOM.t @@ -1,4 +1,4 @@ -# $Id: 1-Net-Z3950-ZOOM.t,v 1.16 2007-09-14 10:36:13 mike Exp $ +# $Id: 1-Net-Z3950-ZOOM.t,v 1.17 2008-05-14 13:32:55 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 1-Net-Z3950-ZOOM.t' @@ -82,11 +82,10 @@ my $n = Net::Z3950::ZOOM::resultset_size($rs); ok($n == 1, "found 1 record as expected"); my $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); -my $len = 0; -my $data = Net::Z3950::ZOOM::record_get($rec, "render", $len); +my $data = Net::Z3950::ZOOM::record_get($rec, "render"); ok($data =~ /^245 +\$a ISOTOPIC DATES OF ROCKS AND MINERALS$/m, "rendered record has expected title"); -my $raw = Net::Z3950::ZOOM::record_get($rec, "raw", $len); +my $raw = Net::Z3950::ZOOM::record_get($rec, "raw"); ok($raw =~ /^00966n/, "raw record contains expected header"); Net::Z3950::ZOOM::resultset_destroy($rs); diff --git a/t/12-query.t b/t/12-query.t index 459cbc9..768c27e 100644 --- a/t/12-query.t +++ b/t/12-query.t @@ -1,4 +1,4 @@ -# $Id: 12-query.t,v 1.10 2006-11-03 09:50:58 mike Exp $ +# $Id: 12-query.t,v 1.11 2008-05-14 13:32:55 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 12-query.t' @@ -147,8 +147,7 @@ sub check_record { my $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); ok(1, "got record idenfified by query"); - my $len = 0; - my $data = Net::Z3950::ZOOM::record_get($rec, "render", $len); + my $data = Net::Z3950::ZOOM::record_get($rec, "render"); ok(1, "rendered record"); ok($data =~ /^035 \$a ESDD0006$/m, "record is the expected one"); diff --git a/t/13-resultset.t b/t/13-resultset.t index 046bb7b..73d8e06 100644 --- a/t/13-resultset.t +++ b/t/13-resultset.t @@ -1,4 +1,4 @@ -# $Id: 13-resultset.t,v 1.9 2006-11-28 16:47:19 mike Exp $ +# $Id: 13-resultset.t,v 1.10 2008-05-14 13:32:55 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 13-resultset.t' @@ -33,21 +33,20 @@ ok($errcode == 238, "can't fetch CANMARC ($errmsg)"); Net::Z3950::ZOOM::resultset_option_set($rs, preferredRecordSyntax => "usmarc"); $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); -my $len = 0; -my $data1 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +my $data1 = Net::Z3950::ZOOM::record_get($rec, "render"); Net::Z3950::ZOOM::resultset_option_set($rs, elementSetName => "b"); -my $data2 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +my $data2 = Net::Z3950::ZOOM::record_get($rec, "render"); ok($data2 eq $data1, "record doesn't know about RS options"); # Now re-fetch record from result-set with new option $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); -$data2 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +$data2 = Net::Z3950::ZOOM::record_get($rec, "render"); ok(length($data2) < length($data1), "re-fetched record is brief, old was full"); Net::Z3950::ZOOM::resultset_option_set($rs, preferredRecordSyntax => "xml"); $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); my $cloned = Net::Z3950::ZOOM::record_clone($rec); ok(defined $cloned, "cloned record"); -$data2 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +$data2 = Net::Z3950::ZOOM::record_get($rec, "render"); ok($data2 =~ //i, "option for XML syntax is honoured"); # Now we test ZOOM_resultset_record_immediate(), which should only @@ -57,7 +56,7 @@ ok($data2 =~ /<title>/i, "option for XML syntax is honoured"); # $rec = Net::Z3950::ZOOM::resultset_record_immediate($rs, 0); ok(defined $rec, "prefetched record obtained with _immediate()"); -my $data3 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +my $data3 = Net::Z3950::ZOOM::record_get($rec, "render"); ok($data3 eq $data2, "_immediate record renders as expected"); $rec = Net::Z3950::ZOOM::resultset_record_immediate($rs, 1); ok(!defined $rec, "non-prefetched record obtained with _immediate()"); @@ -72,7 +71,7 @@ ok(defined $rec, "_immediate(0) ok after resultset_records()"); # Fetch all records at once using records() $tmp = Net::Z3950::ZOOM::resultset_records($rs, 0, 2, 1); ok(@$tmp == 2, "resultset_records() returned two records"); -$data3 = Net::Z3950::ZOOM::record_get($tmp->[0], "render", $len); +$data3 = Net::Z3950::ZOOM::record_get($tmp->[0], "render"); ok($data3 eq $data2, "record returned from resultset_records() renders as expected"); $rec = Net::Z3950::ZOOM::resultset_record_immediate($rs, 1); ok(defined $rec, "_immediate(1) ok after resultset_records()"); @@ -82,7 +81,7 @@ ok(1, "destroyed result-set"); Net::Z3950::ZOOM::connection_destroy($conn); ok(1, "destroyed connection"); -$data3 = Net::Z3950::ZOOM::record_get($cloned, "render", $len); +$data3 = Net::Z3950::ZOOM::record_get($cloned, "render"); ok(1, "rendered cloned record after its result-set was destroyed"); ok($data3 eq $data2, "render of clone as expected"); Net::Z3950::ZOOM::record_destroy($cloned); diff --git a/t/14-sorting.t b/t/14-sorting.t index ea74c6c..7b13815 100644 --- a/t/14-sorting.t +++ b/t/14-sorting.t @@ -1,4 +1,4 @@ -# $Id: 14-sorting.t,v 1.8 2006-11-02 17:48:26 mike Exp $ +# $Id: 14-sorting.t,v 1.9 2008-05-14 13:32:55 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 14-sorting.t' @@ -33,8 +33,7 @@ my $previous = ""; # Sorts before all legitimate titles foreach my $i (1 .. $n) { my $rec = Net::Z3950::ZOOM::resultset_record($rs, $i-1); ok(defined $rec, "got record $i of $n"); - my $len = 0; - my $raw = Net::Z3950::ZOOM::record_get($rec, "raw", $len); + my $raw = Net::Z3950::ZOOM::record_get($rec, "raw"); my $marc = new_from_usmarc MARC::Record($raw); my $title = $marc->title(); ok($title ge $previous, "title '$title' ge previous '$previous'"); @@ -52,8 +51,7 @@ $previous = "z"; # Sorts after all legitimate titles foreach my $i (1 .. $n) { my $rec = Net::Z3950::ZOOM::resultset_record($rs, $i-1); ok(defined $rec, "got record $i of $n"); - my $len = 0; - my $raw = Net::Z3950::ZOOM::record_get($rec, "raw", $len); + my $raw = Net::Z3950::ZOOM::record_get($rec, "raw"); my $marc = new_from_usmarc MARC::Record($raw); my $title = $marc->title(); ok($title le $previous, "title '$title' le previous '$previous'"); diff --git a/t/18-charset.t b/t/18-charset.t index f4d02c1..3971474 100644 --- a/t/18-charset.t +++ b/t/18-charset.t @@ -1,4 +1,4 @@ -# $Id: 18-charset.t,v 1.1 2006-04-06 13:08:14 mike Exp $ +# $Id: 18-charset.t,v 1.2 2008-05-14 13:32:55 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 18-charset.t' @@ -30,14 +30,13 @@ ok($n == 1, "found $n records (expected 1)"); my $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); ok(defined $rec, "got first record"); -my $len = 0; -my $xml = Net::Z3950::ZOOM::record_get($rec, "xml", $len); +my $xml = Net::Z3950::ZOOM::record_get($rec, "xml"); ok(defined $xml, "got XML"); ok($xml =~ m(<subfield code="b">aus der .* f\350ur), "got MARC pre-accented composed characters"); -$xml = Net::Z3950::ZOOM::record_get($rec, "xml;charset=marc-8,utf-8", $len); +$xml = Net::Z3950::ZOOM::record_get($rec, "xml;charset=marc-8,utf-8"); ok(defined $xml, "got XML in Unicode"); ok($xml =~ m(<subfield code="b">aus der .* für),