Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e1b6e8bc605be4818efdb09425eb5a015c0bb000
Ticket: 625441ffffffffffffffffffffffffffffffffff
Error in compiling regexp
User & Date: schmitzu on 2002-10-18 22:41:45
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I've detected an error in the compilation of the
    regexp command.
    
    Put the following code into a file called
    tstRegexp.tcl:
    
    <code>
    proc isblank {word} {
       if {[regexp {^[ ]*$} $word]} {
          puts "is blank"
       } else {
          puts "is not blank"
       }
    
    #...some unnecessary lines
       .
       . <Repeat this line 1000 times!>
       .
    #...some unnecessary lines
    
    }
    
    puts [time [list isblank "Hello"]]
    </code>
    
    It's *very* important to repeat the
    comment line!!
    
    On my old 400Mhz AMD with WinME and
    the new ActiveTcl4.0.1 distribution,
    the output of "tclsh84 tstRegexp.tcl" is:
    
    is not blank
    94107834 microseconds per iteration
    
    Over 90 seconds is a very long time,
    for such a simple script!
    
    With the older Tcl8.3.4 the output varies
    between 0 and 60000 microseconds.
    
    I've looked a little bit deeper into
    it, and detected that most of the time is
    wasted in TclCompileRegexpCmd. A little
    bit deeper in the calling tree it does
    many recursive calls to duptraverse.
    The problem seems to be, that the 
    string for the regexp compilation is
    the whole rest of the proc (including
    the many comments). I think there is
    an error in detecting the end of 
    the regexp string?!
    
    
    
  4. foundin changed to: "obsolete: 8.4.0"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "schmitzu"
  9. subsystem changed to: "43. Regexp"
  10. title changed to: "Error in compiling regexp"
  11. type changed to: "Bug"