Fix snprintf() to properly handle precision specification for %f.

This commit is contained in:
Bruce Momjian 2005-03-12 04:00:56 +00:00
parent a214e9c996
commit c82f76e1ac
1 changed files with 3 additions and 1 deletions

View File

@ -65,7 +65,7 @@
* causing nasty effects.
**************************************************************/
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.18 2005/03/11 19:13:43 momjian Exp $";*/
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.19 2005/03/12 04:00:56 momjian Exp $";*/
int pg_snprintf(char *str, size_t count, const char *fmt,...);
int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
@ -252,6 +252,7 @@ dopr(char *buffer, const char *format, va_list args, char *end)
case '8':
case '9':
if (pointflag)
/* could also be precision */
maxwidth = maxwidth * 10 + ch - '0';
else
{
@ -455,6 +456,7 @@ dopr(char *buffer, const char *format, va_list args, char *end)
fmtpar[fmtpos].ljust = ljust;
fmtpar[fmtpos].len = len;
fmtpar[fmtpos].maxwidth = maxwidth;
fmtpar[fmtpos].precision = position;
fmtpar[fmtpos].pointflag = pointflag;
fmtpar[fmtpos].func = FMTFLOAT;
fmtpar[fmtpos].realpos = realpos?realpos:fmtpos;