Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 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) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
333011ffddc0be91f76811458f03ad1e |
User & Date: | drh 2003-04-26 13:19:39.000 |
Context
2003-04-29
| ||
16:20 | The sqlite_complete() function should ignore carriage-return characters. (Oops - some unrelated edits also made it into this check-in.) (CVS 942) (check-in: c6bf62e41c user: drh tags: trunk) | |
2003-04-26
| ||
13:19 | 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) (check-in: 333011ffdd user: drh tags: trunk) | |
03:03 | Fix the shell tool to do a better job of ignoring whitespace. Ticket #234. (CVS 940) (check-in: 639957e9f7 user: drh tags: trunk) | |
Changes
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.24 2003/04/26 13:19:39 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | static int getVmPointer(Tcl_Interp *interp, const char *zArg, sqlite_vm **ppVm){ if( sscanf(zArg, PTR_FMT, (void**)ppVm)!=1 ){ Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0); return TCL_ERROR; } return TCL_OK; } /* ** Usage: sqlite_open filename ** ** Returns: The name of an open database. */ static int sqlite_test_open( | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | static int getVmPointer(Tcl_Interp *interp, const char *zArg, sqlite_vm **ppVm){ if( sscanf(zArg, PTR_FMT, (void**)ppVm)!=1 ){ Tcl_AppendResult(interp, "\"", zArg, "\" is not a valid pointer value", 0); return TCL_ERROR; } 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 ** ** Returns: The name of an open database. */ static int sqlite_test_open( |
︙ | ︙ | |||
70 71 72 73 74 75 76 | } db = sqlite_open(argv[1], 0666, &zErr); if( db==0 ){ Tcl_AppendResult(interp, zErr, 0); free(zErr); return TCL_ERROR; } | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | } db = sqlite_open(argv[1], 0666, &zErr); if( db==0 ){ Tcl_AppendResult(interp, zErr, 0); free(zErr); return TCL_ERROR; } if( makePointerStr(interp, zBuf, db) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** The callback routine for sqlite_exec_printf(). */ |
︙ | ︙ | |||
619 620 621 622 623 624 625 | assert( vm==0 ); sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, zErr, 0); sqlite_freemem(zErr); return TCL_ERROR; } if( vm ){ | | | 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | assert( vm==0 ); sprintf(zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, zErr, 0); sqlite_freemem(zErr); return TCL_ERROR; } if( vm ){ if( makePointerStr(interp, zBuf, vm) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); } return TCL_OK; } /* ** Usage: sqlite_step VM NVAR VALUEVAR COLNAMEVAR |
︙ | ︙ |