Tk Source Code

View Ticket
Login
Ticket UUID: 1513517
Title: .text search -regexp wraps despite stopIndex is specified
Type: Bug Version: obsolete: 8.4.15
Submitter: fvogel Created on: 2006-06-27 18:34:06
Subsystem: 18. [text] Assigned To: vincentdarley
Priority: 4 Severity:
Status: Closed Last Modified: 2014-02-19 21:42:19
Resolution: Wont Fix Closed By: vincentdarley
    Closed on: 2007-11-02 13:08:47
Description:
The help page for the text widget states that (.text 
search command):

If stopIndex is omitted, the entire text will be 
searched: when the beginning or end of the text is 
reached, the search continues at the other end until 
the starting location is reached again; if stopIndex 
is specified, no wrap-around will occur.

However, the following demonstrates that wraparound 
occurs when start and stop indices are both equal to 
[.t index end]

text .t
pack .t
.t insert end "hello1\n"
.t insert end "hello2\n"
.t insert end "hello3\n"
.t insert end "hello4\n"
set ind [.t index end]

# WRONG: returns 1.0 -> it wraps!
.t search -regexp -- "^" $ind $ind

# CORRECT: returns 5.0
.t search -regexp -- "^" $ind-1c $ind

# WRONG: returns 1.2 -> it wraps!
.t search -- "llo" $ind $ind           

# CORRECT: returns ""
.t search -- "llo" $ind-1c $ind


Therefore, contrary to the claims of the manual, the 
search wraps if the start and stop indices are both 
equal to [.t index end] (which is not so uncommon 
during a search for all the occurrences of a string 
in a text).


Francois
User Comments: vincentdarley added on 2007-11-02 20:08:47:
Logged In: YES 
user_id=32170
Originator: NO

Indeed, the fixes in 8.5 (of which there are dozens) can't in any meaningful way be backported.  The fixes for 8.4 would be entirely different code.  Therefore won't fix.

dkf added on 2007-11-01 21:08:39:
Logged In: YES 
user_id=79902
Originator: NO

Chances of a backport are virtually nil; the [text] guts are profoundly different in 8.5 than in 8.4.

Maintainer may wish to mark as Won't Fix.

dkf added on 2007-11-01 21:07:56:
Logged In: YES 
user_id=79902
Originator: NO

Chances of a backport are virtually nil; the [text] guts are profoundly different in 8.5 than in 8.4.

Maintainer may wish to mark as Won't Fix.

fvogelnew1 added on 2007-11-01 19:27:13:
Logged In: YES 
user_id=1245417
Originator: YES

I reported this bug initially with 8.4.13.

It's still present in 8.4.15, but for some reason it doesn't show up in 8.5b2.

Francois