Commit 21a7fa8a authored by Bruce Momjian's avatar Bruce Momjian

It is not fixed and I doubt that it is working fine in current CVS. The

bugfix is in the attached patch. Please apply it. Thanks.

 Output must be:

test=# SELECT to_char(485, 'RN');
     to_char
-----------------
         CDLXXXV
(1 row)

test=# SELECT to_char(485, 'FMRN');
 to_char
---------
 CDLXXXV
(1 row)

test=# SELECT to_char(1000, 'RN');
     to_char
-----------------
               M
(1 row)


test=# SELECT to_char(7.2, '"Welcome to"9.9 "release! :-)"');
           to_char
-----------------------------
 Welcome to 7.2 release! :-)
(1 row)

Karel Zak
parent 33a82e7f
/* -----------------------------------------------------------------------
* formatting.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.39 2001/09/06 03:22:42 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.40 2001/09/12 04:01:57 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
......@@ -45,8 +45,9 @@
* Karel Zak
*
* TODO
* - check last used entry in the cache_search
* - better number building (formatting)
* - better number building (formatting) / parsing, now it isn't
* ideal code
* - use Assert()
* - add support for abstime
* - add support for roman number to standard number conversion
* - add support for number spelling
......@@ -3824,6 +3825,10 @@ NUM_numpart_to_char(NUMProc *Np, int id)
++Np->num_curr;
}
/*
* Note: 'plen' is used in FROM_CHAR conversion and it's length of
* input (inout). In TO_CHAR conversion it's space before first number.
*/
static char *
NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
int plen, int sign, int type)
......@@ -4117,7 +4122,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
Np->inout_p += strlen(Np->inout_p) - 1;
}
else
Np->inout_p += snprintf(Np->inout_p, plen - (Np->inout_p - Np->inout), "%15s", Np->number_p) - 1;
Np->inout_p += sprintf(Np->inout_p, "%15s", Np->number_p) - 1;
break;
case NUM_rn:
......@@ -4127,7 +4132,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
Np->inout_p += strlen(Np->inout_p) - 1;
}
else
Np->inout_p += snprintf(Np->inout_p, plen - (Np->inout_p - Np->inout), "%15s", str_tolower(Np->number_p)) - 1;
Np->inout_p += sprintf(Np->inout_p, "%15s", str_tolower(Np->number_p)) - 1;
break;
case NUM_th:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment