Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Andrew Klossner;685-2505;61-201;...
Wed, 23 Aug 1989 21:22
can't use system V's setvbuf()
Author: Andrew Klossner;685-2505;61-201;...
Date: Wed, 23 Aug 1989 21:22
Date: Wed, 23 Aug 1989 21:22
20 lines
1584 bytes
1584 bytes
Under system V, cplus-lex.c has a cute hack that uses setvbuf to trick
stdio into treating a chunk of memory as a file, so that the lexer can
read characters from a stored inline function. But the hack is fragile
and breaks easily. A problem that I have encountered (while trying to
make the libg++ tests) is that, if the buffer given to setvbuf is
shorter than eight bytes long, setvbuf will (in violation of its man
page) ignore the buffer and call malloc to get a bigger one. The
comment in setvbuf, in vanilla system V release 3.2, says that stdio
needs at least eight bytes of slop because of synchronization problems
after signals.
I hacked the hack with a local copy of setvbuf that operates more
faithfully. But I think the "right" thing to do here is to lose the
hack, and move the switch between file input and inline-buffer input up
above the stdio abstraction. Mucking with the internals of a stdio
(*FILE) is impolite, and ironic when done in the name of a language
that champions strong data abstraction.
-=- Andrew Klossner (uunet!tektronix!frip.WV.TEK!andrew) [UUCP]
(andrew%frip.wv.tek.com@relay.cs.net) [ARPA]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads