Uses string compare instead of !=/== when possible.
[egate.git] / www / z39util.tcl
index cafca96..8553519 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.31 1996/02/20 16:07:39 adam Exp $
+# $Id: z39util.tcl,v 1.33 1996/02/21 16:57:39 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -506,7 +506,7 @@ proc z39scan {setNo scanNo tno scanLines scanPos cache} {
     $zz callback ok-response
     $zz failback fail-response
     set thisHost [splitHostSpec $host]
-    if {$oldHost != $thisHost} {
+    if {[string compare $oldHost $thisHost]} {
         catch [list $zz disconnect]
 
         set sessionWait 0
@@ -665,7 +665,7 @@ proc z39search {setNo piggy tno elements} {
     $zz callback ok-response
     $zz failback fail-response
     set thisHost [splitHostSpec $host]
-    if {$oldHost != $thisHost} {
+    if {[string compare $oldHost $thisHost]} {
         catch [list $zz disconnect]
 
         set sessionWait 0
@@ -706,15 +706,19 @@ proc z39search {setNo piggy tno elements} {
             displayError "Cannot initialize target $thisHost" $u
             return 0
         }
-    } else {
-        if {[info exists hist($setNo,hits)] && \
-                ![catch [list $zz.$setNo smallSetUpperBound 0]]} {
-            return 1
+    } elseif {![catch  [list $zz.$setNo smallSetUpperBound 0]]} {
+        if {$tno > 0} {
+            if {[info exists hist($setNo,$tno,hits)]} {
+                return 1
+            }
+        } else {
+            if {[info exists hist($setNo,hits)]} {
+                return 1
+            }
         }
-        
     }
     ir-set $zz.$setNo $zz
-    
+
     if {![lindex $targets($host) 5]} {
         set elements {}
     }
@@ -805,13 +809,17 @@ proc search-m-response {setNo i start number} {
     egw_log debug "search-m-response"
     set status [z39$i.$setNo responseStatus]
     egw_log debug "search-m-response1"
-    if {[lindex $status 0] != "DBOSD"} {
+    if {[lindex $status 0] == "OK"} {
+        set nor 0
+    } elseif {[lindex $status 0] == "DBOSD"} {
+        set nor [z39$i.$setNo numberOfRecordsReturned]
+    } else {
         egw_log debug "search-m-response2"
         incr zleft -1
         set zstatus($i) 2
         return
     }
-    set nor [z39$i.$setNo numberOfRecordsReturned]
+    set hist($setNo,$i,hits) [z39$i.$setNo resultCount]
     egw_log debug "search-m-response3"
     set hist($setNo,$i,offset) [expr $start + $nor -1]
     if {[expr $nor + $start] > [z39$i.$setNo resultCount]} {
@@ -855,7 +863,7 @@ proc z39msearch {setNo elements start number cache} {
         }
         set oldHost [z39$i connect]
         set thisHost [splitHostSpec $host]
-        if {$oldHost != $thisHost} {
+        if {[string compare $oldHost $thisHost]} {
             catch {z39$i disconnect}
         }
         z39$i callback [list connect-m-response $i]
@@ -866,7 +874,7 @@ proc z39msearch {setNo elements start number cache} {
         set oldHost [z39$i connect]
         set host $hist($setNo,$i,host)
         set thisHost [splitHostSpec $host]
-        if {$oldHost == $thisHost} {
+        if {![string compare $oldhost $thisHost]} {
             continue
         }
         egw_log debug "old=$oldHost this=$thisHost"