? modules/fileinput
? modules/ftp/example
? modules/ftpd/examples
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/ChangeLog,v
retrieving revision 1.130
diff -u -r1.130 ChangeLog
--- ChangeLog	27 Mar 2002 03:05:03 -0000	1.130
+++ ChangeLog	1 Apr 2002 19:52:55 -0000
@@ -1,3 +1,9 @@
+2002-04-01  Andreas Kupries  <andreas_kupries@users.sourceforge.net>
+
+	* struct (matrix): Fixed bug #532791.
+
+	* doctools: Fixed SF Bug #535382.
+
 2002-03-25  Andreas Kupries  <andreas_kupries@users.sourceforge.net>
 
 	* doctools: Implemented FR #530059 and FR #527029.
Index: modules/doctools/ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/doctools/ChangeLog,v
retrieving revision 1.15
diff -u -r1.15 ChangeLog
--- modules/doctools/ChangeLog	1 Apr 2002 14:58:05 -0000	1.15
+++ modules/doctools/ChangeLog	1 Apr 2002 19:52:55 -0000
@@ -2,7 +2,7 @@
 
 	* Committed changes to list generation (better generation of
 	  whitespace for HTML, allowing hints). Only the HTML formatter
-	  currently acknowledges hints.
+	  currently acknowledges hints. This fixes SF Bug #535382.
 
 2002-03-26  Andreas Kupries  <andreas_kupries@users.sourceforge.net>
 
Index: modules/struct/ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/struct/ChangeLog,v
retrieving revision 1.28
diff -u -r1.28 ChangeLog
--- modules/struct/ChangeLog	1 Apr 2002 14:58:06 -0000	1.28
+++ modules/struct/ChangeLog	1 Apr 2002 19:52:55 -0000
@@ -1,5 +1,12 @@
 2002-04-01  Andreas Kupries  <andreas_kupries@users.sourceforge.net>
 
+	* matrix.tcl: Fixed SF Tcllib #532791 about unsetting of elements
+	  in linked arrays as reported by Ken Jones
+	  <kenj@users.sourceforge.net>. Unsetting an element in a linked
+	  array now sets the corresponding cell in the matrix to the empty
+	  string, and the corresponding elements in other linked arrays
+	  are now unset too.
+
 	* tree.man: New file, doctools manpage.
 
 2002-03-25  Andreas Kupries  <andreas_kupries@users.sourceforge.net>
Index: modules/struct/matrix.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/struct/matrix.tcl,v
retrieving revision 1.9
diff -u -r1.9 matrix.tcl
--- modules/struct/matrix.tcl	25 Mar 2002 18:54:35 -0000	1.9
+++ modules/struct/matrix.tcl	1 Apr 2002 19:52:55 -0000
@@ -29,7 +29,8 @@
     # - rowh    cache of rowheights
     # - link    information about linked arrays
     # - lock    boolean flag to disable MatTraceIn while in MatTraceOut [#532783]
-    
+    # - unset   string used to convey information about 'unset' traces from MatTraceIn to MatTraceOut.
+
     # counter is used to give a unique name for unnamed matrixs
     variable counter 0
 
@@ -101,12 +102,14 @@
 	variable rowh
 	variable link
 	variable lock
+	variable unset
 
-	array set data {}
-	array set colw {}
-	array set rowh {}
-	array set link {}
-	set       lock 0
+	array set data  {}
+	array set colw  {}
+	array set rowh  {}
+	array set link  {}
+	set       lock  0
+	set       unset {}
     }
 
     # Create the command to manipulate the matrix
@@ -301,7 +304,7 @@
     set mode   exact
     set nocase 0
 
-    while 1 {
+    while {1} {
 	switch -glob -- [lindex $args 0] {
 	    -exact - -glob - -regexp {
 		set mode [string range [lindex $args 0] 1 end]
@@ -1981,8 +1984,13 @@
     upvar ::struct::matrix::matrix${name}::lock lock
     if {$lock} {return}
 
-    if {![string compare $op u]} {
-	# External array was destroyed, perform automatic unlink.
+    # We have to cover two possibilities when encountering an "unset" operation ...
+    # 1. The external array was destroyed: perform automatic unlink.
+    # 2. An individual element was unset:  Set the corresponding cell to the empty string.
+    #    See SF Tcllib Bug #532791.
+
+    if {(![string compare $op u]) && ($idx == {})} {
+	# Possibility 1: Array was destroyed
 	$name unlink $avar
 	return
     }
@@ -2001,6 +2009,25 @@
     # Use standard method to propagate the change.
     # => Get automatically index checks, cache updates, ...
 
+    if {![string compare $op u]} {
+	# Unset possibility 2: Element was unset.
+	# Note: Setting the cell to the empty string will
+	# invoke MatTraceOut for this array and thus try
+	# to recreate the destroyed element of the array.
+	# We don't want this. But we do want to propagate
+	# the change to other arrays, as "unset". To do
+	# all of this we use another state variable to
+	# signal this situation.
+
+	upvar ::struct::matrix::matrix${name}::unset unset
+	set unset $avar
+
+	$name set cell $c $r ""
+
+	set unset {}
+	return
+    }
+
     $name set cell $c $r $array($idx)
     return
 }
@@ -2020,6 +2047,14 @@
 proc ::struct::matrix::MatTraceOut {avar name var idx op} {
     # Propagate changes in the matrix data array into the linked array.
 
+    upvar ::struct::matrix::matrix${name}::unset unset
+
+    if {![string compare $avar $unset]} {
+	# Do not change the variable currently unsetting
+	# one of its elements.
+	return
+    }
+
     upvar ::struct::matrix::matrix${name}::lock lock
     set lock 1 ; # Disable MatTraceIn [#532783]
 
@@ -2035,7 +2070,18 @@
 	foreach {c r} [split $idx ,] break
     }
 
-    set array($c,$r) $data($idx)
+    if {$unset != {}} {
+	# We are currently propagating the unset of an
+	# element in a different linked array to this
+	# array. We make sure that this is an unset too.
+
+	unset array($c,$r)
+    } else {
+	set array($c,$r) $data($idx)
+    }
     set lock 0
     return
 }
+
+
+
Index: modules/struct/matrix.test
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/struct/matrix.test,v
retrieving revision 1.6
diff -u -r1.6 matrix.test
--- modules/struct/matrix.test	25 Mar 2002 18:54:35 -0000	1.6
+++ modules/struct/matrix.test	1 Apr 2002 19:52:55 -0000
@@ -40,6 +40,7 @@
 	    puts $chan "$matrix add rows    $r"
 	    puts $chan "$matrix add columns $c"
 	    puts $chan "$matrix set rect 0 0 [list [$matrix get rect 0 0 end end]]"
+	    return ""
 	}
 	default {
 	    return -code error "Unknown method $cmd"
@@ -1605,7 +1606,27 @@
 
     mymatrix destroy
     set result
-} {{0,0 1 0,1 a 1,0 2 1,1 b 2,0 3 2,1 c} {{1 2 3} {a b c}}}
+} {{0,0 1 0,1 a 1,0 2 1,1 b 2,0 3 2,1 c} {{{} 2 3} {a b c}}}
+
+test matrix-9.12a {unset in linked array} {
+    matrix mymatrix
+    mymatrix add columns 3
+    mymatrix add row {1 2 3}
+    mymatrix add row {a b c}
+
+    catch {unset a}
+    mymatrix link a
+    catch {unset b}
+    mymatrix link b
+
+    set     result [list]
+    lappend result [aget a]
+    unset a(0,0)
+    lappend result [aget b]
+
+    mymatrix destroy
+    set result
+} {{0,0 1 0,1 a 1,0 2 1,1 b 2,0 3 2,1 c} {0,1 a 1,0 2 1,1 b 2,0 3 2,1 c}}
 
 test matrix-9.13 {operation on linked matrix} {
     catch {unset a}
@@ -1617,7 +1638,7 @@
     set result [mymatrix get rect 0 0 end end]
     mymatrix destroy
     set result
-} {{1 2 3 {}} {a b c d}}}
+} {{1 2 3 {}} {a b c d}}
 
 test 10.1 {search errors} {
     matrix mymatrix
