Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: (So-Called) ANSI C Message-ID: <6978@brl-smoke.ARPA> Date: 8 Jan 88 04:54:48 GMT References: <4668@pyr.gatech.EDU> <2046@haddock.ISC.COM> <400@uniq.UUCP> <6942@brl-smoke.ARPA> <38060@sun.uucp> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 11 In article <38060@sun.uucp> guy@gorodish.Sun.COM (Guy Harris) writes: >The trouble is that "_doscan" uses "ungetc" ... Ah, now I see the problem. It is the caller's buffer, not stdio's, that is being modified. That is clearly a bug, which is relatively easy to fix in sscanf() by strdup()ing the caller's buffer. This further reinforces the position that ANSI C *scanf() should not use ungetc(), although I think the AT&T folks believe that by allowing a couple of extra "slop space" bytes in a FILE structure's buffer they can get away with using ungetc(). I've never been convinced of that.