1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Never use strlen(). Use our own internal sqlite3Strlen30() which is

guaranteed to never overflow an integer.  Additional explicit casts to
avoid nuisance warning messages. (CVS 6007)

FossilOrigin-Name: c872d554930ecf221ac2be5f886d5d67bb35288c
This commit is contained in:
drh
2008-12-10 19:26:22 +00:00
parent b27b7f5d3b
commit ea6788322e
35 changed files with 300 additions and 250 deletions

View File

@ -1,5 +1,5 @@
C More\sexplicit\stype\scasting\sto\ssilence\sVC++.\s(CVS\s6006)
D 2008-12-10T18:03:46
C Never\suse\sstrlen().\s\sUse\sour\sown\sinternal\ssqlite3Strlen30()\swhich\sis\nguaranteed\sto\snever\soverflow\san\sinteger.\s\sAdditional\sexplicit\scasts\sto\navoid\snuisance\swarning\smessages.\s(CVS\s6007)
D 2008-12-10T19:26:22
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -94,7 +94,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
F sqlite3.def a1be7b9a4b8b51ac41c6ff6e8e44a14ef66b338b
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
F src/alter.c 0a00c184052b7fd20271e783f65fec4efec6fe30
F src/alter.c 7eee66a6de2605a4aa6a85be6b4688b89e0f48ff
F src/analyze.c c86fd6a1425b22b3a46ce72ad403e4280026364f
F src/attach.c 1c35f95da3c62d19de75b44cfefd12c81c1791b3
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
@ -103,30 +103,30 @@ F src/btmutex.c 63c5cc4ad5715690767ffcb741e185d7bc35ec1a
F src/btree.c ba7baa987f9723882ef4655886327622e02a497f
F src/btree.h 179c3ea813780df78a289a8f5130db18e6d4616e
F src/btreeInt.h 7ef2c872371d7508657f8d7a4efe651c741d6ee6
F src/build.c 01919ad8f5d259b534e04896454e3ed5a344074f
F src/callback.c e970e5beddbdb23f89a6d05cb1a6419d9f755624
F src/build.c 64e9eb409ab39feb08919d28bf112fc3bf07d8e6
F src/callback.c 5538f3fb2507f6cc44623b06a87c861b1c0477bd
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 80b158ab6d14f07bc81df8415c5ab2c477947d42
F src/delete.c d60885716666e5ea0f177b8db73c22c67ccba2cb
F src/date.c 9a6156445442625e72f1ec06b1f392658240f6e6
F src/delete.c 1817205f833a084f66fa9c8e322ab46ba998e4c7
F src/expr.c ee295129a9efa0466ae4ebdb03adc33cd5c2e184
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
F src/func.c b4570eb73d873041b8e68f5cdbb4556ff13a94c3
F src/func.c 1246828c0d16ad4660c00b39ad83644ed2205e0c
F src/global.c 91723e45a2ad03ae5bb97a0a0d2dbb1a0e69527b
F src/hash.c 582c00618efe2051785e66ba1b6430d5a129de3f
F src/hash.c 831e9c199d8de5976c698e5aca278e2de74ff93b
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
F src/hwtime.h 4a1d45f4cae1f402ea19686acf24acf4f0cb53cb
F src/insert.c 665a0e747044b39e87ed42989e9514ac9e16accd
F src/insert.c c34dab7d450cf6612859f7c66d48ec6d4aa409fd
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
F src/legacy.c 4f7410b29598d991628ca40b150aa089649f17d8
F src/loadext.c 2f53996c693a347edc2d773e9217dde49d96ae64
F src/main.c 12b674019503ad90649cd8e6295425ef3078ce12
F src/malloc.c 89c7c58fbec06b80101fdc6dcdf9ee849b7cd7ac
F src/malloc.c 6a5b91159f87238392f190b02b5fba09fe526984
F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c
F src/mem1.c bb8e26adde7d463270e961f045802c61dbabc8f1
F src/mem2.c 7029ff791a248a634b1cad2c92f8cda100e09c16
F src/mem2.c 4c53c0071d3c68b8f252fe85d1667bad59421396
F src/mem3.c 67153ec933e08b70714055e872efb58a6b287939
F src/mem5.c 838309b521c96a2a34507f74a5a739d28de4aac6
F src/memjournal.c bd536c4d6d701b4fa7428545128c5684d2adf779
F src/memjournal.c f9fbded1b4ead4378a4f751fa3ae2bc429f72976
F src/mutex.c e9cb5fbe94afb4328869afaf3ac49bd1327559eb
F src/mutex.h 9e686e83a88838dac8b9c51271c651e833060f1e
F src/mutex_noop.c f5a07671f25a1a9bd7c10ad7107bc2585446200f
@ -136,30 +136,30 @@ F src/mutex_w32.c ee9cf003a330e2a9d80feefbd2c49899d5d43d6d
F src/os.c ed93a6b46132a602c4fd7a58142e2981c829c79d
F src/os.h 4ee25a35c00e75a569cecb5080be299b0c3e208e
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c 36196e71292a44bf2d393413cd8c86199694b8b4
F src/os_unix.c cec838fe55eaa53f1ff02ecb311cdd2188c4db95
F src/os_win.c 79e55bbe2177c4824d24d365b1274703c710f504
F src/pager.c e72e92d44365d75563d26957e6ba4a2ec0796da5
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
F src/os_unix.c 970e4a98a2d026cbeb2464694e4d13e079102b2f
F src/os_win.c af9459fcd0ba1852c75c0844ec82781e6767d909
F src/pager.c 64269ef14e57c545f8a9588eba15fface4265166
F src/pager.h 37f5173612b7803f44656c16e80df3280234bb18
F src/parse.y 3dfd941533cdc6ce0b09b905b25c4eb73858400b
F src/pcache.c 16dc8da6e6ba6250f8dfd9ee46036db1cbceedc6
F src/pcache.h f20c3e82dd6da622c3fe296170cb1801f9a2d75a
F src/pcache1.c 533b18aa2456b0f135e376289443e0a342e0c456
F src/pragma.c 88050d5afa74fcae1bb260311fe05918f04bc8a5
F src/prepare.c 26808c3d6ad2cd85a67969b14fd77bfbe92aaffb
F src/printf.c b42e767ee0546587a831a5c0a1d7e8b8d80cbb40
F src/random.c 67bf41b20f1983a0e481e7abb98d64704ee26884
F src/resolve.c 83d668f2d622e2639f520fff00e129925bdc9d3b
F src/pragma.c ad7c6eef96b599c6d0e9b2ae9a1a6a3e66108211
F src/prepare.c 51d11eb1eece7548038e7e33c33ee95dc7f82e2d
F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f
F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
F src/resolve.c 18dc9f0df1d60048e012ce6632251063e0dd356a
F src/rowset.c 2256fa4a928f750e2f3d6fc733523034beceb1d6
F src/select.c ea915ff233f1d7136ceaee1443d676ade95d4a08
F src/shell.c 484bddeefac9314be18d4a60d401e93848274ee8
F src/select.c 49296e1abf019b965f04a6dc5ff9fafa3ae46396
F src/shell.c 793aaebd8024896c58ded47414fe688fb8b1ef6d
F src/sqlite.h.in 619a82b485fbf02276ecb8b1cc629f0c8bcda4ca
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h e61d837e04b03c75bf860f06cbb327224e320fba
F src/sqliteInt.h d34967323d5e1351a3b719c4121aed6bc3c9f520
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c caf335a98a1093a5e8e79557d17053755f9aa474
F src/tclsqlite.c 96049bd454f1547abff0a57c45f0dfa57701e076
F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8
F src/tclsqlite.c 63fcca6796db7dc0a5f65da953cf548cdc559c72
F src/test1.c 30986773b10d75904f21bae5c3e8e8b9f20fa479
F src/test2.c 897528183edf2839c2a3c991d415905db56f1240
F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14
@ -189,21 +189,21 @@ F src/test_tclvar.c 9e42fa59d3d2f064b7ab8628e7ab2dc8a9fe93d4
F src/test_thread.c d74fc445e0dba0e00806117eb449b307c0b146bf
F src/test_wsd.c c297d7d6b8a990239e1bd25935e81d612d8ae31d
F src/tokenize.c aaa5fa6a4536a9dd7c855a3f66f32508f1612138
F src/trigger.c 9244c483e5256982e6f32d6f430af6ec10344980
F src/trigger.c 5a669d8fc9197db393ff85fa95ec882282162bb5
F src/update.c 3e022c24e265b0975e51f2ec0348ef84eeaba311
F src/utf.c 515ce4f1e039635197e7f0df46cf8a7ac659a571
F src/utf.c 7bc90bc7d1a0239f876e2c2ce573e9b103aedcd4
F src/util.c 6e997af379d3aa609bf084d7d10fdc1cf32cc72c
F src/vacuum.c 383d6297bddc011ab04a9eed110db6eaf523e8e9
F src/vdbe.c b99af9ad1764b34831ce7e91975d1a7acf6121a7
F src/vdbe.c 0244413f3dae1ee63479f541ec2e950b05c65112
F src/vdbe.h 03516f28bf5aca00a53c4dccd6c313f96adb94f6
F src/vdbeInt.h e6e80a99ce634983b7cc2498843b4d2e5540900a
F src/vdbeapi.c 85c33cfbfa56249cbe627831610afafba754477d
F src/vdbeaux.c 2b7bfb736a9ad9f48b82149a47c8f430e5df730a
F src/vdbeaux.c 5356c9bbac2fb0cb75b816de1d5963b26547f656
F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
F src/vdbemem.c 598741bc060400643b6110a3fe24891333df3d07
F src/vtab.c 09df27d47ed9fef31ad94c79053fac02d5d2073a
F src/vdbemem.c f9c859ac17e2e05a0f249868ce4f191f69edd31d
F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
F src/where.c c5a21be6d5705d1c2c6f5d56a97785e4752791d2
F src/where.c 7c6ab881411110fd8cf2735205532e15475d3349
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@ -664,7 +664,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P e7e9fa4fa1b7fc0668f4e3a51873ee5d11893f42
R 3fdd485d39b8ec78e53f9d12f6f15e2c
P 14e6d19c3157ccdce170e769d678c7f472dd3db2
R 540b254104078d68363402828d97892e
U drh
Z 0329544b446f709fe3cdc363492e43f9
Z 8a01ff0a84aab7060e0a3bce21036dfb

View File

@ -1 +1 @@
14e6d19c3157ccdce170e769d678c7f472dd3db2
c872d554930ecf221ac2be5f886d5d67bb35288c

View File

@ -12,7 +12,7 @@
** This file contains C code routines that used to generate VDBE code
** that implements the ALTER TABLE command.
**
** $Id: alter.c,v 1.50 2008/11/19 09:05:27 danielk1977 Exp $
** $Id: alter.c,v 1.51 2008/12/10 19:26:22 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -305,7 +305,9 @@ void sqlite3AlterRenameTable(
/* Make sure it is not a system table being altered, or a reserved name
** that the table is being renamed to.
*/
if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){
if( sqlite3Strlen30(pTab->zName)>6
&& 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
){
sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
goto exit_rename_table;
}

View File

@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.505 2008/12/10 17:20:00 drh Exp $
** $Id: build.c,v 1.506 2008/12/10 19:26:22 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -369,7 +369,8 @@ static void sqliteDeleteIndex(Index *p){
Index *pOld;
const char *zName = p->zName;
pOld = sqlite3HashInsert(&p->pSchema->idxHash, zName, strlen(zName)+1, 0);
pOld = sqlite3HashInsert(&p->pSchema->idxHash, zName,
sqlite3Strlen30(zName)+1, 0);
assert( pOld==0 || pOld==p );
freeIndex(p);
}
@ -534,7 +535,7 @@ void sqlite3DeleteTable(Table *pTable){
for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){
pNextFKey = pFKey->pNextFrom;
assert( sqlite3HashFind(&pTable->pSchema->aFKey,
pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey );
pFKey->zTo, sqlite3Strlen30(pFKey->zTo)+1)!=pFKey );
sqlite3DbFree(db, pFKey);
}
#endif
@ -565,11 +566,12 @@ void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){
assert( iDb>=0 && iDb<db->nDb );
assert( zTabName && zTabName[0] );
pDb = &db->aDb[iDb];
p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, strlen(zTabName)+1,0);
p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
sqlite3Strlen30(zTabName)+1,0);
if( p ){
#ifndef SQLITE_OMIT_FOREIGN_KEY
for(pF1=p->pFKey; pF1; pF1=pF1->pNextFrom){
int nTo = strlen(pF1->zTo) + 1;
int nTo = sqlite3Strlen30(pF1->zTo) + 1;
pF2 = sqlite3HashFind(&pDb->pSchema->aFKey, pF1->zTo, nTo);
if( pF2==pF1 ){
sqlite3HashInsert(&pDb->pSchema->aFKey, pF1->zTo, nTo, pF1->pNextTo);
@ -632,9 +634,9 @@ int sqlite3FindDb(sqlite3 *db, Token *pName){
zName = sqlite3NameFromToken(db, pName);
if( zName ){
n = strlen(zName);
n = sqlite3Strlen30(zName);
for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){
if( (!OMIT_TEMPDB || i!=1 ) && n==strlen(pDb->zName) &&
if( (!OMIT_TEMPDB || i!=1 ) && n==sqlite3Strlen30(pDb->zName) &&
0==sqlite3StrICmp(pDb->zName, zName) ){
break;
}
@ -1365,7 +1367,7 @@ static char *createTableStmt(sqlite3 *db, Table *p, int isTemp){
n += identLength(pCol->zName);
z = pCol->zType;
if( z ){
n += (strlen(z) + 1);
n += (sqlite3Strlen30(z) + 1);
}
}
n += identLength(p->zName);
@ -1386,19 +1388,19 @@ static char *createTableStmt(sqlite3 *db, Table *p, int isTemp){
}
sqlite3_snprintf(n, zStmt,
!OMIT_TEMPDB&&isTemp ? "CREATE TEMP TABLE ":"CREATE TABLE ");
k = strlen(zStmt);
k = sqlite3Strlen30(zStmt);
identPut(zStmt, &k, p->zName);
zStmt[k++] = '(';
for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
sqlite3_snprintf(n-k, &zStmt[k], zSep);
k += strlen(&zStmt[k]);
k += sqlite3Strlen30(&zStmt[k]);
zSep = zSep2;
identPut(zStmt, &k, pCol->zName);
if( (z = pCol->zType)!=0 ){
zStmt[k++] = ' ';
assert( (int)(strlen(z)+k+1)<=n );
assert( (int)(sqlite3Strlen30(z)+k+1)<=n );
sqlite3_snprintf(n-k, &zStmt[k], "%s", z);
k += strlen(z);
k += sqlite3Strlen30(z);
}
}
sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
@ -1606,7 +1608,8 @@ void sqlite3EndTable(
Table *pOld;
FKey *pFKey;
Schema *pSchema = p->pSchema;
pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, strlen(p->zName)+1,p);
pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName,
sqlite3Strlen30(p->zName)+1,p);
if( pOld ){
assert( p==pOld ); /* Malloc must have failed inside HashInsert() */
db->mallocFailed = 1;
@ -1615,7 +1618,7 @@ void sqlite3EndTable(
#ifndef SQLITE_OMIT_FOREIGN_KEY
for(pFKey=p->pFKey; pFKey; pFKey=pFKey->pNextFrom){
void *data;
int nTo = strlen(pFKey->zTo) + 1;
int nTo = sqlite3Strlen30(pFKey->zTo) + 1;
pFKey->pNextTo = sqlite3HashFind(&pSchema->aFKey, pFKey->zTo, nTo);
data = sqlite3HashInsert(&pSchema->aFKey, pFKey->zTo, nTo, pFKey);
if( data==(void *)pFKey ){
@ -2172,7 +2175,7 @@ void sqlite3CreateForeignKey(
nByte = sizeof(*pFKey) + nCol*sizeof(pFKey->aCol[0]) + pTo->n + 1;
if( pToCol ){
for(i=0; i<pToCol->nExpr; i++){
nByte += strlen(pToCol->a[i].zName) + 1;
nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1;
}
}
pFKey = sqlite3DbMallocZero(db, nByte );
@ -2211,7 +2214,7 @@ void sqlite3CreateForeignKey(
}
if( pToCol ){
for(i=0; i<nCol; i++){
int n = strlen(pToCol->a[i].zName);
int n = sqlite3Strlen30(pToCol->a[i].zName);
pFKey->aCol[i].zCol = z;
memcpy(z, pToCol->a[i].zName, n);
z[n] = 0;
@ -2497,7 +2500,7 @@ void sqlite3CreateIndex(
*/
if( pList==0 ){
nullId.z = (u8*)pTab->aCol[pTab->nCol-1].zName;
nullId.n = strlen((char*)nullId.z);
nullId.n = sqlite3Strlen30((char*)nullId.z);
pList = sqlite3ExprListAppend(pParse, 0, 0, &nullId);
if( pList==0 ) goto exit_create_index;
pList->a[0].sortOrder = sortOrder;
@ -2510,14 +2513,14 @@ void sqlite3CreateIndex(
Expr *pExpr;
CollSeq *pColl;
if( (pExpr = pList->a[i].pExpr)!=0 && (pColl = pExpr->pColl)!=0 ){
nExtra += (1 + strlen(pColl->zName));
nExtra += (1 + sqlite3Strlen30(pColl->zName));
}
}
/*
** Allocate the index structure.
*/
nName = strlen(zName);
nName = sqlite3Strlen30(zName);
nCol = pList->nExpr;
pIndex = sqlite3DbMallocZero(db,
sizeof(Index) + /* Index structure */
@ -2581,7 +2584,7 @@ void sqlite3CreateIndex(
assert( pListItem->pExpr->pColl );
zColl = zExtra;
sqlite3_snprintf(nExtra, zExtra, "%s", pListItem->pExpr->pColl->zName);
zExtra += (strlen(zColl) + 1);
zExtra += (sqlite3Strlen30(zColl) + 1);
}else{
zColl = pTab->aCol[j].zColl;
if( !zColl ){
@ -2654,7 +2657,8 @@ void sqlite3CreateIndex(
if( db->init.busy ){
Index *p;
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
pIndex->zName, strlen(pIndex->zName)+1, pIndex);
pIndex->zName, sqlite3Strlen30(pIndex->zName)+1,
pIndex);
if( p ){
assert( p==pIndex ); /* Malloc must have failed */
db->mallocFailed = 1;

View File

@ -13,7 +13,7 @@
** This file contains functions used to access the internal hash tables
** of user defined functions and collation sequences.
**
** $Id: callback.c,v 1.32 2008/10/10 17:41:29 drh Exp $
** $Id: callback.c,v 1.33 2008/12/10 19:26:22 drh Exp $
*/
#include "sqliteInt.h"
@ -56,7 +56,7 @@ static void callCollNeeded(sqlite3 *db, const char *zName, int nName){
static int synthCollSeq(sqlite3 *db, CollSeq *pColl){
CollSeq *pColl2;
char *z = pColl->zName;
int n = strlen(z);
int n = sqlite3Strlen30(z);
int i;
static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };
for(i=0; i<3; i++){
@ -287,7 +287,7 @@ void sqlite3FuncDefInsert(
FuncDef *pDef /* The function definition to insert */
){
FuncDef *pOther;
int nName = strlen(pDef->zName);
int nName = sqlite3Strlen30(pDef->zName);
u8 c1 = (u8)pDef->zName[0];
int h = (sqlite3UpperToLower[c1] + nName) % ArraySize(pHash->a);
pOther = functionSearch(pHash, h, pDef->zName, nName);

View File

@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: date.c,v 1.95 2008/12/09 04:59:00 shane Exp $
** $Id: date.c,v 1.96 2008/12/10 19:26:22 drh Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
@ -657,7 +657,7 @@ static int parseModifier(const char *zMod, DateTime *p){
}
z += n;
while( isspace(*(u8*)z) ) z++;
n = (int)strlen(z);
n = sqlite3Strlen30(z);
if( n>10 || n<3 ) break;
if( z[n-1]=='s' ){ z[n-1] = 0; n--; }
computeJD(p);
@ -912,7 +912,7 @@ static void strftimeFunc(
double s = x.s;
if( s>59.999 ) s = 59.999;
sqlite3_snprintf(7, &z[j],"%06.3f", s);
j += strlen(&z[j]);
j += sqlite3Strlen30(&z[j]);
break;
}
case 'H': sqlite3_snprintf(3, &z[j],"%02d",x.h); j+=2; break;
@ -938,7 +938,7 @@ static void strftimeFunc(
}
case 'J': {
sqlite3_snprintf(20, &z[j],"%.16g",x.iJD/86400000.0);
j+=strlen(&z[j]);
j+=sqlite3Strlen30(&z[j]);
break;
}
case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
@ -946,12 +946,18 @@ static void strftimeFunc(
case 's': {
sqlite3_snprintf(30,&z[j],"%d",
(int)(x.iJD/1000.0 - 210866760000.0));
j += strlen(&z[j]);
j += sqlite3Strlen30(&z[j]);
break;
}
case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
case 'w': z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; break;
case 'Y': sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=strlen(&z[j]);break;
case 'w': {
z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0';
break;
}
case 'Y': {
sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=sqlite3Strlen30(&z[j]);
break;
}
default: z[j++] = '%'; break;
}
}

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements.
**
** $Id: delete.c,v 1.188 2008/12/04 20:40:10 drh Exp $
** $Id: delete.c,v 1.189 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -106,7 +106,7 @@ void sqlite3MaterializeView(
pWhere = sqlite3ExprDup(db, pWhere);
viewName.z = (u8*)pView->zName;
viewName.n = (unsigned int)strlen((const char*)viewName.z);
viewName.n = (unsigned int)sqlite3Strlen30((const char*)viewName.z);
pFrom = sqlite3SrcListAppendFromTerm(pParse, 0, 0, 0, &viewName, pDup, 0,0);
pDup = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);
}

View File

@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.206 2008/11/19 16:52:44 danielk1977 Exp $
** $Id: func.c,v 1.207 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -1253,7 +1253,8 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
*/
static void setLikeOptFlag(sqlite3 *db, const char *zName, int flagVal){
FuncDef *pDef;
pDef = sqlite3FindFunction(db, zName, strlen(zName), 2, SQLITE_UTF8, 0);
pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName),
2, SQLITE_UTF8, 0);
if( pDef ){
pDef->flags = flagVal;
}

View File

@ -12,7 +12,7 @@
** This is the implementation of generic hash-tables
** used in SQLite.
**
** $Id: hash.c,v 1.31 2008/10/10 17:41:29 drh Exp $
** $Id: hash.c,v 1.32 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <assert.h>
@ -63,7 +63,7 @@ void sqlite3HashClear(Hash *pH){
static int strHash(const void *pKey, int nKey){
const char *z = (const char *)pKey;
int h = 0;
if( nKey<=0 ) nKey = strlen(z);
if( nKey<=0 ) nKey = sqlite3Strlen30(z);
while( nKey > 0 ){
h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];
nKey--;

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
** $Id: insert.c,v 1.254 2008/12/10 17:20:00 drh Exp $
** $Id: insert.c,v 1.255 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -1272,10 +1272,10 @@ void sqlite3GenerateConstraintChecks(
char zErrMsg[200];
sqlite3_snprintf(ArraySize(zErrMsg), zErrMsg,
pIdx->nColumn>1 ? "columns " : "column ");
n1 = strlen(zErrMsg);
n1 = sqlite3Strlen30(zErrMsg);
for(j=0; j<pIdx->nColumn && n1<ArraySize(zErrMsg)-30; j++){
char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
n2 = strlen(zCol);
n2 = sqlite3Strlen30(zCol);
if( j>0 ){
sqlite3_snprintf(ArraySize(zErrMsg)-n1, &zErrMsg[n1], ", ");
n1 += 2;

View File

@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: legacy.c,v 1.29 2008/08/02 03:50:39 drh Exp $
** $Id: legacy.c,v 1.30 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -131,7 +131,7 @@ exec_out:
rc = sqlite3ApiExit(db, rc);
if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){
int nErrMsg = 1 + strlen(sqlite3_errmsg(db));
int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));
*pzErrMsg = sqlite3Malloc(nErrMsg);
if( *pzErrMsg ){
memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);

View File

@ -12,7 +12,7 @@
**
** Memory allocation functions used throughout sqlite.
**
** $Id: malloc.c,v 1.49 2008/12/05 15:24:17 drh Exp $
** $Id: malloc.c,v 1.50 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -724,7 +724,7 @@ char *sqlite3DbStrDup(sqlite3 *db, const char *z){
if( z==0 ){
return 0;
}
n = strlen(z)+1;
n = (db ? sqlite3Strlen(db, z) : sqlite3Strlen30(z))+1;
assert( (n&0x7fffffff)==n );
zNew = sqlite3DbMallocRaw(db, (int)n);
if( zNew ){

View File

@ -19,7 +19,7 @@
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
** $Id: mem2.c,v 1.41 2008/12/05 17:17:08 drh Exp $
** $Id: mem2.c,v 1.42 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -363,7 +363,7 @@ void sqlite3MemdebugBacktraceCallback(void (*xBacktrace)(int, int, void **)){
** Set the title string for subsequent allocations.
*/
void sqlite3MemdebugSettitle(const char *zTitle){
unsigned int n = strlen(zTitle) + 1;
unsigned int n = sqlite3Strlen30(zTitle) + 1;
sqlite3_mutex_enter(mem.mutex);
if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;
memcpy(mem.zTitle, zTitle, n);

View File

@ -14,7 +14,7 @@
** The in-memory rollback journal is used to journal transactions for
** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
**
** @(#) $Id: memjournal.c,v 1.5 2008/11/19 16:52:44 danielk1977 Exp $
** @(#) $Id: memjournal.c,v 1.6 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -99,7 +99,7 @@ static int memjrnlRead(
zOut += nCopy;
nRead -= iSpace;
iChunkOffset = 0;
} while( nRead>=0 && (pChunk=pChunk->pNext) && nRead>0 );
} while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
p->readpoint.iOffset = iOfst+iAmt;
p->readpoint.pChunk = pChunk;

View File

@ -12,7 +12,7 @@
**
** This file contains code that is specific to OS/2.
**
** $Id: os_os2.c,v 1.62 2008/11/26 20:03:21 pweilbacher Exp $
** $Id: os_os2.c,v 1.63 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -694,7 +694,7 @@ static int getTempname(int nBuf, char *zBuf ){
/* Strip off a trailing slashes or backslashes, otherwise we would get *
* multiple (back)slashes which causes DosOpen() to fail. *
* Trailing spaces are not allowed, either. */
j = strlen(zTempPath);
j = sqlite3Strlen30(zTempPath);
while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/'
|| zTempPath[j-1] == ' ' ) ){
j--;
@ -709,7 +709,7 @@ static int getTempname(int nBuf, char *zBuf ){
sqlite3_snprintf( nBuf-30, zBuf,
"%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath );
}
j = strlen( zBuf );
j = sqlite3Strlen30( zBuf );
sqlite3_randomness( 20, &zBuf[j] );
for( i = 0; i < 20; i++, j++ ){
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];

View File

@ -43,7 +43,7 @@
** * Definitions of sqlite3_vfs objects for all locking methods
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
**
** $Id: os_unix.c,v 1.230 2008/12/08 18:19:18 drh Exp $
** $Id: os_unix.c,v 1.231 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_UNIX /* This file is used on unix only */
@ -483,7 +483,7 @@ static struct vxworksFileId *vxworksFindFileId(const char *zAbsoluteName){
int n; /* Length of zAbsoluteName string */
assert( zAbsoluteName[0]=='/' );
n = strlen(zAbsoluteName);
n = (int)strlen(zAbsoluteName);
pNew = sqlite3_malloc( sizeof(*pNew) + (n+1) );
if( pNew==0 ) return 0;
pNew->zCanonicalName = (char*)&pNew[1];
@ -3307,7 +3307,7 @@ static int fillInUnixFile(
*/
char *zLockFile;
int nFilename;
nFilename = strlen(zFilename) + 6;
nFilename = (int)strlen(zFilename) + 6;
zLockFile = (char *)sqlite3_malloc(nFilename);
if( zLockFile==0 ){
rc = SQLITE_NOMEM;
@ -3375,7 +3375,7 @@ static int openDirectory(const char *zFilename, int *pFd){
char zDirname[MAX_PATHNAME+1];
sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename);
for(ii=strlen(zDirname); ii>=0 && zDirname[ii]!='/'; ii--);
for(ii=(int)strlen(zDirname); ii>=0 && zDirname[ii]!='/'; ii--);
if( ii>0 ){
zDirname[ii] = '\0';
fd = open(zDirname, O_RDONLY|O_BINARY, 0);
@ -3441,7 +3441,7 @@ static int getTempname(int nBuf, char *zBuf){
do{
sqlite3_snprintf(nBuf-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
j = strlen(zBuf);
j = (int)strlen(zBuf);
sqlite3_randomness(15, &zBuf[j]);
for(i=0; i<15; i++, j++){
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
@ -3743,7 +3743,7 @@ static int unixFullPathname(
if( getcwd(zOut, nOut-1)==0 ){
return SQLITE_CANTOPEN;
}
nCwd = strlen(zOut);
nCwd = (int)strlen(zOut);
sqlite3_snprintf(nOut-nCwd, &zOut[nCwd], "/%s", zPath);
}
return SQLITE_OK;
@ -4280,7 +4280,7 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
}
/* transform the db path to a unique cache name */
dbLen = strlen(dbPath);
dbLen = (int)strlen(dbPath);
for( i=0; i<dbLen && (i+len+7)<maxLen; i++){
char c = dbPath[i];
lPath[i+len] = (c=='/')?'_':c;
@ -4516,7 +4516,7 @@ static int proxyReleaseConch(unixFile *pFile){
*/
static int proxyCreateConchPathname(char *dbPath, char **pConchPath){
int i; /* Loop counter */
int len = strlen(dbPath); /* Length of database filename - dbPath */
int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
char *conchPath; /* buffer in which to construct conch name */
/* Allocate space for the conch filename and initialize the name to
@ -4542,7 +4542,7 @@ static int proxyCreateConchPathname(char *dbPath, char **pConchPath){
/* append the "-conch" suffix to the file */
memcpy(&conchPath[i+1], "-conch", 7);
assert( strlen(conchPath) == len+7 );
assert( (int)strlen(conchPath) == len+7 );
return SQLITE_OK;
}
@ -4592,7 +4592,7 @@ static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){
if( pFile->pMethod == &afpIoMethods ){
/* afp style keeps a reference to the db path in the filePath field
** of the struct */
assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN );
assert( (int)strlen((char*)pFile->lockingContext)<=MAXPATHLEN );
strcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath);
}else
#endif

View File

@ -12,7 +12,7 @@
**
** This file contains code that is specific to windows.
**
** $Id: os_win.c,v 1.141 2008/12/08 18:19:18 drh Exp $
** $Id: os_win.c,v 1.142 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#if SQLITE_OS_WIN /* This file is used for windows only */
@ -685,7 +685,7 @@ static int winWrite(
LONG upperBits = (offset>>32) & 0x7fffffff;
LONG lowerBits = offset & 0xffffffff;
DWORD rc;
DWORD wrote;
DWORD wrote = 0;
winFile *pFile = (winFile*)id;
assert( id!=0 );
SimulateIOError(return SQLITE_IOERR_WRITE);
@ -1149,11 +1149,11 @@ static int getTempname(int nBuf, char *zBuf){
}
#endif
}
for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
zTempPath[i] = 0;
sqlite3_snprintf(nBuf-30, zBuf,
"%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
j = strlen(zBuf);
j = sqlite3Strlen30(zBuf);
sqlite3_randomness(20, &zBuf[j]);
for(i=0; i<20; i++, j++){
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
@ -1350,7 +1350,7 @@ static int winDelete(
){
int cnt = 0;
DWORD rc;
DWORD error;
DWORD error = 0;
void *zConverted = convertUtf8Filename(zFilename);
if( zConverted==0 ){
return SQLITE_NOMEM;
@ -1393,7 +1393,7 @@ static int winAccess(
int *pResOut /* OUT: Result */
){
DWORD attr;
int rc;
int rc = 0;
void *zConverted = convertUtf8Filename(zFilename);
if( zConverted==0 ){
return SQLITE_NOMEM;

View File

@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.511 2008/12/10 16:45:51 drh Exp $
** @(#) $Id: pager.c,v 1.512 2008/12/10 19:26:24 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@ -815,7 +815,7 @@ static int writeMasterJournal(Pager *pPager, const char *zMaster){
if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ) return SQLITE_OK;
pPager->setMaster = 1;
len = strlen(zMaster);
len = sqlite3Strlen30(zMaster);
for(i=0; i<len; i++){
cksum += zMaster[i];
}
@ -1287,7 +1287,7 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){
goto delmaster_out;
}
}
zJournal += (strlen(zJournal)+1);
zJournal += (sqlite3Strlen30(zJournal)+1);
}
}
@ -1795,7 +1795,7 @@ int sqlite3PagerOpen(
sqlite3_free(zPathname);
return rc;
}
nPathname = strlen(zPathname);
nPathname = sqlite3Strlen30(zPathname);
}
/* Allocate memory for the pager structure */
@ -1903,7 +1903,8 @@ int sqlite3PagerOpen(
/* Fill in Pager.zDirectory[] */
memcpy(pPager->zDirectory, pPager->zFilename, nPathname+1);
for(i=strlen(pPager->zDirectory); i>0 && pPager->zDirectory[i-1]!='/'; i--){}
for(i=sqlite3Strlen30(pPager->zDirectory);
i>0 && pPager->zDirectory[i-1]!='/'; i--){}
if( i>0 ) pPager->zDirectory[i-1] = 0;
/* Fill in Pager.zJournal[] */
@ -2504,8 +2505,8 @@ static int pagerStress(void *p, PgHdr *pPg){
static int hasHotJournal(Pager *pPager, int *pExists){
sqlite3_vfs *pVfs = pPager->pVfs;
int rc = SQLITE_OK;
int exists;
int locked;
int exists = 0;
int locked = 0;
assert( pPager!=0 );
assert( pPager->useJournal );
assert( pPager->fd->pMethods );

View File

@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
** $Id: pragma.c,v 1.196 2008/12/10 17:20:01 drh Exp $
** $Id: pragma.c,v 1.197 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -40,7 +40,7 @@ static int getSafetyLevel(const char *z){
if( isdigit(*z) ){
return atoi(z);
}
n = strlen(z);
n = sqlite3Strlen30(z);
for(i=0; i<ArraySize(iLength); i++){
if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){
return iValue[i];
@ -464,7 +464,7 @@ void sqlite3Pragma(
if( zRight==0 ){
eMode = PAGER_JOURNALMODE_QUERY;
}else{
int n = strlen(zRight);
int n = sqlite3Strlen30(zRight);
eMode = sizeof(azModeName)/sizeof(azModeName[0]) - 1;
while( eMode>=0 && sqlite3StrNICmp(zRight, azModeName[eMode], n)!=0 ){
eMode--;
@ -1345,7 +1345,7 @@ void sqlite3Pragma(
#if SQLITE_HAS_CODEC
if( sqlite3StrICmp(zLeft, "key")==0 ){
sqlite3_key(db, zRight, strlen(zRight));
sqlite3_key(db, zRight, sqlite3Strlen30(zRight));
}else
#endif
#if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD)

View File

@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.102 2008/12/10 17:20:01 drh Exp $
** $Id: prepare.c,v 1.103 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -295,7 +295,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
** file_format==3 Version 3.1.4. // ditto but with non-NULL defaults
** file_format==4 Version 3.3.0. // DESC indices. Boolean constants
*/
pDb->pSchema->file_format = meta[1];
pDb->pSchema->file_format = (u8)meta[1];
if( pDb->pSchema->file_format==0 ){
pDb->pSchema->file_format = 1;
}
@ -623,7 +623,7 @@ static int sqlite3Prepare(
}
if( saveSqlFlag ){
sqlite3VdbeSetSql(sParse.pVdbe, zSql, sParse.zTail - zSql);
sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail - zSql));
}
if( rc!=SQLITE_OK || db->mallocFailed ){
sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe);
@ -766,7 +766,7 @@ static int sqlite3Prepare16(
** characters between zSql8 and zTail8, and then returning a pointer
** the same number of characters into the UTF-16 string.
*/
int chars_parsed = sqlite3Utf8CharLen(zSql8, zTail8-zSql8);
int chars_parsed = sqlite3Utf8CharLen(zSql8, (int)(zTail8-zSql8));
*pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);
}
sqlite3DbFree(db, zSql8);

View File

@ -5,7 +5,7 @@
** an historical reference. Most of the "enhancements" have been backed
** out so that the functionality is now the same as standard printf().
**
** $Id: printf.c,v 1.98 2008/12/10 18:03:46 drh Exp $
** $Id: printf.c,v 1.99 2008/12/10 19:26:24 drh Exp $
**
**************************************************************************
**
@ -156,7 +156,7 @@ static const et_info fmtinfo[] = {
** 16 (the number of significant digits in a 64-bit float) '0' is
** always returned.
*/
static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
int digit;
LONGDOUBLE_TYPE d;
if( (*cnt)++ >= 16 ) return '0';
@ -164,7 +164,7 @@ static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
d = digit;
digit += '0';
*val = (*val - d)*10.0;
return digit;
return (char)digit;
}
#endif /* SQLITE_OMIT_FLOATING_POINT */
@ -413,7 +413,7 @@ void sqlite3VXPrintf(
bufpt = &buf[etBUFSIZE-1];
if( xtype==etORDINAL ){
static const char zOrd[] = "thstndrd";
int x = longvalue % 10;
int x = (int)(longvalue % 10);
if( x>=4 || (longvalue/10)%10==1 ){
x = 0;
}
@ -431,7 +431,7 @@ void sqlite3VXPrintf(
longvalue = longvalue/base;
}while( longvalue>0 );
}
length = &buf[etBUFSIZE-1]-bufpt;
length = (int)(&buf[etBUFSIZE-1]-bufpt);
for(idx=precision-length; idx>0; idx--){
*(--bufpt) = '0'; /* Zero pad */
}
@ -442,7 +442,7 @@ void sqlite3VXPrintf(
pre = &aPrefix[infop->prefix];
for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;
}
length = &buf[etBUFSIZE-1]-bufpt;
length = (int)(&buf[etBUFSIZE-1]-bufpt);
break;
case etFLOAT:
case etEXP:
@ -470,7 +470,7 @@ void sqlite3VXPrintf(
if( xtype==etFLOAT ) realvalue += rounder;
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
exp = 0;
if( sqlite3IsNaN(realvalue) ){
if( sqlite3IsNaN((double)realvalue) ){
bufpt = "NaN";
length = 3;
break;
@ -489,7 +489,7 @@ void sqlite3VXPrintf(
}else{
bufpt = "Inf";
}
length = strlen(bufpt);
length = sqlite3Strlen30(bufpt);
break;
}
}
@ -520,7 +520,7 @@ void sqlite3VXPrintf(
e2 = exp;
}
nsd = 0;
flag_dp = (precision>0) | flag_alternateform | flag_altform2;
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
/* The sign in front of the number */
if( prefix ){
*(bufpt++) = prefix;
@ -568,18 +568,18 @@ void sqlite3VXPrintf(
*(bufpt++) = '+';
}
if( exp>=100 ){
*(bufpt++) = (exp/100)+'0'; /* 100's digit */
*(bufpt++) = (char)((exp/100)+'0'); /* 100's digit */
exp %= 100;
}
*(bufpt++) = exp/10+'0'; /* 10's digit */
*(bufpt++) = exp%10+'0'; /* 1's digit */
*(bufpt++) = (char)(exp/10+'0'); /* 10's digit */
*(bufpt++) = (char)(exp%10+'0'); /* 1's digit */
}
*bufpt = 0;
/* The converted number is in buf[] and zero terminated. Output it.
** Note that the number is in the usual order, not reversed as with
** integer conversions. */
length = bufpt-buf;
length = (int)(bufpt-buf);
bufpt = buf;
/* Special case: Add leading zeros if the flag_zeropad flag is
@ -606,9 +606,10 @@ void sqlite3VXPrintf(
length = 1;
break;
case etCHARX:
c = buf[0] = va_arg(ap,int);
c = va_arg(ap,int);
buf[0] = (char)c;
if( precision>=0 ){
for(idx=1; idx<precision; idx++) buf[idx] = c;
for(idx=1; idx<precision; idx++) buf[idx] = (char)c;
length = precision;
}else{
length =1;
@ -626,14 +627,15 @@ void sqlite3VXPrintf(
if( precision>=0 ){
for(length=0; length<precision && bufpt[length]; length++){}
}else{
length = strlen(bufpt);
length = sqlite3Strlen30(bufpt);
}
break;
case etSQLESCAPE:
case etSQLESCAPE2:
case etSQLESCAPE3: {
int i, j, n, ch, isnull;
int i, j, n, isnull;
int needQuote;
char ch;
char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote character */
char *escarg = va_arg(ap,char*);
isnull = escarg==0;
@ -723,7 +725,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
return;
}
if( N<0 ){
N = strlen(z);
N = sqlite3Strlen30(z);
}
if( N==0 || z==0 ){
return;
@ -744,7 +746,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
p->tooBig = 1;
return;
}else{
p->nAlloc = szNew;
p->nAlloc = (int)szNew;
}
zNew = sqlite3DbMallocRaw(p->db, p->nAlloc );
if( zNew ){

View File

@ -15,7 +15,7 @@
** Random numbers are used by some of the database backends in order
** to generate random integer keys for tables or random filenames.
**
** $Id: random.c,v 1.28 2008/12/08 18:19:18 drh Exp $
** $Id: random.c,v 1.29 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -45,7 +45,7 @@ static SQLITE_WSD struct sqlite3PrngType {
** (Later): Actually, OP_NewRowid does not depend on a good source of
** randomness any more. But we will leave this code in all the same.
*/
static int randomByte(void){
static u8 randomByte(void){
unsigned char t;
@ -79,7 +79,7 @@ static int randomByte(void){
wsdPrng.i = 0;
sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);
for(i=0; i<256; i++){
wsdPrng.s[i] = i;
wsdPrng.s[i] = (u8)i;
}
for(i=0; i<256; i++){
wsdPrng.j += wsdPrng.s[i] + k[i];

View File

@ -14,7 +14,7 @@
** resolve all identifiers by associating them with a particular
** table and column.
**
** $Id: resolve.c,v 1.14 2008/12/10 18:03:46 drh Exp $
** $Id: resolve.c,v 1.15 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@ -69,7 +69,7 @@ static void resolveAlias(
pDup = sqlite3PExpr(pParse, TK_AS, pDup, 0, 0);
if( pDup==0 ) return;
if( pEList->a[iCol].iAlias==0 ){
pEList->a[iCol].iAlias = ++pParse->nAlias;
pEList->a[iCol].iAlias = (u16)(++pParse->nAlias);
}
pDup->iTable = pEList->a[iCol].iAlias;
}
@ -483,7 +483,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int nId; /* Number of characters in function name */
const char *zId; /* The function name. */
FuncDef *pDef; /* Information about the function */
int enc = ENC(pParse->db); /* The database encoding */
u8 enc = ENC(pParse->db); /* The database encoding */
zId = (char*)pExpr->token.z;
nId = pExpr->token.n;
@ -756,7 +756,7 @@ static int resolveCompoundOrderBy(
pE->pColl = pColl;
pE->flags |= EP_IntValue | flags;
pE->iTable = iCol;
pItem->iCol = iCol;
pItem->iCol = (u16)iCol;
pItem->done = 1;
}else{
moreToDo = 1;
@ -860,7 +860,7 @@ static int resolveOrderGroupBy(
** a copy of the iCol-th result-set column. The subsequent call to
** sqlite3ResolveOrderGroupBy() will convert the expression to a
** copy of the iCol-th result-set expression. */
pItem->iCol = iCol;
pItem->iCol = (u16)iCol;
continue;
}
if( sqlite3ExprIsInteger(pE, &iCol) ){
@ -871,7 +871,7 @@ static int resolveOrderGroupBy(
resolveOutOfRangeError(pParse, zType, i+1, nResult);
return 1;
}
pItem->iCol = iCol;
pItem->iCol = (u16)iCol;
continue;
}

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.492 2008/12/10 18:03:46 drh Exp $
** $Id: select.c,v 1.493 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -37,7 +37,7 @@ static void clearSelect(sqlite3 *db, Select *p){
** Initialize a SelectDest structure.
*/
void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
pDest->eDest = eDest;
pDest->eDest = (u8)eDest;
pDest->iParm = iParm;
pDest->affinity = 0;
pDest->iMem = 0;
@ -191,7 +191,7 @@ static int columnIndex(Table *pTab, const char *zCol){
*/
static void setToken(Token *p, const char *z){
p->z = (u8*)z;
p->n = z ? strlen(z) : 0;
p->n = z ? sqlite3Strlen30(z) : 0;
p->dyn = 0;
}
@ -220,13 +220,13 @@ static void setQuotedToken(Parse *pParse, Token *p, const char *z){
/* String contains " characters - copy and quote the string. */
p->z = (u8 *)sqlite3MPrintf(pParse->db, "\"%w\"", z);
if( p->z ){
p->n = strlen((char *)p->z);
p->n = sqlite3Strlen30((char *)p->z);
p->dyn = 1;
}
}else{
/* String contains no " characters - copy the pointer. */
p->z = (u8*)z;
p->n = (z2 - z);
p->n = (int)(z2 - z);
p->dyn = 0;
}
}
@ -756,7 +756,7 @@ static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){
pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );
if( pInfo ){
pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];
pInfo->nField = nExpr;
pInfo->nField = (u16)nExpr;
pInfo->enc = ENC(db);
pInfo->db = db;
for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){
@ -1195,7 +1195,7 @@ static int selectColumnsFromExprList(
/* Make sure the column name is unique. If the name is not unique,
** append a integer to the name so that it becomes unique.
*/
nName = strlen(zName);
nName = sqlite3Strlen30(zName);
for(j=cnt=0; j<i; j++){
if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
char *zNewName;
@ -1538,7 +1538,7 @@ static int multiSelect(
case TK_EXCEPT:
case TK_UNION: {
int unionTab; /* Cursor number of the temporary table holding result */
int op = 0; /* One of the SRT_ operations to apply to self */
u8 op = 0; /* One of the SRT_ operations to apply to self */
int priorOp; /* The SRT_ operation to apply to prior selects */
Expr *pLimit, *pOffset; /* Saved values of p->nLimit and p->nOffset */
int addr;
@ -1733,7 +1733,7 @@ static int multiSelect(
}
pKeyInfo->enc = ENC(db);
pKeyInfo->nField = nCol;
pKeyInfo->nField = (u16)nCol;
for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){
*apColl = multiSelectCollSeq(pParse, p, i);
@ -2091,7 +2091,7 @@ static int multiSelectOrderBy(
pNew->flags |= EP_IntValue;
pNew->iTable = i;
pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew, 0);
pOrderBy->a[nOrderBy++].iCol = i;
pOrderBy->a[nOrderBy++].iCol = (u16)i;
}
}
}
@ -2114,7 +2114,7 @@ static int multiSelectOrderBy(
sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));
if( pKeyMerge ){
pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];
pKeyMerge->nField = nOrderBy;
pKeyMerge->nField = (u16)nOrderBy;
pKeyMerge->enc = ENC(db);
for(i=0; i<nOrderBy; i++){
CollSeq *pColl;
@ -2154,7 +2154,7 @@ static int multiSelectOrderBy(
sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );
if( pKeyDup ){
pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];
pKeyDup->nField = nExpr;
pKeyDup->nField = (u16)nExpr;
pKeyDup->enc = ENC(db);
for(i=0; i<nExpr; i++){
pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);
@ -2786,7 +2786,7 @@ static int flattenSubquery(
*/
for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){
int nSubSrc;
int jointype = 0;
u8 jointype = 0;
pSubSrc = pSub->pSrc; /* FROM clause of subquery */
nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */
pSrc = pParent->pSrc; /* FROM clause of the outer query */
@ -3430,7 +3430,7 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
}
sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
(void*)pF->pFunc, P4_FUNCDEF);
sqlite3VdbeChangeP5(v, nArg);
sqlite3VdbeChangeP5(v, (u8)nArg);
sqlite3ReleaseTempRange(pParse, regAgg, nArg);
sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
if( addrNext ){
@ -4014,7 +4014,7 @@ int sqlite3Select(
if( flag ){
pDel = pMinMax = sqlite3ExprListDup(db, p->pEList->a[0].pExpr->pList);
if( pMinMax && !db->mallocFailed ){
pMinMax->a[0].sortOrder = flag!=WHERE_ORDERBY_MIN;
pMinMax->a[0].sortOrder = flag!=WHERE_ORDERBY_MIN ?1:0;
pMinMax->a[0].pExpr->op = TK_COLUMN;
}
}

View File

@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.191 2008/12/08 18:27:31 drh Exp $
** $Id: shell.c,v 1.192 2008/12/10 19:26:24 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
@ -362,6 +362,16 @@ static const char *modeDescr[] = {
*/
#define ArraySize(X) (int)(sizeof(X)/sizeof(X[0]))
/*
** Compute a string length that is limited to what can be stored in
** lower 30 bits of a 32-bit signed integer.
*/
int sqlite3Strlen30(const char *z){
const char *z2 = z;
while( *z2 ){ z2++; }
return 0x3fffffff & (int)(z2 - z);
}
/*
** Output the given string as a quoted string using SQL quoting conventions.
*/
@ -477,7 +487,7 @@ static void output_csv(struct callback_data *p, const char *z, int bSep){
fprintf(out,"%s",p->nullvalue);
}else{
int i;
int nSep = strlen(p->separator);
int nSep = sqlite3Strlen30(p->separator);
for(i=0; z[i]; i++){
if( needCsvQuote[((unsigned char*)z)[i]]
|| (z[i]==p->separator[0] &&
@ -525,7 +535,7 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
int w = 5;
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
int len = strlen(azCol[i] ? azCol[i] : "");
int len = sqlite3Strlen30(azCol[i] ? azCol[i] : "");
if( len>w ) w = len;
}
if( p->cnt++>0 ) fprintf(p->out,"\n");
@ -546,9 +556,9 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
w = 0;
}
if( w<=0 ){
w = strlen(azCol[i] ? azCol[i] : "");
w = sqlite3Strlen30(azCol[i] ? azCol[i] : "");
if( w<10 ) w = 10;
n = strlen(azArg && azArg[i] ? azArg[i] : p->nullvalue);
n = sqlite3Strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
if( w<n ) w = n;
}
if( i<ArraySize(p->actualWidth) ){
@ -580,8 +590,9 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
}else{
w = 10;
}
if( p->mode==MODE_Explain && azArg[i] && strlen(azArg[i])>(unsigned)w ){
w = strlen(azArg[i]);
if( p->mode==MODE_Explain && azArg[i] &&
sqlite3Strlen30(azArg[i])>w ){
w = sqlite3Strlen30(azArg[i]);
}
fprintf(p->out,"%-*.*s%s",w,w,
azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
@ -728,8 +739,8 @@ static void set_table_name(struct callback_data *p, const char *zName){
static char *appendText(char *zIn, char const *zAppend, char quote){
int len;
int i;
int nAppend = strlen(zAppend);
int nIn = (zIn?strlen(zIn):0);
int nAppend = sqlite3Strlen30(zAppend);
int nIn = (zIn?sqlite3Strlen30(zIn):0);
len = nAppend+nIn+1;
if( quote ){
@ -896,7 +907,7 @@ static int run_schema_dump_query(
rc = sqlite3_exec(p->db, zQuery, dump_callback, p, pzErrMsg);
if( rc==SQLITE_CORRUPT ){
char *zQ2;
int len = strlen(zQuery);
int len = sqlite3Strlen30(zQuery);
if( pzErrMsg ) sqlite3_free(*pzErrMsg);
zQ2 = malloc( len+100 );
if( zQ2==0 ) return rc;
@ -1070,7 +1081,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
/* Process the input line.
*/
if( nArg==0 ) return rc;
n = strlen(azArg[0]);
n = sqlite3Strlen30(azArg[0]);
c = azArg[0][0];
if( c=='b' && n>1 && strncmp(azArg[0], "bail", n)==0 && nArg>1 ){
bail_on_error = booleanValue(azArg[1]);
@ -1208,14 +1219,14 @@ static int do_meta_command(char *zLine, struct callback_data *p){
int lineno = 0; /* Line number of input file */
open_db(p);
nSep = strlen(p->separator);
nSep = sqlite3Strlen30(p->separator);
if( nSep==0 ){
fprintf(stderr, "non-null separator required for import\n");
return 0;
}
zSql = sqlite3_mprintf("SELECT * FROM '%q'", zTable);
if( zSql==0 ) return 0;
nByte = strlen(zSql);
nByte = sqlite3Strlen30(zSql);
rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ){
@ -1230,7 +1241,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
zSql = malloc( nByte + 20 + nCol*2 );
if( zSql==0 ) return 0;
sqlite3_snprintf(nByte+20, zSql, "INSERT INTO '%q' VALUES(?", zTable);
j = strlen(zSql);
j = sqlite3Strlen30(zSql);
for(i=1; i<nCol; i++){
zSql[j++] = ',';
zSql[j++] = '?';
@ -1363,7 +1374,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
#endif
if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){
int n2 = strlen(azArg[1]);
int n2 = sqlite3Strlen30(azArg[1]);
if( strncmp(azArg[1],"line",n2)==0
||
strncmp(azArg[1],"lines",n2)==0 ){
@ -1521,7 +1532,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
output_c_string(p->out, p->nullvalue);
fprintf(p->out, "\n");
fprintf(p->out,"%9.9s: %s\n","output",
strlen(p->outfile) ? p->outfile : "stdout");
sqlite3Strlen30(p->outfile) ? p->outfile : "stdout");
fprintf(p->out,"%9.9s: ", "separator");
output_c_string(p->out, p->separator);
fprintf(p->out, "\n");
@ -1570,7 +1581,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
int nPrintCol, nPrintRow;
for(i=1; i<=nRow; i++){
if( azResult[i]==0 ) continue;
len = strlen(azResult[i]);
len = sqlite3Strlen30(azResult[i]);
if( len>maxlen ) maxlen = len;
}
nPrintCol = 80/(maxlen+2);
@ -1717,7 +1728,7 @@ static int process_input(struct callback_data *p, FILE *in){
int i;
for(i=0; zLine[i] && isspace((unsigned char)zLine[i]); i++){}
if( zLine[i]!=0 ){
nSql = strlen(zLine);
nSql = sqlite3Strlen30(zLine);
zSql = malloc( nSql+1 );
if( zSql==0 ){
fprintf(stderr, "out of memory\n");
@ -1727,7 +1738,7 @@ static int process_input(struct callback_data *p, FILE *in){
startline = lineno;
}
}else{
int len = strlen(zLine);
int len = sqlite3Strlen30(zLine);
zSql = realloc( zSql, nSql + len + 2 );
if( zSql==0 ){
fprintf(stderr,"%s: out of memory!\n", Argv0);
@ -1814,7 +1825,7 @@ static char *find_home_dir(void){
zDrive = getenv("HOMEDRIVE");
zPath = getenv("HOMEPATH");
if( zDrive && zPath ){
n = strlen(zDrive) + strlen(zPath) + 1;
n = sqlite3Strlen30(zDrive) + sqlite3Strlen30(zPath) + 1;
home_dir = malloc( n );
if( home_dir==0 ) return 0;
sqlite3_snprintf(n, home_dir, "%s%s", zDrive, zPath);
@ -1827,7 +1838,7 @@ static char *find_home_dir(void){
#endif /* !_WIN32_WCE */
if( home_dir ){
int n = strlen(home_dir) + 1;
int n = sqlite3Strlen30(home_dir) + 1;
char *z = malloc( n );
if( z ) memcpy(z, home_dir, n);
home_dir = z;
@ -1858,7 +1869,7 @@ static void process_sqliterc(
#endif
return;
}
nBuf = strlen(home_dir) + 16;
nBuf = sqlite3Strlen30(home_dir) + 16;
zBuf = malloc( nBuf );
if( zBuf==0 ){
fprintf(stderr,"%s: out of memory!\n", Argv0);
@ -2081,9 +2092,12 @@ int main(int argc, char **argv){
sqlite3_libversion()
);
zHome = find_home_dir();
if( zHome && (zHistory = malloc(nHistory = strlen(zHome)+20))!=0 ){
if( zHome ){
nHistory = sqlite3Strlen30(zHome) + 20;
if( (zHistory = malloc(nHistory))!=0 ){
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
}
}
#if defined(HAVE_READLINE) && HAVE_READLINE==1
if( zHistory ) read_history(zHistory);
#endif

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.807 2008/12/09 13:04:29 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.808 2008/12/10 19:26:24 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -2064,6 +2064,7 @@ int sqlite3StrICmp(const char *, const char *);
int sqlite3StrNICmp(const char *, const char *, int);
int sqlite3IsNumber(const char*, int*, u8);
int sqlite3Strlen(sqlite3*, const char*);
int sqlite3Strlen30(const char*);
int sqlite3MallocInit(void);
void sqlite3MallocEnd(void);

View File

@ -16,7 +16,7 @@
** These routines are in a separate files so that they will not be linked
** if they are not used.
**
** $Id: table.c,v 1.37 2008/12/09 03:55:14 drh Exp $
** $Id: table.c,v 1.38 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
@ -92,7 +92,7 @@ static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
if( argv[i]==0 ){
z = 0;
}else{
int n = (int)strlen(argv[i])+1;
int n = sqlite3Strlen30(argv[i])+1;
z = sqlite3_malloc( n );
if( z==0 ) goto malloc_failed;
memcpy(z, argv[i], n);

View File

@ -12,7 +12,7 @@
** A TCL Interface to SQLite. Append this file to sqlite3.c and
** compile the whole thing to build a TCL-enabled version of SQLite.
**
** $Id: tclsqlite.c,v 1.228 2008/10/09 14:45:26 drh Exp $
** $Id: tclsqlite.c,v 1.229 2008/12/10 19:26:24 drh Exp $
*/
#include "tcl.h"
#include <errno.h>
@ -129,6 +129,19 @@ struct IncrblobChannel {
IncrblobChannel *pPrev; /* Linked list of all open incrblob channels */
};
#ifndef SQLITE_AMALGAMATION
/*
** Compute a string length that is limited to what can be stored in
** lower 30 bits of a 32-bit signed integer.
*/
int sqlite3Strlen30(const char *z){
const char *z2 = z;
while( *z2 ){ z2++; }
return 0x3fffffff & (int)(z2 - z);
}
#endif
#ifndef SQLITE_OMIT_INCRBLOB
/*
** Close all incrblob channels opened using database connection pDb.
@ -384,7 +397,7 @@ static int safeToUseEvalObjv(Tcl_Interp *interp, Tcl_Obj *pCmd){
static SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){
SqlFunc *p, *pNew;
int i;
pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + strlen(zName) + 1 );
pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + sqlite3Strlen30(zName) + 1 );
pNew->zName = (char*)&pNew[1];
for(i=0; zName[i]; i++){ pNew->zName[i] = tolower(zName[i]); }
pNew->zName[i] = 0;
@ -1339,8 +1352,8 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zConflict = Tcl_GetStringFromObj(objv[2], 0);
zTable = Tcl_GetStringFromObj(objv[3], 0);
zFile = Tcl_GetStringFromObj(objv[4], 0);
nSep = strlen(zSep);
nNull = strlen(zNull);
nSep = sqlite3Strlen30(zSep);
nNull = sqlite3Strlen30(zNull);
if( nSep==0 ){
Tcl_AppendResult(interp,"Error: non-null separator required for copy",0);
return TCL_ERROR;
@ -1360,7 +1373,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
Tcl_AppendResult(interp, "Error: no such table: ", zTable, 0);
return TCL_ERROR;
}
nByte = strlen(zSql);
nByte = sqlite3Strlen30(zSql);
rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ){
@ -1380,7 +1393,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
}
sqlite3_snprintf(nByte+50, zSql, "INSERT OR %q INTO '%q' VALUES(?",
zConflict, zTable);
j = strlen(zSql);
j = sqlite3Strlen30(zSql);
for(i=1; i<nCol; i++){
zSql[j++] = ',';
zSql[j++] = '?';
@ -1425,7 +1438,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
}
if( i+1!=nCol ){
char *zErr;
int nErr = strlen(zFile) + 200;
int nErr = sqlite3Strlen30(zFile) + 200;
zErr = malloc(nErr);
if( zErr ){
sqlite3_snprintf(nErr, zErr,
@ -1439,7 +1452,9 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
}
for(i=0; i<nCol; i++){
/* check for null data, if so, bind as null */
if ((nNull>0 && strcmp(azCol[i], zNull)==0) || strlen(azCol[i])==0) {
if( (nNull>0 && strcmp(azCol[i], zNull)==0)
|| sqlite3Strlen30(azCol[i])==0
){
sqlite3_bind_null(pStmt, i+1);
}else{
sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC);
@ -1580,7 +1595,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
** which matches the next sequence of SQL.
*/
pStmt = 0;
len = strlen(zSql);
len = sqlite3Strlen30(zSql);
for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){
int n = pPreStmt->nSql;
if( len>=n
@ -1833,7 +1848,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
pPreStmt->pStmt = pStmt;
pPreStmt->nSql = len;
pPreStmt->zSql = sqlite3_sql(pStmt);
assert( strlen(pPreStmt->zSql)==len );
assert( sqlite3Strlen30(pPreStmt->zSql)==len );
assert( 0==memcmp(pPreStmt->zSql, zSql, len) );
}
@ -1894,7 +1909,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
int nArg = -1;
if( objc==6 ){
const char *z = Tcl_GetString(objv[3]);
int n = strlen(z);
int n = sqlite3Strlen30(z);
if( n>2 && strncmp(z, "-argcount",n)==0 ){
if( Tcl_GetIntFromObj(interp, objv[4], &nArg) ) return TCL_ERROR;
if( nArg<0 ){

View File

@ -10,7 +10,7 @@
*************************************************************************
**
**
** $Id: trigger.c,v 1.131 2008/12/09 03:55:14 drh Exp $
** $Id: trigger.c,v 1.132 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -119,7 +119,7 @@ void sqlite3BeginTrigger(
goto trigger_cleanup;
}
if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),
zName, (int)strlen(zName)) ){
zName, sqlite3Strlen30(zName)) ){
if( !noErr ){
sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);
}
@ -256,13 +256,13 @@ void sqlite3FinishTrigger(
Table *pTab;
Trigger *pDel;
pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash,
pTrig->name, (int)strlen(pTrig->name), pTrig);
pTrig->name, sqlite3Strlen30(pTrig->name), pTrig);
if( pDel ){
assert( pDel==pTrig );
db->mallocFailed = 1;
goto triggerfinish_cleanup;
}
n = (int)strlen(pTrig->table) + 1;
n = sqlite3Strlen30(pTrig->table) + 1;
pTab = sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n);
assert( pTab!=0 );
pTrig->pNext = pTab->pTrigger;
@ -465,7 +465,7 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){
assert( pName->nSrc==1 );
zDb = pName->a[0].zDatabase;
zName = pName->a[0].zName;
nName = strlen(zName);
nName = sqlite3Strlen30(zName);
for(i=OMIT_TEMPDB; i<db->nDb; i++){
int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue;
@ -489,7 +489,7 @@ drop_trigger_cleanup:
** is set on.
*/
static Table *tableOfTrigger(Trigger *pTrigger){
int n = (int)strlen(pTrigger->table) + 1;
int n = sqlite3Strlen30(pTrigger->table) + 1;
return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n);
}
@ -554,7 +554,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
*/
void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){
Trigger *pTrigger;
int nName = (int)strlen(zName);
int nName = sqlite3Strlen30(zName);
pTrigger = sqlite3HashInsert(&(db->aDb[iDb].pSchema->trigHash),
zName, nName, 0);
if( pTrigger ){
@ -645,7 +645,7 @@ static SrcList *targetSrcList(
if( iDb==0 || iDb>=2 ){
assert( iDb<pParse->db->nDb );
sDb.z = (u8*)pParse->db->aDb[iDb].zName;
sDb.n = (int)strlen((char*)sDb.z);
sDb.n = sqlite3Strlen30((char*)sDb.z);
pSrc = sqlite3SrcListAppend(pParse->db, 0, &sDb, &pStep->target);
} else {
pSrc = sqlite3SrcListAppend(pParse->db, 0, &pStep->target, 0);

View File

@ -12,7 +12,7 @@
** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE.
**
** $Id: utf.c,v 1.68 2008/12/09 03:55:14 drh Exp $
** $Id: utf.c,v 1.69 2008/12/10 19:26:24 drh Exp $
**
** Notes on UTF-8:
**
@ -288,7 +288,7 @@ int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
WRITE_UTF16BE(z, c);
}
}
pMem->n = z - zOut;
pMem->n = (int)(z - zOut);
*z++ = 0;
}else{
assert( desiredEnc==SQLITE_UTF8 );
@ -407,7 +407,7 @@ int sqlite3Utf8CharLen(const char *zIn, int nByte){
int sqlite3Utf8To8(unsigned char *zIn){
unsigned char *zOut = zIn;
unsigned char *zStart = zIn;
unsigned char *zTerm = &zIn[strlen((char *)zIn)];
unsigned char *zTerm = &zIn[sqlite3Strlen30((char *)zIn)];
u32 c;
while( zIn[0] ){

View File

@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.794 2008/12/10 18:03:47 drh Exp $
** $Id: vdbe.c,v 1.795 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -370,12 +370,12 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
}
sqlite3_snprintf(100, zCsr, "%c", c);
zCsr += strlen(zCsr);
zCsr += sqlite3Strlen30(zCsr);
sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
zCsr += strlen(zCsr);
zCsr += sqlite3Strlen30(zCsr);
for(i=0; i<16 && i<pMem->n; i++){
sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
zCsr += strlen(zCsr);
zCsr += sqlite3Strlen30(zCsr);
}
for(i=0; i<16 && i<pMem->n; i++){
char z = pMem->z[i];
@ -384,10 +384,10 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
}
sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem->enc]);
zCsr += strlen(zCsr);
zCsr += sqlite3Strlen30(zCsr);
if( f & MEM_Zero ){
sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
zCsr += strlen(zCsr);
zCsr += sqlite3Strlen30(zCsr);
}
*zCsr = '\0';
}else if( f & MEM_Str ){
@ -407,7 +407,7 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
}
k = 2;
sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
k += strlen(&zBuf[k]);
k += sqlite3Strlen30(&zBuf[k]);
zBuf[k++] = '[';
for(j=0; j<15 && j<pMem->n; j++){
u8 c = pMem->z[j];
@ -419,7 +419,7 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
}
zBuf[k++] = ']';
sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);
k += strlen(&zBuf[k]);
k += sqlite3Strlen30(&zBuf[k]);
zBuf[k++] = 0;
}
}
@ -882,7 +882,7 @@ case OP_Real: { /* same as TK_FLOAT, out2-prerelease */
case OP_String8: { /* same as TK_STRING, out2-prerelease */
assert( pOp->p4.z!=0 );
pOp->opcode = OP_String;
pOp->p1 = strlen(pOp->p4.z);
pOp->p1 = sqlite3Strlen30(pOp->p4.z);
#ifndef SQLITE_OMIT_UTF16
if( encoding!=SQLITE_UTF8 ){

View File

@ -14,7 +14,7 @@
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.425 2008/12/10 17:20:01 drh Exp $
** $Id: vdbeaux.c,v 1.426 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -576,7 +576,7 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){
pOp->p4.p = (void*)zP4;
pOp->p4type = (signed char)n;
}else{
if( n==0 ) n = (int)strlen(zP4);
if( n==0 ) n = sqlite3Strlen30(zP4);
pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n);
pOp->p4type = P4_DYNAMIC;
}
@ -640,11 +640,11 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
int i, j;
KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;
sqlite3_snprintf(nTemp, zTemp, "keyinfo(%d", pKeyInfo->nField);
i = (int)strlen(zTemp);
i = sqlite3Strlen30(zTemp);
for(j=0; j<pKeyInfo->nField; j++){
CollSeq *pColl = pKeyInfo->aColl[j];
if( pColl ){
int n = (int)strlen(pColl->zName);
int n = sqlite3Strlen30(pColl->zName);
if( i+n>nTemp-6 ){
memcpy(&zTemp[i],",...",4);
break;
@ -878,7 +878,7 @@ int sqlite3VdbeList(
pMem->flags = MEM_Static|MEM_Str|MEM_Term;
pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
assert( pMem->z!=0 );
pMem->n = (int)strlen(pMem->z);
pMem->n = sqlite3Strlen30(pMem->z);
pMem->type = SQLITE_TEXT;
pMem->enc = SQLITE_UTF8;
pMem++;
@ -911,7 +911,7 @@ int sqlite3VdbeList(
sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0);
}else{
assert( pMem->z!=0 );
pMem->n = (int)strlen(pMem->z);
pMem->n = sqlite3Strlen30(pMem->z);
pMem->enc = SQLITE_UTF8;
}
pMem->type = SQLITE_TEXT;
@ -933,7 +933,7 @@ int sqlite3VdbeList(
if( pOp->zComment ){
pMem->flags = MEM_Str|MEM_Term;
pMem->z = pOp->zComment;
pMem->n = (int)strlen(pMem->z);
pMem->n = sqlite3Strlen30(pMem->z);
pMem->enc = SQLITE_UTF8;
pMem->type = SQLITE_TEXT;
}else
@ -1293,7 +1293,9 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
** that case we do not support atomic multi-file commits, so use the
** simple case then too.
*/
if( 0==strlen(sqlite3BtreeGetFilename(db->aDb[0].pBt)) || nTrans<=1 ){
if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
|| nTrans<=1
){
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
Btree *pBt = db->aDb[i].pBt;
if( pBt ){
@ -1369,8 +1371,8 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
needSync = 1;
}
rc = sqlite3OsWrite(pMaster, zFile, (int)strlen(zFile)+1, offset);
offset += strlen(zFile)+1;
rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
offset += sqlite3Strlen30(zFile)+1;
if( rc!=SQLITE_OK ){
sqlite3OsCloseFree(pMaster);
sqlite3OsDelete(pVfs, zMaster, 0);

View File

@ -15,7 +15,7 @@
** only within the VDBE. Interface routines refer to a Mem using the
** name sqlite_value
**
** $Id: vdbemem.c,v 1.132 2008/12/10 18:03:47 drh Exp $
** $Id: vdbemem.c,v 1.133 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -228,7 +228,7 @@ int sqlite3VdbeMemStringify(Mem *pMem, int enc){
assert( fg & MEM_Real );
sqlite3_snprintf(nByte, pMem->z, "%!.15g", pMem->r);
}
pMem->n = (int)strlen(pMem->z);
pMem->n = sqlite3Strlen30(pMem->z);
pMem->enc = SQLITE_UTF8;
pMem->flags |= MEM_Str|MEM_Term;
sqlite3VdbeChangeEncoding(pMem, enc);
@ -898,11 +898,11 @@ void sqlite3VdbeMemSanity(Mem *pMem){
/* If the string is UTF-8 encoded and nul terminated, then pMem->n
** must be the length of the string. (Later:) If the database file
** has been corrupted, '\000' characters might have been inserted
** into the middle of the string. In that case, the strlen() might
** be less.
** into the middle of the string. In that case, the sqlite3Strlen30()
** might be less.
*/
if( pMem->enc==SQLITE_UTF8 && (flags & MEM_Term) ){
assert( strlen(pMem->z)<=pMem->n );
assert( sqlite3Strlen30(pMem->z)<=pMem->n );
assert( pMem->z[pMem->n]==0 );
}
}

View File

@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to help implement virtual tables.
**
** $Id: vtab.c,v 1.80 2008/12/10 18:03:47 drh Exp $
** $Id: vtab.c,v 1.81 2008/12/10 19:26:24 drh Exp $
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE
#include "sqliteInt.h"
@ -27,7 +27,7 @@ static int createModule(
Module *pMod;
sqlite3_mutex_enter(db->mutex);
nName = (int)strlen(zName);
nName = sqlite3Strlen30(zName);
pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1);
if( pMod ){
Module *pDel;
@ -241,7 +241,8 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
db = pParse->db;
if( pTab->nModuleArg<1 ) return;
zModule = pTab->azModuleArg[0];
pMod = (Module*)sqlite3HashFind(&db->aModule, zModule, (int)strlen(zModule));
pMod = (Module*)sqlite3HashFind(&db->aModule, zModule,
sqlite3Strlen30(zModule));
pTab->pMod = pMod;
/* If the CREATE VIRTUAL TABLE statement is being entered for the
@ -289,7 +290,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
zWhere = sqlite3MPrintf(db, "name='%q'", pTab->zName);
sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC);
sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
pTab->zName, (int)strlen(pTab->zName) + 1);
pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
}
/* If we are rereading the sqlite_master table create the in-memory
@ -300,7 +301,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
Table *pOld;
Schema *pSchema = pTab->pSchema;
const char *zName = pTab->zName;
int nName = (int)strlen(zName) + 1;
int nName = sqlite3Strlen30(zName) + 1;
pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab);
if( pOld ){
db->mallocFailed = 1;
@ -405,7 +406,7 @@ static int vtabCallConstructor(
int nType;
int i = 0;
if( !zType ) continue;
nType = (int)strlen(zType);
nType = sqlite3Strlen30(zType);
if( sqlite3StrNICmp("hidden", zType, 6) || (zType[6] && zType[6]!=' ') ){
for(i=0; i<nType; i++){
if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
@ -804,13 +805,14 @@ FuncDef *sqlite3VtabOverloadFunction(
/* Create a new ephemeral function definition for the overloaded
** function */
pNew = sqlite3DbMallocZero(db, sizeof(*pNew) + (int)strlen(pDef->zName) );
pNew = sqlite3DbMallocZero(db, sizeof(*pNew)
+ sqlite3Strlen30(pDef->zName) );
if( pNew==0 ){
return pDef;
}
*pNew = *pDef;
pNew->zName = (char *)&pNew[1];
memcpy(pNew->zName, pDef->zName, strlen(pDef->zName)+1);
memcpy(pNew->zName, pDef->zName, sqlite3Strlen30(pDef->zName)+1);
pNew->xFunc = xFunc;
pNew->pUserData = pArg;
pNew->flags |= SQLITE_FUNC_EPHEM;

View File

@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.335 2008/12/09 01:32:03 drh Exp $
** $Id: where.c,v 1.336 2008/12/10 19:26:24 drh Exp $
*/
#include "sqliteInt.h"
@ -2801,7 +2801,7 @@ WhereInfo *sqlite3WhereBegin(
pTabItem = &pTabList->a[pLevel->iFrom];
z = pTabItem->zAlias;
if( z==0 ) z = pTabItem->pTab->zName;
n = strlen(z);
n = sqlite3Strlen30(z);
if( n+nQPlan < sizeof(sqlite3_query_plan)-10 ){
if( pLevel->wsFlags & WHERE_IDX_ONLY ){
memcpy(&sqlite3_query_plan[nQPlan], "{}", 2);
@ -2821,7 +2821,7 @@ WhereInfo *sqlite3WhereBegin(
memcpy(&sqlite3_query_plan[nQPlan], "{} ", 3);
nQPlan += 3;
}else{
n = strlen(pLevel->pIdx->zName);
n = sqlite3Strlen30(pLevel->pIdx->zName);
if( n+nQPlan < sizeof(sqlite3_query_plan)-2 ){
memcpy(&sqlite3_query_plan[nQPlan], pLevel->pIdx->zName, n);
nQPlan += n;