bug-gnulib
[Top][All Lists]
Advanced

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

snprintf function is not C99 compliant on PA-RISC HP-UX 11.00 through 11


From: John David Anglin
Subject: snprintf function is not C99 compliant on PA-RISC HP-UX 11.00 through 11.11
Date: Wed, 22 Sep 2021 14:27:05 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

When I run configure on applications using the gnulib (e.g., bison), I get the 
following defines
in config.h:

/* Define if the return value of the snprintf function is the number of of
   bytes (excluding the terminating NUL) that would have been produced if the
   buffer had been large enough. */
#define HAVE_SNPRINTF_RETVAL_C99 1

/* Define if the string produced by the snprintf function is always NUL
   terminated. */
#define HAVE_SNPRINTF_TRUNCATION_C99 1

The HAVE_SNPRINTF_RETVAL define is definitely incorrect for HP-UX 11.11:

 RETURN VALUE
      Each function returns the number of bytes transmitted (excluding the
      \0 in the case of sprintf() or a negative value if an output error was
      encountered.

I would not trust that the string is always null terminated when an error 
occurs.

The behavior on 11.31 may be correct when application is compiled for UNIX 2003 
but maybe it's best
to assume snprintf is not C99 compliant on all versions of HP-UX.  Changing the 
defines as follows
seems to work fine:

/* Define if the return value of the snprintf function is the number of of
   bytes (excluding the terminating NUL) that would have been produced if the
   buffer had been large enough. */
/* #undef HAVE_SNPRINTF_RETVAL_C99 */

/* Define if the string produced by the snprintf function is always NUL
   terminated. */
/* #undef HAVE_SNPRINTF_TRUNCATION_C99 */

Haven't had time to find why the configure ouput is wrong.

Dave
-- 
John David Anglin  dave.anglin@bell.net



reply via email to

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