Mail Archives: djgpp-workers/2000/11/10/18:21:49
> Date: Fri, 10 Nov 2000 20:25:12 +0000
> From: Richard Dawe <richdawe AT bigfoot DOT com>
>
> > > 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 ;-)
- Raw text -