summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorgriffin <briang42@easystreet.net>2024-09-01 22:43:33 (GMT)
committergriffin <briang42@easystreet.net>2024-09-01 22:43:33 (GMT)
commitcf8be2a4a6881ce0776abd08e4fafdd63d178523 (patch)
treeab00ed589794e115792478a8fad372b6d5bda845 /generic
parent39c100c9b3ca73d645e13277ab18407815fe59d2 (diff)
downloadtcl-cf8be2a4a6881ce0776abd08e4fafdd63d178523.zip
tcl-cf8be2a4a6881ce0776abd08e4fafdd63d178523.tar.gz
tcl-cf8be2a4a6881ce0776abd08e4fafdd63d178523.tar.bz2
Fix for ticket [f4a4bd7f1070] - lseq "count" argument also dictates output formatting.
Solved by only consdering the start, end, and step values to determine the value formatting of the results. Real numbers can still be used for the Count value, as long as the value is a whole number.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdIL.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 8c1c162..19a6226 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -4139,7 +4139,8 @@ Tcl_LseqObjCmd(
Tcl_WideInt values[5];
Tcl_Obj *numValues[5];
Tcl_Obj *numberObj;
- int status = TCL_ERROR, keyword, useDoubles = 0, allowedArgs = NumericArg;
+ int status = TCL_ERROR, keyword, allowedArgs = NumericArg;
+ int useDoubles = 0;
int remNums = 3;
Tcl_Obj *arithSeriesPtr;
SequenceOperators opmode;
@@ -4184,7 +4185,7 @@ Tcl_LseqObjCmd(
}
numValues[value_i] = numberObj;
values[value_i] = keyword; /* TCL_NUMBER_* */
- useDoubles |= (keyword == TCL_NUMBER_DOUBLE) ? 1 : 0;
+ useDoubles += (keyword == TCL_NUMBER_DOUBLE) ? 1 : 0;
value_i++;
break;
@@ -4213,6 +4214,10 @@ Tcl_LseqObjCmd(
elementCount = numValues[0];
end = NULL;
step = one;
+ useDoubles = 0; // Can only have Integer value. If a fractional value
+ // is given, this will fail later. In other words,
+ // "3.0" is allowed and used as Integer, but "3.1"
+ // will be flagged as an error. (bug f4a4bd7f1070)
break;
/* lseq n n */
@@ -4339,6 +4344,8 @@ Tcl_LseqObjCmd(
/* Count needs to be integer, so try to convert if possible */
if (elementCount && TclHasInternalRep(elementCount, &tclDoubleType)) {
double d;
+ // Don't consider Count type to indicate using double values in seqence
+ useDoubles -= (useDoubles > 0) ? 1 : 0;
(void)Tcl_GetDoubleFromObj(NULL, elementCount, &d);
if (floor(d) == d) {
if ((d >= (double)WIDE_MAX) || (d <= (double)WIDE_MIN)) {