Tcl Library Source Code

Artifact [a6cd1b9081]
Login

Artifact a6cd1b9081583b8d739f24143a193c9443bb36aa:

Attachment "refchan.patch" to ticket [5465d70388] added by andy 2017-08-02 01:17:51.
Index: lib/virtchannel_base/memchan.tcl
==================================================================
--- lib/virtchannel_base/memchan.tcl
+++ lib/virtchannel_base/memchan.tcl
@@ -129,20 +129,20 @@
 	# Compute the new location per the arguments.
 
 	set max [string length $content]
 	switch -exact -- $base {
 	    start   { set newloc $offset}
-	    current { set newloc [expr {$at  + $offset    }] }
-	    end     { set newloc [expr {$max + $offset - 1}] }
+	    current { set newloc [expr {$at  + $offset}] }
+	    end     { set newloc [expr {$max + $offset}] }
 	}
 
 	# Check if the new location is beyond the range given by the
 	# content.
 
 	if {$newloc < 0} {
 	    return -code error "Cannot seek before the start of the channel"
-	} elseif {$newloc >= $max} {
+	} elseif {$newloc > $max} {
 	    # We can seek beyond the end of the current contents, add
 	    # a block of zeros.
 	    append content [binary format @[expr {$newloc - $max}]]
 	}
 

Index: lib/virtchannel_base/string.tcl
==================================================================
--- lib/virtchannel_base/string.tcl
+++ lib/virtchannel_base/string.tcl
@@ -87,20 +87,20 @@
 	# Compute the new location per the arguments.
 
 	set max [string length $content]
 	switch -exact -- $base {
 	    start   { set newloc $offset}
-	    current { set newloc [expr {$at  + $offset    }] }
-	    end     { set newloc [expr {$max + $offset - 1}] }
+	    current { set newloc [expr {$at  + $offset}] }
+	    end     { set newloc [expr {$max + $offset}] }
 	}
 
 	# Check if the new location is beyond the range given by the
 	# content.
 
 	if {$newloc < 0} {
 	    return -code error "Cannot seek before the start of the channel"
-	} elseif {$newloc >= $max} {
+	} elseif {$newloc > $max} {
 	    return -code error "Cannot seek after the end of the channel"
 	}
 
 	# Commit to new location, switch readable events, and report.
 	set at $newloc

Index: lib/virtchannel_base/variable.tcl
==================================================================
--- lib/virtchannel_base/variable.tcl
+++ lib/virtchannel_base/variable.tcl
@@ -142,20 +142,20 @@
 	# Compute the new location per the arguments.
 
 	set max [string length $content]
 	switch -exact -- $base {
 	    start   { set newloc $offset}
-	    current { set newloc [expr {$at  + $offset    }] }
-	    end     { set newloc [expr {$max + $offset - 1}] }
+	    current { set newloc [expr {$at  + $offset}] }
+	    end     { set newloc [expr {$max + $offset}] }
 	}
 
 	# Check if the new location is beyond the range given by the
 	# content.
 
 	if {$newloc < 0} {
 	    return -code error "Cannot seek before the start of the channel"
-	} elseif {$newloc >= $max} {
+	} elseif {$newloc > $max} {
 	    # We can seek beyond the end of the current contents, add
 	    # a block of zeros.
 	    append content [binary format @[expr {$newloc - $max}]]
 	}