##Eskil Plugin : Case insensitive matching
#
# This plugin implements case insensitive matching, similar to the
# -nocase flag.
# Example file for a plugin.
# A plugin's first line must start exactly like this one.
# The text after : is the summary you can get at the command line
# A plugin must define this procedure to do the job.
# side: left or right
# chi: An input channel for reading the original file.
# cho: An output channel for writing the processed file.
proc PreProcess {side chi cho} {
while {1} {
# Read data in large chunks for speed
set data [read $chi 100000]
if {$data eq ""} break
# Use lower case for comparison, thus getting case insensitive
puts -nonewline $cho [string tolower $data]
}
# Signal that the file after processing should be used only for
# comparison, not for displaying.
# The processed file must match the original line-wise.
return 0
}
# To be used in directory diff, a plugin must define this procedure.
# ch1: An input channel for reading the first file.
# ch2: An input channel for reading the second file.
# info1: A dictionary with info about the first file.
# info2: A dictionary with info about the second file.
# Info dictionaries contain at least elements "name" and "size".
proc FileCompare {ch1 ch2 info1 info2} {
set bufsz 65536
while 1 {
set f1 [read $ch1 $bufsz]
set f2 [read $ch2 $bufsz]
if {$f1 eq "" && $f2 eq ""} break
if { ! [string equal -nocase $f1 $f2]} {
# Returning 0 signals "not equal"
return 0
}
}
# Return 1 means "equal"
# Return 2 means "equal this far", and lets normal compare take over
return 1
}