From 9e6c9d4fc77054eb0ff29488dd31b23919f913a5 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 24 Jul 2005 12:14:18 +0000 Subject: [PATCH] * sysutils.format: floating point formatting takes care of currency type now git-svn-id: trunk@736 - --- .gitattributes | 1 + rtl/objpas/sysutils/sysformt.inc | 30 ++++++++++++++++++++---------- tests/webtbs/tw4215.pp | 13 +++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 tests/webtbs/tw4215.pp diff --git a/.gitattributes b/.gitattributes index 1e461953e4..c433e8573c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6151,6 +6151,7 @@ tests/webtbs/tw4173.pp svneol=native#text/plain tests/webtbs/tw4188.pp svneol=native#text/plain tests/webtbs/tw4199.pp svneol=native#text/plain tests/webtbs/tw4202.pp svneol=native#text/plain +tests/webtbs/tw4215.pp svneol=native#text/plain tests/webtbs/ub1873.pp svneol=native#text/plain tests/webtbs/ub1883.pp svneol=native#text/plain tests/webtbs/uw0555.pp svneol=native#text/plain diff --git a/rtl/objpas/sysutils/sysformt.inc b/rtl/objpas/sysutils/sysformt.inc index 2e713ea418..4a961d5cf1 100644 --- a/rtl/objpas/sysutils/sysformt.inc +++ b/rtl/objpas/sysutils/sysformt.inc @@ -231,24 +231,34 @@ begin ToAdd:=StringOfChar('0',Index)+ToAdd end; 'E' : begin - CheckArg(vtExtended,true); - ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffexponent,Prec,3); + if CheckArg(vtCurrency,false) then + ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffexponent,Prec,3) + else if CheckArg(vtExtended,true) then + ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffexponent,Prec,3); end; 'F' : begin - CheckArg(vtExtended,true); - ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffFixed,9999,Prec); + if CheckArg(vtCurrency,false) then + ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffFixed,9999,Prec) + else if CheckArg(vtExtended,true) then + ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffFixed,9999,Prec); end; 'G' : begin - CheckArg(vtExtended,true); - ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffGeneral,Prec,3); + if CheckArg(vtCurrency,false) then + ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffGeneral,Prec,3) + else if CheckArg(vtExtended,true) then + ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffGeneral,Prec,3); end; 'N' : begin - CheckArg(vtExtended,true); - ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffNumber,9999,Prec); + if CheckArg(vtCurrency,false) then + ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffNumber,9999,Prec) + else if CheckArg(vtExtended,true) then + ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffNumber,9999,Prec); end; 'M' : begin - CheckArg(vtExtended,true); - ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffCurrency,9999,Prec); + if CheckArg(vtExtended,false) then + ToAdd:=FloatToStrF(Args[doarg].VExtended^,ffCurrency,9999,Prec) + else if CheckArg(vtCurrency,true) then + ToAdd:=FloatToStrF(Args[doarg].VCurrency^,ffCurrency,9999,Prec); end; 'S' : begin if CheckArg(vtString,false) then diff --git a/tests/webtbs/tw4215.pp b/tests/webtbs/tw4215.pp new file mode 100644 index 0000000000..181f696104 --- /dev/null +++ b/tests/webtbs/tw4215.pp @@ -0,0 +1,13 @@ +{ Source provided for Free Pascal Bug Report 4215 } +{ Submitted by "Tony Maro" on 2005-07-24 } +{ e-mail: tony@maro.net } +uses + sysutils; +var + MyCurrency: Currency; +begin + CurrencyFormat := 0; // optional? It's my default anyway. + MyCurrency := 12.53; + writeln(MyCurrency); // this works + writeln(format('%n',[MyCurrency])); // this doesn't +end.