Overview
| Artifact ID: | 06d3b88ae3c9e8a686c87c4c975581ec245cafa9e0bbc2bf51bca566e80f29e8 |
|---|---|
| Ticket: | c11e0c5ce426ac09151318d346c910b67d92346f
Regression in Tcl_UtfCharComplete |
| User & Date: | jan.nijtmans on 2020-04-21 10:19:25 |
Changes
- icomment:
OK, the promised explanation. The invariant is that Tcl_UtfCharComplete(src, TCL_UTF_MAX) should always return true. Since TCL_UTF_MAX is the maximum number of bytes Tcl_UtfToUniChar() can advance, supplying a buffer of TCL_UTF_MAX bytes should be enough for Tcl_UtfToUniChar() to advance. This means that the table used by Tcl_UtfCharComplete() can not have any table entry with a value > TCL_UTF_MAX. Well, I made the same mistake in the TIP #542 implementation. I corrected that in commit [5f382f20565ff8ed] (together with another small improvement, handling byte C1 as invalid). There's another small cornercase, missed in the TIP #542 implementation. If an extension is compiled with TCL_UTF_MAX=4 while Tcl is built with TCL_UTF_MAX=3, then it might happen that the extension calls Tcl_UtfCharComplete() which then might give the wrong result. For Tcl_UtfToUniChar() special stub entries are created for this purpose, but for Tcl_UtfCharComplete() there are not separate stub entries for TCL_UTF_MAX=3 and TCL_UTF_MAX=4. The easiest fix is supplying a macro for this corner-case. Fixed here: [8d2927e1c43e9c83] So, let's fix [27944a3661] first, then I'll continue handling this for core-8-6-branch.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"