]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Further refine the dtostr() testing function in the CLI so that it takes an
authordrh <>
Thu, 29 Jun 2023 17:26:21 +0000 (17:26 +0000)
committerdrh <>
Thu, 29 Jun 2023 17:26:21 +0000 (17:26 +0000)
optional second parameter which is the number of significant digits to display.

FossilOrigin-Name: 2f9d4444aa503102a00d6e6769dadc57d4b26a2c07f145f23f2f28e0c161246d

manifest
manifest.uuid
src/shell.c.in

index 9f0e3dfb07a7bae1a141b1545a04f27a1750d394..897ab5ae64761df51a1ef0ec95e64fb25cc2a8d6 100644 (file)
--- 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.
index 9f9ca72c0b4aef895aed639b995e4a36d6a261e6..ceb4c37b4bfd90e262d5f2cafcad42c588e632eb 100644 (file)
@@ -1 +1 @@
-d758859f6ab94ddb9b3ee6f6f5f24b16e2b7a7712761080cfc6540d68b5a0c97
\ No newline at end of file
+2f9d4444aa503102a00d6e6769dadc57d4b26a2c07f145f23f2f28e0c161246d
\ No newline at end of file
index 5bda7c9cdfdf35b02380b1ca7e990dbaebf887b4..fef9d45c324348bbbc97f1ad8118f75fbcdd572a 100644 (file)
@@ -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,