On Tue, Jan 13, 2015 at 12:01:51AM +0000, Olly Betts wrote:
> On Mon, Jan 12, 2015 at 04:29:09PM +0100, Stacho Mudrak wrote:
> > I am sorry, I was never able replicate this bug.
> 
> You need a large log file for it to be noticeable, as the problem seems
> to be that trying to match this pattern causes Tcl's regexp engine to do
> a lot of backtracking:
> 
>   set rx {\S*[^\]\s]\s+\[\d+\]}
> 
> I don't really follow the Tcl code around this, but if this is trying to
> match on lines such as:
> 
> 2253> input:42871 -- gemse.th [4]
> 
> Then adding "-- " to the start of the pattern and then adjusting the
> offsets when highlighting in the text widget should address the problem.
> The fixed substring "-- " serves as a way to efficiently limit where the
> regexp engine tries to match the pattern.

I managed to guess enough tcl and tk to implement this, patch attached
which fixes the 10 minute wait while xtherion parse the log, while still
creating the links as before (at least as best I can tell).

Cheers,
    Olly
Description: Fix long delay processing large log files
 The regexp her causes excessive backtracking, and can take 10 minutes to
 process a log file.  With this patch, it's close to instant.
Author: Olly Betts <o...@survex.com>
Bug-Debian: https://bugs.debian.org/751471
Forwarded: no
Last-Update: 2015-01-13

--- therion-5.3.16.orig/xtherion/cp_procs.tcl
+++ therion-5.3.16/xtherion/cp_procs.tcl
@@ -791,19 +791,19 @@ proc xth_cp_show_errors {} {
   set w $xth(cp,log).txt
   $w tag remove xtherr 1.0 end
 
-  set rx {\S*[^\]\s]\s+\[\d+\]}
+  set rx {\-- \S*[^\]\s]\s+\[\d+\]}
   set fnd [$w search -regexp -count cnt $rx 1.0 end]
   
   set i 0
   while {([string length $fnd] > 0) && ($i < 10000)} {
     
     set enx [$w index "$fnd + $cnt chars"]
-    set ctext [$w get $fnd "$fnd lineend"]
+    set ctext [$w get "$fnd + 3 chars" "$fnd lineend"]
     set cfnm {}
     regexp {\S+} $ctext cfnm
   
     if {![regexp {(\.mp|\.tex)\)?$} $cfnm]} {
-      $w tag add xtherr $fnd $enx
+      $w tag add xtherr "$fnd + 3 chars" $enx
     }
 
     set fnd [$w search -regexp -count cnt $rx $enx end]

Reply via email to