In the test code, make several attempts to convert a pointer to a string
and test each attempt to make sure it works before returnning, in order to work around incompatibilities between various systems. Ticket #284. (CVS 941) FossilOrigin-Name: 333011ffddc0be91f76811458f03ad1ec0331b51
This commit is contained in:
parent
70c7a4b1da
commit
7d8085a8e4
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sthe\sshell\stool\sto\sdo\sa\sbetter\sjob\sof\signoring\swhitespace.\s\sTicket\s#234.\s(CVS\s940)
|
||||
D 2003-04-26T03:03:07
|
||||
C In\sthe\stest\scode,\smake\sseveral\sattempts\sto\sconvert\sa\spointer\sto\sa\sstring\nand\stest\seach\sattempt\sto\smake\ssure\sit\sworks\sbefore\sreturnning,\sin\sorder\sto\nwork\saround\sincompatibilities\sbetween\svarious\ssystems.\s\sTicket\s#284.\s(CVS\s941)
|
||||
D 2003-04-26T13:19:39
|
||||
F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -50,7 +50,7 @@ F src/sqlite.h.in eec06462cba262c0ee03f38462a18a4bc66dda4e
|
||||
F src/sqliteInt.h 0c7474068c37a5aad715810c8190266edcbd4f4c
|
||||
F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
|
||||
F src/tclsqlite.c 9e25f98f1765afa0716144ef57abda75c88f688d
|
||||
F src/test1.c 4484806861a3099670188a09e12f858ec65aa56c
|
||||
F src/test1.c 4596acd9d9f2a49fda0160a8a6dee5bfc7c6c325
|
||||
F src/test2.c 5014337d8576b731cce5b5a14bec4f0daf432700
|
||||
F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5
|
||||
F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
|
||||
@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
|
||||
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
|
||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||
P 92ded93376635f37e2f5a7a8f4077c85d5bce735
|
||||
R a6549a02bf88e45588d8dc89d4315963
|
||||
P 639957e9f793eddce027050d2655863d82fe8ac9
|
||||
R 55c305a0471c4f4afa1a6daa2bfcd3e3
|
||||
U drh
|
||||
Z 2a7401700105d8209d91c7c271e81f42
|
||||
Z f6cc1e6c8eb8613b9394102a1cbb5f97
|
||||
|
@ -1 +1 @@
|
||||
639957e9f793eddce027050d2655863d82fe8ac9
|
||||
333011ffddc0be91f76811458f03ad1ec0331b51
|
36
src/test1.c
36
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.23 2003/04/22 20:30:40 drh Exp $
|
||||
** $Id: test1.c,v 1.24 2003/04/26 13:19:39 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@ -49,6 +49,36 @@ static int getVmPointer(Tcl_Interp *interp, const char *zArg, sqlite_vm **ppVm){
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Generate a text representation of a pointer that can be understood
|
||||
** by the getDbPointer and getVmPointer routines above.
|
||||
**
|
||||
** The problem is, on some machines (Solaris) if you do a printf with
|
||||
** "%p" you cannot turn around and do a scanf with the same "%p" and
|
||||
** get your pointer back. You have to prepend a "0x" before it will
|
||||
** work. Or at least that is what is reported to me (drh). But this
|
||||
** behavior varies from machine to machine. The solution used her is
|
||||
** to test the string right after it is generated to see if it can be
|
||||
** understood by scanf, and if not, try prepending an "0x" to see if
|
||||
** that helps. If nothing works, a fatal error is generated.
|
||||
*/
|
||||
static int makePointerStr(Tcl_Interp *interp, char *zPtr, void *p){
|
||||
void *p2;
|
||||
sprintf(zPtr, PTR_FMT, p);
|
||||
if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
|
||||
sprintf(zPtr, "0x" PTR_FMT, p);
|
||||
if( sscanf(zPtr, PTR_FMT, &p2)!=1 || p2!=p ){
|
||||
Tcl_AppendResult(interp, "unable to convert a pointer to a string "
|
||||
"in the file " __FILE__ " in function makePointerStr(). Please "
|
||||
"report this problem to the SQLite mailing list or as a new but "
|
||||
"report. Please provide detailed information about how you compiled "
|
||||
"SQLite and what computer you are running on.", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite_open filename
|
||||
**
|
||||
@ -74,7 +104,7 @@ static int sqlite_test_open(
|
||||
free(zErr);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
sprintf(zBuf,PTR_FMT, db);
|
||||
if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR;
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
return TCL_OK;
|
||||
}
|
||||
@ -623,7 +653,7 @@ static int test_compile(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( vm ){
|
||||
sprintf(zBuf, PTR_FMT, vm);
|
||||
if( makePointerStr(interp, zBuf, vm) ) return TCL_ERROR;
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
}
|
||||
return TCL_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user