Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2020-05-13
20:33 • Closed ticket [c11e0c5ce4]: Regression in Tcl_UtfCharComplete plus 6 other c... artifact: 4e7c0f38a9 user: jan.nijtmans
2020-04-23
11:31
Fix [27944a3661]: Taming test utf-6.88 Fix [c11e0c5ce4]: Regression in Tcl_UtfCharComplete Fix [1b1f... check-in: 5c322bbd51 user: jan.nijtmans tags: core-8-6-branch
2020-04-21
10:19 • Ticket [c11e0c5ce4] Regression in Tcl_UtfCharComplete status still Open with... artifact: 06d3b88ae3 user: jan.nijtmans
2020-04-20
15:27 • Ticket [c11e0c5ce4]: 4 changes artifact: 46ab521d30 user: jan.nijtmans
15:20
Proposed fix for [c11e0c5ce4]: Regression in Tcl_UtfCharComplete. check-in: 21362ee023 user: jan.nijtmans tags: bug-c11e0c5ce4
2020-04-19
10:17 • New ticket [c11e0c5ce4] Regression in Tcl_UtfCharComplete. artifact: 75979458ab user: jan.nijtmans

Regression in Tcl_UtfCharComplete

Closed / Fixedc11e0c5ce426ac09151318d346c910b67d92346fCreated 7 years agoUpdated 7 years ago
Descriptionwiki2020-04-19 10:17:41
Starting with commit [c18f3f5870fc0b20], The original contract of Tcl_UtfCharComplete() is broken. It's easy to fix, and the fix has the fix for [27944a3661] as prequisite.

So, there is no test-case yet proving this, I'll come back too this ticket as soon as [27944a3661] is fixed.

Referenced by2
jan.nijtmanswiki2020-04-20 15:27:08

Proposed fix in: [21362ee023f0b464]. More testing needed, I'm not 100% sure yet this is what we want. Still need to add more explanation here, why the current core-8-6-branch situation is wrong ....

jan.nijtmanswiki2020-04-21 10:19:25

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.

jan.nijtmanswiki2020-05-13 20:33:10

Since in core-8-6-branch, Tcl_UtfPrev() and Tcl_UtfNext() now maximum jump TCL_UTF_MAX bytes, the regression mentioned in this ticket is fixed. A little bit different than I thought .... but OK. So, closing.

Log in (anonymous is fine) to add a comment.