From e29b1a05a7e86fdd5bb58cd2f4f8bbc700bb01f3 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 17 Jul 2004 21:56:09 +0000 Subject: [PATCH] mprintf() correctly handles "%s","". Fix for ticket #812. (CVS 1800) FossilOrigin-Name: 4f56db1149f65dc2edf6626fa20ae255a5f5280c --- manifest | 22 ++++----- manifest.uuid | 2 +- src/printf.c | 9 ++-- src/test1.c | 28 +++++++++++- test/printf.test | 9 +++- www/arch.tcl | 19 +------- www/arch2.fig | 115 +++++++++++++++++++++-------------------------- www/support.tcl | 15 +++++-- 8 files changed, 116 insertions(+), 103 deletions(-) diff --git a/manifest b/manifest index 7f6c58bc25..56e9a12849 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\sF_FULLFSYNC\sfctrl\sif\sit\sis\savailable.\s\sRecord\sthe\sname\sof\sfiles\nthat\sare\sopened\sin\sthe\sOsFile\sstructure.\s(CVS\s1799) -D 2004-07-17T21:44:57 +C mprintf()\scorrectly\shandles\s"%s","".\s\sFix\sfor\sticket\s#812.\s(CVS\s1800) +D 2004-07-17T21:56:10 F Makefile.in 77d1219b6563476711a7a962e865979a6f314eb0 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -54,7 +54,7 @@ F src/pager.c 5f8cdc92ee9efb5a7849dc8b561b53122b700c78 F src/pager.h 269b6cfc114dba0148203446e41dd19f9647dd53 F src/parse.y 51c8e696276c409618e66a4ccf316fcff245506e F src/pragma.c 8326df8c400f573eb43004dfb8e53e5102acb3e4 -F src/printf.c 3090c8ff397d549bc0de09b16d8ab7fd37a0c3f7 +F src/printf.c 36090f6d7b4946539de97c1850675ce55ef66c16 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c f02a65af34231031896e8442161cb5251e191e75 F src/shell.c ebec5da57ea401f4886eefc790917b939d94d595 @@ -62,7 +62,7 @@ F src/sqlite.h.in aaf46c8d458efd8aca694ec4f18c6ecf616ee55e F src/sqliteInt.h aeae6793d1db335ec1179ad9f26b0affc0ec658a F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49 F src/tclsqlite.c 62848128011e59291902c6e5c6f910c05956fcbb -F src/test1.c d491aea9d451d2b6a24cf028cd7e3a9d875bb0f3 +F src/test1.c 004885b49a7b5a594192f137c671135920f64c94 F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40 F src/test3.c d0c56667e89f79ad0f060fdf010d1c34a4bc2988 F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2 @@ -143,7 +143,7 @@ F test/null.test 64730a1c32955e5cc510b7632fed6b9929a4029a F test/pager.test 059cc5c58d3b5a851343dff8c56cf7286425d03a F test/pager2.test 55469c7c1c1a54d6b32d7b3cc99001e90101a1ce F test/pragma.test 212d810e02a51c0ff9784a19d55e35d23382005d -F test/printf.test 5ed2e033a0b47f901764096bf1907915d6e39406 +F test/printf.test 428ad9be92963b68ba222dac4c19724cc4e304ea F test/progress.test 76c722f090b1ccb575e7e4e203a71608c5763beb x F test/quick.test bbe4abf7f434d71c0de26626c8cbb4858e1bcb18 F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d @@ -196,8 +196,8 @@ F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4 -F www/arch.tcl 3f4f9173a3b7dc05b0ea67ae0c942866558ad35d -F www/arch2.fig 613b5ac63511109064c2f93c5754ee662219937d +F www/arch.tcl b833057e89aeb43335c0bf84a3d5b7f9d11df6fa +F www/arch2.fig ae2432145c26cfa148fa0116589517ad3cd5fc65 F www/arch2.gif 49c6bb36160f03ca2b89eaa5bfb1f560c7d68ee7 F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0 F www/c_interface.tcl 2176519fc2bd2d2cf6fe74fd806fc2d8362de2c8 @@ -228,12 +228,12 @@ F www/opcode.tcl e8c421fd2c70c503b25cedb3f9617a1f387ac7ea F www/quickstart.tcl 4e97bef825e6a4153c43afb9f97235fc4da278ab F www/speed.tcl 19cf0c1bf73c4b534dfafc95b3eacff4825740b4 F www/sqlite.tcl b51fd15f0531a54874de785a9efba323eecd5975 -F www/support.tcl 836a8d63f9a4feb72b7004c8dbc7a7e4142d9e10 +F www/support.tcl 96c8324cea27b5ded53ff5c60c127ba2053f688e F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P c01f13267f592dc2678e78ea45dadddcdc154f82 -R a9f4dab888d922312d00d87de0e5cb2e +P 1d30d0dd46c2bd12ce3f7dc06492f3e27ab6bcee +R a883873c22c5f6280ed24904f9fd2d42 U drh -Z d985f788c605dfd4069fa22794ea5ba6 +Z 687b24d8f66905314c3d6818e3ab8a29 diff --git a/manifest.uuid b/manifest.uuid index d60bbb8ed2..22e5577537 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1d30d0dd46c2bd12ce3f7dc06492f3e27ab6bcee \ No newline at end of file +4f56db1149f65dc2edf6626fa20ae255a5f5280c \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index a190a10170..2ed674a883 100644 --- a/src/printf.c +++ b/src/printf.c @@ -228,6 +228,7 @@ static int vxprintf( int nsd; /* Number of significant digits returned */ #endif + func(arg,"",0); count = length = 0; bufpt = 0; for(; (c=(*fmt))!=0; ++fmt){ @@ -684,9 +685,11 @@ static void mout(void *arg, const char *zNewText, int nNewChar){ } } } - if( pM->zText && nNewChar>0 ){ - memcpy(&pM->zText[pM->nChar], zNewText, nNewChar); - pM->nChar += nNewChar; + if( pM->zText ){ + if( nNewChar>0 ){ + memcpy(&pM->zText[pM->nChar], zNewText, nNewChar); + pM->nChar += nNewChar; + } pM->zText[pM->nChar] = 0; } } diff --git a/src/test1.c b/src/test1.c index 38271b6cfb..852a1649f0 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.93 2004/07/15 14:15:02 drh Exp $ +** $Id: test1.c,v 1.94 2004/07/17 21:56:10 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -669,6 +669,31 @@ static int sqlite3_mprintf_scaled( return TCL_OK; } +/* +** Usage: sqlite3_mprintf_stronly FORMAT STRING +** +** Call mprintf with a single double argument which is the product of the +** two arguments given above. This is used to generate overflow and underflow +** doubles to test that they are converted properly. +*/ +static int sqlite3_mprintf_stronly( + void *NotUsed, + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int argc, /* Number of arguments */ + char **argv /* Text of each argument */ +){ + char *z; + if( argc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], + " FORMAT STRING\"", 0); + return TCL_ERROR; + } + z = sqlite3_mprintf(argv[1], argv[2]); + Tcl_AppendResult(interp, z, 0); + sqlite3_free(z); + return TCL_OK; +} + /* ** Usage: sqlite_malloc_fail N ** @@ -2287,6 +2312,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_mprintf_int", (Tcl_CmdProc*)sqlite3_mprintf_int }, { "sqlite3_mprintf_int64", (Tcl_CmdProc*)sqlite3_mprintf_int64 }, { "sqlite3_mprintf_str", (Tcl_CmdProc*)sqlite3_mprintf_str }, + { "sqlite3_mprintf_stronly", (Tcl_CmdProc*)sqlite3_mprintf_stronly}, { "sqlite3_mprintf_double", (Tcl_CmdProc*)sqlite3_mprintf_double }, { "sqlite3_mprintf_scaled", (Tcl_CmdProc*)sqlite3_mprintf_scaled }, { "sqlite3_mprintf_z_test", (Tcl_CmdProc*)test_mprintf_z }, diff --git a/test/printf.test b/test/printf.test index c991142362..159c240d37 100644 --- a/test/printf.test +++ b/test/printf.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the sqlite_*_printf() interface. # -# $Id: printf.test,v 1.11 2004/06/29 13:04:33 drh Exp $ +# $Id: printf.test,v 1.12 2004/07/17 21:56:10 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -161,4 +161,11 @@ do_test printf-9.4 { sqlite3_mprintf_int {%yhello} 0 0 0 } {%} +# Ticket #812 +# +do_test printf-10.1 { + sqlite3_mprintf_stronly %s {} +} {} + + finish_test diff --git a/www/arch.tcl b/www/arch.tcl index 0161634b7d..39977484eb 100644 --- a/www/arch.tcl +++ b/www/arch.tcl @@ -1,7 +1,7 @@ # # Run this Tcl script to generate the sqlite.html file. # -set rcsid {$Id: arch.tcl,v 1.13 2004/06/16 03:02:04 drh Exp $} +set rcsid {$Id: arch.tcl,v 1.14 2004/07/17 21:56:10 drh Exp $} source common.tcl header {Architecture of SQLite} puts { @@ -148,23 +148,6 @@ The vdbeaux.c file contains utilities used by the virtual machine and interface modules used by the rest of the library to construct VM programs.

-

Backend

- -

The backend is an abstraction layer that presents a uniform interface -to the virtual machine for either the B-Tree drivers for disk-based -databases or the Red/Black Tree driver for in-memory databases. -The btree.h source file contains the details.

- -

Red/Black Tree

- -

In SQLite version 2.X, in-memory databases are stored in a red/black -tree implementation contain in the btree_rb.c source file. In -version 3.0, the red/black tree implementation is omitted. In-memory -databases use the same B-Tree and pager code with a special flag that -tells the pager to maintain all data in cache and never write to the -disk. -

-

B-Tree

An SQLite database is maintained on disk using a B-tree implementation diff --git a/www/arch2.fig b/www/arch2.fig index 97a1a38245..70bc5f16a8 100644 --- a/www/arch2.fig +++ b/www/arch2.fig @@ -15,54 +15,58 @@ Single 0 37 #efdbd7 0 38 #e7efcf 0 39 #9e9e9e -6 4950 4275 6525 4800 -2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 5025 4350 6525 4350 6525 4800 5025 4800 5025 4350 -2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 4950 4275 6450 4275 6450 4725 4950 4725 4950 4275 -4 1 0 50 0 2 12 0.0000 4 135 1335 5700 4575 Red/Black Tree\001 --6 -6 5400 5475 6825 6000 -2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 5400 5475 6750 5475 6750 5925 5400 5925 5400 5475 -2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 5475 5550 6825 5550 6825 6000 5475 6000 5475 5550 -4 1 0 50 0 2 12 0.0000 4 135 630 6000 5775 Utilities\001 --6 -6 5400 6300 6825 6825 -2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 5400 6300 6750 6300 6750 6750 5400 6750 5400 6300 -2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 5475 6375 6825 6375 6825 6825 5475 6825 5475 6375 -4 1 0 50 0 2 12 0.0000 4 135 855 6000 6600 Test Code\001 --6 -2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 5475 2625 6825 2625 6825 3525 5475 3525 5475 2625 -2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 5400 2550 6750 2550 6750 3450 5400 3450 5400 2550 -2 3 0 1 0 35 55 0 20 0.000 0 0 -1 0 0 9 - 2850 3675 4875 3675 4875 3975 6750 3975 6750 5025 4875 5025 - 4875 6975 2850 6975 2850 3675 -2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 3225 6300 4575 6300 4575 6750 3225 6750 3225 6300 -2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 3300 6375 4650 6375 4650 6825 3300 6825 3300 6375 +6 3225 3900 4650 6000 2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 3225 5475 4575 5475 4575 5925 3225 5925 3225 5475 2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 3300 5550 4650 5550 4650 6000 3300 6000 3300 5550 2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 3225 4725 4575 4725 4575 5175 3225 5175 3225 4725 + 3225 4650 4575 4650 4575 5100 3225 5100 3225 4650 2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 3300 4800 4650 4800 4650 5250 3300 5250 3300 4800 + 3300 4725 4650 4725 4650 5175 3300 5175 3300 4725 2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 3225 3900 4575 3900 4575 4350 3225 4350 3225 3900 2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 3300 3975 4650 3975 4650 4425 3300 4425 3300 3975 +2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 3900 4350 3900 4650 +2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 3900 5100 3900 5475 +4 1 0 50 0 2 12 0.0000 4 135 1050 3900 5775 OS Interface\001 +4 1 0 50 0 2 12 0.0000 4 135 615 3900 4200 B-Tree\001 +4 1 0 50 0 2 12 0.0000 4 180 495 3900 4950 Pager\001 +-6 +6 5400 4725 6825 5250 2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 - 5400 1800 6750 1800 6750 2250 5400 2250 5400 1800 + 5400 4725 6750 4725 6750 5175 5400 5175 5400 4725 2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 - 5475 1875 6825 1875 6825 2325 5475 2325 5475 1875 + 5475 4800 6825 4800 6825 5250 5475 5250 5475 4800 +4 1 0 50 0 2 12 0.0000 4 135 630 6000 5025 Utilities\001 +-6 +6 5400 5550 6825 6075 +2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 + 5400 5550 6750 5550 6750 6000 5400 6000 5400 5550 +2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 + 5475 5625 6825 5625 6825 6075 5475 6075 5475 5625 +4 1 0 50 0 2 12 0.0000 4 135 855 6000 5850 Test Code\001 +-6 +6 5400 2775 6825 3750 +2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 + 5475 2850 6825 2850 6825 3750 5475 3750 5475 2850 +2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 + 5400 2775 6750 2775 6750 3675 5400 3675 5400 2775 +4 1 0 50 0 2 12 0.0000 4 135 420 6075 3150 Code\001 +4 1 0 50 0 2 12 0.0000 4 135 855 6075 3375 Generator\001 +-6 +6 5400 1950 6825 2475 +2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 + 5400 1950 6750 1950 6750 2400 5400 2400 5400 1950 +2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 + 5475 2025 6825 2025 6825 2475 5475 2475 5475 2025 +4 1 0 50 0 2 12 0.0000 4 135 570 6075 2250 Parser\001 +-6 2 2 0 1 0 7 51 0 20 0.000 0 0 -1 0 0 5 5400 1050 6750 1050 6750 1500 5400 1500 5400 1050 2 2 0 0 0 33 52 0 20 0.000 0 0 -1 0 0 5 @@ -93,44 +97,27 @@ Single 4575 1950 5400 1350 2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 1 1 1.00 60.00 120.00 - 5400 2925 4650 2175 -2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 3900 4350 3900 4725 -2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 4575 4200 4950 4500 -2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 3900 5175 3900 5475 -2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 3900 5925 3900 6300 -2 2 0 1 0 37 55 0 20 0.000 0 0 -1 0 0 5 - 5175 750 7200 750 7200 3750 5175 3750 5175 750 + 5400 2925 4650 2325 2 2 0 1 0 34 55 0 20 0.000 0 0 -1 0 0 5 2850 750 4875 750 4875 3375 2850 3375 2850 750 2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 1 1 1.00 60.00 120.00 - 6075 1500 6075 1800 + 6075 1500 6075 1950 +2 3 0 1 0 35 55 0 20 0.000 0 0 -1 0 0 5 + 2850 3675 4875 3675 4875 6225 2850 6225 2850 3675 +2 2 0 1 0 37 55 0 20 0.000 0 0 -1 0 0 5 + 5175 750 7200 750 7200 4050 5175 4050 5175 750 +2 2 0 1 0 38 55 0 20 0.000 0 0 -1 0 0 5 + 5175 4425 7200 4425 7200 6225 5175 6225 5175 4425 2 1 0 1 0 38 50 0 -1 0.000 0 0 -1 1 0 2 1 1 1.00 60.00 120.00 - 6075 2250 6075 2550 -2 2 0 1 0 38 55 0 20 0.000 0 0 -1 0 0 5 - 5175 5250 7200 5250 7200 6975 5175 6975 5175 5250 + 6075 2475 6075 2775 4 1 0 50 0 2 12 0.0000 4 135 855 6075 1350 Tokenizer\001 -4 1 0 50 0 2 12 0.0000 4 135 570 6075 2100 Parser\001 -4 1 0 50 0 2 12 0.0000 4 135 420 6075 2925 Code\001 -4 1 0 50 0 2 12 0.0000 4 135 855 6075 3150 Generator\001 -4 1 0 50 0 2 12 0.0000 4 135 720 3900 4200 Backend\001 -4 1 0 50 0 2 12 0.0000 4 135 1050 3900 6600 OS Interface\001 -4 1 0 50 0 2 12 0.0000 4 135 615 3900 5025 B-Tree\001 -4 1 0 50 0 2 12 0.0000 4 180 495 3900 5775 Pager\001 4 1 0 50 0 1 12 1.5708 4 180 1020 7125 2250 SQL Compiler\001 -4 1 0 50 0 1 12 1.5708 4 135 885 7125 6150 Accessories\001 -4 1 0 50 0 1 12 1.5708 4 135 645 3075 5250 Backend\001 4 1 0 50 0 1 12 1.5708 4 135 345 3075 2025 Core\001 4 1 0 50 0 2 12 0.0000 4 135 1290 3900 2850 Virtual Machine\001 4 1 0 50 0 2 12 0.0000 4 165 1185 3900 1995 SQL Command\001 4 1 0 50 0 2 12 0.0000 4 135 855 3900 2183 Processor\001 4 1 0 50 0 2 14 0.0000 4 150 870 3900 1350 Interface\001 +4 1 0 50 0 1 12 1.5708 4 135 885 7125 5400 Accessories\001 +4 1 0 50 0 1 12 1.5708 4 135 645 3075 4875 Backend\001 diff --git a/www/support.tcl b/www/support.tcl index 54714bd9a5..bb8cee2eee 100644 --- a/www/support.tcl +++ b/www/support.tcl @@ -1,4 +1,4 @@ -set rcsid {$Id: support.tcl,v 1.3 2004/07/15 14:15:02 drh Exp $} +set rcsid {$Id: support.tcl,v 1.4 2004/07/17 21:56:10 drh Exp $} source common.tcl header {SQLite Support Options} puts { @@ -25,11 +25,18 @@ sent by to you by return email.

-An archive of the mailing list can be found at +There are multiple archives of the mailing list: +

+ +
-http://www.mail-archive.com/sqlite-users%40sqlite.org and at +http://www.mail-archive.com/sqlite-users%40sqlite.org
-http://www.theaimsgroup.com/. +http://www.theaimsgroup.com/
+ +http://news.gmane.org/gmane.comp.db.sqlite.general +
+

Professional Support