From: drh <> Date: Thu, 29 Jun 2023 17:26:21 +0000 (+0000) Subject: Further refine the dtostr() testing function in the CLI so that it takes an X-Git-Tag: version-3.43.0~172 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a75011a891db06ae496851f8fe8a4a95bec74fe0;p=thirdparty%2Fsqlite.git Further refine the dtostr() testing function in the CLI so that it takes an optional second parameter which is the number of significant digits to display. FossilOrigin-Name: 2f9d4444aa503102a00d6e6769dadc57d4b26a2c07f145f23f2f28e0c161246d --- diff --git a/manifest b/manifest index 9f0e3dfb07..897ab5ae64 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\s(undocumented)\sdtostr()\sSQL\sfunction\sin\sthe\sCLI\sso\sthat\sit\sonly\nshows\sthe\sfirst\s26\ssignificant\sdigits\s-\s10\smore\sdigits\sthan\sare\savailable\nin\sa\s64-bit\sdouble. -D 2023-06-29T16:48:25.462 +C Further\srefine\sthe\sdtostr()\stesting\sfunction\sin\sthe\sCLI\sso\sthat\sit\stakes\san\noptional\ssecond\sparameter\swhich\sis\sthe\snumber\sof\ssignificant\sdigits\sto\sdisplay. +D 2023-06-29T17:26:21.732 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -638,7 +638,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 37953a5f36c60bea413c3c04efcd433b6177009f508ef2ace0494728912fe2e9 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 383b9dba12493c365ee2036bcadd73013b7c0f7d2afcda0c378317c335d60ac2 -F src/shell.c.in 8b5b1b4b47d60b3efa13a3c4ff0769228c6427cb27d3d10de1cc814ced078861 +F src/shell.c.in 63e3b76912c92ece8165577df0f7981808d52c5fd169fa5ab92d2e668f7d8bdd F src/sqlite.h.in 3076d78836b6dac53b3ab0875fc8fd15bca8077aad4d33c85336e05af6aef8c7 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h da473ce2b3d0ae407a6300c4a164589b9a6bfdbec9462688a8593ff16f3bb6e4 @@ -2041,8 +2041,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 61d4923913e88b980ce93db4f3f9f9d7ba3baaac724995c36c9b887c034accdc -R 983575d0194b3a14d01efc5f1f8181d6 +P d758859f6ab94ddb9b3ee6f6f5f24b16e2b7a7712761080cfc6540d68b5a0c97 +R a4c45eeed81feef61bc930db9802b9d0 U drh -Z 4fcd0225dec5f74728c5f2d47e52e14a +Z 04c984163e7286ef19d8dbc870dfbf03 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9f9ca72c0b..ceb4c37b4b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d758859f6ab94ddb9b3ee6f6f5f24b16e2b7a7712761080cfc6540d68b5a0c97 \ No newline at end of file +2f9d4444aa503102a00d6e6769dadc57d4b26a2c07f145f23f2f28e0c161246d \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 5bda7c9cdf..fef9d45c32 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1237,8 +1237,11 @@ static void shellDtostr( sqlite3_value **apVal ){ double r = sqlite3_value_double(apVal[0]); - char z[200]; - sprintf(z, "%#+.26e", r); + int n = nVal>=2 ? sqlite3_value_int(apVal[1]) : 26; + char z[400]; + if( n<1 ) n = 1; + if( n>350 ) n = 350; + sprintf(z, "%#+.*e", n, r); sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); } @@ -5503,6 +5506,8 @@ static void open_db(ShellState *p, int openFlags){ shellStrtod, 0, 0); sqlite3_create_function(p->db, "dtostr", 1, SQLITE_UTF8, 0, shellDtostr, 0, 0); + sqlite3_create_function(p->db, "dtostr", 2, SQLITE_UTF8, 0, + shellDtostr, 0, 0); sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0, shellAddSchemaName, 0, 0); sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0,