[Net-z3950] [PATCH] Net::Z3950 0.28 misc fixes

Dave Mitchell davem at fdgroup.com
Thu May 16 17:29:00 CEST 2002


Mike, 
here here's a patch for Net::Z39.50 for you to use or ignore as your fancy
takes you :-)

It fixes:

1) if you do the following:
	do a search, don't retrieve any records, do another search,
	then retrieve a record,
it'll try to deref an undef ref.

2) A server I'm interacting with sometimes gives a present response that
claims to have a record, but doesn't actually contain one. Hardy
Net::Z3950's fault, but this patch allows it to cope gracefully.

3) a typo in receive.c that was harmless as long as OID components are
never 0.

Dave.


--- yazwrap/receive.c-	Thu May 16 13:08:34 2002
+++ yazwrap/receive.c	Thu May 16 13:15:05 2002
@@ -570,7 +570,7 @@ static SV *translateOID(Odr_oid *x)
     *buf = '\0';
     for (i = 0; x[i] >= 0; i++) {
 	sprintf(buf + strlen(buf), "%d", (int) x[i]);
-	if (x[i+1] >- 0)
+	if (x[i+1] >= 0)
 	    strcat(buf, ".");
     }
 
--- Z3950/ResultSet.pm-	Thu May 16 12:46:37 2002
+++ Z3950/ResultSet.pm	Thu May 16 14:37:32 2002
@@ -198,6 +198,7 @@
 
     my $esn = $this->option('elementSetName');
     my $records = $this->{records}->{$esn};
+    return unless defined $records;
     my $n = @$records;
 
     ###	If our interface to the C function makePresentRequest allowed
@@ -316,6 +317,18 @@
     my $esn = $this->option('elementSetName');
     my $records = $this->{records}->{$esn};
     my $rawrecs = $apdu->records();
+
+    # Some badly-behaved servers claim records but don't include any.
+    # Fake up an error in this case.
+
+    unless (defined $rawrecs) {
+	$rawrecs = bless {
+			diagnosticSetId => '1.2.840.10003.4.1', # bib1 diag
+			condition	=> 14, # syserr presenting recs
+			addinfo => 'no records supplied by server',
+		    }, 'Net::Z3950::APDU::DefaultDiagFormat';
+    }
+
     if ($rawrecs->isa('Net::Z3950::APDU::DefaultDiagFormat')) {
 	# Now what?  We want to report the error back to the caller,
 	# but we got here from a callback from the event loop, and




More information about the Net-z3950 mailing list