Skip to content

Commit c82f76e

Browse files
committed
Fix snprintf() to properly handle precision specification for %f.
1 parent a214e9c commit c82f76e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/port/snprintf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
* causing nasty effects.
6666
**************************************************************/
6767

68-
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.18 2005/03/11 19:13:43 momjian Exp $";*/
68+
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.19 2005/03/12 04:00:56 momjian Exp $";*/
6969

7070
int pg_snprintf(char *str, size_t count, const char *fmt,...);
7171
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)
252252
case '8':
253253
case '9':
254254
if (pointflag)
255+
/* could also be precision */
255256
maxwidth = maxwidth * 10 + ch - '0';
256257
else
257258
{
@@ -455,6 +456,7 @@ dopr(char *buffer, const char *format, va_list args, char *end)
455456
fmtpar[fmtpos].ljust = ljust;
456457
fmtpar[fmtpos].len = len;
457458
fmtpar[fmtpos].maxwidth = maxwidth;
459+
fmtpar[fmtpos].precision = position;
458460
fmtpar[fmtpos].pointflag = pointflag;
459461
fmtpar[fmtpos].func = FMTFLOAT;
460462
fmtpar[fmtpos].realpos = realpos?realpos:fmtpos;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy