Skip to content

Commit 854b784

Browse files
author
jan.nijtmans
committed
Fix [16e25e1402]: tcl_startOfPreviousWord cannot handle "end-1"
2 parents f50f3ec + 4700e9e commit 854b784

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

library/word.tcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ proc tcl_startOfPreviousWord {str start} {
147147
variable ::tcl::WordBreakRE
148148
set word {-1 -1}
149149
if {$start > 0} {
150-
regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \
150+
regexp -indices -- $WordBreakRE(previous) [string range [string range $str 0 $start] 0 end-1] \
151151
result word
152152
}
153153
return [lindex $word 0]

tests/word.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test word-2.6 {tcl_startOfPreviousWord} -body {
6464
test word-2.7 {tcl_startOfPreviousWord} -body {
6565
tcl_startOfPreviousWord "ab cd" end
6666
} -result 3
67-
test word-2.8 {tcl_startOfPreviousWord, bug [16e25e1402]} -constraints knownBug -body {
67+
test word-2.8 {tcl_startOfPreviousWord, bug [16e25e1402]} -body {
6868
tcl_startOfPreviousWord "ab cd" end-1
6969
} -result 0
7070

0 commit comments

Comments
 (0)