]> granicus.if.org Git - postgresql/commitdiff
Fix len so decimal length is only added when a period appears in the output.
authorBruce Momjian <bruce@momjian.us>
Mon, 18 Jul 2005 19:27:37 +0000 (19:27 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 18 Jul 2005 19:27:37 +0000 (19:27 +0000)
src/bin/psql/print.c

index 9a963490544288a99b2d818e7e479cc705106b90..25d08a81c03c9faa078b2ba11245d0516187d49a 100644 (file)
@@ -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