mprintf() correctly handles "%s","". Fix for ticket #812. (CVS 1800)

FossilOrigin-Name: 4f56db1149f65dc2edf6626fa20ae255a5f5280c
This commit is contained in:
drh
2004-07-17 21:56:09 +00:00
parent dd809b087f
commit e29b1a05a7
8 changed files with 116 additions and 103 deletions
+6 -3
View File
@@ -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;
}
}
+27 -1
View File
@@ -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 },