www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/06/10/11:38:47

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199906101538.LAA23385@mccoy2.ECE.McGill.CA>
Subject: Re: {v,}snprintf.c ???
To: djgpp-workers AT delorie DOT com
Date: Thu, 10 Jun 1999 11:38:48 -0400 (EDT)
In-Reply-To: <Pine.SUN.3.91.990610110520.17697O-100000@is> from "Eli Zaretskii" at Jun 10, 99 11:07:02 am
X-Mailer: ELM [version 2.4 PL25]
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

Bonjour

> On Wed, 9 Jun 1999, Alain Magloire wrote:
> 
> > If you decide to use it and need the *.txh equivalent let me know.
> 
> Since everybody seems to want them, I will add them.  Please send the 
> .txh files.  A simple test program (for inclusion in djtstNNN.zip) would 
> be also nice.
> 

Sorry folks, the first email was incomplete.  It did not include
the patch for doprnt.c.

DJ's post made me think it may  be wiser to put it in 2.xy then the
bugfix 2.03.

Ok, I don't know if this is the right approach, I simply redefine
the PUTC(ch) macro in  doprnt.c :

/*
Only if the stream is an ouput string, check for buffer overun.
The do {..}while(0) is for atomicity, any compiler should
eliminate the constant condition.
*/
#define PUTC(ch) \
do { \
	if (fp->_flags & _IOSTRG && fp->_flags & _IOWRT && !fp->_cnt) \
		return counter; \
	(void) putc(ch); \
	counter++; \
} while (0)

There is probably other ways, like in _flsbuf() or __putc_raw()
check if we're dealing with a string output and take the appropriate action.

Let me know, what you think.  And I'll resubmit a complete patch
with *.txh, tests etc .. according to the comments, that includes
"forget it, too much trouble".

-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!

- Raw text -


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