Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-04-28
02:03 • Closed ticket [577093ffff]: Tcl_(FS)OpenFileChannel and 'rb' plus 8 ... artifact: 8288743cf3 user: dgp
01:41 • Ticket [577093ffff]: 4 changes artifact: d79b0d89fd user: dgp
01:41 • Ticket [577093ffff]: 4 changes artifact: de749b0848 user: dgp
01:41 • Add attachment 577093.patch to ticket [577093ffff] artifact: 14bd28c510 user: dgp
01:35 • Ticket [577093ffff] Tcl_(FS)OpenFileChannel and 'rb' status still Op... artifact: 75b37833a1 user: dgp
01:34 • Ticket [577093ffff]: 4 changes artifact: 33dca2ba3e user: dgp
01:34 • Ticket [577093ffff]: 4 changes artifact: 65e45c2a87 user: dgp
2005-04-01
15:55 • Ticket [577093ffff]: 4 changes artifact: d535ee98ac user: vincentdarley
06:30 • Ticket [577093ffff]: 4 changes artifact: f57574c042 user: dgp
2005-03-25
00:43 • Ticket [577093ffff]: 4 changes artifact: 939894e7e8 user: dgp
2005-03-24
01:45 • Ticket [577093ffff]: 4 changes artifact: b90f6c41b6 user: dgp
2003-11-13
05:59 • Ticket [577093ffff]: 1 change artifact: 4dc6244b45 user: dgp
2003-02-25
16:32 • Ticket [577093ffff]: 1 change artifact: a1195a2a62 user: dkf
2002-07-04
21:48 • Ticket [577093ffff]: 8 changes artifact: 00b4d41410 user: vincentdarley
01:53 • Ticket [577093ffff]: 5 changes artifact: 40eaa87526 user: andreas_kupries
2002-07-03
17:51 • New ticket [577093ffff]. artifact: b47ca5e533 user: vincentdarley

Tcl_(FS)OpenFileChannel and 'rb'

Closed / Accepted577093ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 22 years ago
Descriptionplain2002-07-03 17:51:17
The standard 'fopen()' C function allows the 
optional "b" mode specifier alongside "rwa+" to 
specify that the file to be opened is binary.

Tcl's Tcl_(FS)OpenFileChannel commands do not 
support "b" and throw an error if it is given.  It 
would be quite easy to parse out the "b" and do call 
Tcl_SetChannelOption(NULL, chan, "-
translation", "binary") after the channel is opened.

Should this be added to Tcl?

I don't know enough about generic channels in Tcl 
to know if it is possible for that action to fail or 
otherwise cause problems (bear in mind that, with 
VFS, the channel may not be a file, but could be a 
memchan, for example).
andreas_kupriesplain2002-07-04 01:53:31
Logged In: YES 
user_id=75003

What is the behaviour of 8.3 when using a "b" specifier ?
If it is the same I would consider this a feature request, and 
not a bug.
vincentdarleyplain2002-07-04 21:48:41
Logged In: YES 
user_id=32170

The behaviour hasn't changed since 8.3, so I guess this 
is indeed a feature request.  One could even imagine a 
hookable mechanism in the future which allowed other 
(arbitrary) actions to be taken on open.  (Set 
the 'encoding' automatically might be nice, then 
perhaps 'source' could deal with unicode files).
dkf Ticket [577093ffff]: 1 change [History diff]2003-02-25 16:32:56
dgp Ticket [577093ffff]: 1 change [History diff]2003-11-13 05:59:22
dgpplain2005-03-24 01:45:51
Logged In: YES 
user_id=80530


This is TIP 183.
dgpplain2005-03-25 00:43:19
Logged In: YES 
user_id=80530


Actually this is a bit different from
TIP 183, which proposes the change
only for [open].  That's simpler to do
than changing for Tcl_FSOpenFileChannel()
since the latter raises questions about
what changes each Tcl_Filesystem's
Tcl_FSOpenFileChannelProc might
have to handle in its "mode" argument.
dgpplain2005-04-01 06:30:02
File Added - 128021: 577093.patch

Logged In: YES 
user_id=80530

Turns out doing this at the
Tcl_FSOpenFileChannel() level
works fine, and spares the VFS
drivers from having to do anything.
Here's the patch.
vincentdarleyplain2005-04-01 15:55:52
Logged In: YES 
user_id=32170

I haven't had time to test right now, but the patch itself
looks nice and clean.

It would be good to add a new test which writes some stuff
to a file in binary and then reads it back and check that \r
\n line endings have not been mangled.
dgpplain2005-04-28 01:34:56
Logged In: YES 
user_id=80530


Updated patch contains docs and tests.
dgpplain2005-04-28 01:34:59
File Added - 131982: 577093.patch
dgpplain2005-04-28 01:35:01
File Deleted - 128021:
dgpplain2005-04-28 01:41:12
Logged In: YES 
user_id=80530

correction.
dgpplain2005-04-28 01:41:15
File Deleted - 131982: 



File Added - 131986: 577093.patch
dgpplain2005-04-28 02:03:05
Logged In: YES 
user_id=80530


Committed for Tcl 8.5a3
Log in (anonymous is fine) to add a comment.

Attachments: