librepcb: 1.1.0 -> 1.2.0
[NixPkgs.git] / pkgs / by-name / cb / cbrowser / backslashes-quotes.diff
blobcc42f0745da53120d8075222b6dd427bdac22639
1 Based on this:
2 http://sourceforge.net/tracker/?func=detail&aid=1493886&group_id=5152&atid=305152
3 fix the infinite loops in quote highlight - ID: 1493886
5 --- cbrowser-0.8-2/ftcllib.tcl 2000-07-04 01:17:43.000000000 +0200
6 +++ cbrowser-0.8/ftcllib.tcl 2006-05-24 00:39:18.833762522 +0200
7 @@ -1290,13 +1290,39 @@
8 foreach {start end} [concat 1.0 [$widget tag ranges comment] end] {
10 while {[set temp [$widget search -regexp -- $pattern $start $end]] != ""} {
11 + set startquote [$widget index "$temp + 1chars"]
13 - set endquote [$widget search -regexp -- {[^\\]\"} "$temp + 1chars" $end]
14 + set temp [$widget index "$startquote + 1chars"]
15 + while {1==1} {
16 + set endquote [$widget search -regexp -- {\"} $temp $end]
18 + # The program will not break if a /*C comment*/ is between C quotes.
19 + if { $endquote == "" } {
20 + set endquote $startquote
21 + break
22 + }
24 + # look for double backslashes
25 + if {[set temp2 [$widget search -regexp -- {\\\\} $temp $endquote]] != ""} {
26 + set temp "$temp2 + 2chars"
27 + continue
28 + }
30 + # look for \"
31 + if {[set temp2 [$widget search -regexp -- {\\\"} $temp $endquote]] != ""} {
32 + set temp "$temp2 + 2chars"
33 + continue
34 + }
36 + break
37 + }
39 if {[strlen $endquote] > 0} {
40 - set start [$widget index "$endquote + 2chars"]
41 + set start [$widget index "$endquote + 1chars"]
43 - $widget tag add quote "$temp + 1chars" $start
44 + $widget tag add quote $startquote $start
45 + } else {
46 + set start [$widget index "$start + 1chars"]