autoconf
[Top][All Lists]
Advanced

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

Re: snprintf function portability


From: Paul Eggert
Subject: Re: snprintf function portability
Date: Fri, 17 Aug 2001 09:16:17 -0700 (PDT)

> From: Kevin Ryde <address@hidden>
> Date: 17 Aug 2001 11:51:53 +1000
> 
> No worries about rewording, but perhaps the point that sparc64 solaris
> 7 doesn't truncate the output at all could be retained...

OK.  I installed the following patch, which also fixed a couple of
other minor glitches in the neighborhood (e.g. I would hardly call
snprintf "Classical" -- perhaps because I've been around too long :-).
Thanks again for the suggestion.

2001-08-17  Paul Eggert  <address@hidden>

        * doc/autoconf.texi (Function Portability): Mention snprintf,
        following up on a suggestion by Kevin Ryde.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.510
retrieving revision 1.511
diff -p -u -r1.510 -r1.511
--- doc/autoconf.texi   2001/08/17 14:54:15     1.510
+++ doc/autoconf.texi   2001/08/17 16:09:26     1.511
@@ -3248,19 +3248,35 @@ it, then you can use one of the general 
 @end menu
 
 @node Function Portability, Particular Functions, Library Functions, Library 
Functions
address@hidden Portability of Classical Functions
address@hidden Portability of C Functions
 
 Most usual functions can either be missing, or be buggy, or be limited
 on some architectures.  This section tries to make an inventory of these
 portability issues.  By definition, this list will always require
-additions, please help us keeping it as complete as possible
+additions.  Please help us keeping it as complete as possible.
 
 @table @asis
address@hidden @code{snprintf}
address@hidden @fuindex snprintf
address@hidden @code{snprintf}
address@hidden @fuindex vsnprintf
address@hidden @code{vsnprintf}
+The ISO C99 standard says that if the output array isn't big enough and
+if no other errors occur, @code{snprintf} and @code{vsnprintf} truncate
+the output and return the number of bytes that ought to have been
+produced.  Some older systems return the truncated length (e.g., GNU C
+Library 2.0.x or IRIX 6.5), some a negative value (e.g., earlier GNU C
+Library versions), and some the buffer length without truncation (e.g.,
+32-bit Solaris 7).  Also, some buggy older systems ignore the length and
+overrun the buffer (e.g., 64-bit Solaris 7).
+
 @item @code{sprintf}
 @c @fuindex sprintf
 @prindex @code{sprintf}
address@hidden @fuindex vsprintf
address@hidden @code{vsprintf}
 The ISO C standard says @code{sprintf} and @code{vsprintf} return the
-number of characters written, but on some old systems (SunOS for
+number of bytes written, but on some old systems (SunOS 4 for
 instance) they return the buffer pointer instead.
 
 @item @code{unlink}



reply via email to

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