1.1 --- a/extensions/sqlite/sqlite-source/tokenize.c Sun Oct 28 05:06:12 2007 +0000
1.2 +++ b/extensions/sqlite/sqlite-source/tokenize.c Sun Oct 28 05:48:06 2007 +0000
1.3 @@ -18,7 +18,6 @@
1.4 ** $Id$
1.5 */
1.6 #include "sqliteInt.h"
1.7 -#include "os.h"
1.8 #include <ctype.h>
1.9 #include <stdlib.h>
1.10
1.11 @@ -86,7 +85,7 @@
1.12 ** But the feature is undocumented.
1.13 */
1.14 #ifdef SQLITE_ASCII
1.15 -const char sqlite3IsIdChar[] = {
1.16 +const char sqlite3IsAsciiIdChar[] = {
1.17 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
1.18 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */
1.19 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 3x */
1.20 @@ -95,10 +94,10 @@
1.21 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */
1.22 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */
1.23 };
1.24 -#define IdChar(C) (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsIdChar[c-0x20]))
1.25 +#define IdChar(C) (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsAsciiIdChar[c-0x20]))
1.26 #endif
1.27 #ifdef SQLITE_EBCDIC
1.28 -const char sqlite3IsIdChar[] = {
1.29 +const char sqlite3IsEbcdicIdChar[] = {
1.30 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
1.31 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */
1.32 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */
1.33 @@ -113,7 +112,7 @@
1.34 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */
1.35 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */
1.36 };
1.37 -#define IdChar(C) (((c=C)>=0x42 && sqlite3IsIdChar[c-0x40]))
1.38 +#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))
1.39 #endif
1.40
1.41
1.42 @@ -381,17 +380,10 @@
1.43 }
1.44
1.45 /*
1.46 -** The interface to the LEMON-generated parser
1.47 -*/
1.48 -void *sqlite3ParserAlloc(void*(*)(size_t));
1.49 -void sqlite3ParserFree(void*, void(*)(void*));
1.50 -void sqlite3Parser(void*, int, Token, Parse*);
1.51 -
1.52 -/*
1.53 ** Run the parser on the given SQL string. The parser structure is
1.54 ** passed in. An SQLITE_ status code is returned. If an error occurs
1.55 ** and pzErrMsg!=NULL then an error message might be written into
1.56 -** memory obtained from malloc() and *pzErrMsg made to point to that
1.57 +** memory obtained from sqlite3_malloc() and *pzErrMsg made to point to that
1.58 ** error message. Or maybe not.
1.59 */
1.60 int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
1.61 @@ -407,8 +399,9 @@
1.62 }
1.63 pParse->rc = SQLITE_OK;
1.64 i = 0;
1.65 - pEngine = sqlite3ParserAlloc((void*(*)(size_t))sqlite3MallocX);
1.66 + pEngine = sqlite3ParserAlloc((void*(*)(size_t))sqlite3_malloc);
1.67 if( pEngine==0 ){
1.68 + db->mallocFailed = 1;
1.69 return SQLITE_NOMEM;
1.70 }
1.71 assert( pParse->sLastToken.dyn==0 );
1.72 @@ -419,7 +412,7 @@
1.73 assert( pParse->nVarExprAlloc==0 );
1.74 assert( pParse->apVarExpr==0 );
1.75 pParse->zTail = pParse->zSql = zSql;
1.76 - while( !sqlite3MallocFailed() && zSql[i]!=0 ){
1.77 + while( !db->mallocFailed && zSql[i]!=0 ){
1.78 assert( i>=0 );
1.79 pParse->sLastToken.z = (u8*)&zSql[i];
1.80 assert( pParse->sLastToken.dyn==0 );
1.81 @@ -441,8 +434,8 @@
1.82 }
1.83 case TK_ILLEGAL: {
1.84 if( pzErrMsg ){
1.85 - sqliteFree(*pzErrMsg);
1.86 - *pzErrMsg = sqlite3MPrintf("unrecognized token: \"%T\"",
1.87 + sqlite3_free(*pzErrMsg);
1.88 + *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"",
1.89 &pParse->sLastToken);
1.90 }
1.91 nErr++;
1.92 @@ -470,8 +463,8 @@
1.93 }
1.94 sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
1.95 }
1.96 - sqlite3ParserFree(pEngine, sqlite3FreeX);
1.97 - if( sqlite3MallocFailed() ){
1.98 + sqlite3ParserFree(pEngine, sqlite3_free);
1.99 + if( db->mallocFailed ){
1.100 pParse->rc = SQLITE_NOMEM;
1.101 }
1.102 if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
1.103 @@ -481,7 +474,7 @@
1.104 if( pzErrMsg && *pzErrMsg==0 ){
1.105 *pzErrMsg = pParse->zErrMsg;
1.106 }else{
1.107 - sqliteFree(pParse->zErrMsg);
1.108 + sqlite3_free(pParse->zErrMsg);
1.109 }
1.110 pParse->zErrMsg = 0;
1.111 if( !nErr ) nErr++;
1.112 @@ -492,7 +485,7 @@
1.113 }
1.114 #ifndef SQLITE_OMIT_SHARED_CACHE
1.115 if( pParse->nested==0 ){
1.116 - sqliteFree(pParse->aTableLock);
1.117 + sqlite3_free(pParse->aTableLock);
1.118 pParse->aTableLock = 0;
1.119 pParse->nTableLock = 0;
1.120 }
1.121 @@ -507,7 +500,7 @@
1.122 }
1.123
1.124 sqlite3DeleteTrigger(pParse->pNewTrigger);
1.125 - sqliteFree(pParse->apVarExpr);
1.126 + sqlite3_free(pParse->apVarExpr);
1.127 if( nErr>0 && (pParse->rc==SQLITE_OK || pParse->rc==SQLITE_DONE) ){
1.128 pParse->rc = SQLITE_ERROR;
1.129 }