Skip to content
Tcl Source Code Artifact [4988a3b3af]
Login

Artifact [4988a3b3af]

Artifact 4988a3b3afe92840d598f28f54c95e6f6cb73a3b354eb29ea66306d2fb9b9975:

Ticket change [4988a3b3af] - New ticket [3e7c4a039d32955f|3e7c4a039d] <i>tcl_startOfPreviousWord ignores the last character when start is the string length</i>. by serhiy.storchaka on 2026-10-25 11:56:01.
D 2026-10-25T11:56:01.288
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment <tt>tcl_startOfPreviousWord</tt>\sreturns\sa\swrong\sresult\swhen\s<tt>start</tt>\sis\sequal\sto\s(or\sgreater\sthan)\sthe\slength\sof\sthe\sstring\sand\sthe\slast\sword\shas\sone\scharacter:\n\n<verbatim>\n%\stcl_startOfPreviousWord\s{a\sb\sc}\s5\n2\n%\stcl_startOfPreviousWord\s{ab\sc}\s4\n0\n</verbatim>\n\nThe\sexpected\sresults\sare\s4\sand\s3,\swhich\s8.5\sand\s8.6.13\sreturn.\sThe\slast\scharacter\sis\sdropped,\sso\sthe\slast\sword\sis\snot\sfound\swhen\sit\shas\sone\scharacter.\sFor\slonger\swords\sthe\sresult\shappens\sto\sbe\sright\s(word-2.6).\n\nThis\sis\sa\sregression\sfrom\sthe\sfix\sfor\s[16e25e1402]\s([8f65470f72],\s8.6.14):\s<tt>[string\srange\s[string\srange\s$str\s0\s$start]\s0\send-1]</tt>\sdrops\sthe\slast\scharacter\salso\swhen\s<tt>$start</tt>\sis\sbeyond\sthe\send\sof\sthe\sstring,\swhile\sthe\sold\s<tt>[string\srange\s$str\s0\s$start-1]</tt>\sdid\snot.\n\nIt\saffects\sTk:\sin\san\sentry\sor\sspinbox\susing\sthese\sprocedures\s(8.6,\sor\s<tt>-locale\stcl8</tt>\sin\s9.x),\sCtrl+Left\sfrom\sthe\send\sof\sthe\stext\sskips\sa\sfinal\sone-character\sword.\n\nA\spossible\sfix\sthat\skeeps\s<tt>end-1</tt>\sworking:\n<verbatim>\nset\sprefix\s[string\srange\s$str\s0\s$start]\nif\s{[string\sindex\s$str\s$start]\sne\s""}\s{\n\s\s\s\sset\sprefix\s[string\srange\s$prefix\s0\send-1]\n}\nregexp\s-indices\s--\s$WordBreakRE(previous)\s$prefix\sresult\sword\n</verbatim>\nwith\stests\ssuch\sas\s<tt>tcl_startOfPreviousWord\s"ab\sc"\s4</tt>\s→\s3\sand\s<tt>tcl_startOfPreviousWord\s"ab\sc"\send+1</tt>\s→\s3.\sWith\sit,\sall\sword-2.*\scases\sstill\sgive\sthe\ssame\sresults\s(checked\swith\s8.6.18\sand\s9.1.1\sby\sredefining\sthe\sprocedure).
J foundin 8.6.14,\s9.0.5,\s9.1.1
J login serhiy.storchaka
J priority 5\sMedium
J resolution None
J severity Minor
J status Open
J submitter serhiy.storchaka
J subsystem 69.\sOther
J title tcl_startOfPreviousWord\signores\sthe\slast\scharacter\swhen\sstart\sis\sthe\sstring\slength
J type Bug
K 3e7c4a039d32955f5bd5b6d2de3af84f5c5fca76
U serhiy.storchaka
Z b814d547d3fbced04a74fdd0087ff57a