From adeede13916fadf53a63cc06d6301e30dac76f60 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 18 Jul 2005 18:58:45 +0000 Subject: [PATCH] Fix numiericsep length computations. Eugen Nedelcu --- src/bin/psql/print.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 7b6b164006..9a96349054 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.69 2005/07/14 21:12:41 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.70 2005/07/18 18:58:45 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -68,10 +68,11 @@ len_numericseps(const char *my_str) int int_len = integer_digits(my_str), sep_len; int groupdigits = atoi(grouping); - if (int_len % groupdigits != 0) - sep_len = int_len / groupdigits; + if (int_len == 0) + sep_len = 0; else - sep_len = int_len / groupdigits - 1; /* no leading separator */ + /* Don't count a leading separator */ + sep_len = int_len / groupdigits - (int_len % groupdigits == 0); return sep_len * strlen(thousands_sep) - strlen(".") + strlen(decimal_point); @@ -93,7 +94,7 @@ format_numericsep(char *my_str) if (my_str[0] == '-') my_str++; - new_str = pg_local_malloc(len_numericseps(my_str) + 1); + new_str = pg_local_malloc(len_with_numericsep(my_str) + 1); leading_digits = (int_len % groupdigits != 0) ? int_len % groupdigits : groupdigits; -- 2.40.0