Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 206b1e5

Browse files
committed
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.
1 parent 9706f54 commit 206b1e5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/port/snprintf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2828
* SUCH DAMAGE.
2929
*
30-
* $PostgreSQL: pgsql/src/port/snprintf.c,v 1.34 2007/03/26 21:44:11 momjian Exp $
30+
* $PostgreSQL: pgsql/src/port/snprintf.c,v 1.35 2008/03/18 01:49:44 tgl Exp $
3131
*/
3232

3333
#include "c.h"
@@ -565,7 +565,10 @@ dopr(PrintfTarget *target, const char *format, va_list args)
565565
{
566566
precision = starval;
567567
if (precision < 0)
568+
{
568569
precision = 0;
570+
pointflag = 0;
571+
}
569572
}
570573
else
571574
{
@@ -590,7 +593,10 @@ dopr(PrintfTarget *target, const char *format, va_list args)
590593
{
591594
precision = starval;
592595
if (precision < 0)
596+
{
593597
precision = 0;
598+
pointflag = 0;
599+
}
594600
}
595601
else
596602
{

0 commit comments

Comments
 (0)