Eskil

Check-in [61d3fb5962]
Login

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

Overview
Comment:Added ignorenewline.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61d3fb5962a192aee6dbb366d876b4fa7eadec4f
User & Date: peter 2007-02-24 21:03:09.000
Context
2007-02-24
21:03
corrected Mount syntaxx check-in: ddd494ee03 user: peter tags: trunk
21:03
Added ignorenewline. check-in: 61d3fb5962 user: peter tags: trunk
2007-02-23
05:30
Added check-in: 4a0f71fd51 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/eskil.tcl.
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Stop Tk from meddling with the command line by copying it first.
set ::eskil(argv) $::argv
set ::eskil(argc) $::argc
set ::argv {}
set ::argc 0

set debug 0
set diffver "Version 2.1+ 2007-02-17"
set ::thisScript [file join [pwd] [info script]]

# Do initalisations for needed packages and globals.
# This is not run until needed to speed up command line error reporting.
proc Init {} {
    package require Tk 8.4
    catch {package require textSearch}







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Stop Tk from meddling with the command line by copying it first.
set ::eskil(argv) $::argv
set ::eskil(argc) $::argc
set ::argv {}
set ::argc 0

set debug 0
set diffver "Version 2.1+ 2007-02-24"
set ::thisScript [file join [pwd] [info script]]

# Do initalisations for needed packages and globals.
# This is not run until needed to speed up command line error reporting.
proc Init {} {
    package require Tk 8.4
    catch {package require textSearch}
199
200
201
202
203
204
205
206
207



208
209
210
211
212
213
214
            catch {file delete $f}
        }
        set ::tmpfiles {}
    }
}

# Insert lineno and text
proc insertLine {top n line text {tag {}}} {
    $::widgets($top,wDiff$n) insert end "$text\n" $tag



    if {$tag != ""} {
        set tag "hl$::HighLightCount $tag"
    }
    $::widgets($top,wLine$n) insert end [myFormL $line] $tag
}

proc emptyLine {top n {highlight 1}} {







|

>
>
>







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
            catch {file delete $f}
        }
        set ::tmpfiles {}
    }
}

# Insert lineno and text
proc insertLine {top n line text {tag {}} {linetag {}}} {
    $::widgets($top,wDiff$n) insert end "$text\n" $tag
    if {$linetag ne ""} {
        append tag " $linetag"
    }
    if {$tag != ""} {
        set tag "hl$::HighLightCount $tag"
    }
    $::widgets($top,wLine$n) insert end [myFormL $line] $tag
}

proc emptyLine {top n {highlight 1}} {
283
284
285
286
287
288
289

290
291
292
293
294
295
296
297
298










































































299
300
301
302
303
304
305
    }
    incr doingLine1
    incr doingLine2
}

# Insert two blocks of lines in the compare windows.
# Returns number of lines used to display the blocks

proc insertMatchingBlocks {top block1 block2} {
    global doingLine1 doingLine2

    # A large block may take time.  Give a small warning.
    if {[llength $block1] * [llength $block2] > 1000} {
        set ::widgets($top,eqLabel) "!"
        #puts "Eskil warning: Analyzing a large block. ($size1 $size2)"
        update idletasks
    }











































































    set apa [compareBlocks $block1 $block2]

    set t1 0
    set t2 0
    foreach c $apa {
        if {$c eq "c"} {







>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
    }
    incr doingLine1
    incr doingLine2
}

# Insert two blocks of lines in the compare windows.
# Returns number of lines used to display the blocks
# Negative if the block should be viewed as equal
proc insertMatchingBlocks {top block1 block2} {
    global doingLine1 doingLine2

    # A large block may take time.  Give a small warning.
    if {[llength $block1] * [llength $block2] > 1000} {
        set ::widgets($top,eqLabel) "!"
        #puts "Eskil warning: Analyzing a large block. ($size1 $size2)"
        update idletasks
    }

    # Detect if only newlines has changed within the block, e.g.
    # when rearranging newlines.
    # Rearranging newlines in comment blocks usually leads to
    # words moving across "*", ignore * too.
    if {$::eskil(ignorenewline)} {
        set map {{ } {} \t {}}
        set RE {\n\s*\*?|\s}
        set equal 0
        set visible [expr {$::eskil(ignorenewline) == 1}]

        if 1 {
            set block1nospace [regsub -all $RE [join $block1 \n] {}]
            set block2nospace [regsub -all $RE [join $block2 \n] {}]
            if {$block1nospace eq $block2nospace} {
                set equal 1
            }
        } else {
            set block1nospace [string map $map [join $block1 ""]]
            set block2nospace [string map $map [join $block2 ""]]
            if {$block1nospace eq $block2nospace} {
                set equal 1
            } else {
                # Look for newlines rearranged in a comment block.
                set block1nostar [string map {* {}} $block1nospace]
                set block2nostar [string map {* {}} $block2nospace]
                if {$block1nostar eq $block2nostar} {
                    set equal 1
                }
            }
        }
        if {$equal} {
            if {$visible} {set tag change} else {set tag {}}
            # Just insert the blocks
            foreach line $block1 {
                insertLine $top 1 $doingLine1 $line {} $tag
                incr doingLine1
            }
            foreach line $block2 {
                insertLine $top 2 $doingLine2 $line {} $tag
                incr doingLine2
            }
            set n1 [llength $block1]
            set n2 [llength $block2]
            if {$n1 <= $n2} {
                for {set t $n1} {$t < $n2} {incr t} {
                    if {$visible} {
                        $::widgets($top,wDiff1) insert end "\n" "padding change"
                        $::widgets($top,wLine1) insert end "\n" hl$::HighLightCount
                    } else {
                        emptyLine $top 1
                    }
                }
            } elseif {$n2 < $n1} {
                if {$visible} {
                    for {set t $n2} {$t < $n1} {incr t} {
                        $::widgets($top,wDiff2) insert end "\n" "padding change"
                        $::widgets($top,wLine2) insert end "\n" hl$::HighLightCount
                    }
                } else {
                    emptyLine $top 2
                }
            }
            if {$visible} {
                $::widgets($top,wDiff1) insert end "\n" "padding change"
                $::widgets($top,wDiff2) insert end "\n" "padding change"
                $::widgets($top,wLine1) insert end "\n" hl$::HighLightCount
                $::widgets($top,wLine2) insert end "\n" hl$::HighLightCount
                return [expr {($n1 > $n2 ? $n1 : $n2) + 1}]
            } else {
                return [expr {-($n1 > $n2 ? $n1 : $n2)}]
            }
        }
    }

    set apa [compareBlocks $block1 $block2]

    set t1 0
    set t2 0
    foreach c $apa {
        if {$c eq "c"} {
463
464
465
466
467
468
469
470
471




472
473
474
475
476
477
478
            }
            set block2 {}
            for {set t 0} {$t < $n2} {incr t} {
                gets $ch2 apa
                lappend block2 $apa
            }
            set apa [insertMatchingBlocks $top $block1 $block2]

            addChange $top $apa change $line1 $n1 $line2 $n2




        } else {
            # No extra parsing at all.
            for {set t 0} {$t < $n1} {incr t} {
                gets $ch1 apa
                insertLine $top 1 $doingLine1 $apa $tag1
                incr doingLine1
            }







|
|
>
>
>
>







541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
            }
            set block2 {}
            for {set t 0} {$t < $n2} {incr t} {
                gets $ch2 apa
                lappend block2 $apa
            }
            set apa [insertMatchingBlocks $top $block1 $block2]
            if {$apa >= 0} {
                addChange $top $apa change $line1 $n1 $line2 $n2
            } else {
                addMapLines $top [expr {-$apa}]
                return 1
            }
        } else {
            # No extra parsing at all.
            for {set t 0} {$t < $n1} {incr t} {
                gets $ch1 apa
                insertLine $top 1 $doingLine1 $apa $tag1
                incr doingLine1
            }
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062

1063
1064

1065
1066
1067
1068
1069
1070
1071
            incr doingLine2
        }
    }

    set t 0
    foreach i $diffres {
        foreach {line1 n1 line2 n2} $i break
        doText $top $ch1 $ch2 $n1 $n2 $line1 $line2
        if {$::diff($top,limitlines) && \
                ($::diff($top,mapMax) > $::diff($top,limitlines))} {
            break
        }

        bindHighlight $top
        incr ::HighLightCount


        # Get one update when the screen has been filled.
        # Show the first diff.
        if {$firstview && $::diff($top,mapMax) > 100} {
            set firstview 0
            showDiff $top 0
            update idletasks







|




>
|
|
>







1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
            incr doingLine2
        }
    }

    set t 0
    foreach i $diffres {
        foreach {line1 n1 line2 n2} $i break
        set notvisible [doText $top $ch1 $ch2 $n1 $n2 $line1 $line2]
        if {$::diff($top,limitlines) && \
                ($::diff($top,mapMax) > $::diff($top,limitlines))} {
            break
        }
        if {$notvisible != 1} {
            bindHighlight $top
            incr ::HighLightCount
        }

        # Get one update when the screen has been filled.
        # Show the first diff.
        if {$firstview && $::diff($top,mapMax) > 100} {
            set firstview 0
            showDiff $top 0
            update idletasks
3010
3011
3012
3013
3014
3015
3016

3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032


3033
3034
3035
3036
3037
3038
3039
                command line to run diff, Eskil will do so unless
                this option is specified.
  -dir        : Start in directory diff mode. Ignores other args.
  -clip       : Start in clip diff mode. Ignores other args.
  -patch      : View patch file.
  -context <n>: Show only differences, with <n> lines of context.
  -foreach    : Open one diff window per file listed.


  -noparse    : Eskil can perform analysis of changed blocks to
  -line       : improve display. See online help for details.
  -smallblock : The default. Do block analysis on small blocks.
  -block      : Full block analysis. This can be slow if there
                are large change blocks.

  -char       : The analysis of changes can be done on either
  -word       : character or word basis. -char is the default.

  -noignore   : Don't ignore any whitespace.
  -b          : Ignore space changes. Default.
  -w          : Ignore all spaces.
  -nocase     : Ignore case changes.
  -nodigit    : Ignore digit changes.
  -nokeyword  : In directory diff, ignore $ Keywords: $



  -prefix <str> : Care mainly about words starting with "str".
  -preprocess <pair> : TBW

  -r <ver>    : Version info for version control mode.

  -conflict   : Treat file as a merge conflict file and enter merge







>
















>
>







3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
                command line to run diff, Eskil will do so unless
                this option is specified.
  -dir        : Start in directory diff mode. Ignores other args.
  -clip       : Start in clip diff mode. Ignores other args.
  -patch      : View patch file.
  -context <n>: Show only differences, with <n> lines of context.
  -foreach    : Open one diff window per file listed.
  -close      : Close windows with no changes.

  -noparse    : Eskil can perform analysis of changed blocks to
  -line       : improve display. See online help for details.
  -smallblock : The default. Do block analysis on small blocks.
  -block      : Full block analysis. This can be slow if there
                are large change blocks.

  -char       : The analysis of changes can be done on either
  -word       : character or word basis. -char is the default.

  -noignore   : Don't ignore any whitespace.
  -b          : Ignore space changes. Default.
  -w          : Ignore all spaces.
  -nocase     : Ignore case changes.
  -nodigit    : Ignore digit changes.
  -nokeyword  : In directory diff, ignore $ Keywords: $
  -nonewline  : Try to ignore newline changes.
  -nonewline+ : Try to ignore newline changes, and don't display.

  -prefix <str> : Care mainly about words starting with "str".
  -preprocess <pair> : TBW

  -r <ver>    : Version info for version control mode.

  -conflict   : Treat file as a merge conflict file and enter merge
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
        return
    }
    
    set allOpts {
        -w --help -help -b -noignore -i -nocase -nodigit -nokeyword -prefix
        -noparse -line -smallblock -block -char -word -limit -nodiff -dir
        -clip -patch -browse -conflict -print -server -o -r -context
        -foreach -preprocess -close
    }

    # If the first option is "--query", use it to ask about options.
    if {$::eskil(argc) == 2 && [lindex $::eskil(argv) 0] == "--query"} {
        set arg [lindex $::eskil(argv) 1]
        if {[lsearch -exact $allOpts $arg] < 0} {
            set match [lsearch -glob -all -inline $allOpts $arg*]







|







3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
        return
    }
    
    set allOpts {
        -w --help -help -b -noignore -i -nocase -nodigit -nokeyword -prefix
        -noparse -line -smallblock -block -char -word -limit -nodiff -dir
        -clip -patch -browse -conflict -print -server -o -r -context
        -foreach -preprocess -close -nonewline
    }

    # If the first option is "--query", use it to ask about options.
    if {$::eskil(argc) == 2 && [lindex $::eskil(argv) 0] == "--query"} {
        set arg [lindex $::eskil(argv) 1]
        if {[lsearch -exact $allOpts $arg] < 0} {
            set match [lsearch -glob -all -inline $allOpts $arg*]
3087
3088
3089
3090
3091
3092
3093

3094
3095
3096
3097
3098
3099
3100
    set doclip 0
    set files ""
    set nextArg ""
    set revNo 1
    set dopatch 0
    set foreach 0
    set ::eskil(autoclose) 0

    foreach arg $::eskil(argv) {
        if {$nextArg != ""} {
            if {$nextArg eq "mergeFile"} {
                set opts(mergeFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "printFile"} {
                set opts(printFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "revision"} {







>







3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
    set doclip 0
    set files ""
    set nextArg ""
    set revNo 1
    set dopatch 0
    set foreach 0
    set ::eskil(autoclose) 0
    set ::eskil(ignorenewline) 0
    foreach arg $::eskil(argv) {
        if {$nextArg != ""} {
            if {$nextArg eq "mergeFile"} {
                set opts(mergeFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "printFile"} {
                set opts(printFile) [file join [pwd] $arg]
            } elseif {$nextArg eq "revision"} {
3189
3190
3191
3192
3193
3194
3195




3196
3197
3198
3199
3200
3201
3202
            set doclip 1
        } elseif {$arg eq "-patch"} {
            set dopatch 1
        } elseif {$arg eq "-browse"} {
            set autobrowse 1
        } elseif {$arg eq "-foreach"} {
            set foreach 1




        } elseif {$arg eq "-close"} {
            set ::eskil(autoclose) 1
        } elseif {$arg eq "-conflict"} {
            set opts(mode) "conflict"
        } elseif {$arg eq "-print"} {
            set nextArg printFile
        } elseif {$arg eq "-server"} {







>
>
>
>







3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
            set doclip 1
        } elseif {$arg eq "-patch"} {
            set dopatch 1
        } elseif {$arg eq "-browse"} {
            set autobrowse 1
        } elseif {$arg eq "-foreach"} {
            set foreach 1
        } elseif {$arg eq "-nonewline"} {
            set ::eskil(ignorenewline) 1
        } elseif {$arg eq "-nonewline+"} {
            set ::eskil(ignorenewline) 2
        } elseif {$arg eq "-close"} {
            set ::eskil(autoclose) 1
        } elseif {$arg eq "-conflict"} {
            set opts(mode) "conflict"
        } elseif {$arg eq "-print"} {
            set nextArg printFile
        } elseif {$arg eq "-server"} {