Public Comment Number PC-UK0088 ISO/IEC CD 9899 (SC22N2620) Public Comment =========================================== Date: 1998-02-25 Author: N.M Maclaren Author Affiliation: Self Postal Address: University of Cambridge, Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB3 3QG, United Kingdom E-mail Address: Telephone Number: +44 1223 334761 Fax Number: +44 1223 334679 Number of individual comments: 1 Comment 1. Category: Normative change to existing feature retaining the original intent Committee Draft subsection: 7.13.8 Title: Direct input/output functions Detailed description: These have caused considerable confusion to both users and implementors since they were introduced. What DO they do on text streams on non-Unix systems? Experience shows that they often do something unhelpful - such as fwrite writing files that cannot be read back in again by fread without loss of information. Note that the problem is not in the actual data transfer, but in the problem of how to convert an unspecified block of storage to characters and back again. In particular, 7.13.2 Streams states that only some sequences of characters can be written out and read back in again - actually, there are even more constraints than that (e.g. record lengths). Some non-Unix implementations have converted the data to unsigned characters and then to hexadecimal, but most just write the raw characters and let the chaos ensue. And chaos is precisely what the programmer gets, in general. This ambiguity has caused trouble for long enough. I suggest adding one or other of the paragraphs: An implementation may define that these functions are not available for text streams. If that is the case, calling one of these functions on a text stream shall have no effect except to set errno to an implementation-defined positive value and return EOF. or: It is implementation-defined how the storage is converted to and from characters for I/O to and from text streams. The implementation shall ensure that one or more objects of any type can be written out using the fwrite function and read back in to objects of the same type using the fread function with the same value of size without loss of information.