Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1daac8e

Browse files
committed
Document return-value conventions used by this implementation, per
suggestion from Bruce.
1 parente8c81e1 commit1daac8e

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

‎src/port/snprintf.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232
* SUCH DAMAGE.
3333
*
34-
* $PostgreSQL: pgsql/src/port/snprintf.c,v 1.30 2005/12/0502:39:38 tgl Exp $
34+
* $PostgreSQL: pgsql/src/port/snprintf.c,v 1.31 2005/12/0521:57:00 tgl Exp $
3535
*/
3636

3737
#include"c.h"
@@ -51,9 +51,8 @@
5151
*SNPRINTF, VSNPRINTF and friends
5252
*
5353
* These versions have been grabbed off the net. They have been
54-
* cleaned up to compile properly and support for most of the Single
55-
* Unix Specification has been added. Remaining unimplemented features
56-
* are:
54+
* cleaned up to compile properly and support for most of the Single Unix
55+
* Specification has been added. Remaining unimplemented features are:
5756
*
5857
* 1. No locale support: the radix character is always '.' and the '
5958
* (single quote) format flag is ignored.
@@ -65,6 +64,27 @@
6564
* 4. No support for "long double" ("Lf" and related formats).
6665
*
6766
* 5. Space and '#' flags are not implemented.
67+
*
68+
*
69+
* The result values of these functions are not the same across different
70+
* platforms. This implementation is compatible with the Single Unix Spec:
71+
*
72+
* 1. -1 is returned only if processing is abandoned due to an invalid
73+
* parameter, such as incorrect format string. (Although not required by
74+
* the spec, this happens only when no characters have yet been transmitted
75+
* to the destination.)
76+
*
77+
* 2. For snprintf and sprintf, 0 is returned if str == NULL or count == 0;
78+
* no data has been stored.
79+
*
80+
* 3. Otherwise, the number of bytes actually transmitted to the destination
81+
* is returned (excluding the trailing '\0' for snprintf and sprintf).
82+
*
83+
* For snprintf with nonzero count, the result cannot be more than count-1
84+
* (a trailing '\0' is always stored); it is not possible to distinguish
85+
* buffer overrun from exact fit. This is unlike some implementations that
86+
* return the number of bytes that would have been needed for the complete
87+
* result string.
6888
*/
6989

7090
/**************************************************************

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp