From 998da3a287ef7ec59b52d7a1cc2246eb8e127fcb Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 19 Jun 2004 15:22:56 +0000 Subject: [PATCH] Fix problems with the WatCom C compiler: Arrays must contain at least one element. sqlite3FreeX declared properly. Don't allow run-time expression (the SQLITE_UTF16NATIVE macro) in an array initializer. (CVS 1640) FossilOrigin-Name: fbfc3c95a8abf25bb9e2b44cfeb7186c5b0591d7 --- main.mk | 1 + manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/pragma.c | 19 ++++++++++--------- src/sqliteInt.h | 4 ++-- src/vdbeInt.h | 20 +++++++++++++++----- src/vdbeapi.c | 11 ++++++----- 7 files changed, 45 insertions(+), 32 deletions(-) diff --git a/main.mk b/main.mk index 3a46292520..def74a45d9 100644 --- a/main.mk +++ b/main.mk @@ -119,6 +119,7 @@ TESTSRC = \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ + $(TOP)/src/pragma.c \ $(TOP)/src/printf.c \ $(TOP)/src/test1.c \ $(TOP)/src/test2.c \ diff --git a/manifest b/manifest index 08b7dffdb6..d5f5dab298 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sthe\ssqlite3VdbeCode()\sroutine.\s\sUse\ssqlite3NameFromToken()\smore\sto\nreduce\sthe\samount\sof\scode.\s(CVS\s1639) -D 2004-06-19T14:49:12 +C Fix\sproblems\swith\sthe\sWatCom\sC\scompiler:\s\sArrays\smust\scontain\sat\sleast\sone\nelement.\s\ssqlite3FreeX\sdeclared\sproperly.\s\sDon't\sallow\srun-time\sexpression\n(the\sSQLITE_UTF16NATIVE\smacro)\sin\san\sarray\sinitializer.\s(CVS\s1640) +D 2004-06-19T15:22:56 F Makefile.in d69d53c543518c1572ee0a8e8723d7e00bdb2266 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -17,7 +17,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826 -F main.mk 0a9048137bc0783acde5a9a032a44ec2510da576 +F main.mk bede7ee0070ad5b3519d084c1c678b4be145b0c1 F mkdll.sh 68d34a961a1fdfa15ef27fc4f4740be583112124 F publish.sh 5bc5e493fa1773a3c0d9712182de0f5abd494903 F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b @@ -51,13 +51,13 @@ F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c F src/pager.c d627c5e46084b0c757a16cec2c17adcc8046f8ee F src/pager.h bc58d32a9dee464f7268fb68652c130a4216e438 F src/parse.y 097438674976355a10cf177bd97326c548820b86 -F src/pragma.c 424d812d7411a83816f0d7c41170a5d6e13b3824 +F src/pragma.c 318a60581e8420f16e877e62b1dfabbb23c96177 F src/printf.c 823b6a5cbedb6971a9e62f5d83204fe9b0be7c1b F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c 9aa82bbc63983a304bc51d4a7c259e759f92c8dc F src/shell.c 24b641700c9d90f361fcfa4f432c5b4aff704e6d F src/sqlite.h.in c34414b9f5330f875e26a69fe685e38ca45f11b9 -F src/sqliteInt.h 6a34196b2fc203b738ed3596c5ffef1d0748cc95 +F src/sqliteInt.h b776ee9d096bcd90c0ebdca7ae827e7c89747120 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/tclsqlite.c ddef9b18271fb46344d3d35446bd7c001465a69a F src/test1.c ee426e026ad9223483e7a84bb68849fc6e9f542e @@ -73,8 +73,8 @@ F src/util.c 1b3743413e11cae51a899dc03fa9b829a3a1f160 F src/vacuum.c fcb930215a3f6c50087300782555f61ad11dd80c F src/vdbe.c 324ad6157f9bd0a770be70a4e7dca2cb0d27bd82 F src/vdbe.h 9ad64674c4c7acd6744174cab5d34013413ef0d3 -F src/vdbeInt.h 54af2e00301cde7573b86ea8a9b29a2152e762f7 -F src/vdbeapi.c 1601fb2d015fc88ce3dd6a6a50cf44b6419fdbbf +F src/vdbeInt.h e472de98c61e9e183402bfa00542e0abd26e825c +F src/vdbeapi.c 2163463b13468b2b8651fbf71a2b8548ea071e37 F src/vdbeaux.c cf9caac1163ea384e49b11cb0d405082eef8741d F src/vdbemem.c 9359c53386e070fea9f5403cab0c6f0cfe36496b F src/where.c 6507074d8ce3f78e7a4cd33f667f11e62020553e @@ -225,7 +225,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl af528563442e3039928f9018327a18157e53a44f F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 936e60d7b122079de23db301a55c6e8510c82e18 -R ed730593128daa92468fa18fd3a57762 +P 99d0436e0ee1c917b2b7bbf005f05288b535648a +R db0065ad2b92a7ca2b665309ece9eeec U drh -Z f5520e1d232faa01844b8961883e0286 +Z 991debb39d796778891cff3d4f612b44 diff --git a/manifest.uuid b/manifest.uuid index 58055be525..f287724ed1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99d0436e0ee1c917b2b7bbf005f05288b535648a \ No newline at end of file +fbfc3c95a8abf25bb9e2b44cfeb7186c5b0591d7 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 78fafbf12e..482a82679e 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.49 2004/06/19 14:49:12 drh Exp $ +** $Id: pragma.c,v 1.50 2004/06/19 15:22:56 drh Exp $ */ #include "sqliteInt.h" #include @@ -767,17 +767,18 @@ void sqlite3Pragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){ char *zName; u8 enc; } encnames[] = { - { "UTF-8", SQLITE_UTF8 }, - { "UTF-16le", SQLITE_UTF16LE }, - { "UTF-16be", SQLITE_UTF16BE }, - { "UTF-16", SQLITE_UTF16NATIVE }, - { "UTF8", SQLITE_UTF8 }, - { "UTF16le", SQLITE_UTF16LE }, - { "UTF16be", SQLITE_UTF16BE }, - { "UTF16", SQLITE_UTF16NATIVE }, + { "UTF-8", SQLITE_UTF8 }, + { "UTF8", SQLITE_UTF8 }, + { "UTF-16le", SQLITE_UTF16LE }, + { "UTF16le", SQLITE_UTF16LE }, + { "UTF-16be", SQLITE_UTF16BE }, + { "UTF16be", SQLITE_UTF16BE }, + { "UTF-16", 0 /* Filled in at run-time */ }, + { "UTF16", 0 /* Filled in at run-time */ }, { 0, 0 } }; struct EncName *pEnc; + encnames[6].enc = encnames[7].enc = SQLITE_UTF16NATIVE; if( pRight->z==pLeft->z ){ /* "PRAGMA encoding" */ if( SQLITE_OK!=sqlite3ReadSchema(pParse->db, &pParse->zErrMsg) ){ pParse->nErr++; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 18d91d2dbd..5848b074d4 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.293 2004/06/19 14:49:12 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.294 2004/06/19 15:22:56 drh Exp $ */ #include "config.h" #include "sqlite3.h" @@ -1221,7 +1221,6 @@ void sqlite3RealToSortable(double r, char *); char *sqlite3StrDup_(const char*,char*,int); char *sqlite3StrNDup_(const char*, int,char*,int); void sqlite3CheckMemory(void*,int); - void sqlite3FreeX(void *p); #else void *sqlite3Malloc(int); void *sqlite3MallocRaw(int); @@ -1231,6 +1230,7 @@ void sqlite3RealToSortable(double r, char *); char *sqlite3StrNDup(const char*, int); # define sqlite3CheckMemory(a,b) #endif +void sqlite3FreeX(void*); char *sqlite3MPrintf(const char*, ...); char *sqlite3VMPrintf(const char*, va_list); void sqlite3DebugPrintf(const char*, ...); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 1e770e48c9..bae5bba80f 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -181,13 +181,23 @@ struct Sorter { */ #define MEM_AggCtx 0x0400 /* Mem.z points to an agg function context */ + +/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains +** additional information about auxiliary information bound to arguments +** of the function. This is used to implement the sqlite3_get_auxdata() +** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data +** that can be associated with a constant argument to a function. This +** allows functions such as "regexp" to compile their constant regular +** expression argument once and reused the compiled code for multiple +** invocations. +*/ struct VdbeFunc { - FuncDef *pFunc; - int nAux; + FuncDef *pFunc; /* The definition of the function */ + int nAux; /* Number of entries allocated for apAux[] */ struct AuxData { - void *pAux; - void (*xDelete)(void *); - } apAux[0]; + void *pAux; /* Aux data for the i-th argument */ + void (*xDelete)(void *); /* Destructor for the aux data */ + } apAux[1]; /* One slot for each function argument */ }; typedef struct VdbeFunc VdbeFunc; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 7ca1e59970..6aee6b673d 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -236,11 +236,12 @@ void sqlite3_set_auxdata( if( iArg<0 ) return; if( !pCtx->pVdbeFunc || pCtx->pVdbeFunc->nAux<=iArg ){ - int nMalloc = sizeof(VdbeFunc)+sizeof(struct AuxData)*(iArg+1); - pCtx->pVdbeFunc = sqliteRealloc(pCtx->pVdbeFunc, nMalloc); - if( !pCtx->pVdbeFunc ) return; - pCtx->pVdbeFunc->nAux = iArg+1; - pCtx->pVdbeFunc->pFunc = pCtx->pFunc; + VdbeFunc *pVdbeFunc; + int nMalloc = sizeof(VdbeFunc)+sizeof(struct AuxData)*iArg; + pCtx->pVdbeFunc = pVdbeFunc = sqliteRealloc(pCtx->pVdbeFunc, nMalloc); + if( !pVdbeFunc ) return; + pVdbeFunc->nAux = iArg+1; + pVdbeFunc->pFunc = pCtx->pFunc; } pAuxData = &pCtx->pVdbeFunc->apAux[iArg];