|
31 | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | 32 | * SUCH DAMAGE. |
33 | 33 | * |
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 $ |
35 | 35 | */ |
36 | 36 |
|
37 | 37 | #include"c.h" |
|
51 | 51 | *SNPRINTF, VSNPRINTF and friends |
52 | 52 | * |
53 | 53 | * 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: |
57 | 56 | * |
58 | 57 | * 1. No locale support: the radix character is always '.' and the ' |
59 | 58 | * (single quote) format flag is ignored. |
|
65 | 64 | * 4. No support for "long double" ("Lf" and related formats). |
66 | 65 | * |
67 | 66 | * 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. |
68 | 88 | */ |
69 | 89 |
|
70 | 90 | /************************************************************** |
|