From 487afeafb49cf664828bc5ccb8781791e57df28a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 24 Jun 2025 14:54:48 +0000 Subject: Fix [ecafd8611d]: Euro-sign missing from cp864 encoding. While on it, add cp165 which is very similar to cp864 --- library/encoding/cp165.enc | 20 ++++++++++++++++++++ library/encoding/cp864.enc | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 library/encoding/cp165.enc diff --git a/library/encoding/cp165.enc b/library/encoding/cp165.enc new file mode 100755 index 0000000..83ac442 --- /dev/null +++ b/library/encoding/cp165.enc @@ -0,0 +1,20 @@ +# Encoding file: cp165, single-byte +S +003F 0 1 +00 +0000000100020003000400050006000700080009000A000B000C000D000E000F +0010001100120013001400150016001700180019001A001B001C001D001E001F +00200021002200230024066A0026002700280029002A002B002C002D002E002F +0030003100320033003400350036003700380039003A003B003C003D003E003F +0040004100420043004400450046004700480049004A004B004C004D004E004F +0050005100520053005400550056005700580059005A005B005C005D005E005F +0060006100620063006400650066006700680069006A006B006C006D006E006F +0070007100720073007400750076007700780079007A007B007C007D007E007F +00B000B72219221A259225002502253C2524252C251C25342510250C25142518 +03B2221E03C600B100BD00BC224800AB00BBFEF7FEF8FEF9FEFAFEFBFEFC009F +00A000ADFE8200A300A4FE84FE87FE88FE8EFE8FFE95FE99060CFE9DFEA1FEA5 +0660066106620663066406650666066706680669FED1061BFEB1FEB5FEB9061F +00A2FE80FE81FE83FE85FECAFE8BFE8DFE91FE93FE97FE9BFE9FFEA3FEA7FEA9 +FEABFEADFEAFFEB3FEB7FEBBFEBFFEC1FEC5FECBFECF00A600AC00F700D7FEC9 +0640FED3FED7FEDBFEDFFEE3FEE7FEEBFEEDFEEFFEF3FEBDFECCFECEFECDFEE1 +FE7D0651FEE5FEE9FEECFEF0FEF2FED0FED5FEF5FEF6FEDDFED9FEF125A000A0 diff --git a/library/encoding/cp864.enc b/library/encoding/cp864.enc index 71f9e62..e2a9e6e 100644 --- a/library/encoding/cp864.enc +++ b/library/encoding/cp864.enc @@ -12,7 +12,7 @@ S 0070007100720073007400750076007700780079007A007B007C007D007E007F 00B000B72219221A259225002502253C2524252C251C25342510250C25142518 03B2221E03C600B100BD00BC224800AB00BBFEF7FEF8009B009CFEFBFEFC009F -00A000ADFE8200A300A4FE8400000000FE8EFE8FFE95FE99060CFE9DFEA1FEA5 +00A000ADFE8200A300A4FE84000020ACFE8EFE8FFE95FE99060CFE9DFEA1FEA5 0660066106620663066406650666066706680669FED1061BFEB1FEB5FEB9061F 00A2FE80FE81FE83FE85FECAFE8BFE8DFE91FE93FE97FE9BFE9FFEA3FEA7FEA9 FEABFEADFEAFFEB3FEB7FEBBFEBFFEC1FEC5FECBFECF00A600AC00F700D7FEC9 -- cgit v0.12 From 69768ac78c9e9f3b05c648eba323f732550b3165 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 24 Jun 2025 14:59:34 +0000 Subject: Fix encoding-28.0 unit-test, since we now have an additional encoding --- tests/encoding.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/encoding.test b/tests/encoding.test index 93a52aa..b37e13c 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -735,7 +735,7 @@ test encoding-28.0 {all encodings load} -body { llength $name } return $count -} -result 85 +} -result 86 runtests -- cgit v0.12 From 122a3f6a2d14ec2cbbcd1a1a938fe14e1f2f840b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 24 Jun 2025 15:09:15 +0000 Subject: Add testcases --- tests/encoding.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/encoding.test b/tests/encoding.test index b37e13c..46f3b15 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -310,6 +310,12 @@ test encoding-12.5 {LoadTableEncoding: symbol encoding} { test encoding-12.6 {LoadTableEncoding: overflow in char value} ucs2 { encoding convertto iso8859-3 \U010000 } ? +test encoding-12.7 {cp864 [ecafd8611d]} { + scan [encoding convertfrom cp864 \xA7] %c +} 8364 +test encoding-12.8 {cp165 [ecafd8611d]} { + scan [encoding convertfrom cp165 \xA7] %c +} 65160 test encoding-13.1 {LoadEscapeTable} { viewable [set x [encoding convertto iso2022 ab\u4E4E\u68D9g]] -- cgit v0.12 From 5193d058c2cb451adf74ed7a8b12fcf365a3fc97 Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 24 Jun 2025 17:15:01 +0000 Subject: [ecf35c7120] Correct nested handling of return option -options (backport from 9.0) --- generic/tclResult.c | 92 +++++++++++++++++++++++++++++------------------------ tests/cmdMZ.test | 13 ++++++++ 2 files changed, 63 insertions(+), 42 deletions(-) diff --git a/generic/tclResult.c b/generic/tclResult.c index 8ec9184..1d9ac84 100644 --- a/generic/tclResult.c +++ b/generic/tclResult.c @@ -1362,6 +1362,9 @@ TclProcessReturn( * * Parses, checks, and stores the options to the [return] command. * + * The number of arguments (objc) must be even, with the corresponding + * objv holding values to be processed as key value .... key value. + * * Results: * Returns TCL_ERROR if any of the option values are invalid. Otherwise, * returns TCL_OK, and writes the returnOpts, code, and level values to @@ -1373,6 +1376,49 @@ TclProcessReturn( *---------------------------------------------------------------------- */ +static int +ExpandedOptions( + Tcl_Interp *interp, /* Current interpreter. */ + Tcl_Obj **keys, /* Built-in keys (per thread) */ + Tcl_Obj *returnOpts, /* Options dict we are building */ + int objc, /* Number of arguments. */ + Tcl_Obj *const objv[]) /* Argument objects. */ +{ + for (; objc > 1; objv += 2, objc -= 2) { + const char *opt = TclGetString(objv[0]); + const char *compare = TclGetString(keys[KEY_OPTIONS]); + + if ((objv[0]->length == keys[KEY_OPTIONS]->length) + && (memcmp(opt, compare, objv[0]->length) == 0)) { + /* Process the -options switch to emulate {*} expansion. + * + * Use lists so duplicate keys are not lost. + */ + + int nestc; + Tcl_Obj **nestv; + + if (TCL_ERROR == TclListObjGetElements(interp, objv[1], + &nestc, &nestv) || (nestc % 2)) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "bad -options value: expected dictionary but got" + " \"%s\"", TclGetString(objv[1]))); + Tcl_SetErrorCode(interp, "TCL", "RESULT", "ILLEGAL_OPTIONS", + (char *)NULL); + return TCL_ERROR; + } + + if (TCL_ERROR == + ExpandedOptions(interp, keys, returnOpts, nestc, nestv)) { + return TCL_ERROR; + } + } else { + Tcl_DictObjPut(NULL, returnOpts, objv[0], objv[1]); + } + } + return TCL_OK; +} + int TclMergeReturnOptions( Tcl_Interp *interp, /* Current interpreter. */ @@ -1392,49 +1438,11 @@ TclMergeReturnOptions( Tcl_Obj *returnOpts; Tcl_Obj **keys = GetKeys(); - TclNewObj(returnOpts); - for (; objc > 1; objv += 2, objc -= 2) { - int optLen, compareLen; - const char *opt = TclGetStringFromObj(objv[0], &optLen); - const char *compare = - TclGetStringFromObj(keys[KEY_OPTIONS], &compareLen); - - if ((optLen == compareLen) && (memcmp(opt, compare, optLen) == 0)) { - Tcl_DictSearch search; - int done = 0; - Tcl_Obj *keyPtr; - Tcl_Obj *dict = objv[1]; - - nestedOptions: - if (TCL_ERROR == Tcl_DictObjFirst(NULL, dict, &search, - &keyPtr, &valuePtr, &done)) { - /* - * Value is not a legal dictionary. - */ + /* All callers are expected to pass an even value for objc. */ - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad %s value: expected dictionary but got \"%s\"", - compare, TclGetString(objv[1]))); - Tcl_SetErrorCode(interp, "TCL", "RESULT", "ILLEGAL_OPTIONS", - (char *)NULL); - goto error; - } - - while (!done) { - Tcl_DictObjPut(NULL, returnOpts, keyPtr, valuePtr); - Tcl_DictObjNext(&search, &keyPtr, &valuePtr, &done); - } - - Tcl_DictObjGet(NULL, returnOpts, keys[KEY_OPTIONS], &valuePtr); - if (valuePtr != NULL) { - dict = valuePtr; - Tcl_DictObjRemove(NULL, returnOpts, keys[KEY_OPTIONS]); - goto nestedOptions; - } - - } else { - Tcl_DictObjPut(NULL, returnOpts, objv[0], objv[1]); - } + TclNewObj(returnOpts); + if (TCL_ERROR == ExpandedOptions(interp, keys, returnOpts, objc, objv)) { + goto error; } /* diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index 5ca1ed4..b8f572b 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -197,6 +197,19 @@ test cmdMZ-return-2.18 {return option handling} { return -code error -errorstack [list CALL a CALL b] yo } -> foo] [dictSort $foo] [info errorstack] } {2 {-code 1 -errorcode NONE -errorstack {CALL a CALL b} -level 1} {CALL a CALL b}} +test cmdMZ-return-2.19 {return option handling} -body { + return -level 0 -options {-options {-code break} -code continue} +} -returnCodes continue -result {} +test cmdMZ-return-2.20 {return option handling} { + list [catch { + return -level 0 -options {-foo 1} -options {-bar 2} + } -> foo] $foo +} {0 {-foo 1 -bar 2 -code 0 -level 0}} +test cmdMZ-return-2.21 {return option handling} { + list [catch { + return -level 0 -options {-options {-foo 1} -options {-bar 2}} + } -> foo] $foo +} {0 {-foo 1 -bar 2 -code 0 -level 0}} # Check that the result of a [return -options $opts $result] is # indistinguishable from that of the originally caught script, no matter what -- cgit v0.12 From 264e9e9793c226da345b341c28c8050cb33bd7b3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 25 Jun 2025 11:51:09 +0000 Subject: Fix [ecafd8611d]: Euro/Tail-sign missing from cp864 encoding --- changes | 2 +- library/encoding/cp165.enc | 2 +- library/encoding/cp864.enc | 2 +- tools/encoding/cp864.txt | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changes b/changes index 327a4bf..31c2ad6 100644 --- a/changes +++ b/changes @@ -9399,4 +9399,4 @@ Many code fixes to avoid overflow or undefined behavior. Thanks chrstphrchvz. 2025-06-24 (bug) [ecf35c] Correct nested handling of return option -options (porter) -2025-06-25 (bug) [ecafd8] Euro-sign missing from cp864 encoding (nijtmans) +2025-06-25 (bug) [ecafd8] Euro/Tail-sign missing from cp864 encoding (nijtmans) diff --git a/library/encoding/cp165.enc b/library/encoding/cp165.enc index 83ac442..b796d58 100755 --- a/library/encoding/cp165.enc +++ b/library/encoding/cp165.enc @@ -11,7 +11,7 @@ S 0060006100620063006400650066006700680069006A006B006C006D006E006F 0070007100720073007400750076007700780079007A007B007C007D007E007F 00B000B72219221A259225002502253C2524252C251C25342510250C25142518 -03B2221E03C600B100BD00BC224800AB00BBFEF7FEF8FEF9FEFAFEFBFEFC009F +03B2221E03C600B100BD00BC224800AB00BBFEF7FEF8FEF9FEFAFEFBFEFCFE73 00A000ADFE8200A300A4FE84FE87FE88FE8EFE8FFE95FE99060CFE9DFEA1FEA5 0660066106620663066406650666066706680669FED1061BFEB1FEB5FEB9061F 00A2FE80FE81FE83FE85FECAFE8BFE8DFE91FE93FE97FE9BFE9FFEA3FEA7FEA9 diff --git a/library/encoding/cp864.enc b/library/encoding/cp864.enc index e2a9e6e..13c715c 100644 --- a/library/encoding/cp864.enc +++ b/library/encoding/cp864.enc @@ -11,7 +11,7 @@ S 0060006100620063006400650066006700680069006A006B006C006D006E006F 0070007100720073007400750076007700780079007A007B007C007D007E007F 00B000B72219221A259225002502253C2524252C251C25342510250C25142518 -03B2221E03C600B100BD00BC224800AB00BBFEF7FEF8009B009CFEFBFEFC009F +03B2221E03C600B100BD00BC224800AB00BBFEF7FEF8009B009CFEFBFEFCFE73 00A000ADFE8200A300A4FE84000020ACFE8EFE8FFE95FE99060CFE9DFEA1FEA5 0660066106620663066406650666066706680669FED1061BFEB1FEB5FEB9061F 00A2FE80FE81FE83FE85FECAFE8BFE8DFE91FE93FE97FE9BFE9FFEA3FEA7FEA9 diff --git a/tools/encoding/cp864.txt b/tools/encoding/cp864.txt index 7aa055f..98b9630 100644 --- a/tools/encoding/cp864.txt +++ b/tools/encoding/cp864.txt @@ -174,7 +174,7 @@ 0x9c #UNDEFINED 0x9d 0xfefb #ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM 0x9e 0xfefc #ARABIC LIGATURE LAM WITH ALEF FINAL FORM -0x9f #UNDEFINED +0x9f 0xfe73 #ARABIC TAIL FRAGMENT 0xa0 0x00a0 #NON-BREAKING SPACE 0xa1 0x00ad #SOFT HYPHEN 0xa2 0xfe82 #ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM @@ -182,7 +182,7 @@ 0xa4 0x00a4 #CURRENCY SIGN 0xa5 0xfe84 #ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM 0xa6 #UNDEFINED -0xa7 #UNDEFINED +0xa7 0x20ac #EURO SIGN 0xa8 0xfe8e #ARABIC LETTER ALEF FINAL FORM 0xa9 0xfe8f #ARABIC LETTER BEH ISOLATED FORM 0xaa 0xfe95 #ARABIC LETTER TEH ISOLATED FORM -- cgit v0.12