Skip to content

Commit 71d0cab

Browse files
committed
Fix len so decimal length is only added when a period appears in the output.
1 parent affcb43 commit 71d0cab

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/bin/psql/print.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.70 2005/07/18 18:58:45 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.71 2005/07/18 19:27:37 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -65,17 +65,18 @@ integer_digits(const char *my_str)
6565
static int
6666
len_numericseps(const char *my_str)
6767
{
68-
int int_len = integer_digits(my_str), sep_len;
68+
int int_len = integer_digits(my_str), len = 0;
6969
int groupdigits = atoi(grouping);
7070

71-
if (int_len == 0)
72-
sep_len = 0;
73-
else
71+
if (int_len > 0)
7472
/* Don't count a leading separator */
75-
sep_len = int_len / groupdigits - (int_len % groupdigits == 0);
73+
len = (int_len / groupdigits - (int_len % groupdigits == 0)) *
74+
strlen(thousands_sep);
7675

77-
return sep_len * strlen(thousands_sep) -
78-
strlen(".") + strlen(decimal_point);
76+
if (strchr(my_str, '.') != NULL)
77+
len += strlen(decimal_point) - strlen(".");
78+
79+
return len;
7980
}
8081

8182
static int

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