diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-01-28 18:50:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-01-28 18:50:32 (GMT) |
commit | 468b1a434681f98ea64d399abce7ddd8c605617d (patch) | |
tree | 5b0780a8104388c5d245fc2b035f1c3e85f94887 | |
parent | 5d13f6b52781e4d4f0063f4df3f25cce990f6697 (diff) | |
download | tcl-468b1a434681f98ea64d399abce7ddd8c605617d.zip tcl-468b1a434681f98ea64d399abce7ddd8c605617d.tar.gz tcl-468b1a434681f98ea64d399abce7ddd8c605617d.tar.bz2 |
Fix "format %c 0x10000041", should give the same answer as in Tcl 8.6 (Handling of TCL_COMBINE flag should not be visible at script level)
-rw-r--r-- | generic/tclStringObj.c | 3 | ||||
-rw-r--r-- | tests/format.test | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index a041d4c..e1376f4 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2130,6 +2130,9 @@ Tcl_AppendFormatToObj( if (TclGetIntFromObj(interp, segment, &code) != TCL_OK) { goto error; } + if ((unsigned)code > 0x10FFFF) { + code = 0xFFFD; + } length = Tcl_UniCharToUtf(code, buf); #if TCL_UTF_MAX < 4 if ((code >= 0xD800) && (length < 3)) { diff --git a/tests/format.test b/tests/format.test index c47774a..8cabbf1 100644 --- a/tests/format.test +++ b/tests/format.test @@ -402,6 +402,9 @@ test format-8.26 {Undocumented formats} -body { test format-8.27 {Undocumented formats} -constraints pointerIs64bit -body { format "%p %#llx" [expr {2**33}] [expr {2**33}] } -result {0x200000000 0x200000000} +test format-8.28 {Internal use of TCL_COMBINE flag should not be visiable at script level} { + format %c 0x10000041 +} \uFFFD test format-9.1 {long result} { set a {1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} |