From: Bruce Momjian Date: Mon, 18 Jul 2005 19:27:37 +0000 (+0000) Subject: Fix len so decimal length is only added when a period appears in the output. X-Git-Tag: REL8_1_0BETA1~285 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71d0cabecdb4d704b9a7bbed5ef11e1e59fb26de;p=postgresql Fix len so decimal length is only added when a period appears in the output. --- diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 9a96349054..25d08a81c0 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -3,7 +3,7 @@ * * 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 "common.h" @@ -65,17 +65,18 @@ integer_digits(const char *my_str) static int 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); - if (int_len == 0) - sep_len = 0; - else + if (int_len > 0) /* 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) - - strlen(".") + strlen(decimal_point); + if (strchr(my_str, '.') != NULL) + len += strlen(decimal_point) - strlen("."); + + return len; } static int