Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix issue [b3628609ad73a105] by scrapping most of TclStringCat() in favor of
Tcl_AppendObjToObj().
jn: See https://github.com/tcltk/tcl/actions/runs/4740740589/jobs/8416919499 for one of the reasons for rejection. Also, I share Ashok's remark |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | pyk-b3628609ad |
Files: | files | file ages | folders |
SHA3-256: |
b699959d625540f801955902b97b0d13 |
User & Date: | pooryorick 2023-04-21 22:10:46.698 |
Original Comment: | Fix issue [b3628609ad73a105] by scrapping most of TclStringCat() in favor of Tcl_AppendObjToObj(). |
References
2023-09-12
| ||
12:40 | • Closed ticket [b3628609ad]: concatenating strings is broken when the "bytes" field of a Tcl_Obj contains invalid data and the type is not tclStringType plus 6 other changes artifact: 695c5061ed user: jan.nijtmans | |
2023-04-21
| ||
22:14 | • Pending ticket [b3628609ad]. artifact: b22b9b706c user: pooryorick | |
Context
2023-04-22
| ||
19:07 | Remove after that was inserted for debugging. Closed-Leaf check-in: 40f8ebb234 user: pooryorick tags: pyk-b3628609ad | |
2023-04-21
| ||
22:10 | Fix issue [b3628609ad73a105] by scrapping most of TclStringCat() in favor of Tcl_AppendObjToObj(). ... check-in: b699959d62 user: pooryorick tags: pyk-b3628609ad | |
20:39 | Merge 8.7 check-in: 9cbb0b212f user: jan.nijtmans tags: trunk, main | |
Changes
Changes to generic/tclStringObj.c.
︙ | ︙ | |||
1421 1422 1423 1424 1425 1426 1427 | Tcl_Obj *appendObjPtr) /* The value to append. */ { String *stringPtr; Tcl_Size length = 0, numChars; Tcl_Size appendNumChars = TCL_INDEX_NONE; const char *bytes; | | > > > > > | > > > > > | 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 | Tcl_Obj *appendObjPtr) /* The value to append. */ { String *stringPtr; Tcl_Size length = 0, numChars; Tcl_Size appendNumChars = TCL_INDEX_NONE; const char *bytes; if (appendObjPtr->bytes == &tclEmptyString || (( TclIsPureByteArray(appendObjPtr) && Tcl_GetCharLength(appendObjPtr) == 0) ) ) { return; } if (objPtr->bytes == &tclEmptyString || ( TclIsPureByteArray(objPtr) && Tcl_GetCharLength(objPtr) == 0 ) ) { TclSetDuplicateObj(objPtr, appendObjPtr); return; } if ( TclIsPureByteArray(appendObjPtr) && (TclIsPureByteArray(objPtr) || objPtr->bytes == &tclEmptyString) |
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 | AppendUnicodeToUnicodeRep(objPtr, unicode, numChars); } else { bytes = Tcl_GetStringFromObj(appendObjPtr, &length); AppendUtfToUnicodeRep(objPtr, bytes, length); } return; } /* * Append to objPtr's UTF string rep. If we know the number of characters * in both objects before appending, then set the combined number of * characters in the final (appended-to) object. */ | > | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | AppendUnicodeToUnicodeRep(objPtr, unicode, numChars); } else { bytes = Tcl_GetStringFromObj(appendObjPtr, &length); AppendUtfToUnicodeRep(objPtr, bytes, length); } return; } /* * Append to objPtr's UTF string rep. If we know the number of characters * in both objects before appending, then set the combined number of * characters in the final (appended-to) object. */ |
︙ | ︙ | |||
3105 3106 3107 3108 3109 3110 3111 | * On error, when interp is not NULL, error information is left in it. * *--------------------------------------------------------------------------- */ Tcl_Obj * TclStringCat( | | < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 | * On error, when interp is not NULL, error information is left in it. * *--------------------------------------------------------------------------- */ Tcl_Obj * TclStringCat( TCL_UNUSED(Tcl_Interp *), Tcl_Size objc, Tcl_Obj * const objv[], int flags) { Tcl_Obj *objResultPtr, * const *ov; Tcl_Size oc; int inPlace = flags & TCL_STRING_IN_PLACE; /* assert ( objc >= 0 ) */ if (objc <= 1) { /* Negative (shouldn't be), one or no objects; return first or empty */ return objc == 1 ? objv[0] : Tcl_NewObj(); } /* assert ( objc >= 2 ) */ if (inPlace && !Tcl_IsShared(objv[0])) { objResultPtr = objv[0]; } else { objResultPtr = Tcl_DuplicateObj(objv[0]); } ov = ++objv, oc = --objc; do { Tcl_Obj *objPtr = *ov++; Tcl_AppendObjToObj(objResultPtr, objPtr); } while (--oc); return objResultPtr; } /* *--------------------------------------------------------------------------- * * TclStringCmp -- * Compare two Tcl_Obj values as strings. |
︙ | ︙ |
Changes to tests/append.test.
︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | } -result \uD83D\uDE02 test append-3.7 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \xC0] string length [append x [testbytestring \x80]] } -result 2 test append-3.8 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \xC0] string length $x[testbytestring \x80] } -result 2 test append-3.9 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \x80] string length [testbytestring \xC0]$x } -result 2 test append-3.10 {append surrogates} -body { | > > > > > > > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | } -result \uD83D\uDE02 test append-3.7 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \xC0] string length [append x [testbytestring \x80]] } -result 2 test append-3.8 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \xC0] string length $x[testbytestring \x80] } -result 2 test append-3.8.list { append \xC0 \x80 using [list] to make sure internal rep isn't tclStringType Intended to exercise TclStringCat, which is on the byte-compiled path. } -constraints testbytestring -body { set x [list [testbytestring \xC0]] after 1 string length $x[testbytestring \x80] } -result 2 test append-3.9 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \x80] string length [testbytestring \xC0]$x } -result 2 test append-3.10 {append surrogates} -body { |
︙ | ︙ |
Changes to tests/string.test.
︙ | ︙ | |||
2429 2430 2431 2432 2433 2434 2435 | test string-29.11.$noComp {string cat, efficiency} -body { tcl::unsupported::representation \ [run {string cat [list x] [encoding convertto utf-8 {}]}] } -match glob -result {*no string representation} test string-29.12.$noComp {string cat, efficiency} -body { tcl::unsupported::representation \ [run {string cat [encoding convertto utf-8 {}] [list x]}] | | | | 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 | test string-29.11.$noComp {string cat, efficiency} -body { tcl::unsupported::representation \ [run {string cat [list x] [encoding convertto utf-8 {}]}] } -match glob -result {*no string representation} test string-29.12.$noComp {string cat, efficiency} -body { tcl::unsupported::representation \ [run {string cat [encoding convertto utf-8 {}] [list x]}] } -match glob -result {*, no string representation} test string-29.13.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat \ [encoding convertto utf-8 {}] [encoding convertto utf-8 {}] [list x]}] } -match glob -result {*, no string representation} test string-29.14.$noComp {string cat, efficiency} -setup { set e [encoding convertto utf-8 {}] } -cleanup { unset e } -body { tcl::unsupported::representation [run {string cat $e $e [list x]}] } -match glob -result {*no string representation} |
︙ | ︙ |