diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sqliteInt.h | 3 | ||||
-rw-r--r-- | src/tclsqlite.c | 8 | ||||
-rw-r--r-- | src/tokenize.c | 13 | ||||
-rw-r--r-- | src/util.c | 6 | ||||
-rw-r--r-- | src/vdbeaux.c | 26 | ||||
-rw-r--r-- | src/vdbemem.c | 6 |
6 files changed, 36 insertions, 26 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4b4b825f9..270d38382 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.254 2004/05/27 01:53:56 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.255 2004/05/27 13:35:20 danielk1977 Exp $ */ #include "config.h" #include "sqlite.h" @@ -1351,3 +1351,4 @@ int sqlite3atoi64(const char*, i64*); void sqlite3Error(sqlite *, int, const char*,...); int sqlite3utfTranslate(const void *, int , u8 , void **, int *, u8); u8 sqlite3UtfReadBom(const void *zData, int nData); +char *sqlite3HexToBlob(const char *z); diff --git a/src/tclsqlite.c b/src/tclsqlite.c index a8dc7c09b..29e609303 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.74 2004/05/27 12:11:32 danielk1977 Exp $ +** $Id: tclsqlite.c,v 1.75 2004/05/27 13:35:20 danielk1977 Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -815,10 +815,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ if( SQLITE3_BLOB!=sqlite3_column_type(pStmt, i) ){ pVal = Tcl_NewStringObj(sqlite3_column_text(pStmt, i), -1); }else{ - pVal = Tcl_NewByteArrayObj( - sqlite3_column_blob(pStmt, i), - sqlite3_column_bytes(pStmt, i) - ); + int bytes = sqlite3_column_bytes(pStmt, i); + pVal = Tcl_NewByteArrayObj(sqlite3_column_blob(pStmt, i), bytes); } if( objc==5 ){ diff --git a/src/tokenize.c b/src/tokenize.c index 122e61440..77d760003 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.71 2004/05/27 09:28:43 danielk1977 Exp $ +** $Id: tokenize.c,v 1.72 2004/05/27 13:35:20 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -377,14 +377,19 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){ } case 'x': case 'X': { if( z[1]=='\'' || z[1]=='"' ){ - int delim = z[0]; - for(i=1; z[i]; i++){ + int delim = z[1]; + *tokenType = TK_BLOB; + for(i=2; z[i]; i++){ if( z[i]==delim ){ + if( i%2 ) *tokenType = TK_ILLEGAL; break; } + if( !isxdigit(z[i]) ){ + *tokenType = TK_ILLEGAL; + return i; + } } if( z[i] ) i++; - *tokenType = TK_BLOB; return i; } /* Otherwise fall through to the next case */ diff --git a/src/util.c b/src/util.c index 8f5334966..27c94bc02 100644 --- a/src/util.c +++ b/src/util.c @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.91 2004/05/27 09:28:43 danielk1977 Exp $ +** $Id: util.c,v 1.92 2004/05/27 13:35:20 danielk1977 Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -1307,7 +1307,7 @@ char * sqlite3HexToBlob(const char *z){ zBlob = (char *)sqliteMalloc(n/2); - for(i=0; i<n; i+=2){ + for(i=0; i<n; i++){ u8 c; if ( z[i]>47 && z[i]<58 ) c = (z[i]-48)<<4; @@ -1317,6 +1317,7 @@ char * sqlite3HexToBlob(const char *z){ sqliteFree(zBlob); return 0; } + i++; if ( z[i]>47 && z[i]<58 ) c += (z[i]-48); else if( z[i]>64 && z[i]<71 ) c += (z[i]-55); else if( z[i]>96 && z[i]<103 ) c += (z[i]-87); @@ -1327,6 +1328,7 @@ char * sqlite3HexToBlob(const char *z){ zBlob[i/2] = c; } + return zBlob; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 56155d903..5028dc938 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -612,20 +612,22 @@ int sqlite3VdbeList( */ static int translateOp(Op *pOp){ if( pOp->opcode==OP_HexBlob ){ - char *zBlob = sqlite3HexToBlob(pOp->p3); - if( !zBlob ){ - if( sqlite3_malloc_failed ){ - return SQLITE_NOMEM; - } - return SQLITE_ERROR; - } pOp->p1 = strlen(pOp->p3)/2; - if( pOp->p3type==P3_DYNAMIC ){ - sqliteFree(pOp->p3); + if( pOp->p1 ){ + char *zBlob = sqlite3HexToBlob(pOp->p3); + if( !zBlob ) return SQLITE_NOMEM; + if( pOp->p3type==P3_DYNAMIC ){ + sqliteFree(pOp->p3); + } + pOp->p3 = zBlob; + pOp->p3type = P3_DYNAMIC; + }else{ + pOp->p3type = P3_STATIC; + pOp->p3 = ""; } - pOp->p3 = zBlob; - pOp->p3type = P3_DYNAMIC; + pOp->opcode = OP_Blob; } + return SQLITE_OK; } /* @@ -699,7 +701,7 @@ void sqlite3VdbeMakeReady( } } #endif - { + if( !isExplain ){ int i; for(i=0; i<p->nOp; i++){ translateOp(&p->aOp[i]); diff --git a/src/vdbemem.c b/src/vdbemem.c index 3cf07d58b..205150e03 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -315,9 +315,9 @@ int sqlite3VdbeMemSetStr( pMem->z = (char *)z; if( eCopy ){ - pMem->flags = MEM_Ephem|MEM_Str; + pMem->flags = MEM_Ephem; }else{ - pMem->flags = MEM_Static|MEM_Str; + pMem->flags = MEM_Static; } pMem->enc = enc; pMem->type = enc==0 ? SQLITE3_BLOB : SQLITE3_TEXT; @@ -328,6 +328,7 @@ int sqlite3VdbeMemSetStr( break; case TEXT_Utf8: + pMem->flags |= MEM_Str; if( n<0 ){ pMem->n = strlen(z); pMem->flags |= MEM_Term; @@ -336,6 +337,7 @@ int sqlite3VdbeMemSetStr( case TEXT_Utf16le: case TEXT_Utf16be: + pMem->flags |= MEM_Str; if( n<0 ){ pMem->n = sqlite3utf16ByteLen(z,-1); pMem->flags |= MEM_Term; |