Date: Sat, 11 Nov 2000 01:22:56 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: richdawe AT bigfoot DOT com Message-Id: <1659-Sat11Nov2000012256+0200-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 CC: djgpp-workers AT delorie DOT com In-reply-to: <3A0C59A8.9DB02164@bigfoot.com> (message from Richard Dawe on Fri, 10 Nov 2000 20:25:12 +0000) Subject: Re: Summary of the snprintf() situation References: <3A09EAB9 DOT 6924045A AT bigfoot DOT com> <3A0B329F DOT D33F7737 AT bigfoot DOT com> <7458-Fri10Nov2000111820+0200-eliz AT is DOT elta DOT co DOT il> <3A0C59A8 DOT 9DB02164 AT bigfoot DOT com> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Date: Fri, 10 Nov 2000 20:25:12 +0000 > From: Richard Dawe > > > > I have to admit, reading this again, I am confused by what you say, > > > Eli. If you don't track the position in the buffer using _cnt, what > > > do you use? > > > > p->_cnt is not used for tracking the position, it is only used to know > > how much more free space do we have in p->_buf. To track the buffer > > position, we use p->_ptr; see the code above. > > By 'p->_buf', I guess you mean 'p->_base'. Yes. > As it stands, the snprintf() code does not set up p->_base. So if we > do not use p->_cnt, this will need fixing. It does use p->_ptr, which is the vehicle for tracking the buffer position. Isn't that what you were asking about? > If n is too large, then _cnt (an int) will be negative if you just put n > (a size_t) into it (actually n - 1 to leave space for nul). Therefore I > suggest we put a restriction on n, to avoid this (and hence wrap-around & > returning EOF). Why not? I don't see anything wrong with this approach. > Things are pretty clear in my mind now. Maybe I will get time to produce > some patches on Sunday. Then the code can do the talking. Sounds like a good plan ;-)