|
2014-10-10
| ||
| 19:57 | • Closed ticket [bf7135428c]: Tcl_Write() breaks interface in 8.5.16 and 8.6.2... artifact: 07341351a8 user: dgp | |
| 19:56 | [bf7135428c] Restore the Tcl_Write() return value logic. check-in: 2e1556fb0e user: dgp tags: trunk | |
| 19:54 | [bf7135428c] Restore the Tcl_Write() return value logic. check-in: 9e301d16f7 user: dgp tags: core-8-5-branch | |
| 17:04 | • Ticket [bf7135428c] Tcl_Write() breaks interface in 8.5.16 and 8.6.2 status ... artifact: 05db5524d8 user: dgp | |
| 16:31 | • New ticket [bf7135428c]. artifact: d76ca959dd user: dgp | |
Tcl_Write() breaks interface in 8.5.16 and 8.6.2
Closed / Fixedbf7135428c3086e7704e2ccddf8c3066eb7fc36cCreated 12 years agoUpdated 12 years ago
Descriptionplain2014-10-10 16:31:23
Tcl_Write() as released in Tcl 8.5.16 and 8.6.2 no longer compatibly returns the same values it did in prior releases. Tcl_Write(chan, buf, toWrite) does not have its return value clearly documented. It is only described as "similar to Tcl_WriteChars". In the code comments heading the Tcl_Write implementation it is claimed that the return value is "number of bytes written or -1 in case of error". But this is ambiguous. Does that mean the number of bytes taken out of "buf" (some value <= toWrite)? Or does it mean the number of bytes sent out to the channel output driver? If we take our clue from the "similar to Tcl_WriteChars" language, we might assume that, like every other Tcl_Write* routine, what gets reported is the number of bytes sent out to the driver. Since the only way Tcl_Write could consume less than "toWrite" bytes from "buf" would be in case of an error, and we have the special value -1 to signal errors, it's natural to assume that Tcl_Write () would not be returning the number of bytes taken from "buf" because in the absence of an error that would always just be an echo back of the "toWrite" value, and useless. But you'd be making assumptions contrary to the code history. In fact, up until now, Tcl_Write() has indeed been echoing back the "toWrite" value on success. The refactoring work on channels incompatibly changed that to reporting the number of bytes written, and on Windows by default, and anywhere with -translation crlf active, that can be an incompatible difference. As you might guess, this is damaging a deployed application of mine. As soon as folks upgrade to ActiveTcl 8.6.2.0, their programs stop working. That's what's reported. It's clear the same issue will plague those working with deployed programs using tcl85.dll from ActiveTcl 8.5.16.0.
Referenced by2
2e1556fb0e[bf7135428c] Restore the Tcl_Write() return value logic. check-in2014-10-10 19:56:069e301d16f7[bf7135428c] Restore the Tcl_Write() return value logic. check-in2014-10-10 19:54:19
dgpplain2014-10-10 17:04:34
ok, the "useless" assessment is too strong. If toWrite = -1 is passed in, all bytes up to the terminating NUL are written, and the return is a count of how many that was.
dgpplain2014-10-10 19:57:04
Trivially simple fix committed to both branches.
Log in (anonymous is fine) to add a comment.