🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #1340

Re: ungetc will put characters back into an _IOSTRG input stream

#1340
From: Jack Jansen
Date: Mon, 13 Feb 1989 23:10
12 lines
889 bytes
I ran into this problem as well, some time ago.

My fix was to have ungetc() only push the character back if it
isn't there already, i.e.
	if( *--fp->_ptr != ch )
		*fp->_ptr = ch;
Makes sscanf work with read-only strings, and still keeps the
semantics the same.
-- 
--
Fight war, not wars			| Jack Jansen, jack@cwi.nl
Destroy power, not people! -- Crass	| (or mcvax!jack)
Technical Details
Message-ID: <7898@boring.cwi.nl>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!itsgw!steinmetz!uunet!mcvax!jack
References: <20282@lll-winken.LLNL.GOV>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!itsgw!steinmetz!uunet!mcvax!jack
From: jack@cwi.nl (Jack Jansen)
Newsgroups: comp.bugs.4bsd
Subject: Re: ungetc will put characters back into an _IOSTRG input stream
Keywords: writable strings, shared strings (text segment), sscanf, ungetc
Message-ID: <7898@boring.cwi.nl>
Date: 13 Feb 89 23:10:12 GMT
References: <20282@lll-winken.LLNL.GOV>
Sender: news@cwi.nl
Organization: AMOEBA project, CWI, Amsterdam
Lines: 12