Date: Sun, 13 Jun 1999 11:12:34 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Alain Magloire cc: djgpp-workers AT delorie DOT com Subject: Re: {v,}snprintf.c ??? In-Reply-To: <199906101538.LAA23385@mccoy2.ECE.McGill.CA> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 10 Jun 1999, Alain Magloire wrote: > Ok, I don't know if this is the right approach, I simply redefine > the PUTC(ch) macro in doprnt.c : I'd prefer to change __putc (on ) so that it simply returns without doing anything when fp->_cnt is non-positive. After all, __putc has no business calling _flsbuf for fake streams with _IOSTRG flag set, so we might as well say it explicitly, instead of relying on INT_MAX to never be exhausted, which just might become untrue one day. DJ, do you have preferences as to where to make this change? > #define PUTC(ch) \ > do { \ > if (fp->_flags & _IOSTRG && fp->_flags & _IOWRT && !fp->_cnt) \ > return counter; \ This seems to be inconsistent with the function definition: the counter needs to be bumped up even if the string buffer is already exhausted. Otherwise, we won't be able to return the space that should have been allocated in order to produce the complete output.