Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-01-22
03:38 • Closed ticket [506297ffff]: Problems writing iso2022-jp plus 7 other changes artifact: 77c7adc412 user: andreas_kupries
03:36 • Ticket [506297ffff]: 4 changes artifact: b4c232d7a4 user: andreas_kupries
03:36 • Add attachment 506297-84.diff to ticket [506297ffff] artifact: 6dafb0e11d user: andreas_kupries
03:36 • Ticket [506297ffff] Problems writing iso2022-jp status still Open with 4 oth... artifact: f2839af489 user: andreas_kupries
03:36 • Add attachment 506297-834.diff to ticket [506297ffff] artifact: a1e350766e user: andreas_kupries
02:52 • Ticket [506297ffff] Problems writing iso2022-jp status still Open with 4 oth... artifact: 4d80a063b5 user: andreas_kupries
2002-01-21
13:14 • Ticket [506297ffff]: 4 changes artifact: b4f6876f6a user: andreas_kupries
12:57 • Ticket [506297ffff]: 5 changes artifact: 68d4973346 user: ruric
12:46 • Add attachment patch to ticket [506297ffff] artifact: e592cfa4f6 user: ruric
12:46 • Ticket [506297ffff] Problems writing iso2022-jp status still Open with 4 oth... artifact: b8be565ff9 user: ruric
05:46 • New ticket [506297ffff]. artifact: 9dee264f54 user: ruric

Problems writing iso2022-jp

Closed / Fixed506297ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2002-01-21 05:46:15
This happens on tcl8.3.4 (also tested on 8.3.3) on Linux.

I have a channel open for writing with encoding
iso2022-jp. When I "puts" a certain string tcl gets
stuck in a loop and the output file starts growing
indefinitely. The problem can be demonstrated by the
following script:

set string [format %s%c [string repeat " " 4094] 12399]
set f [open out w 0644]
fconfigure $f -encoding iso2022-jp
puts -nonewline $f $string
close $f

This script will, when executed, never get past teh
puts statement and the outfile will start to grow (fast:-).

The problem lies in WriteChars in tclIO.c. When
Tcl_UtfToExternal is called with TCL_ENCODING_START set
among the flags, then it will always generate at least
three bytes (assuming the output encoding is
iso2022-jp).  However it did not consume any of the
characters in the input buffer (at least not if
TCL_ENCODING_END is clear). But the logic in WriteChars
thinks that since it generated output we shoudl call it
again...

The attached patch fixes this by removing the
TCL_ENCODING_START bit from flags after the first call
to Tcl_UtfToExternal.
ruricplain2002-01-21 12:46:16
File Added - 16459: patch
ruricplain2002-01-21 12:57:07
Logged In: YES 
user_id=433503

OOPS, it seems as sourceforge actually inserted this into
the bug-database even through it gave men an error. At least
that applies to the earlier three copies now in there(:-().

So currently there are four reports for this bug:  506189
506292 506296 and this one
andreas_kupriesplain2002-01-21 13:14:39
Logged In: YES 
user_id=75003

Yep. I closed the others already. I will take this as the
main report, simply because here the submitter is not
Nobody/Anonymous :)
andreas_kupriesplain2002-01-22 02:52:38
Logged In: YES 
user_id=75003

* Confirmed behaviour for 8.3.4 and 8.4cvs

After the fix an outfile of size 4105
bytes is generated. Checksumming:

[andreask@pliers 84]$ cksum out
1762614785 4105 out

[andreask@pliers 84]$ md5sum out
b14544da022231b9116e2c4ca1acb7c5  out
andreas_kupriesplain2002-01-22 03:36:04
File Added - 16496: 506297-834.diff

Logged In: YES 
user_id=75003

Enclosing the official patches. Additional comments in the 
code explaining the problem and the fix. Additional test in 
the testsuite to check for this problem.
andreas_kupriesplain2002-01-22 03:36:39
File Added - 16497: 506297-84.diff
andreas_kupriesplain2002-01-22 03:38:49
Logged In: YES 
user_id=75003

Committed to head and core-8-3-1-branch.
Log in (anonymous is fine) to add a comment.

Attachments: