Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2011-01-17
19:39 • Closed ticket [3151675fff]: Commands "read/puts" incorrectly interpret... artifact: 1d77ef0b26 user: nijtmans
18:31 • Ticket [3151675fff]: 5 changes artifact: 97c35d303b user: nijtmans
2011-01-06
17:46 • Ticket [3151675fff]: 4 changes artifact: 6550958663 user: nijtmans
17:46 • Add attachment 3151675.patch to ticket [3151675fff] artifact: b26c898d38 user: nijtmans
17:45 • Ticket [3151675fff] Commands "read/puts" incorrectly interpret paramet... artifact: 62eb11521a user: nijtmans
2011-01-05
16:18 • Ticket [3151675fff]: 6 changes artifact: 796abb1328 user: dkf
07:09 • New ticket [3151675fff]. artifact: aca7bdc2ba user: daapp

Commands "read/puts" incorrectly interpret parameters.

Closed / Fixed3151675fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2011-01-05 07:09:01
Bug with parameterswith tcl 8.5.8/8.6b1 with command read, this sample works, but it's incorrect:
% read stdin nonewline
If second parameter of read in "nonewline", than read works, but this is bug, second parameter must be number of characters to read.

if replace nonewline with other word, then
% read stdin xzy
bad argument "xzy": should be "nonewline"

Command "puts" interprep parameters the same way:
% puts stdout hello nonewline
hello%
% puts stdout hello xyz
bad argument "xyz": should be "nonewline"
dkfplain2011-01-05 16:18:05
It's ugly legacy code to support very old scripts. Use the forms described on the manual page (read ?-nonewline? channelId / read channelId numChars / puts ?-nonewline? ?channelId? string) and ignore these nasty things that really should have been deleted long ago.

Don't know that we can actually squelch this yet. :-(
nijtmansplain2011-01-06 17:45:35
At least, what I would propose is change the
horrible error-message to the nornal
Tcl_WrongNumArgs. Then the legacy
form is not exposed any more in the
error message.

Proposed patch attached.
nijtmansplain2011-01-06 17:46:55
File Added - 397809: 3151675.patch
nijtmansplain2011-01-17 18:31:06
Checked in in HEAD with some more improvements:
- Don't output a WrongNumArgs when actually the number of arguments is correct.
- if TCL_MAJOR_VERSION < 9, so we will not forget to remove this for Tcl9 ;-)
- First check for integer, then for "nonewline", so there is no performance
peanalty any more. I see no reason to remove this before Tcl9
nijtmansplain2011-01-17 19:39:10
allow_comments - 1

backported to 8.5. Closing, because at least the output-message now correctly indicates what the command syntax should be. Legacy form still works, but this is no longer visible in  any error-message.
Log in (anonymous is fine) to add a comment.

Attachments: