summaryrefslogtreecommitdiff
path: root/src/port/snprintf.c
diff options
context:
space:
mode:
authorTom Lane2008-03-18 01:49:44 +0000
committerTom Lane2008-03-18 01:49:44 +0000
commit206b1e558a1106db88de42abaabb893eb97aec81 (patch)
tree06a9d8f461b8ddff442ab22a473577a1985c9a55 /src/port/snprintf.c
parent9706f54d5df2b3d7934db6eb74aa97f3debec18d (diff)
Fix our printf implementation to follow spec: if a star parameter
value for a precision is negative, act as though precision weren't specified at all, that is the whole .* part of the format spec should be ignored. Our previous coding took it as .0 which is certainly wrong. Per report from Kris Jurka and local testing. Possibly this should be back-patched, but it would be good to get some more testing first; in any case there are no known cases where there's really a problem on the backend side.
Diffstat (limited to 'src/port/snprintf.c')
-rw-r--r--src/port/snprintf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 415eb89948c..3ccac709e11 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/src/port/snprintf.c,v 1.34 2007/03/26 21:44:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/snprintf.c,v 1.35 2008/03/18 01:49:44 tgl Exp $
*/
#include "c.h"
@@ -565,7 +565,10 @@ nextch2:
{
precision = starval;
if (precision < 0)
+ {
precision = 0;
+ pointflag = 0;
+ }
}
else
{
@@ -590,7 +593,10 @@ nextch2:
{
precision = starval;
if (precision < 0)
+ {
precision = 0;
+ pointflag = 0;
+ }
}
else
{