-C Code\ssimplifications\sand\ssize\sreductions.\s(CVS\s1983)
-D 2004-09-25T13:12:15
+C Code\scleanup:\sget\srid\sof\sthe\ssqlite3SetNString\sutility\sfunction.\s(CVS\s1984)
+D 2004-09-25T14:39:18
F Makefile.in abdeb5bd9d017822691884935c320037c33f6ee6
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/auth.c 65408baa7e6621520882478dfa1e6b8c1d6c1850
F src/btree.c 470e00b08688f065c2e62a6dcd3fb18880e8e309
F src/btree.h 94dfec0a1722d33359b23e7e310f2b64ffedf029
-F src/build.c c5ecf114af4ebc2963a03142b6bd6f2284ee35fc
+F src/build.c 86318bdcd291919d4f87700385fdb73146436531
F src/date.c eb8d5fa1a6d5cfc09031c8852d10ff742a94b15b
F src/delete.c d862b383a9abc0b79f4588783c2619fe52d74ea7
F src/expr.c f255c5c56c0371cb2955cbc2733621051e4f79f8
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
F src/insert.c 2c10c001f62cde92e9517ec7516b6584519754d1
F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
-F src/main.c 82a952ef3e5f7bacaa1b20060d0588f8767a6774
+F src/main.c b86dacaaa09eb614dec7051a8a006434a7bcaa06
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
F src/os_common.h cd7eb025fdab7dc91e0e97bf6310f1648205857f
F src/pager.c 705a61117f05d7dd031762408f9a279834e88c3a
F src/pager.h 67739fe649f33be55dba522ca8a9cc4e42d14f71
F src/parse.y 93edda0f1e9b25bee7cdfb5bf624ae85f8e9e5c9
-F src/pragma.c 5fb6647fda4c95edb08447a505e6c98c041e5b31
+F src/pragma.c 45978cc82fdf91f00d024a8e875c2b679fbce488
F src/printf.c 40770e1f553612d13dfc86d236086e69baa62fe1
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
-F src/select.c 97c5f11b2b456dc6113454e592dbf03dc46e2b9d
+F src/select.c 96b1489111abe9b584be2f2cce26ad6f2d425b4e
F src/shell.c 0856973c2b94e22664bc43f398ba3fc22d5e080c
F src/sqlite.h.in e29a526593b806f148017ed8bada760ada84cf2f
-F src/sqliteInt.h 581437ae245e5b8294bfc20c9a06a16bb6b3d281
-F src/table.c 8168c6e824009f8485bff79fc60ea8fea6829b10
+F src/sqliteInt.h 1259d965d61209d35e5fb3704ab5167a8a123a72
+F src/table.c 549f324e3239d3c3658e333e5e422bdcab81b9a0
F src/tclsqlite.c 0302e3f42f015d132d1291f3388c06e86c24a008
F src/test1.c 1305825c29575ee55a1c8b98a191669fd78b6287
F src/test2.c 0f3e0ad7b675a6f3323211ab4ea95490855654c3
F src/test3.c 5b5b0f3d11b097399c1054fff73d8f3711092301
F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df
F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1
-F src/tokenize.c 418ef7ba1149603a30dcf0057e04a3ea0e99edbe
+F src/tokenize.c 85a5b0de4635bc96ec9860274449448ff0d0726d
F src/trigger.c d1f770ee37a80391dd6d0948ee821b0272f99ae7
F src/update.c 7157084216c4b02a23cdb23eb6d246aa9034fa4d
F src/utf.c f4f83acd73389090e32d6589d307fc55d794c7ed
-F src/util.c f9b661a3b80a1469777771776a59a5f0e2f193fc
+F src/util.c 39a6718b221b5c575e09bb9069ec7c7fb539d5a5
F src/vacuum.c 257de36230cb988842f66eb08dc6c0250b8e05f3
F src/vdbe.c 0542852785220807feb02b9dee1150ac2e592c8d
F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
F src/vdbeInt.h 6017100adff362b8dfa37a69e3f1431f084bfa5b
F src/vdbeapi.c 81ab9e84c55f5762f552904e6e5d309269b02017
-F src/vdbeaux.c dc3848209aee05b32636a9c1dd913a56ef8dac79
+F src/vdbeaux.c 598af6c20124a205306475cd9dcee04317d0c622
F src/vdbemem.c ef9ac7d32acfe4bce5c5b408b1294c8d9e0cdb56
F src/where.c 04d3ee039d8e66c520e3b6bd5103dc3b8c3eb76b
F test/all.test 929bfa932b55e75c96fe2203f7650ba451c1862c
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P b2f3d4bb8e24212d3cef7615c24da13f29c1440c
-R 7b7549a8227df9a562548ecaa05d3fba
+P cb631a135da92fd689ee40a8b7e2695a510eb765
+R 0e57f8bf788b1fab54d791e8a0ff38cb
U drh
-Z e21d66c92b9e14b190cf7982b2d07af5
+Z 4e1f4e3ae25eddb22e2a4ce1e3a8ec1c
-cb631a135da92fd689ee40a8b7e2695a510eb765
\ No newline at end of file
+9ef4c24a9acc2128891303de1ffd2ef4509d779c
\ No newline at end of file
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.253 2004/09/15 13:38:11 drh Exp $
+** $Id: build.c,v 1.254 2004/09/25 14:39:18 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
pCol = &p->aCol[i];
pz = &pCol->zType;
n = pLast->n + Addr(pLast->z) - Addr(pFirst->z);
- sqlite3SetNString(pz, pFirst->z, n, (char*)0);
- z = *pz;
+ assert( pCol->zType==0 );
+ z = pCol->zType = sqlite3MPrintf("%.*s", n, pFirst->z);
if( z==0 ) return;
for(i=j=0; z[i]; i++){
int c = z[i];
void sqlite3AddDefaultValue(Parse *pParse, Token *pVal, int minusFlag){
Table *p;
int i;
- char **pz;
+ char *z;
if( (p = pParse->pNewTable)==0 ) return;
i = p->nCol-1;
if( i<0 ) return;
- pz = &p->aCol[i].zDflt;
- if( minusFlag ){
- sqlite3SetNString(pz, "-", 1, pVal->z, pVal->n, (char*)0);
- }else{
- sqlite3SetNString(pz, pVal->z, pVal->n, (char*)0);
- }
- sqlite3Dequote(*pz);
+ assert( p->aCol[i].zDflt==0 );
+ z = p->aCol[i].zDflt = sqlite3MPrintf("%s%T", minusFlag ? "-" : "", pVal);
+ sqlite3Dequote(z);
}
/*
}
}
if( pParse->nErr==0 ){
- sqlite3SetNString(&pParse->zErrMsg, "no such collation sequence: ",
- -1, z, n, (char*)0);
+ sqlite3ErrorMsg(pParse, "no such collation sequence: %.*s", n, z);
}
pParse->nErr++;
return SQLITE_ERROR;
u8 enc = pParse->db->enc;
u8 initbusy = pParse->db->init.busy;
CollSeq *pColl = sqlite3FindCollSeq(pParse->db, enc, zName, nName, initbusy);
+ if( nName<0 ) nName = strlen(zName);
if( !initbusy && (!pColl || !pColl->xCmp) ){
/* No collation sequence of this type for this encoding is registered.
** Call the collation factory to see if it can supply us with one.
/* If nothing has been found, write the error message into pParse */
if( !initbusy && (!pColl || !pColl->xCmp) ){
if( pParse->nErr==0 ){
- sqlite3SetNString(&pParse->zErrMsg, "no such collation sequence: ", -1,
- zName, nName, (char*)0);
+ sqlite3ErrorMsg(pParse, "no such collation sequence: %.*s", nName, zName);
}
- pParse->nErr++;
pColl = 0;
}
return pColl;
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.260 2004/09/15 13:38:11 drh Exp $
+** $Id: main.c,v 1.261 2004/09/25 14:39:18 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
** SQLite is a DLL. For some reason, it does not work to call free()
** directly.
**
-** Note that we need to call free() not sqliteFree() here, since every
-** string that is exported from SQLite should have already passed through
-** sqlite3StrRealloc().
+** Note that we need to call free() not sqliteFree() here.
*/
void sqlite3_free(char *p){ free(p); }
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.66 2004/09/17 20:25:25 drh Exp $
+** $Id: pragma.c,v 1.67 2004/09/25 14:39:19 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
zLeft = sqlite3NameFromToken(pId);
if( !zLeft ) return;
if( minusFlag ){
- zRight = 0;
- sqlite3SetNString(&zRight, "-", 1, pValue->z, pValue->n, (char*)0);
+ zRight = sqlite3MPrintf("-%T", pValue);
}else{
zRight = sqlite3NameFromToken(pValue);
}
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.210 2004/09/25 13:12:16 drh Exp $
+** $Id: select.c,v 1.211 2004/09/25 14:39:19 drh Exp $
*/
#include "sqliteInt.h"
(jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
(jointype & JT_ERROR)!=0
){
- static Token dummy = { 0, 0 };
- char *zSp1 = " ", *zSp2 = " ";
- if( pB==0 ){ pB = &dummy; zSp1 = 0; }
- if( pC==0 ){ pC = &dummy; zSp2 = 0; }
- sqlite3SetNString(&pParse->zErrMsg, "unknown or unsupported join type: ", 0,
- pA->z, pA->n, zSp1, 1, pB->z, pB->n, zSp2, 1, pC->z, pC->n, (char*)0);
- pParse->nErr++;
+ const char *zSp1 = " ";
+ const char *zSp2 = " ";
+ if( pB==0 ){ zSp1++; }
+ if( pC==0 ){ zSp2++; }
+ sqlite3ErrorMsg(pParse, "unknown or unsupported join type: "
+ "%T%s%T%s%T", pA, zSp1, pB, zSp2, pC);
jointype = JT_INNER;
}else if( jointype & JT_RIGHT ){
sqlite3ErrorMsg(pParse,
if( pOrderBy ){
pushOntoSorter(pParse, v, pOrderBy);
}else{
- char const *affStr;
char aff = (iParm>>16)&0xFF;
aff = sqlite3CompareAffinity(pEList->a[0].pExpr, aff);
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, &aff, 1);
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.323 2004/09/25 13:12:16 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.324 2004/09/25 14:39:19 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
# define sqliteRealloc(X,Y) sqlite3Realloc_(X,Y,__FILE__,__LINE__)
# define sqliteStrDup(X) sqlite3StrDup_(X,__FILE__,__LINE__)
# define sqliteStrNDup(X,Y) sqlite3StrNDup_(X,Y,__FILE__,__LINE__)
- void sqlite3StrRealloc(char**);
#else
# define sqliteFree sqlite3FreeX
# define sqliteMalloc sqlite3Malloc
# define sqliteMallocRaw sqlite3MallocRaw
# define sqliteRealloc sqlite3Realloc
-/* # define sqliteRealloc_(X,Y) sqlite3Realloc(X,Y) */
-# define sqlite3StrRealloc(X)
-# define sqliteStrDup sqlite3StrDup
-# define sqliteStrNDup sqlite3StrNDup
+# define sqliteStrDup sqlite3StrDup
+# define sqliteStrNDup sqlite3StrNDup
#endif
/*
void sqlite3DebugPrintf(const char*, ...);
void *sqlite3TextToPtr(const char*);
void sqlite3SetString(char **, const char *, ...);
-void sqlite3SetNString(char **, ...);
void sqlite3ErrorMsg(Parse*, const char*, ...);
void sqlite3Dequote(char*);
int sqlite3KeywordCode(const char*, int);
if( res.zErrMsg ){
if( pzErrMsg ){
free(*pzErrMsg);
- *pzErrMsg = res.zErrMsg;
- sqlite3StrRealloc(pzErrMsg);
- }else{
- sqliteFree(res.zErrMsg);
+ *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg);
}
+ sqliteFree(res.zErrMsg);
}
return res.rc;
}
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
-** $Id: tokenize.c,v 1.87 2004/09/08 15:09:41 drh Exp $
+** $Id: tokenize.c,v 1.88 2004/09/25 14:39:19 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
break;
}
case TK_ILLEGAL: {
- sqlite3SetNString(pzErrMsg, "unrecognized token: \"", -1,
- pParse->sLastToken.z, pParse->sLastToken.n, "\"", 1, (char*)0);
+ if( pzErrMsg ){
+ sqliteFree(*pzErrMsg);
+ *pzErrMsg = sqlite3MPrintf("unrecognized token: \"%T\"",
+ &pParse->sLastToken);
+ }
nErr++;
goto abort_parse;
}
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.117 2004/09/08 20:13:06 drh Exp $
+** $Id: util.c,v 1.118 2004/09/25 14:39:19 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
return p;
}
-/*
-** Make a duplicate of a string into memory obtained from malloc()
-** Free the original string using sqliteFree().
-**
-** This routine is called on all strings that are passed outside of
-** the SQLite library. That way clients can free the string using free()
-** rather than having to call sqliteFree().
-*/
-void sqlite3StrRealloc(char **pz){
- char *zNew;
- if( pz==0 || *pz==0 ) return;
- zNew = malloc( strlen(*pz) + 1 );
- if( zNew==0 ){
- sqlite3_malloc_failed++;
- sqliteFree(*pz);
- *pz = 0;
- }
- strcpy(zNew, *pz);
- sqliteFree(*pz);
- *pz = zNew;
-}
-
/*
** Make a copy of a string in memory obtained from sqliteMalloc()
*/
#endif
}
-/*
-** Works like sqlite3SetString, but each string is now followed by
-** a length integer which specifies how much of the source string
-** to copy (in bytes). -1 means use the whole string. The 1st
-** argument must either be NULL or point to memory obtained from
-** sqliteMalloc().
-*/
-void sqlite3SetNString(char **pz, ...){
- va_list ap;
- int nByte;
- const char *z;
- char *zResult;
- int n;
-
- if( pz==0 ) return;
- nByte = 0;
- va_start(ap, pz);
- while( (z = va_arg(ap, const char*))!=0 ){
- n = va_arg(ap, int);
- if( n<=0 ) n = strlen(z);
- nByte += n;
- }
- va_end(ap);
- sqliteFree(*pz);
- *pz = zResult = sqliteMallocRaw( nByte + 1 );
- if( zResult==0 ) return;
- va_start(ap, pz);
- while( (z = va_arg(ap, const char*))!=0 ){
- n = va_arg(ap, int);
- if( n<=0 ) n = strlen(z);
- memcpy(zResult, z, n);
- zResult += n;
- }
- *zResult = 0;
-#ifdef SQLITE_DEBUG
-#if SQLITE_DEBUG>1
- fprintf(stderr,"string at 0x%x is %s\n", (int)*pz, *pz);
-#endif
-#endif
- va_end(ap);
-}
-
/*
** Set the most recent error code and error string for the sqlite
** handle "db". The error code is set to "err_code".
pOp->p3 = (char*)zP3;
pOp->p3type = n;
}else{
- sqlite3SetNString(&pOp->p3, zP3, n, (char*)0);
+ if( n==0 ) n = strlen(zP3);
+ pOp->p3 = sqliteStrNDup(zP3, n);
pOp->p3type = P3_DYNAMIC;
}
}