ungetc will put characters back into an _IOSTRG input stream

Michael "Ford" Ditto ditto at cbmvax.UUCP
Tue Feb 14 12:43:58 AEST 1989


In article <20282 at lll-winken.LLNL.GOV> casey at lll-crg.llnl.gov (Casey Leedom) writes:
>	! 	if (iop->_flag & _IOSTRG)
>	! 		--iop->_ptr;
>	! 	else
>	! 		*--iop->_ptr = c;

As an alternative to the above four lines, why not:

	if (*--iop->_ptr != (char)c)
		*iop->ptr = c;

This will give anyone ungetc'ing something weird into a readonly string
the segmentation fault they deserve, and still allow ungetc'ing into
a writable string (even though nobody should be doing that).
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford at kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto at cbmvax.commodore.com



More information about the Comp.bugs.4bsd.ucb-fixes mailing list