Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2020-04-23
11:39 • Closed ticket [493dccc2de]: Taming test utf-2.11 plus 5 other changes artifact: 3b19b59715 user: jan.nijtmans
2020-04-22
15:24 • Ticket [493dccc2de]: 3 changes artifact: 89cfdd0ca2 user: dgp
15:01 • Ticket [493dccc2de]: 3 changes artifact: 70e5dd9e2f user: dgp
14:58 • Ticket [493dccc2de]: 3 changes artifact: 7f511400a7 user: dgp
13:39 • Ticket [493dccc2de]: 3 changes artifact: 49a96d913f user: jan.nijtmans
13:38 • Ticket [493dccc2de]: 3 changes artifact: 0b1b99edce user: jan.nijtmans
13:20 • Ticket [493dccc2de]: 3 changes artifact: e8257216a4 user: sebres
12:06 • Ticket [493dccc2de]: 3 changes artifact: abe26f8161 user: jan.nijtmans
10:21 • Ticket [493dccc2de]: 3 changes artifact: 4ca718a482 user: sebres
07:45 • Ticket [493dccc2de]: 3 changes artifact: f4ef2c6d73 user: jan.nijtmans
2020-04-20
05:09
Apply fix for [493dccc2de] and adjust tests. check-in: 7db642d35a user: dgp tags: dgp-utf-explore
2020-04-17
21:08 • Pending ticket [493dccc2de]: Taming test utf-2.11 plus 4 other changes artifact: 63df3958ac user: dgp
21:07
[493dccc2de] Revise sequence validity check to reject out of range decodes too. check-in: 2282b5ecbf user: dgp tags: core-8-5-branch
20:38
[493dccc2de] Coverage that Tcl_UtfPrev also checks the upper range validity. check-in: 610d63729c user: dgp tags: core-8-5-branch
16:04 • Ticket [493dccc2de] Taming test utf-2.11 status still Open with 3 other chan... artifact: 51111fe6dc user: dgp
15:42 • Ticket [493dccc2de]: 3 changes artifact: d2247384ca user: dgp
15:40 • Ticket [493dccc2de]: 3 changes artifact: af46db5c46 user: dgp
15:37 • Ticket [493dccc2de]: 3 changes artifact: a8d75c8ba3 user: jan.nijtmans
15:26 • Ticket [493dccc2de]: 4 changes artifact: 91c9b63cb0 user: dgp
15:22 • New ticket [493dccc2de]. artifact: 7c3e86aeaf user: dgp

Taming test utf-2.11

Closed / Fixed493dccc2def8f673fba39d1d144fc6a35b5b9a5cCreated 7 years agoUpdated 7 years ago
Descriptionplain2020-04-17 15:22:57
Fresh ticket to sort out what we expect from test utf-2.11 with body:

    string length [testbytestring "\xF4\x90\x80\x80"]

According to the normal rules of UTF-8, the test considers the proper
4 byte encoding of the codepoint U+10000 and the test is testing what
Tcl does with it. We should expect different version and different 
configuration builds to give different results.
Referenced by3
dgp Ticket [493dccc2de]: 4 changes [History diff]2020-04-17 15:26:33
jan.nijtmansplain2020-04-17 15:37:43
No, it translates to code point U+110000, which is too big.
dgpplain2020-04-17 15:40:38
Aha!  Misread the lead byte and get the wrong answer.

\xF4\x90\x80\x80
     ^

would decode to U+110000 which is outside the Unicode range,
which is what the test is meant to check the handling of.
dgpplain2020-04-17 15:42:00
Important lesson, the set of codepoints that can be encoded in a 4-byte sequence
is strictly greater than the set of codepoints acceptable in Unicode.
dgpplain2020-04-17 16:04:40
Thanks for your patience. This should be simple to fix with
an adaptation of Overlong(). Stay tuned.
dgpplain2020-04-17 21:08:12
Fix committed to 8.5.  Careful merge work still needed.
jan.nijtmansplain2020-04-22 07:45:12
Since the fix is merged to 8.6, and never existed on 8.7 and 9.0, this ticket can be closed now.

Don, agreed!
sebreswiki2020-04-22 10:21:35

As for [b38c307e41], why not both (testsize command and format as fallback) for ucs2 constraint, Jan?

I mean:

  [expr {[llength [info commands testsize]] ?
	[testsize unichar] == 2 : [format %c 0x010000] eq "\uFFFD"
  }]
Because if tested with compiled test-module, testsize is more "precise" or rather fewer error-prone then, otherwise the tests become "protected" by format expression (at least for 8.5/8.6).

jan.nijtmanswiki2020-04-22 12:06:10

@sebres, Well, "format %c" uses Tcl_UniCharToUtf() to convert the integer to a UTF-8 byte sequence. This function returns the UTF-8 sequence of \xFFFD for out-of range Unicode character values. It does this, even as far back as Tcl 8.4:

https://core.tcl-lang.org/tcl/artifact?udc=1&ln=183-211&name=b972e779b5e039b4

Looks like a perfect feature-test to me, works for any Tcl version in the past, should work for any Tcl version in the future. Your suggestion is harmless, but I don't see the added values. Sorry :-)

sebreswiki2020-04-22 13:20:24

> 1. "format %c" uses Tcl_UniCharToUtf() to convert the integer to a UTF-8 byte sequence.
> 2. This function returns the UTF-8 sequence of \xFFFD for out-of range Unicode character values.
Sure, but either 1 or 2 can change in some version (or derivation). But OK, I understand.
Nevertheless I would at least change it to something more clear and less conditional, like this:
   [expr {[scan [format %c 0x010000] %c] != 0x010000}]

jan.nijtmanswiki2020-04-22 13:38:07

> Sure, but either 1 or 2 can change in some version (or derivation)

Well, Tcl 8.7 will use utf16 in stead of ucs2 for internal storage:

$ tclsh8.7 % format %c 0x010000 𐀀 % expr {[format %c 0x010000] eq "\uFFFD"} 0 % expr {[format %c 0x010000] eq "\U010000"} 1 %

This means that the "ucs2" 'feature' will be gone when Tcl 8.6 is gone. Long live Tcl 8.7!

jan.nijtmanswiki2020-04-22 13:39:39

Well, Tcl 8.7 will use utf16 in stead of ucs2 for internal storage:

$ tclsh8.7
% format %c 0x010000
𐀀
% expr {[format %c 0x010000] eq "\uFFFD"}
0
% expr {[format %c 0x010000] eq "\U010000"}
1
%
This means that the "ucs2" 'feature' will be gone when Tcl 8.6 is gone. Long live Tcl 8.7!

dgpplain2020-04-22 14:58:54
Ok, the constraint conversation is over here.  Here's my comment copied over:

The constraint "ucs2" is distinct from "compat85" and needs to be restored.

"ucs2" might be a bad name for it. We can change that, but I need a way
to directly determine whether (sizeof(Tcl_UniChar) == 2) and nothing else.

The "compat85" constraint tests whether Tcl has no way to internally
store codepoints > U+FFFF. That is not the same thing.

In a default build of Tcl 8.7, the "compat85" constraint should be false,
but the "ucs2" constraint should be true.
dgpplain2020-04-22 15:01:33
The purpose of the "ucs2" constraint is to permit skipping of tests in builds
where the bug [1004065] is not fixed and not made irrelevant by other
developments.  My hope is that the use of this constraint will be temporary.
dgpplain2020-04-22 15:24:53
I like "ucs2" as a better name for what used to be "compat85". Keep that.

I'll convert the other constraint to the name "twobyteunit" unless someone else beats me to it.
jan.nijtmans Closed ticket [493dccc2de]. [History diff]2020-04-23 11:39:18
Log in (anonymous is fine) to add a comment.