Index: openacs-4/packages/acs-tcl/tcl/util-diff-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/util-diff-procs.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-tcl/tcl/util-diff-procs.tcl 4 Dec 2018 20:50:18 -0000 1.8 +++ openacs-4/packages/acs-tcl/tcl/util-diff-procs.tcl 4 Dec 2018 20:53:39 -0000 1.9 @@ -35,25 +35,25 @@ # each chunk is either 'deleted', 'added', or 'changed' set i 0 foreach chunk $result { - ns_log notice "\n$chunk\n" + ns_log notice "\n$chunk\n" set action [lindex $chunk 0] - lassign [lindex $chunk 1] old_index1 old_index2 - lassign [lindex $chunk 2] new_index1 new_index2 - + lassign [lindex $chunk 1] old_index1 old_index2 + lassign [lindex $chunk 2] new_index1 new_index2 + while {$i < $old_index1} { lappend output [lindex $old $i] incr i } if { $action eq "changed" } { - if {$show_old_p} { - lappend output - foreach item [lrange $old $old_index1 $old_index2] { - lappend output [string trim $item] - } - lappend output - } + if {$show_old_p} { + lappend output + foreach item [lrange $old $old_index1 $old_index2] { + lappend output [string trim $item] + } + lappend output + } lappend output foreach item [lrange $new $new_index1 $new_index2] { lappend output [string trim $item] @@ -79,7 +79,7 @@ lappend output } } - + # add any remaining words at the end. while {$i < $len1} { lappend output [lindex $old $i] @@ -117,52 +117,52 @@ set frag $old set old_list [list] while {$frag ne ""} { - if {![regexp "(\[^<]*)(<(/?)(\[^ \r\n\t>]+)(\[^>]*)>)?(.*)" $frag match pretag fulltag close tag tagbody frag]} { + if {![regexp "(\[^<]*)(<(/?)(\[^ \r\n\t>]+)(\[^>]*)>)?(.*)" $frag match pretag fulltag close tag tagbody frag]} { # should never get here since above will match anything. ns_log Error "util_close_html_tag - NO MATCH: should never happen! frag=$frag" - lappend old_list $frag - set frag {} - } - if {$pretag ne ""} { - set pretag [string map {\n " "} $pretag] - set pretag2 [list] - foreach element [split $pretag " "] { - if {[string trim $element] ne ""} { - lappend pretag2 [string trim $element] - } - } - if {[llength $pretag2]} { - lappend old_list {*}$pretag2 - } - } - if {$fulltag ne ""} { - lappend old_list $fulltag - } + lappend old_list $frag + set frag {} + } + if {$pretag ne ""} { + set pretag [string map {\n " "} $pretag] + set pretag2 [list] + foreach element [split $pretag " "] { + if {[string trim $element] ne ""} { + lappend pretag2 [string trim $element] + } + } + if {[llength $pretag2]} { + lappend old_list {*}$pretag2 + } + } + if {$fulltag ne ""} { + lappend old_list $fulltag + } } set frag $new set new_list [list] while {$frag ne ""} { - if {![regexp "(\[^<]*)(<(/?)(\[^ \r\n\t>]+)(\[^>]*)>)?(.*)" $frag match pretag fulltag close tag tagbody frag]} { + if {![regexp "(\[^<]*)(<(/?)(\[^ \r\n\t>]+)(\[^>]*)>)?(.*)" $frag match pretag fulltag close tag tagbody frag]} { # should never get here since above will match anything. - lappend new_list $frag - set frag {} - } - if {$pretag ne ""} { - set pretag [string map {\n " "} $pretag] - set pretag2 [list] - foreach element [split $pretag " "] { - if {[string trim $element] ne ""} { - lappend pretag2 [string trim $element] - } - } - if {[llength $pretag2]} { - lappend new_list {*}$pretag2 - } - } - if {$fulltag ne ""} { - lappend new_list $fulltag - } + lappend new_list $frag + set frag {} + } + if {$pretag ne ""} { + set pretag [string map {\n " "} $pretag] + set pretag2 [list] + foreach element [split $pretag " "] { + if {[string trim $element] ne ""} { + lappend pretag2 [string trim $element] + } + } + if {[llength $pretag2]} { + lappend new_list {*}$pretag2 + } + } + if {$fulltag ne ""} { + lappend new_list $fulltag + } } # tcllib procs to get a list of differences between 2 lists # see: http://tcllib.sourceforge.net/doc/struct_list.html @@ -178,43 +178,43 @@ set action [lindex $chunk 0] - lassign [lindex $chunk 1] old_index1 old_index2 - lassign [lindex $chunk 2] new_index1 new_index2 + lassign [lindex $chunk 1] old_index1 old_index2 + lassign [lindex $chunk 2] new_index1 new_index2 while {$i < $old_index1} { lappend output [lindex $old_list $i] incr i } if { $action eq "changed" } { - if {$show_old_p} { - #ns_log notice "adding <@d@>" - lappend output <@d@> - foreach item [lrange $old_list $old_index1 $old_index2] { - if {![string match "<*>" [string trim $item]]} { + if {$show_old_p} { + #ns_log notice "adding <@d@>" + lappend output <@d@> + foreach item [lrange $old_list $old_index1 $old_index2] { + if {![string match "<*>" [string trim $item]]} { #ns_log notice "deleting item '${item}'" - # showing deleted tags is a bad idea. - lappend output [string trim $item] - } else { - ns_log notice "SKIPPED DELETE of tag $item" - } + # showing deleted tags is a bad idea. + lappend output [string trim $item] + } else { + ns_log notice "SKIPPED DELETE of tag $item" + } - } - #ns_log notice "adding " - lappend output - } - #ns_log notice "adding <@a@>" - lappend output <@a@> + } + #ns_log notice "adding " + lappend output + } + #ns_log notice "adding <@a@>" + lappend output <@a@> foreach item [lrange $new_list $new_index1 $new_index2] { - if {![string match "<*>" [string trim $item]]} { - #ns_log notice "adding item '${item}'" - lappend output [string trim $item] - } else { - lappend output ${item}<@a@> - #ns_log notice "adding${item}<@a@>" - } + if {![string match "<*>" [string trim $item]]} { + #ns_log notice "adding item '${item}'" + lappend output [string trim $item] + } else { + lappend output ${item}<@a@> + #ns_log notice "adding${item}<@a@>" + } } - #ns_log notice "adding " - lappend output + #ns_log notice "adding " + lappend output incr i [expr {$old_index2 - $old_index1 + 1}] } elseif { $action eq "deleted" } { lappend output <@d@> @@ -225,21 +225,21 @@ incr i [expr {$old_index2 - $old_index1 + 1}] } elseif { $action eq "added" } { while {$i < $old_index2} { - #ns_log notice "unchanged item" + #ns_log notice "unchanged item" lappend output [lindex $old_list $i] incr i } lappend output <@a@> foreach item [lrange $new_list $new_index1 $new_index2] { - if {![string match "<*>" [string trim $item]]} { - #ns_log notice "adding item" - lappend output [string trim $item] - } + if {![string match "<*>" [string trim $item]]} { + #ns_log notice "adding item" + lappend output [string trim $item] + } } lappend output } } - + # add any remaining words at the end. while {$i < $len1} { lappend output [lindex $old_list $i]