diff --git a/manifest b/manifest index 42323ae01b..f88d1a06e6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sto\sjoin.test.\sNo\scode\schanges,\sno\sbugs\sfound.\s(CVS\s5384) -D 2008-07-09T14:47:21 +C Test\scoverage\simprovements\son\sprintf.\s(CVS\s5385) +D 2008-07-09T16:51:51 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -138,7 +138,7 @@ F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba F src/parse.y 097bff733e89fbf554a07d9327046718ce364011 F src/pragma.c 6fad83fbcc7ec6e76d91fe2805fe972ff3af6a0c F src/prepare.c c9bb0aacb7a571d049805699ed18f2bb136ea091 -F src/printf.c 0e4bd1413226e8aaeadec251ffcee93448400417 +F src/printf.c 2a759d2759f43f07a84771c43e8045d7f742bb04 F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a F src/select.c e6edf11f024a5207e34683a25f33a700a2f1b43b F src/shell.c 484e7297e066f22830f9c15d7abbcdd2acb097b0 @@ -166,7 +166,7 @@ F src/test_devsym.c 6012cb8e3acf812513511025a4fa5d626e0ba19b F src/test_func.c ade4f0117cc96c5a05682e1ef38b84320a866ad9 F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f F src/test_loadext.c df8ab3a6481ddebbdf0d28ebac5d9e0790f7860f -F src/test_malloc.c e762a634a858417eee7225203fc2a5c564b9db20 +F src/test_malloc.c e9e1500f85c50964adc34892045410c08aaf67ff F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071 F src/test_mutex.c 64c88ef9fed47c896fe470af03bffcd0f6f058f2 F src/test_onefile.c 243157b10275251c5dc2d6619aee2ff9ae22379c @@ -177,7 +177,7 @@ F src/test_tclvar.c 73530070df8378571c8ce6bbbbb993236ae3ad0b F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730 F src/tokenize.c b5fdc79fb7e00077b9c02af7a0da3b89c9f3398e F src/trigger.c bdb56bb9db1a7b18f8505484051221ab5123f21d -F src/update.c 945242ccc4fa09799333632baf6b47c657f43cbc +F src/update.c 4e698fcc0c91c241a960304c4236dc3a49603155 F src/utf.c 8d52f620a7153d90b058502124fe51d821fcdf57 F src/util.c fbfb7fe4344e93245d8fc2ef975c6d2340f81388 F src/vacuum.c ef342828002debc97514617af3424aea8ef8522c @@ -188,7 +188,7 @@ F src/vdbeapi.c a7c6b8db324cf7eccff32de871dea36aa305c994 F src/vdbeaux.c 734d27d1e18bb4fb3c7f94d499039a8d3bbf8407 F src/vdbeblob.c 9345f6dcd675fdcfdb537d2d2f487542d9ea136a F src/vdbefifo.c c46dae1194e4277bf007144d7e5b0c0b1c24f136 -F src/vdbemem.c 3a27b04a25e933a46e9609356426f802fd1ef945 +F src/vdbemem.c 0c72b58ffd759676ce4829f42bacb83842a58c21 F src/vtab.c 2096c03ec5540a43c8c73a8f43407dfd3549a982 F src/where.c 3324f8273a9c40d4b04b65cdef0a8c4954c1cce6 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 @@ -412,7 +412,7 @@ F test/misc3.test 7212ed8dad01427e9acab9bd3e7e5e2c2e89be9e F test/misc4.test 91e8ed25c092c2bb4e0bb01864631e2930f8d7de F test/misc5.test 0b68dcb630d44af2dbcdca94dd2b17c8d580f6fa F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test 26e0d948a413bca61ed031159907a03d64647409 +F test/misc7.test 68198e6a699f0e8e8e7641d597a9e77c87c961d6 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 F test/mutex1.test 77719e9da234ba23f50e89e9fb19be8c116ad27a F test/mutex2.test a006d753714ea7e00b90b6f9c061bdde5be16435 @@ -428,7 +428,7 @@ F test/pagesize.test e0a8b3fe80f8b8e808d94a00734c7a18c76c407e F test/permutations.test af83024a469d1cade2a6ca9ce33e61bcdd7c2672 F test/pragma.test e1984ed47f699a4a817008dab4111be31ee8b935 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 -F test/printf.test b04797fc069ffad3ec2e45980bbfa1671dd66550 +F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test 83150cb7b513e33cce90fdc68f4b1817551857c0 F test/quick.test 3dba257b9d4e06e1b0199bc1401052f554ab5f14 @@ -480,7 +480,7 @@ F test/tableapi.test 892208d49e7be4817a4d3e4f641dbcbbee8cd03c F test/tclsqlite.test 3dfb48f46de4353376fad835390b493ba066b4dc F test/tempdb.test b88ac8a19823cf771d742bf61eef93ef337c06b1 F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125 -F test/tester.tcl 4cb72d06312d635bf7281b23ddc388f3b0e19f82 +F test/tester.tcl fbb53d7a92ab9156cf123a2dd47528a22c649860 F test/thread001.test 8fbd9559da0bbdc273e00318c7fd66c162020af7 F test/thread002.test 2c4ad2c386f60f6fe268cd91c769ee35b3c1fd0b F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35 @@ -600,7 +600,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 8aae4fe7e702b7636fba1fd609a0ca22fdcc3371 -R cfbfcaf3163b710506b897f4bbc58497 -U danielk1977 -Z 3e68bbb0c53d3688bc63cc9fa9482f9f +P 417aa1580abec8cc335dcb6ac36245c081a31ef8 +R 4491ab2e53ba152326327f2a45cdeff6 +U drh +Z 410f438828d348b456a7ce8e20b13c60 diff --git a/manifest.uuid b/manifest.uuid index e598fde1b4..3b1234278d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -417aa1580abec8cc335dcb6ac36245c081a31ef8 \ No newline at end of file +2d8f7bebf0f13f3a95f1e2163e35d43229cabfea \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 5a75fca225..4d1f4a18f7 100644 --- a/src/printf.c +++ b/src/printf.c @@ -5,7 +5,7 @@ ** an historical reference. Most of the "enhancements" have been backed ** out so that the functionality is now the same as standard printf(). ** -** $Id: printf.c,v 1.88 2008/07/08 19:34:07 drh Exp $ +** $Id: printf.c,v 1.89 2008/07/09 16:51:51 drh Exp $ ** ************************************************************************** ** @@ -68,15 +68,14 @@ #define etPERCENT 8 /* Percent symbol. %% */ #define etCHARX 9 /* Characters. %c */ /* The rest are extensions, not normally found in printf() */ -#define etCHARLIT 10 /* Literal characters. %' */ -#define etSQLESCAPE 11 /* Strings with '\'' doubled. %q */ -#define etSQLESCAPE2 12 /* Strings with '\'' doubled and enclosed in '', +#define etSQLESCAPE 10 /* Strings with '\'' doubled. %q */ +#define etSQLESCAPE2 11 /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ -#define etTOKEN 13 /* a pointer to a Token structure */ -#define etSRCLIST 14 /* a pointer to a SrcList */ -#define etPOINTER 15 /* The %p conversion */ -#define etSQLESCAPE3 16 /* %w -> Strings with '\"' doubled */ -#define etORDINAL 17 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ +#define etTOKEN 12 /* a pointer to a Token structure */ +#define etSRCLIST 13 /* a pointer to a SrcList */ +#define etPOINTER 14 /* The %p conversion */ +#define etSQLESCAPE3 15 /* %w -> Strings with '\"' doubled */ +#define etORDINAL 16 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ /* @@ -444,9 +443,7 @@ void sqlite3VXPrintf( const char *pre; char x; pre = &aPrefix[infop->prefix]; - if( *bufpt!=pre[0] ){ - for(; (x=(*pre))!=0; pre++) *(--bufpt) = x; - } + for(; (x=(*pre))!=0; pre++) *(--bufpt) = x; } length = &buf[etBUFSIZE-1]-bufpt; break; @@ -485,9 +482,11 @@ void sqlite3VXPrintf( while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; } while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; } - while( realvalue<1e-8 && exp>=-350 ){ realvalue *= 1e8; exp-=8; } - while( realvalue<1.0 && exp>=-350 ){ realvalue *= 10.0; exp--; } - if( exp>350 || exp<-350 ){ + if( realvalue>0.0 ){ + while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; } + while( realvalue<1.0 ){ realvalue *= 10.0; exp--; } + } + if( exp>350 ){ if( prefix=='-' ){ bufpt = "-Inf"; }else if( prefix=='+' ){ @@ -545,7 +544,8 @@ void sqlite3VXPrintf( } /* "0" digits after the decimal point but before the first ** significant digit of the number */ - for(e2++; e2<0 && precision>0; precision--, e2++){ + for(e2++; e2<0; precision--, e2++){ + assert( precision>0 ); *(bufpt++) = '0'; } /* Significant digits after the decimal point */ @@ -565,7 +565,7 @@ void sqlite3VXPrintf( } } /* Add the "eNNN" suffix */ - if( flag_exp || (xtype==etEXP && exp) ){ + if( flag_exp || xtype==etEXP ){ *(bufpt++) = aDigits[infop->charset]; if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; @@ -610,9 +610,8 @@ void sqlite3VXPrintf( bufpt = buf; length = 1; break; - case etCHARLIT: case etCHARX: - c = buf[0] = (xtype==etCHARX ? va_arg(ap,int) : *++fmt); + c = buf[0] = va_arg(ap,int); if( precision>=0 ){ for(idx=1; idxz ){ + if( pToken ){ sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n); } length = width = 0; diff --git a/src/test_malloc.c b/src/test_malloc.c index a35562a5f6..d5eeef7e36 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -13,7 +13,7 @@ ** This file contains code used to implement test interfaces to the ** memory allocation subsystem. ** -** $Id: test_malloc.c,v 1.34 2008/07/09 13:28:54 drh Exp $ +** $Id: test_malloc.c,v 1.35 2008/07/09 16:51:51 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -1061,6 +1061,8 @@ static int test_status( if( Tcl_GetIntFromObj(interp, objv[1], &op) ) return TCL_ERROR; } if( Tcl_GetBooleanFromObj(interp, objv[2], &resetFlag) ) return TCL_ERROR; + iValue = 0; + mxValue = 0; rc = sqlite3_status(op, &iValue, &mxValue, resetFlag); pResult = Tcl_NewObj(); Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc)); diff --git a/src/update.c b/src/update.c index 22d3012407..9df83664f9 100644 --- a/src/update.c +++ b/src/update.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.179 2008/07/08 23:40:20 drh Exp $ +** $Id: update.c,v 1.180 2008/07/09 16:51:51 drh Exp $ */ #include "sqliteInt.h" @@ -458,7 +458,7 @@ void sqlite3Update( sqlite3ExprCacheAffinityChange(pParse, regCols, pTab->nCol); } sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol); - if( pParse->nErr ) goto update_cleanup; + /* if( pParse->nErr ) goto update_cleanup; */ sqlite3VdbeAddOp3(v, OP_Insert, newIdx, regRow, regRowid); sqlite3ReleaseTempReg(pParse, regRowid); sqlite3ReleaseTempReg(pParse, regRow); diff --git a/src/vdbemem.c b/src/vdbemem.c index 22ca21d9a3..a8a2129f97 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -15,7 +15,7 @@ ** only within the VDBE. Interface routines refer to a Mem using the ** name sqlite_value ** -** $Id: vdbemem.c,v 1.117 2008/07/08 22:28:49 shane Exp $ +** $Id: vdbemem.c,v 1.118 2008/07/09 16:51:51 drh Exp $ */ #include "sqliteInt.h" #include @@ -82,8 +82,8 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){ ((pMem->flags&MEM_Static) ? 1 : 0) ); - if( !pMem->zMalloc || sqlite3MallocSize(pMem->zMalloc)32?n:32); + if( n<32 ) n = 32; + if( sqlite3MallocSize(pMem->zMalloc)z==pMem->zMalloc ){ pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); if( !pMem->z ){ diff --git a/test/misc7.test b/test/misc7.test index c9db96cf18..32841df25a 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -10,7 +10,7 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # -# $Id: misc7.test,v 1.19 2008/03/15 14:53:05 drh Exp $ +# $Id: misc7.test,v 1.20 2008/07/09 16:51:52 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -446,6 +446,17 @@ do_test misc7-18.1 { } } {} +# Testing boundary conditions on sqlite3_status() +# +do_test misc7-19.1 { + sqlite3_status -1 0 +} {21 0 0} +do_test misc7-19.2 { + sqlite3_status 1000 0 +} {21 0 0} + + + db close file delete -force test.db diff --git a/test/printf.test b/test/printf.test index d1b09a4b53..346992de19 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.29 2008/07/08 02:24:03 drh Exp $ +# $Id: printf.test,v 1.30 2008/07/09 16:51:52 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -3400,7 +3400,53 @@ do_test printf-2.8.14.8 { do_test printf-2.8.14.9 { sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 3.38826392e-110 } {abc: 3 2 (3.4e-110) :xyz} +do_test printf-2.8.15.1 { + sqlite3_mprintf_double {abc: (% *.*f) :xyz} 3 2 3.38826392e-110 +} {abc: ( 0.00) :xyz} +do_test printf-2.8.15.2 { + sqlite3_mprintf_double {abc: (% *.*e) :xyz} 3 2 3.38826392e-110 +} {abc: ( 3.39e-110) :xyz} +do_test printf-2.8.15.3 { + sqlite3_mprintf_double {abc: (% *.*g) :xyz} 3 2 3.38826392e-110 +} {abc: ( 3.4e-110) :xyz} +do_test printf-2.8.15.4 { + sqlite3_mprintf_double {abc: %d %d (% g) :xyz} 3 2 3.38826392e-110 +} {abc: 3 2 ( 3.38826e-110) :xyz} +do_test printf-2.8.15.5 { + sqlite3_mprintf_double {abc: %d %d (% #g) :xyz} 3 2 3.38826392e-110 +} {abc: 3 2 ( 3.38826e-110) :xyz} +do_test printf-2.8.15.6 { + sqlite3_mprintf_double {abc: %d %d (%0 10g) :xyz} 3 2 3.38826392e-110 +} {abc: 3 2 ( 3.38826e-110) :xyz} +do_test printf-2.8.15.7 { + sqlite3_mprintf_double {abc: %d %d (% 3.2f) :xyz} 3 2 3.38826392e-110 +} {abc: 3 2 ( 0.00) :xyz} +do_test printf-2.8.15.8 { + sqlite3_mprintf_double {abc: %d %d (% 3.2e) :xyz} 3 2 3.38826392e-110 +} {abc: 3 2 ( 3.39e-110) :xyz} +do_test printf-2.8.15.9 { + sqlite3_mprintf_double {abc: %d %d (% 3.2g) :xyz} 3 2 3.38826392e-110 +} {abc: 3 2 ( 3.4e-110) :xyz} +do_test printf-2.9.1 { + sqlite3_mprintf_double {abc: %d %d (%5.0g) :xyz} 0 0 1.234 +} {abc: 0 0 ( 1) :xyz} +do_test printf-2.9.2 { + sqlite3_mprintf_double {abc: %d %d (%+5.0g) :xyz} 0 0 1.234 +} {abc: 0 0 ( +1) :xyz} +do_test printf-2.9.3 { + sqlite3_mprintf_double {abc: %d %d (%+-5.0g) :xyz} 0 0 1.234 +} {abc: 0 0 (+1 ) :xyz} + +do_test printf-2.10.1 { + sqlite3_mprintf_double {abc: %d %d (%-010.5f) :xyz} 0 0 1.234 +} {abc: 0 0 (1.23400 ) :xyz} +do_test printf-2.10.2 { + sqlite3_mprintf_double {abc: %d %d (%010.5f) :xyz} 0 0 1.234 +} {abc: 0 0 (0001.23400) :xyz} +do_test printf-2.10.3 { + sqlite3_mprintf_double {abc: %d %d (%+010.5f) :xyz} 0 0 1.234 +} {abc: 0 0 (+001.23400) :xyz} do_test printf-3.1 { sqlite3_mprintf_str {A String: (%*.*s)} 10 10 {This is the string} @@ -3615,10 +3661,22 @@ do_test printf-14.3 { do_test printf-14.4 { sqlite3_mprintf_str {abc-%#} 0 0 {not used} } {abc-} +do_test printf-14.5 { + sqlite3_mprintf_str {abc-%*.*s-xyz} 10 -10 {a_very_long_string} +} {abc-a_very_lon-xyz} +do_test printf-14.6 { + sqlite3_mprintf_str {abc-%5.10/} 0 0 {not used} +} {abc-} +do_test printf-14.7 { + sqlite3_mprintf_str {abc-%05.5d} 123 0 {not used} +} {abc-00123} +do_test printf-14.8 { + sqlite3_mprintf_str {abc-%05.5d} 1234567 0 {not used} +} {abc-1234567} for {set i 2} {$i<200} {incr i} { set res [string repeat { } [expr {$i-1}]]x - do_test printf-14.10.$i " + do_test printf-14.90.$i " sqlite3_mprintf_str {%*.*s} $i 500 x " $res } diff --git a/test/tester.tcl b/test/tester.tcl index a23d005dc1..8eac43c202 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -11,7 +11,7 @@ # This file implements some common TCL routines used for regression # testing the SQLite library # -# $Id: tester.tcl,v 1.129 2008/07/08 12:07:33 danielk1977 Exp $ +# $Id: tester.tcl,v 1.130 2008/07/09 16:51:52 drh Exp $ # # What for user input before continuing. This gives an opportunity @@ -287,6 +287,16 @@ proc finalize_testing {} { if {$nErr>0} { puts "Failures on these tests: $::failList" } + set failsafe [lindex [sqlite3_status SQLITE_STATUS_FAILSAFE 1] 1] + if {$failsafe} { + puts "Failsafe error code [format 0x%08x $failsafe]" + incr nErr + } + set fs2 [lindex [sqlite3_status SQLITE_STATUS_FAILSAFE 0] 1] + if {$fs2} { + puts "Failsafe failed to reset" + incr nErr + } if {[llength $omitList]>0} { puts "Omitted test cases:" set prec {}