Eskil

Check-in [9379b0b64f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Support -nocase in dirdiff. Repaired plugins for dirdiff (broken by multi plugin).
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9379b0b64faf9953efad7dcbe79103c162a559056dd87cea0d9f29f202711200
User & Date: peter 2017-12-07 16:57:53.045
Context
2017-12-12
23:12
Upgraded tablelist check-in: 520fb06e31 user: peter tags: trunk
2017-12-07
16:57
Support -nocase in dirdiff. Repaired plugins for dirdiff (broken by multi plugin). check-in: 9379b0b64f user: peter tags: trunk
2017-12-06
23:15
Handle GIT revisions better for directory diff. check-in: be2d8c443d user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Changes.




1
2
3
4
5
6
7




2017-12-07
 Handle GIT revisions better for directory diff.
 
2017-12-05
 Bumped revision to 2.8.0

2017-12-04
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
2017-12-07
 Support -nocase in dirdiff.
 Repaired plugins for dirdiff (broken by multi plugin).

2017-12-07
 Handle GIT revisions better for directory diff.
 
2017-12-05
 Bumped revision to 2.8.0

2017-12-04
Changes to plugins/nocase.tcl.
20
21
22
23
24
25
26























        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
}






























>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        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
}
Changes to src/dirdiff.tcl.
77
78
79
80
81
82
83
84
85
86

87
88
89
90
91
92
93
        file stat $file1 stat1
        file stat $file2 stat2
    }
    # If contents is not checked, same size is enough to be equal
    if {$stat1(size) == $stat2(size) && $::Pref(dir,comparelevel) == 0} {
        return 1
    }
    set anyPlugin [expr {$::eskil(.dirdiff,plugin) ne "" && \
                                 [dict get $::eskil(.dirdiff,pluginpinfo) dir]}]
    set ignorekey $::Pref(dir,ignorekey)

    # Different size is enough when doing binary compare
    if {$stat1(size) != $stat2(size) && $::Pref(dir,comparelevel) == 2 \
        && !$ignorekey && !$anyPlugin} {
        return 0
    }
    # Same size and time is always considered equal
    if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {







|
|

>







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        file stat $file1 stat1
        file stat $file2 stat2
    }
    # If contents is not checked, same size is enough to be equal
    if {$stat1(size) == $stat2(size) && $::Pref(dir,comparelevel) == 0} {
        return 1
    }
    set anyPlugin [expr {$::eskil(.dirdiff,plugin,1) ne "" && \
                                 [dict get $::eskil(.dirdiff,pluginpinfo,1) dir]}]
    set ignorekey $::Pref(dir,ignorekey)
    set nocase    $::Pref(nocase)
    # Different size is enough when doing binary compare
    if {$stat1(size) != $stat2(size) && $::Pref(dir,comparelevel) == 2 \
        && !$ignorekey && !$anyPlugin} {
        return 0
    }
    # Same size and time is always considered equal
    if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151





152
153

154
155
156
157
158





159
160

161
162
163
164
165
166
167
            if {$::Pref(dir,comparelevel) == 2} {
                fconfigure $ch1 -translation binary
                fconfigure $ch2 -translation binary
            }
            # Allow a plugin to do its thing
            if {$anyPlugin} {
                #puts "PLUGIN!"
                $::eskil(.dirdiff,plugin) eval \
                        [list array set ::Pref [array get ::Pref]]
                $::eskil(.dirdiff,plugin) eval [list set ::argv $::eskil(argv)]
                interp share {} $ch1 $::eskil(.dirdiff,plugin)
                interp share {} $ch2 $::eskil(.dirdiff,plugin)
                set info1 [dict create name $file1 size $stat1(size)]
                set info2 [dict create name $file2 size $stat2(size)]
                set eq [$::eskil(.dirdiff,plugin) eval \
                                [list FileCompare $ch1 $ch2 $info1 $info2]]
                set allow [dict get $::eskil(.dirdiff,pluginpinfo) allow]
                if {$allow} {
                    $::eskil(.dirdiff,plugin) eval close $ch1
                    $::eskil(.dirdiff,plugin) eval close $ch2
                } else {
                    $::eskil(.dirdiff,plugin) invokehidden close $ch1
                    $::eskil(.dirdiff,plugin) invokehidden close $ch2
                }
            }

            if {$ignorekey} {
                # Assume that all keywords are in the first block
                set f1 [read $ch1 $bufsz]
                set f2 [read $ch2 $bufsz]
                regsub -all {\$\w+:[^\$]*\$} $f1 {} f1
                regsub -all {\$\w+:[^\$]*\$} $f2 {} f2
                # Compensate for any change in length
                if {[string length $f1] < [string length $f2]} {
                    append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]]
                }
                if {[string length $f2] < [string length $f1]} {
                    append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]]
                }





                if {![string equal $f1 $f2]} {
                    set eq 0

                }
            }
            while {$eq == 2 && ![eof $ch1] && ![eof $ch2]} {
                set f1 [read $ch1 $bufsz]
                set f2 [read $ch2 $bufsz]





                if {![string equal $f1 $f2]} {
                    set eq 0

                }
            }
            if {$eq == 2 && (![eof $ch1] || ![eof $ch2])} {
                set eq 0
            }
            # Errors during close are not interesting
            catch {close $ch1}







|

|
|
|


|

|

|
|

|
|
















>
>
>
>
>
|
|
>





>
>
>
>
>
|
|
>







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
            if {$::Pref(dir,comparelevel) == 2} {
                fconfigure $ch1 -translation binary
                fconfigure $ch2 -translation binary
            }
            # Allow a plugin to do its thing
            if {$anyPlugin} {
                #puts "PLUGIN!"
                $::eskil(.dirdiff,plugin,1) eval \
                        [list array set ::Pref [array get ::Pref]]
                $::eskil(.dirdiff,plugin,1) eval [list set ::argv $::eskil(argv)]
                interp share {} $ch1 $::eskil(.dirdiff,plugin,1)
                interp share {} $ch2 $::eskil(.dirdiff,plugin,1)
                set info1 [dict create name $file1 size $stat1(size)]
                set info2 [dict create name $file2 size $stat2(size)]
                set eq [$::eskil(.dirdiff,plugin,1) eval \
                                [list FileCompare $ch1 $ch2 $info1 $info2]]
                set allow [dict get $::eskil(.dirdiff,pluginpinfo,1) allow]
                if {$allow} {
                    $::eskil(.dirdiff,plugin,1) eval close $ch1
                    $::eskil(.dirdiff,plugin,1) eval close $ch2
                } else {
                    $::eskil(.dirdiff,plugin,1) invokehidden close $ch1
                    $::eskil(.dirdiff,plugin,1) invokehidden close $ch2
                }
            }

            if {$ignorekey} {
                # Assume that all keywords are in the first block
                set f1 [read $ch1 $bufsz]
                set f2 [read $ch2 $bufsz]
                regsub -all {\$\w+:[^\$]*\$} $f1 {} f1
                regsub -all {\$\w+:[^\$]*\$} $f2 {} f2
                # Compensate for any change in length
                if {[string length $f1] < [string length $f2]} {
                    append f1 [read $ch1 [expr {[string length $f2] - [string length $f1]}]]
                }
                if {[string length $f2] < [string length $f1]} {
                    append f2 [read $ch2 [expr {[string length $f1] - [string length $f2]}]]
                }
                if {$nocase} {
                    if {![string equal -nocase $f1 $f2]} {
                        set eq 0
                    }
                } else {
                    if {![string equal $f1 $f2]} {
                        set eq 0
                    }
                }
            }
            while {$eq == 2 && ![eof $ch1] && ![eof $ch2]} {
                set f1 [read $ch1 $bufsz]
                set f2 [read $ch2 $bufsz]
                if {$nocase} {
                    if {![string equal -nocase $f1 $f2]} {
                        set eq 0
                    }
                } else {
                    if {![string equal $f1 $f2]} {
                        set eq 0
                    }
                }
            }
            if {$eq == 2 && (![eof $ch1] || ![eof $ch2])} {
                set eq 0
            }
            # Errors during close are not interesting
            catch {close $ch1}
1392
1393
1394
1395
1396
1397
1398

1399
1400
1401
1402
1403
1404
1405
1406
proc makeDirDiffWin {} {
    if {![info exists ::dirdiff(leftDir)]} {
        set ::dirdiff(leftDir) ""
    }
    if {![info exists ::dirdiff(rightDir)]} {
        set ::dirdiff(rightDir) ""
    }

    set ::eskil(.dirdiff,plugin) ""
    foreach {item val} $::eskil(defaultopts) {
        set ::eskil(.dirdiff,$item) $val
    }

    # Support -r for directory diff
    set revs {}
    array set opts $::eskil(defaultopts)







>
|







1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
proc makeDirDiffWin {} {
    if {![info exists ::dirdiff(leftDir)]} {
        set ::dirdiff(leftDir) ""
    }
    if {![info exists ::dirdiff(rightDir)]} {
        set ::dirdiff(rightDir) ""
    }
    # TODO, multi plugin for dirdiff?
    set ::eskil(.dirdiff,plugin,1) ""
    foreach {item val} $::eskil(defaultopts) {
        set ::eskil(.dirdiff,$item) $val
    }

    # Support -r for directory diff
    set revs {}
    array set opts $::eskil(defaultopts)