From 1924acf91b35f711d331881720e51ac5b229b5d1 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 30 Jan 1999 21:52:36 +0000 Subject: [PATCH] new improved style git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1661 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/pricecell.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/register/pricecell.c b/src/register/pricecell.c index 96854d9f33..585e109111 100644 --- a/src/register/pricecell.c +++ b/src/register/pricecell.c @@ -140,7 +140,25 @@ void xaccSetPriceCellValue (PriceCell * cell, double amt) if (cell->blank_zero && (VERY_SMALL > amt) && ((-VERY_SMALL) < amt)) { buff[0] = 0x0; } else { - snprintf (buff, PRTBUF, cell->prt_format, amt); + char *monet; + + /* check for monetary-style format not natively supported by printf */ + /* hack alert -- this type of extended function should be abstracted + * out to a gnc_sprintf type function, however, thjis is much easier said + * than done */ + monet = strstr (cell->prt_format, "%m"); + if (monet) { + char tmpfmt[PRTBUF]; + char tmpval[PRTBUF]; + strcpy (tmpfmt, cell->prt_format); + monet = strstr (tmpfmt, "%m"); + *(monet+1) = 's'; + xaccSPrintAmount (tmpval, amt, PRTSEP); + + snprintf (buff, PRTBUF, tmpfmt, tmpval); + } else { + snprintf (buff, PRTBUF, cell->prt_format, amt); + } } SET ( &(cell->cell), buff);