www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/06/13/04:15:10

Date: Sun, 13 Jun 1999 11:12:34 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
cc: djgpp-workers AT delorie DOT com
Subject: Re: {v,}snprintf.c ???
In-Reply-To: <199906101538.LAA23385@mccoy2.ECE.McGill.CA>
Message-ID: <Pine.SUN.3.91.990613111214.17906J-100000@is>
MIME-Version: 1.0
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

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 <libc/file.h>) 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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019