NOFILES bug in System V.3

Guy Harris guy at auspex.UUCP
Thu Nov 24 07:44:24 AEST 1988


>Sscanf() apparently dummies up a FILE struct and then calls
>_doscan() to do the real work.  It uses the string being scanned as the
>"buffer" in the FILE struct and sets to file descriptor to 20.

This is true.  Some means of indicating that the FILE struct in question
refers to a string, rather than a file, is necessary; you have just
discovered why the method used by System V Releases 2 and 3 (and perhaps
earlier releases) is wrong.  The one used by 4BSD (and perhaps by V7 or
32V) is better; it uses the _IOSTRG flag to indicate that the FILE
struct refers to a string.

An even better one would permit you to create standard I/O streams that
can refer to arbitrary objects, with "put buffer" and "get buffer"
operations; this would 1) permit you to use more than "sprintf" and
"sscanf" on strings, and 2) might permit you to do things like support
string objects that grow dynamically as needed, as well as fixed-length
strings.  I think Chris Torek has done such a version of standard I/O,
which may appear in a future BSD release.



More information about the Comp.bugs.sys5 mailing list