From eb3e640ea2fa06d089b21a73b49673e87e84ce75 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 12 Oct 1998 04:07:53 +0000 Subject: New INET functions from D'Arcy J.M. Cain --- src/backend/utils/adt/cash.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/backend/utils/adt/cash.c') diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 262d2d4ded..a6e9711a46 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.26 1998/09/01 04:32:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.27 1998/10/12 04:07:44 momjian Exp $ */ #include @@ -672,7 +672,7 @@ cashsmaller(Cash *c1, Cash *c2) * This converts a int4 as well but to a representation using words * Obviously way North American centric - sorry */ -const char * +text * cash_words_out(Cash *value) { static char buf[128]; @@ -681,7 +681,8 @@ cash_words_out(Cash *value) Cash m1; Cash m2; Cash m3; - + text *result; + /* work with positive numbers */ if (*value < 0) { @@ -718,8 +719,16 @@ cash_words_out(Cash *value) strcat(buf, (int) (*value / 100) == 1 ? " dollar and " : " dollars and "); strcat(buf, num_word(m0)); strcat(buf, m0 == 1 ? " cent" : " cents"); + + /* capitalize output */ *buf = toupper(*buf); - return buf; + + /* make a text type for output */ + result = (text *) palloc(strlen(buf) + VARHDRSZ); + VARSIZE(result) = strlen(buf) + VARHDRSZ; + StrNCpy(VARDATA(result), buf, strlen(buf)); + + return result; } /* cash_words_out() */ -- cgit v1.2.1