From 8a52d0c94d240cf386966fa8207a75a52fd82dfb Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sat, 24 Nov 2007 16:18:48 +0000
Subject: [PATCH] Clarify how MONEY trims off trailing thousands separator.

---
 src/backend/utils/adt/cash.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index a7c6225f8ab..df5d7bf8629 100644
--- a/src/backend/utils/adt/cash.c
+++ b/src/backend/utils/adt/cash.c
@@ -13,7 +13,7 @@
  * this version handles 64 bit numbers and so can hold values up to
  * $92,233,720,368,547,758.07.
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.76 2007/11/24 15:28:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.77 2007/11/24 16:18:48 momjian Exp $
  */
 
 #include "postgres.h"
@@ -337,9 +337,13 @@ cash_out(PG_FUNCTION_ARGS)
 	strncpy((buf + count - strlen(csymbol) + 1), csymbol, strlen(csymbol));
 	count -= strlen(csymbol) - 1;
 
-	/* XXX What does this do?  It seems to duplicate the last character. */
+	/*
+	 *	If points == 0 and the number of digits % mon_group == 0,
+	 *	the code above adds a trailing ssymbol on the far right,
+	 *	so remove it.
+	 */
 	if (buf[LAST_DIGIT] == ssymbol)
-		buf[LAST_DIGIT] = buf[LAST_PAREN];
+		buf[LAST_DIGIT] = '\0';
 
 	/* see if we need to signify negative amount */
 	if (minus)
-- 
GitLab