Overview
| Artifact ID: | 4e5802db97593b5931dd4731a0d78eef06898c17 |
|---|---|
| Ticket: | 218947ffffffffffffffffffffffffffffffffff
string compare with result from string index does not work p |
| User & Date: | nobody on 2000-10-26 01:08:29 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 2871 Bug Version: 8.2 SubmitDate: '1999-09-23' LastModified: '1999-10-20' Severity: SER Status: Released Submitter: techsupp ChangedBy: hobbs OS: Linux-SuSE OSVersion: 6.0 Machine: Other FixedDate: '1999-10-20' FixedInVersion: 8.2.2 ClosedDate: '2000-10-25' Name: Hans Banken ReproducibleScript: #!/usr/bin/tclsh set str "0123456789\x00\ abcdedfghi" puts "str: $str" puts "before scan - compare index 10 with \x00: [string compare [string index $str 10] \x00]" binary scan $str H* dump puts "access with string index: $dump\ncompare index 10 with \x00: [string compare [string index $str 10] \x00]" puts "access with string range: $dump\ncompare range 10,10 with \x00: [string compare [string range $str 10 10] \x00]" # Executing this script results in: # str: 0123456789 abcdedfghi # before scan - compare index 10 with : 0 # access with string index: 30313233343536373839002061626364656466676869 # compare index 10 with : -1 # access with string range: 30313233343536373839002061626364656466676869 # compare range 10,10 with : 0 ObservedBehavior: You might get wrong results when comparing the result of a string index operation This is tricky. What is happening is that the user is shimmering the object between a string and a bytearray. 'string' has an overloaded use, where it will access a bytearray by bytes, and strings as strings. In the first case, you get the unicode version of \x00. In the second, you get the true one-byte \x00 (just a null byte), which is not the same as the unicode one (which is two bytes). In the third case, STR_RANGE creates a bytearray obj, which will get converted OK. The problem appears to be that STR_INDEX for bytearrays wants to return a string type obj. -- 09/24/1999 hobbs Fixed 10/20/1999 (for 8.3b1) by making STR_INDEX for ByteArrays return a ByteArray object. -- 10/20/1999 hobbs - foundin changed to: "obsolete: 8.2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to:
string compare with result from string index does not work p
- type changed to: "Bug"