* snprintf function is not C99 compliant on PA-RISC HP-UX 11.00 through 11.11
@ 2021-09-22 18:27 John David Anglin
0 siblings, 0 replies; only message in thread
From: John David Anglin @ 2021-09-22 18:27 UTC (permalink / raw)
To: bug-gnulib@gnu.org List
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-22 18:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 18:27 snprintf function is not C99 compliant on PA-RISC HP-UX 11.00 through 11.11 John David Anglin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).