summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2025-07-12 16:42:09 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2025-07-12 16:42:09 (GMT)
commitb9b2db3c5f5a6f18c247029ba1db1d543e83464d (patch)
tree176edc37b793c83879d175a9614e3f7bf415ff52
parent01ff23f34d50a8459cae3c92fa97379840e642f9 (diff)
downloadtcl-b9b2db3c5f5a6f18c247029ba1db1d543e83464d.zip
tcl-b9b2db3c5f5a6f18c247029ba1db1d543e83464d.tar.gz
tcl-b9b2db3c5f5a6f18c247029ba1db1d543e83464d.tar.bz2
[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)
-rw-r--r--doc/string.n17
-rw-r--r--generic/tclCmdMZ.c6
-rw-r--r--tests/string.test4
3 files changed, 15 insertions, 12 deletions
diff --git a/doc/string.n b/doc/string.n
index a78a842..1ae90ea 100644
--- a/doc/string.n
+++ b/doc/string.n
@@ -348,8 +348,9 @@ characters in the reverse order.
Returns a value equal to \fIstring\fR except that all upper (or title)
case letters have been converted to lower case. If \fIfirst\fR is
specified, it refers to the first char index in the string to start
-modifying. If \fIlast\fR is specified, it refers to the char index in
-the string to stop at (inclusive). \fIfirst\fR and \fIlast\fR may be
+modifying. If \fIlast\fR is not specified, only the character at position
+\fIfirst\fR is converted, otherwise \fIlast\fR refers to the char index
+in the string to stop at (inclusive). \fIfirst\fR and \fIlast\fR may be
specified using the forms described in \fBSTRING INDICES\fR.
.\" METHOD: totitle
.TP
@@ -360,9 +361,10 @@ in \fIstring\fR is converted to its Unicode title case variant (or
upper case if there is no title case variant) and the rest of the
string is converted to lower case. If \fIfirst\fR is specified, it
refers to the first char index in the string to start modifying. If
-\fIlast\fR is specified, it refers to the char index in the string to
-stop at (inclusive). \fIfirst\fR and \fIlast\fR may be specified
-using the forms described in \fBSTRING INDICES\fR.
+\fIlast\fR is not specified, only the character at position \fIfirst\fR
+is converted, otherwise \fIlast\fR refers to the char index in
+the string to stop at (inclusive). \fIfirst\fR and \fIlast\fR may be
+specified using the forms described in \fBSTRING INDICES\fR.
.\" METHOD: toupper
.TP
\fBstring toupper \fIstring\fR ?\fIfirst\fR? ?\fIlast\fR?
@@ -370,8 +372,9 @@ using the forms described in \fBSTRING INDICES\fR.
Returns a value equal to \fIstring\fR except that all lower (or title)
case letters have been converted to upper case. If \fIfirst\fR is
specified, it refers to the first char index in the string to start
-modifying. If \fIlast\fR is specified, it refers to the char index in
-the string to stop at (inclusive). \fIfirst\fR and \fIlast\fR may be
+modifying. If \fIlast\fR is not specified, only the character at position
+\fIfirst\fR is converted, otherwise \fIlast\fR refers to the char index
+in the string to stop at (inclusive). \fIfirst\fR and \fIlast\fR may be
specified using the forms described in \fBSTRING INDICES\fR.
.\" METHOD: trim
.TP
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 439d05c..dd06042 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -2922,7 +2922,7 @@ StringLowerCmd(
if (first < 0) {
first = 0;
}
- last = first;
+ last = length1;
if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1,
&last) != TCL_OK)) {
@@ -3007,7 +3007,7 @@ StringUpperCmd(
if (first < 0) {
first = 0;
}
- last = first;
+ last = length1;
if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1,
&last) != TCL_OK)) {
@@ -3092,7 +3092,7 @@ StringTitleCmd(
if (first < 0) {
first = 0;
}
- last = first;
+ last = length1;
if ((objc == 4) && (TclGetIntForIndexM(interp, objv[3], length1,
&last) != TCL_OK)) {
diff --git a/tests/string.test b/tests/string.test
index 6754508..42727fe 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -1753,7 +1753,7 @@ test string-15.6.$noComp {string tolower} {
} {123#$&*()}
test string-15.7.$noComp {string tolower} {
run {string tolower ABC 1}
-} AbC
+} Abc
test string-15.8.$noComp {string tolower} {
run {string tolower ABC 1 end}
} Abc
@@ -1787,7 +1787,7 @@ test string-16.6.$noComp {string toupper} {
} {123#$&*()}
test string-16.7.$noComp {string toupper} {
run {string toupper abc 1}
-} aBc
+} aBC
test string-16.8.$noComp {string toupper} {
run {string toupper abc 1 end}
} aBC