Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-11-14
14:01
Better - more complete - fix for [d433c0e0ad]: TCL_UTF_MAX == 4 problems. It allows emoji to be prod... check-in: 8a640c771e user: jan.nijtmans tags: core-8-6-branch
2019-11-13
14:25 • Closed ticket [d433c0e0ad]: TCL_UTF_MAX == 4 problems plus 5 other changes artifact: 04c41202c6 user: jan.nijtmans
14:07 • Ticket [d433c0e0ad]: 3 changes artifact: a0a66773a3 user: chw
12:39 • Ticket [d433c0e0ad]: 3 changes artifact: 9c486b5da7 user: jan.nijtmans
12:37
Part 2 of bugfix [d433c0e0ad]: TCL_UTF_MAX == 4 problems check-in: e377ac273f user: jan.nijtmans tags: core-8-6-branch
09:51 • Ticket [d433c0e0ad] TCL_UTF_MAX == 4 problems status still Pending with 3 ot... artifact: ca92f08d4b user: chw
09:21 • Ticket [d433c0e0ad]: 3 changes artifact: 3ed9242a56 user: jan.nijtmans
09:10 • Pending ticket [d433c0e0ad]. artifact: ae009b62bd user: jan.nijtmans
09:07
Fix TIP #389 implementation, bug [d433c0e0ad]: TCL_UTF_MAX == 4 problems. Thanks to Christian Werner... check-in: b5633ba3bd user: jan.nijtmans tags: core-8-6-branch
07:52 • Ticket [d433c0e0ad] TCL_UTF_MAX == 4 problems status still Open with 5 other... artifact: 4eb5c62f06 user: jan.nijtmans
06:47 • Ticket [d433c0e0ad]: 3 changes artifact: c9124ea821 user: chw
06:42 • Ticket [d433c0e0ad]: 3 changes artifact: ce383bd55f user: chw
2019-11-12
23:43 • New ticket [d433c0e0ad]. artifact: 2fb00348c4 user: chw

TCL_UTF_MAX == 4 problems

Closed / Fixedd433c0e0add0496ef4a7d73c8580149605dadff6Created 7 years agoUpdated 7 years ago
Descriptionplain2019-11-12 23:43:27
On Debian 9 using

 $ cd .../unix ; CC="cc -DTCL_UTF_MAX=4" ./configure --prefix=/tmp/mytcl --disable-static ; make
 $ ./tclsh
 % set X "\U1F602"

freezes when run in a gnome-terminal.

If an xterm is used instead, more chars than expected are output from the tclsh, as shown in
this strace dump:

 write(1, "\360\302\230\302\230\302\202\r\n", 9) = 9

When rebuilding with

 $ cd .../unix ; CC="cc -DTCL_UTF_MAX=6" ./configure --prefix=/tmp/mytcl --disable-static ; make
 $ ./tclsh
 % set X "\U1F602"

the emoji is properly displayed in gnome-terminal and strace yields the expected

 write(1, "\360\237\230\202\r\n",  6) = 6

Right now, this ticket is a showstopper for undroidwish/vanillawish (not for AndroidWish).
Referenced by3
  • 8a640c771eBetter - more complete - fix for [d433c0e0ad]: TCL_UTF_MAX == 4 problems. It allows emoji to be produced by the system encoding, even for other values of TCL_UTF_MAX. Also added test-cases for this. check-in2019-11-14 14:01:13
  • e377ac273fPart 2 of bugfix [d433c0e0ad]: TCL_UTF_MAX == 4 problems check-in2019-11-13 12:37:24
  • b5633ba3bdFix TIP #389 implementation, bug [d433c0e0ad]: TCL_UTF_MAX == 4 problems. Thanks to Christian Werner for the report. check-in2019-11-13 09:07:08
chwplain2019-11-13 06:42:25
The core-8-7-a3-rc branch built with

 $ cd .../unix ; CC="cc -DTCL_UTF_MAX=4" ./configure --prefix=/tmp/mytcl --disable-static ; make
 $ ./tclsh
 % set X "\U1F602"

gives some weird output in gnome-terminal and the strace dump is:

 write(1, "\360\313\234\313\234\342\200\232\r\n", 10)
chwplain2019-11-13 06:47:37
For reference, the core-8-6-9 branch built with

 $ cd .../unix ; CC="cc -DTCL_UTF_MAX=4" ./configure --prefix=/tmp/mytcl --disable-static ; make
 $ ./tclsh
 % set X "\U1F602"

outputs the expected emoji and the strace dump is:

 write(1, "\360\237\230\202\r\n", 6) = 6
jan.nijtmansplain2019-11-13 07:52:19
Thanks for the report. On core-8-6-10-rc this is definitely exported to work, so raising to "minor"
jan.nijtmanswiki2019-11-13 09:10:00

This should be fixed in [b5633ba3bd8fa74e]. Can you confirm that this fixes this? Thanks!

jan.nijtmanswiki2019-11-13 09:21:36

Did you bisect? If you did, I guess that commit [9e1984c250d1a859] introduced this bug. This commit made it possible that TclUtfToUniChar() is called when it points to the 2nd character of a valid 4-byte UTF-8 character. The macro didn't account for that.

Thanks!

chwplain2019-11-13 09:51:51
Again on Debian 9, core-8-6-branch [b5633ba3bd] using

  $ cd .../unix ; CC="cc -DTCL_UTF_MAX=4" ./configure --prefix=/tmp/mytcl --disable-static ; make
  $ ./tclsh
  % set X "\U1F602"

the gnome-terminal hangs and the strace dump is

  write(1, "\360\302\230\302\230\302\202\r\n", 9)

Using surrogate pair notation outputs the expected emoji

  % set X "\uD83D\uDE02"

and strace dump is

  write(1, "\360\237\230\202\r\n", 6) = 6

Now let's do the opposite direction

  % set X "\uD83D\uDE02"
  % set F [open OUT w]
  % puts -nonewline $F $X
  % close $F
  % set F [open OUT]
  % set Y [read $F] ; close $F
  % set Y

the gnome-terminal hangs again and the strace dump is

  write(1, "\303\260\302\230\302\230\302\202\r\n", 10)
jan.nijtmansplain2019-11-13 12:39:01
Please, try again with [e377ac273f]. I think I really got it now ...
chwplain2019-11-13 14:07:20
Bingo! The exact same sequence I've run against [b5633ba3bd]
now works both with "\U1F602" and "\uD83D\uDE02" notation.
I think you can close the ticket now, thanks for fixing.
jan.nijtmansplain2019-11-13 14:25:53
Thanks for confirming the fix! ..  And for the bug report to start with ... !!!!
Log in (anonymous is fine) to add a comment.