summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-07-03 08:39:53 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-07-03 08:39:53 (GMT)
commit870670e4d40ffddec9c1fda18e8dabfeaa3d9afe (patch)
treed221e83ed6bf4e67002ef94627963af7891cd86a /library
parent22d9a275de6676c097e323284da1e19ae11a45f5 (diff)
downloadtcl-870670e4d40ffddec9c1fda18e8dabfeaa3d9afe.zip
tcl-870670e4d40ffddec9c1fda18e8dabfeaa3d9afe.tar.gz
tcl-870670e4d40ffddec9c1fda18e8dabfeaa3d9afe.tar.bz2
In tcl_startOfPreviousWord, don't bother doing a regexp when $start <= 0.
Diffstat (limited to 'library')
-rw-r--r--library/word.tcl6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/word.tcl b/library/word.tcl
index 3e4bc3a..4e57479 100644
--- a/library/word.tcl
+++ b/library/word.tcl
@@ -146,7 +146,9 @@ proc tcl_startOfNextWord {str start} {
proc tcl_startOfPreviousWord {str start} {
variable ::tcl::WordBreakRE
set word {-1 -1}
- regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \
- result word
+ if {$start > 0} {
+ regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \
+ result word
+ }
return [lindex $word 0]
}