www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/06/14/14:05:33

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199906141805.OAA09094@mccoy2.ECE.McGill.CA>
Subject: Re: {v,}snprintf.c ???
To: djgpp-workers AT delorie DOT com
Date: Mon, 14 Jun 1999 14:05:36 -0400 (EDT)
In-Reply-To: <Pine.SUN.3.91.990613111143.17906I-100000@is> from "Eli Zaretskii" at Jun 13, 99 11:12:08 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 M. Eli Zaretskii
> 
> 
> On Wed, 9 Jun 1999, Alain Magloire wrote:
> 
> > int
> > snprintf(char *str, size_t n, const char *fmt, ...)
> > {
> >   FILE _strbuf;
> >   int len;
> > 
> >   if ((int)n < 1)
> >     return EOF;
> 
> The C9X draft is rather vague on this point, but it surely doesn't say
> that N should be strictly positive.  In fact, I can understand its
> language as meaning that calling {v,}snprintf with a zero N is a way
> to know how many characters should I allocate for the string that I
> pass to it when I *really* need some output.

> 
> What do other implementations do when N is zero?

An unfair question, lots of OS did not have the chance to
catch up with C9X. So they usually will implement the old BSD
behaviour
if (n < 1)
	return EOF;

Even Unix98 and XSH says if n == 0 the behaviour is unspecified.
For example Solaris-2.6 still will return -1(EOF).

But I think your desire to follow C9X std, is fair.

-- 
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