Re: g_snprintf() implementation



Havoc Pennington <rhp@zirx.pair.com> writes:
> On 21 Apr 1999, Raja R Harinath wrote:
> > Actually, I would like it to return the length that would have been
> > formatted if there had been enough space -- this is what the snprintf
> > in GLIBC and Solaris 2.6 are documented as doing. 
> 
> The glibc docs say that, but the old man pages don't. I guess they are
> for libc5, I don't know. 
> 
> Seems like nice behavior. I'm not sure we can trust vsnprintf() to work
> this way; a configure check might be in order.

Hmm....  I think we can get away with

  retval = vsnprintf (...);
  if (retval == -1) retval = n; /* for lack of anything better.  */

Not very nice, I agree.

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]