Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-02-19
01:08 • Closed ticket [688554ffff]: string match doesn't match strings with NULLs</i... artifact: 4cd4608f41 user: hobbs
2003-02-18
17:21 • Ticket [688554ffff]: 5 changes artifact: f89e00617b user: dkf
09:49 • New ticket [688554ffff]. artifact: 6c73a4ee50 user: nobody

string match doesn't match strings with NULLs

Closed / Out of Date688554ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2003-02-18 09:49:10
[email protected]

The following string doesn't work correctly. Depending
on the 'binary' line commented out or not 'string
match' gives different results. This is true for
tcl8.4.0 and tcl8.4.1.


proc MatchElem {constraint queueElem} {
  set result 0
# binary scan $queueElem H* bele1
  set result [string match $constraint $queueElem]
  puts "Match '$constraint' with '$queueElem': result
$result"
  binary scan $queueElem H* bele2
  puts "Match '$constraint' with '$queueElem' ($bele2):
result $result"
  return $result
}

set con "*abc*"

set a "\000@abc"
MatchElem $con $a
puts "[string match $con $a]"

set a "@abc"
MatchElem $con $a
#puts "[string match $con $a]"

set a "\000@abc\000"
MatchElem $con $a
#puts "[string match $con $a]"
dkfplain2003-02-18 17:21:16
Logged In: YES 
user_id=79902

Hmm.  Seems to work for me.  Will investigate further...
hobbsplain2003-02-19 01:08:31
Logged In: YES 
user_id=72656

Already corrected in the HEAD.
Log in (anonymous is fine) to add a comment.