aboutsummaryrefslogtreecommitdiff
path: root/src/printf.c
diff options
context:
space:
mode:
authordrh <>2023-05-04 13:07:49 +0000
committerdrh <>2023-05-04 13:07:49 +0000
commite8468098a00d064cf2b0c436ecc33e1090f82be9 (patch)
tree3dd64cb6acb7940e858a93e9bb59bcd1ac42bb79 /src/printf.c
parentc1e40a3a0299069425342163563f1baba863c44a (diff)
downloadsqlite-e8468098a00d064cf2b0c436ecc33e1090f82be9.tar.gz
sqlite-e8468098a00d064cf2b0c436ecc33e1090f82be9.zip
Add support for the comma (,) modifier to %f formats in the format() function.
FossilOrigin-Name: 7080e196a1f887640ff51ddc508ec6796ce12874c2944855702753b64a8e5e50
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/printf.c b/src/printf.c
index 65e539bef..0cbd4c3c6 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -649,6 +649,7 @@ void sqlite3_str_vappendf(
{
i64 szBufNeeded; /* Size of a temporary buffer needed */
szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
+ if( cThousand ) szBufNeeded += (e2+2)/3;
if( szBufNeeded > etBUFSIZE ){
bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
if( bufpt==0 ) return;
@@ -666,10 +667,12 @@ void sqlite3_str_vappendf(
}else if( msd>0 ){
for(; e2>=0; e2--){
*(bufpt++) = et_getdigit_int(&longvalue,&msd);
+ if( cThousand && (e2%3)==0 && e2>1 ) *(bufpt++) = ',';
}
}else{
for(; e2>=0; e2--){
*(bufpt++) = et_getdigit(&realvalue,&nsd);
+ if( cThousand && (e2%3)==0 && e2>1 ) *(bufpt++) = ',';
}
}
/* The decimal point */