summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-05-30 21:26:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-05-30 21:26:39 (GMT)
commit19592f48720d9e5acc55f0b9086d0a9c380b82a1 (patch)
treedff97bf5517c86961d95833865c2e04da7a4365f
parent6a4ce2b6c03f5c2a44621116154867ef8ab48b2e (diff)
downloadtcl-19592f48720d9e5acc55f0b9086d0a9c380b82a1.zip
tcl-19592f48720d9e5acc55f0b9086d0a9c380b82a1.tar.gz
tcl-19592f48720d9e5acc55f0b9086d0a9c380b82a1.tar.bz2
Let's [9c258a841a|fix] the j%j/%q type specifiers, so they behave like C in scripts, and document them
-rw-r--r--doc/format.n12
-rw-r--r--generic/tclStringObj.c8
2 files changed, 12 insertions, 8 deletions
diff --git a/doc/format.n b/doc/format.n
index b647349..b0a0107 100644
--- a/doc/format.n
+++ b/doc/format.n
@@ -138,19 +138,17 @@ If it is \fBll\fR it specifies that an integer value is taken
without truncation for conversion to a formatted substring.
If it is \fBh\fR it specifies that an integer value is
truncated to a 16-bit range before converting. This option is rarely useful.
-If it is \fBl\fR it specifies that the integer value is
-truncated to the same range as that produced by the \fBwide()\fR
+If it is \fBl\fR (or \fBj\fR or \fBq\fR) it specifies that the integer value
+is truncated to the same range as that produced by the \fBwide()\fR
function of the \fBexpr\fR command (at least a 64-bit range).
If it is \fBz\fR or \fBt\fR it specifies that the integer value is
truncated to the range determined by the value of the \fBpointerSize\fR
element of the \fBtcl_platform\fR array.
If it is \fBL\fR it specifies that an integer or double value is taken
without truncation for conversion to a formatted substring.
-If neither \fBh\fR nor \fBl\fR nor \fBL\fR are present, the integer value is
-truncated to the same range as that produced by the \fBint()\fR
-function of the \fBexpr\fR command (at least a 32-bit range, but
-determined by the value of the \fBwordSize\fR element of the
-\fBtcl_platform\fR array).
+If neither of those are present, the integer value is
+truncated to the range determined by the value of the
+\fBwordSize\fR element of the \fBtcl_platform\fR array).
.SS "MANDATORY CONVERSION TYPE"
.PP
The last thing in a conversion specifier is an alphabetic character
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 494451d..b4da1a9 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -2457,6 +2457,12 @@ Tcl_AppendFormatToObj(
format += step;
step = TclUtfToUniChar(format, &ch);
}
+ } else if ((ch == 'q') || (ch == 'j')) {
+ format += step;
+ step = TclUtfToUniChar(format, &ch);
+#ifndef TCL_WIDE_INT_IS_LONG
+ useWide = 1;
+#endif
} else if ((ch == 't') || (ch == 'z')) {
format += step;
step = TclUtfToUniChar(format, &ch);
@@ -2465,7 +2471,7 @@ Tcl_AppendFormatToObj(
useWide = 1;
}
#endif
- } else if ((ch == 'q') || (ch == 'j') || (ch == 'L')) {
+ } else if (ch == 'L') {
format += step;
step = TclUtfToUniChar(format, &ch);
useBig = 1;