︙ | | | ︙ | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# 1.2 DC-PS 980818 Improved yscroll
# Added map next to y-scrollbar
# 1.3 DC-PS 980921 Added Prev Diff button
# Added colour options, and Only diffs option
# Added 2nd stage line parsing
# Improved block parsing
# Added print
#
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"
set debug 0
set diffver "Version 1.3 980921"
proc myform {lineNo text} {
return [format "%3d: %s\n" $lineNo $text]
}
proc myforml {lineNo} {
return [format "%3d: " $lineNo]
}
proc maxabs {a b} {
return [expr {abs($a) > abs($b) ? $a : $b}]
}
#2nd stage line parsing
#Recursively look for common substrings in strings s1 and s2
proc compareMidString {s1 s2 res1Name res2Name {test 0}} {
global Pref
upvar $res1Name res1
upvar $res2Name res2
|
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# 1.2 DC-PS 980818 Improved yscroll
# Added map next to y-scrollbar
# 1.3 DC-PS 980921 Added Prev Diff button
# Added colour options, and Only diffs option
# Added 2nd stage line parsing
# Improved block parsing
# Added print
# 1.4 Bug-fix in "Ignore nothing"
#
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"
set debug 1
set diffver "Version 1.4 beta"
set tmpcnt 0
proc myform {lineNo text} {
return [format "%3d: %s\n" $lineNo $text]
}
proc myforml {lineNo} {
return [format "%3d: " $lineNo]
}
proc maxabs {a b} {
return [expr {abs($a) > abs($b) ? $a : $b}]
}
proc tmpfile {} {
global tmpcnt tmpfiles
incr tmpcnt
set name "tmpd[pid]a$tmpcnt"
lappend tmpfiles $name
return $name
}
proc cleartmp {} {
global tmpfiles
foreach f $tmpfiles {
file delete $f
}
set tmpfiles {}
}
#2nd stage line parsing
#Recursively look for common substrings in strings s1 and s2
proc compareMidString {s1 s2 res1Name res2Name {test 0}} {
global Pref
upvar $res1Name res1
upvar $res2Name res2
|
︙ | | | ︙ | |
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
|
proc normalCursor {} {
global oldcursor oldcursor2
. config -cursor $oldcursor
.t1 config -cursor $oldcursor2
.t2 config -cursor $oldcursor2
}
proc doDiff {} {
global leftFile rightFile leftOK rightOK RCS
global eqLabel RCS Pref doingLine1 doingLine2
global mapList mapMax
if {$RCS == 0 && ($leftOK == 0 || $rightOK == 0)} {
disableRedo
return
} else {
enableRedo
}
busyCursor
.t1 delete 1.0 end
.t2 delete 1.0 end
set mapList {}
set mapMax 0
update idletasks
if {$RCS} {
set differr [catch {eval exec rcsdiff $Pref(dopt) $Pref(ignore) $rightFile} diffres]
} else {
set differr [catch {eval exec diff $Pref(dopt) $Pref(ignore) $leftFile $rightFile} diffres]
}
set apa [split $diffres "\n"]
set result {}
set result2 {}
foreach i $apa {
if {[string match {[0-9]*} $i]} {
lappend result $i
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
|
|
|
<
|
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
proc normalCursor {} {
global oldcursor oldcursor2
. config -cursor $oldcursor
.t1 config -cursor $oldcursor2
.t2 config -cursor $oldcursor2
}
proc prepareRCS {} {
global leftFile rightFile RCSFile leftLabel rightLabel Pref
set revs {}
set opts {}
set Pref(old_dopt) $Pref(dopt)
foreach opt $Pref(dopt) {
if {[string match "-r*" $opt]} {
lappend revs [string range $opt 2 end]
} else {
lappend opts $opt
}
}
switch [llength $revs] {
0 {
set leftLabel "$RCSFile (RCS)"
set leftFile [tmpfile]
set rightLabel $RCSFile
set rightFile $RCSFile
catch {exec co -p [file nativename $RCSFile] > $leftFile}
}
1 {
set r [lindex $revs 0]
set leftLabel "$RCSFile (RCS $r)"
set leftFile [tmpfile]
set rightLabel $RCSFile
set rightFile $RCSFile
catch {exec co -p$r [file nativename $RCSFile] > $leftFile}
}
default {
set r1 [lindex $revs 0]
set r2 [lindex $revs 1]
set leftLabel "$RCSFile (RCS $r1)"
set leftFile [tmpfile]
set rightLabel "$RCSFile (RCS $r2)"
set rightFile [tmpfile]
catch {exec co -p$r1 [file nativename $RCSFile] > $leftFile}
catch {exec co -p$r2 [file nativename $RCSFile] > $rightFile}
}
}
update idletasks
set Pref(dopt) $opts
}
proc cleanupRCS {} {
global RCSFile rightFile leftFile Pref
cleartmp
set rightFile $RCSFile
set leftFile $RCSFile
set Pref(dopt) $Pref(old_dopt)
unset Pref(old_dopt)
}
proc doDiff {} {
global leftFile rightFile leftOK rightOK
global eqLabel RCS Pref doingLine1 doingLine2
global mapList mapMax
if {$RCS == 0 && ($leftOK == 0 || $rightOK == 0)} {
disableRedo
return
} else {
enableRedo
}
busyCursor
.t1 delete 1.0 end
.t2 delete 1.0 end
set mapList {}
set mapMax 0
update idletasks
if {$RCS} {
prepareRCS
}
set differr [catch {eval exec diff $Pref(dopt) $Pref(ignore) $leftFile $rightFile} diffres]
set apa [split $diffres "\n"]
set result {}
set result2 {}
foreach i $apa {
if {[string match {[0-9]*} $i]} {
lappend result $i
}
|
︙ | | | ︙ | |
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
|
}
}
}
dotext "" $ch2 0 0 0 0
close $ch2
drawMap -1
normalCursor
}
proc doOpenLeft {} {
global leftFile leftDir rightDir leftOK
if {![info exists leftDir]} {
if {[info exists rightDir]} {
set leftDir $rightDir
} else {
set leftDir [pwd]
}
}
set apa [tk_getOpenFile -title "Select left file" -initialdir $leftDir]
if {$apa != ""} {
set leftDir [file dirname $apa]
set leftFile $apa
set leftOK 1
return 1
}
return 0
}
proc doOpenRight {} {
global rightFile rightDir leftDir rightOK
if {![info exists rightDir]} {
if {[info exists leftDir]} {
set rightDir $leftDir
} else {
set rightDir [pwd]
}
}
set apa [tk_getOpenFile -title "Select right file" -initialdir $rightDir]
if {$apa != ""} {
set rightDir [file dirname $apa]
set rightFile $apa
set rightOK 1
return 1
}
return 0
}
proc openLeft {} {
|
>
>
>
>
>
|
>
|
>
|
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
|
}
}
}
dotext "" $ch2 0 0 0 0
close $ch2
if {$RCS} {
cleanupRCS
}
drawMap -1
normalCursor
}
proc doOpenLeft {} {
global leftFile leftDir rightDir leftOK leftLabel
if {![info exists leftDir]} {
if {[info exists rightDir]} {
set leftDir $rightDir
} else {
set leftDir [pwd]
}
}
set apa [tk_getOpenFile -title "Select left file" -initialdir $leftDir]
if {$apa != ""} {
set leftDir [file dirname $apa]
set leftFile $apa
set leftLabel $apa
set leftOK 1
return 1
}
return 0
}
proc doOpenRight {} {
global rightFile rightDir leftDir rightOK rightLabel
if {![info exists rightDir]} {
if {[info exists leftDir]} {
set rightDir $leftDir
} else {
set rightDir [pwd]
}
}
set apa [tk_getOpenFile -title "Select right file" -initialdir $rightDir]
if {$apa != ""} {
set rightDir [file dirname $apa]
set rightFile $apa
set rightLabel $apa
set rightOK 1
return 1
}
return 0
}
proc openLeft {} {
|
︙ | | | ︙ | |
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
|
if {[doOpenRight]} {
set RCS 0
doDiff
}
}
proc openRCS {} {
global RCS leftFile leftOK
if {[doOpenRight]} {
set RCS 1
set leftFile "RCS"
set leftOK 0
doDiff
}
}
proc openBoth {} {
global RCS
|
|
>
|
|
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
|
if {[doOpenRight]} {
set RCS 0
doDiff
}
}
proc openRCS {} {
global RCS leftFile rightFile leftOK RCSFile
if {[doOpenRight]} {
set RCS 1
set RCSFile $rightFile
set leftLabel "RCS"
set leftOK 0
doDiff
}
}
proc openBoth {} {
global RCS
|
︙ | | | ︙ | |
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
|
.mo.mf add radiobutton -label 6 -variable Pref(fontsize) -value 6 -command chFont
.mo.mf add radiobutton -label 7 -variable Pref(fontsize) -value 7 -command chFont
.mo.mf add radiobutton -label 8 -variable Pref(fontsize) -value 8 -command chFont
.mo.mf add radiobutton -label 9 -variable Pref(fontsize) -value 9 -command chFont
.mo.mf add radiobutton -label 10 -variable Pref(fontsize) -value 10 -command chFont
menu .mo.mi
.mo.mi add radiobutton -label "Nothing" -variable Pref(ignore) -value ""
.mo.mi add radiobutton -label "Space changes (-b)" -variable Pref(ignore) -value "-b"
.mo.mi add radiobutton -label "All spaces (-w)" -variable Pref(ignore) -value "-w"
menu .mo.mp
.mo.mp add radiobutton -label "Nothing" -variable Pref(parse) -value "none"
.mo.mp add radiobutton -label "Lines" -variable Pref(parse) -value "line"
.mo.mp add radiobutton -label "Blocks" -variable Pref(parse) -value "block"
|
|
|
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
|
.mo.mf add radiobutton -label 6 -variable Pref(fontsize) -value 6 -command chFont
.mo.mf add radiobutton -label 7 -variable Pref(fontsize) -value 7 -command chFont
.mo.mf add radiobutton -label 8 -variable Pref(fontsize) -value 8 -command chFont
.mo.mf add radiobutton -label 9 -variable Pref(fontsize) -value 9 -command chFont
.mo.mf add radiobutton -label 10 -variable Pref(fontsize) -value 10 -command chFont
menu .mo.mi
.mo.mi add radiobutton -label "Nothing" -variable Pref(ignore) -value " "
.mo.mi add radiobutton -label "Space changes (-b)" -variable Pref(ignore) -value "-b"
.mo.mi add radiobutton -label "All spaces (-w)" -variable Pref(ignore) -value "-w"
menu .mo.mp
.mo.mp add radiobutton -label "Nothing" -variable Pref(parse) -value "none"
.mo.mp add radiobutton -label "Lines" -variable Pref(parse) -value "line"
.mo.mp add radiobutton -label "Blocks" -variable Pref(parse) -value "block"
|
︙ | | | ︙ | |
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
|
button .bfp -text "Prev Diff" -relief raised -command findPrev
entry .eo -width 10 -textvariable Pref(dopt)
label .lo -text "Diff Options"
catch {font delete myfont}
font create myfont -family courier -size $Pref(fontsize)
label .l1 -textvariable leftFile -anchor e -width 10
label .l2 -textvariable rightFile -anchor e -width 10
text .t1 -height 40 -width 60 -wrap none -yscrollcommand my_yscroll \
-xscrollcommand ".sbx1 set" -font myfont
scrollbar .sby -orient vertical -command "my_yview"
scrollbar .sbx1 -orient horizontal -command ".t1 xview"
text .t2 -height 40 -width 60 -wrap none -yscrollcommand my_yscroll \
-xscrollcommand ".sbx2 set" -font myfont
scrollbar .sbx2 -orient horizontal -command ".t2 xview"
|
|
|
|
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
|
button .bfp -text "Prev Diff" -relief raised -command findPrev
entry .eo -width 10 -textvariable Pref(dopt)
label .lo -text "Diff Options"
catch {font delete myfont}
font create myfont -family courier -size $Pref(fontsize)
label .l1 -textvariable leftLabel -anchor e -width 10
label .l2 -textvariable rightLabel -anchor e -width 10
text .t1 -height 40 -width 60 -wrap none -yscrollcommand my_yscroll \
-xscrollcommand ".sbx1 set" -font myfont
scrollbar .sby -orient vertical -command "my_yview"
scrollbar .sbx1 -orient horizontal -command ".t1 xview"
text .t2 -height 40 -width 60 -wrap none -yscrollcommand my_yscroll \
-xscrollcommand ".sbx2 set" -font myfont
scrollbar .sbx2 -orient horizontal -command ".t2 xview"
|
︙ | | | ︙ | |
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
|
.he.t insert end {4: NET '/I$1/N$1457' IC2-11 IC6-7 3: NET '/I$1/N$1457' IC2-11 IC6-7
}
.he.t insert end {5: } change {NET '/I$1/N$1458' } "" {IC2-10} change { } "" {4: } change {NET '/I$1/N$1458' } "" {IC2-9} change "\n"
}
proc parseCommandLine {} {
global argv argc Pref
global rightDir rightFile rightOK leftDir leftFile leftOK RCS
set leftOK 0
set rightOK 0
set RCS 0
set noautodiff 0
if {$argc == 0} return
|
|
|
>
|
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
|
.he.t insert end {4: NET '/I$1/N$1457' IC2-11 IC6-7 3: NET '/I$1/N$1457' IC2-11 IC6-7
}
.he.t insert end {5: } change {NET '/I$1/N$1458' } "" {IC2-10} change { } "" {4: } change {NET '/I$1/N$1458' } "" {IC2-9} change "\n"
}
proc parseCommandLine {} {
global argv argc Pref RCS RCSFile
global rightDir rightFile rightOK rightLabel
global leftDir leftFile leftOK leftLabel
set leftOK 0
set rightOK 0
set RCS 0
set noautodiff 0
if {$argc == 0} return
|
︙ | | | ︙ | |
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
|
set len [llength $files]
if {$len == 1} {
set fullname [file join [pwd] $files]
set fulldir [file dirname $fullname]
if {[glob -nocomplain [file join $fulldir RCS]] != ""} {
set RCS 1
set rightDir $fulldir
set rightFile $fullname
set rightOK 1
set leftFile "RCS"
if {$noautodiff == "1"} {
enableRedo
} else {
after idle doDiff
}
} else {
set leftDir $fulldir
set leftFile $fullname
set leftOK 1
}
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set leftDir $fulldir
set leftFile $fullname
set leftOK 1
set fullname [file join [pwd] [lindex $files 1]]
set fulldir [file dirname $fullname]
set rightDir $fulldir
set rightFile $fullname
set rightOK 1
if {$noautodiff == "1"} {
enableRedo
} else {
after idle doDiff
}
}
|
>
>
|
>
>
>
|
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
|
set len [llength $files]
if {$len == 1} {
set fullname [file join [pwd] $files]
set fulldir [file dirname $fullname]
if {[glob -nocomplain [file join $fulldir RCS]] != ""} {
set RCS 1
set rightDir $fulldir
set RCSFile $fullname
set rightLabel $fullname
set rightFile $fullname
set rightOK 1
set leftLabel "RCS"
if {$noautodiff == "1"} {
enableRedo
} else {
after idle doDiff
}
} else {
set leftDir $fulldir
set leftFile $fullname
set leftLabel $fullname
set leftOK 1
}
} elseif {$len >= 2} {
set fullname [file join [pwd] [lindex $files 0]]
set fulldir [file dirname $fullname]
set leftDir $fulldir
set leftFile $fullname
set leftLabel $fullname
set leftOK 1
set fullname [file join [pwd] [lindex $files 1]]
set fulldir [file dirname $fullname]
set rightDir $fulldir
set rightFile $fullname
set rightLabel $fullname
set rightOK 1
if {$noautodiff == "1"} {
enableRedo
} else {
after idle doDiff
}
}
|
︙ | | | ︙ | |