|
8 | 8 | *
|
9 | 9 | * Copyright (c) 1994, Regents of the University of California
|
10 | 10 | *
|
11 |
| - * $Id: stringinfo.c,v 1.21 1999/08/31 01:28:25 tgl Exp $ |
| 11 | + * $Id: stringinfo.c,v 1.22 1999/09/08 16:31:38 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -121,7 +121,12 @@ appendStringInfo(StringInfo str, const char *fmt,...)
|
121 | 121 | nprinted=vsnprintf(str->data+str->len,avail,
|
122 | 122 | fmt,args);
|
123 | 123 | va_end(args);
|
124 |
| -if (nprinted<avail-1) |
| 124 | +/* |
| 125 | + * Note: some versions of vsnprintf return the number of chars |
| 126 | + * actually stored, but at least one returns -1 on failure. |
| 127 | + * Be conservative about believing whether the print worked. |
| 128 | + */ |
| 129 | +if (nprinted >=0&&nprinted<avail-1) |
125 | 130 | {
|
126 | 131 | /* Success. Note nprinted does not include trailing null. */
|
127 | 132 | str->len+=nprinted;
|
|