Eskil

Artifact [636e1617ea]
Login

Artifact 636e1617ea3e96a15fa9d9e15c5911664e0fa7f7:


##Eskil Plugin : Compare after filtering lines

# Example file for a plugin.
# A plugin must start exactly like this one.
# The text after : is the summary you can get at the command line

# This plugin only compares lines that match a pattern.
# Example usage:
# eskil -plugin grep -plugininfo "-re {<t>}" f1 f2

# 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} {
    if {[catch {llength $::Info}]} {
        puts $cho "Grep plugin needs -plugininfo parameter to be a list"
        return 1
    }
    # Look for parameters in info string
    set opts(-re) "."
    foreach {opt val} $::Info {
        set opts($opt) $val
    }
    while {[gets $chi line] >= 0} {
        if {[regexp -- $opts(-re) $line]} {
            puts $cho $line
        }
    }
    # Signal that the file after processing should be used both
    # for comparison and for displaying.
    return 1
}