2-argument string toupper/tolower/totitle doesn't work as documented
If first is specified, it refers to the first char index in the string to start modifyingThe documentation doesn't specify what happens if _last_ is not specified, but this suggests that modification of the string will be done until the end (just as when neither _first_ and _last_ are specified). That's not what happens:
$ tclsh8.6 % string tolower ABC 1 AbCReading the documentation, I would expect "Abc" as the answer. So, either the documentation or the implementation should change.
I'm not 100% sure, but I'm leaning towards changing the documentation.
038e022dbfDoc update. See [8cd74c5cd2] check-in2025-07-13 08:30:482b9b8fa85bDoc update. See [8cd74c5cd2] check-in2025-07-13 08:02:3529a9305656Doc update. See [8cd74c5cd2]. Backport more doc improvements from 9.1 check-in2025-07-13 07:51:2283bd3ccec5[8cd74c5cd2]: 2-argument string toupper/tolower/totitle doesn't work as documented. Either change the documentation, or the implementation. Both are done in this commit (but only one of them should be merged to trunk) check-in2025-07-12 16:42:09
Commit [83bd3ccec5ec1208] contains both the documentation change (which adapts the documentation to the current behavior) and the implementation change (which adapts the implementation to the current documentation.
Please review: Should "string tolower ABC 1" result in "Abc" (as it currently does) or "Abc" (as the documentation suggests)?
I couldn't find any code which uses "string tolower/toupper/totitle", specifying _first_ but not _last_. But changing the implementation is a risk. Therefore I'm leaning towards changing the documentation. But if you don't agree with that (or if you agree with that), please let me know!
I'm also for documentation change...
Just because this behaviour (first is just an index without last) is at least since 8.5 (if not earlier), so even if actual docu says something different, the code works as it works everywhere dozen years and there is no one reason to change the behaviour of tcl for the sake of documentation.
Especially because it is pretty simple to force the change case to the end, with supplying the last as end (to cause "documented" behaviour):
% string tolower ABCDE 2
ABcDE
% string tolower ABCDE 2 end
ABcde
@Jan, by the way, you wrote the same statement (result) for both variants, so here again (and a bit more clear example):
# if the code wins:
% string tolower ABCDE 2
ABcDE
\------- only given index
# if the docu wins:
% string tolower ABCDE 2
ABcde
\-/ ---- from given index to end
I couldn't find any code which uses "string tolower/toupper/totitle"
Even not in our test suite? That would be worse.
> Even not in our test suite? That would be worse.
In our test suite, yes. But not anywhere else (not even in Tk)
Documentation updated in all branches