Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Error in compiling regexp

Closed / Fixed625441ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-10-18 22:41:45
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?!
hobbsplain2002-10-19 06:10:27
Logged In: YES 
user_id=72656

This is already corrected in the head for 8.4.1.
Log in (anonymous is fine) to add a comment.