diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-30 09:46:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-03-30 09:46:05 (GMT) |
commit | 1ed6e3fd56d286fd7d7fc4a426cf223dbf1bb26b (patch) | |
tree | e0eb5a180c7c146d43e6a618e936ba75f16cd5f9 /library | |
parent | 59c86794ab87fad53c4e4dc350dfaf150edda944 (diff) | |
download | tk-1ed6e3fd56d286fd7d7fc4a426cf223dbf1bb26b.zip tk-1ed6e3fd56d286fd7d7fc4a426cf223dbf1bb26b.tar.gz tk-1ed6e3fd56d286fd7d7fc4a426cf223dbf1bb26b.tar.bz2 |
Only use "string range" when $index > 0, so there's really something to be done.
Diffstat (limited to 'library')
-rw-r--r-- | library/tearoff.tcl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/library/tearoff.tcl b/library/tearoff.tcl index b500023..c2d2d6b 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -154,7 +154,9 @@ proc ::tk::MenuDup {src dst type} { # Copy tags to x, replacing each substring of src with dst. while {[set index [string first $src $tags]] != -1} { - append x [string range $tags 0 [expr {$index - 1}]]$dst + if {$index > 0} { + append x [string range $tags 0 [expr {$index - 1}]]$dst + } set tags [string range $tags [expr {$index + $srcLen}] end] } append x $tags @@ -169,7 +171,9 @@ proc ::tk::MenuDup {src dst type} { # Copy script to x, replacing each substring of event with dst. while {[set index [string first $event $script]] != -1} { - append x [string range $script 0 [expr {$index - 1}]] + if {$index > 0} { + append x [string range $script 0 [expr {$index - 1}]] + } append x $dst set script [string range $script [expr {$index + $eventLen}] end] } |