autoconf-patches
[Top][All Lists]
Advanced

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

Re: more of snprintf function portability


From: Russ Allbery
Subject: Re: more of snprintf function portability
Date: 01 Sep 2001 20:28:48 -0700
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

Kevin Ryde <address@hidden> writes:

> Sparc solaris 7 in 32-bit mode has a perfectly good C99 snprintf as
> far as I can tell. 

No, it doesn't.  It fails the following test case:

#include <stdio.h>
#include <stdarg.h>

char buf[2];

int
test (char *format, ...)
{
  va_list args;
  int count;

  va_start (args, format);
  count = vsnprintf (buf, sizeof buf, format, args);
  va_end (args);
  return count;
}

int
main ()
{
  return ((test ("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0'
           && snprintf(NULL, 0, "%s", "abcd") == 4) ? 0 : 1);
}

I forget precisely what part it fails.  I think it's that it can't handle
NULL as an initial argument to snprintf.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]