Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-08-23
01:04 • Closed ticket [2065115fff]: RE syntax "***=" fails plus 7 other c... artifact: c88a20434c user: dgp
00:21 • Ticket [2065115fff]: 4 changes artifact: 6f080c260b user: dgp
2008-08-22
23:59 • Ticket [2065115fff]: 4 changes artifact: 179256f017 user: dgp
20:17 • Open ticket [2065115fff]. artifact: 8c51d1f45a user: dgp
06:30 • Ticket [2065115fff]: 4 changes artifact: 543af3481f user: andreas_kupries
06:21 • Closed ticket [2065115fff]. artifact: 5589087a56 user: hobbs
03:18 • Ticket [2065115fff]: 5 changes artifact: 6de98198af user: ferrieux
2008-08-21
15:56 • New ticket [2065115fff]. artifact: e80283deda user: duquette

RE syntax "***=" fails

Closed / Fixed2065115fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-08-21 15:56:50
When "***=" appears at the beginning of an RE, the
remainder of the string is supposed to be treated as
a string literal to be matched literally.  This worked
in 8.4.14; it isn't working in 8.5.3, as shown by
this example:

set string "aeiou"
set re "***=o"

if {[regexp -- $re $string]} {
    puts "Match!"
} else {
    puts "Fail!"
}

The script ought to output "Match!"; it outputs "Fail!".

I'm running Tcl 8.5.3 on RedHat Enterprise Linux 4.
ferrieuxplain2008-08-22 03:18:00
Logged In: YES 
user_id=496139
Originator: NO

Fails in 8.5.0 as well. And also in HEAD (8.6).
Looks like ***=o is matched as ^o$ (anchored on both sides).
hobbsplain2008-08-22 06:21:05
Logged In: YES 
user_id=72656
Originator: NO

Fixed for 8.5.5 and 8.6a3.  The translation to faster glob incorrectly made it an exact match.  Amazingly, the few previous tests for this syntax passed because they were exact matches.
andreas_kupriesplain2008-08-22 06:30:14
Logged In: YES 
user_id=75003
Originator: NO

Note: This type of re -> glob conversion originated in Expect.
Checking there we see the same type of 'exact' conversion.
However in Expect this doesn't matter, as it searches the pattern in
the whole buffer anyway, i.e. there are implicit *'s around it, making
it unanchored.
As such I believe Expect can be left unchanged.
dgpplain2008-08-22 20:17:18
Logged In: YES 
user_id=80530
Originator: NO


There are failing and duplicate tests now:

==== regexp-1.8 regexp ***= metasyntax FAILED
==== Contents of test case:

    regexp -- "***=o" "aeiou"

---- Result was:
0
---- Result should have been (exact matching):
1
==== regexp-1.8 FAILED



==== regexp-1.9 regexp ***= metasyntax FAILED
==== Contents of test case:

    set string "aeiou"
    regexp -- "***=o" $string

---- Result was:
0
---- Result should have been (exact matching):
1
==== regexp-1.9 FAILED

regexpComp.test


==== regexp-1.8 regexp ***= metasyntax FAILED
==== Contents of test case:

    evalInProc {
        regexp -- "***=o" "aeiou"
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== regexp-1.8 FAILED



==== regexp-1.9 regexp ***= metasyntax FAILED
==== Contents of test case:

    evalInProc {
        set string "aeiou"
        regexp -- "***=o" $string
    }

---- Result was:
0
---- Result should have been (exact matching):
1
==== regexp-1.9 FAILED
dgpplain2008-08-22 23:59:59
Logged In: YES 
user_id=80530
Originator: NO


trouble is that *exactPtr
isn't set before the early
exit.

Appears there are other problems too.
dgpplain2008-08-23 00:21:30
Logged In: YES 
user_id=80530
Originator: NO


Committed fix so that the tests
all pass.

Now I'm worried that the possibility
of string growth during RE -> glob
translation isn't fully accounted
for and buffer overflows are possible.
dgpplain2008-08-23 01:04:19
Logged In: YES 
user_id=80530
Originator: NO

fixed
Log in (anonymous is fine) to add a comment.