Fix len so decimal length is only added when a period appears in the output.
This commit is contained in:
parent
affcb4371c
commit
71d0cabecd
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.70 2005/07/18 18:58:45 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.71 2005/07/18 19:27:37 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -65,17 +65,18 @@ integer_digits(const char *my_str)
|
||||||
static int
|
static int
|
||||||
len_numericseps(const char *my_str)
|
len_numericseps(const char *my_str)
|
||||||
{
|
{
|
||||||
int int_len = integer_digits(my_str), sep_len;
|
int int_len = integer_digits(my_str), len = 0;
|
||||||
int groupdigits = atoi(grouping);
|
int groupdigits = atoi(grouping);
|
||||||
|
|
||||||
if (int_len == 0)
|
if (int_len > 0)
|
||||||
sep_len = 0;
|
|
||||||
else
|
|
||||||
/* Don't count a leading separator */
|
/* Don't count a leading separator */
|
||||||
sep_len = int_len / groupdigits - (int_len % groupdigits == 0);
|
len = (int_len / groupdigits - (int_len % groupdigits == 0)) *
|
||||||
|
strlen(thousands_sep);
|
||||||
|
|
||||||
return sep_len * strlen(thousands_sep) -
|
if (strchr(my_str, '.') != NULL)
|
||||||
strlen(".") + strlen(decimal_point);
|
len += strlen(decimal_point) - strlen(".");
|
||||||
|
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue