From dc8453fd7acab7acdcbf68c5ef13717e8e8e6587 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Sat, 12 Jun 2004 00:42:34 +0000 Subject: [PATCH] Use the SQLITE_UTF* symbols instead of the old internal TEXT_Utf* symbols. (CVS 1572) FossilOrigin-Name: 9b84f2f488e1d37ba1a4c4cf31490bcbba0f6edd --- manifest | 44 ++++++++++++++++++++++---------------------- manifest.uuid | 2 +- src/build.c | 32 ++++++++++++++++---------------- src/date.c | 4 ++-- src/expr.c | 8 ++++---- src/func.c | 10 +++++----- src/main.c | 8 ++++---- src/pragma.c | 18 +++++++++--------- src/sqlite.h.in | 8 ++++---- src/sqliteInt.h | 6 +++++- src/test5.c | 4 ++-- src/utf.c | 42 +++++++++++++++++++++--------------------- src/util.c | 14 +++++++------- src/vdbe.c | 22 +++++++++++----------- src/vdbeapi.c | 18 +++++++++--------- src/vdbeaux.c | 8 ++++---- src/vdbemem.c | 26 +++++++++++++------------- www/capi3ref.tcl | 8 ++++---- 18 files changed, 143 insertions(+), 139 deletions(-) diff --git a/manifest b/manifest index c594965510..da8027dfd0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\sthe\snew\slocking\sdocument.\s(CVS\s1571) -D 2004-06-11T22:04:31 +C Use\sthe\sSQLITE_UTF*\ssymbols\sinstead\sof\sthe\sold\sinternal\sTEXT_Utf*\ssymbols.\s(CVS\s1572) +D 2004-06-12T00:42:35 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -28,17 +28,17 @@ F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8 F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79 F src/btree.c 281af87aa117de024f5b6c2728a2339cba9ef584 F src/btree.h 589427ac13bb544d298cd99726e2572a6fe4bdaa -F src/build.c b36b62f49aea7d258cb804999dcc8650e4d79464 -F src/date.c 8e6fa3173386fb29fdef012ee08a853c1e9908b2 +F src/build.c 1943d5910d0a9807dd788758c41c5b1900a8da78 +F src/date.c 2d193dbe7ca0d68a81be0ed64fb455b61ceb420d F src/delete.c 911221aadb35d610c84fadb32e71c52990827e58 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 -F src/expr.c 97f3dd76c778a191834ea75d0cddeb82bba70f8b -F src/func.c 91a21c9598b38b8122f745e6ac5cda4ce9f2cfa9 +F src/expr.c 03ab3de3897a89c4b4fce4438566e8fef1d973f7 +F src/func.c a58fef26514e26f49312785d2fde370e3a8a85a4 F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f -F src/main.c 9f20ae4870fc0c0c6c7815316b9f77b4a5ad4e8f +F src/main.c 59b662fab26dd6f39224971755836f328b426cf3 F src/md5.c 4302e84ae516c616bb079c4e6d038c0addb33481 F src/os.h 23c69c5084e71b5fe199ff1c4e35a4aded0f1380 F src/os_common.h 6393ac67a3a7b4aea19ff17529980ecf77eb2348 @@ -51,32 +51,32 @@ F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c F src/pager.c 94ecf938607847e21fb794d2841c9a7f05e2ddb7 F src/pager.h ca8f293e1d623a7c628a1c5e0c6cf43d5bbb80bf F src/parse.y 097438674976355a10cf177bd97326c548820b86 -F src/pragma.c 0bc3adea28df802074996bec067d506d55d28f84 +F src/pragma.c e288bd122d3ca41ec2032475abde1ff5fa3095f4 F src/printf.c 63b15f1ea9fe3daa066bb7430fd20d4a2d717dc8 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c d29488f86e61e0d45dff318e1f04ba6a7e5782d0 F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469 -F src/sqlite.h.in 56c53344a6fbd76328d641d9ddab90d4e4ba9129 -F src/sqliteInt.h 625faf4c9ce2f99b9c85a2bca5c4e73736c30262 +F src/sqlite.h.in 33179b721472c6e2616b7c95f77a0b5b98d30d5a +F src/sqliteInt.h c49c1841842973354bab645d705fdcd8c4b09006 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/tclsqlite.c e974c0b2479ed37334aeb268de331e0a1b21b5a8 F src/test1.c 5f5c0773df1091cc02ddf6608a8f6e0c65940a56 F src/test2.c 05f810c90cf6262d5f352860e87d41a3f34207f9 F src/test3.c beafd0ccf7b9ae784744be1b1e66ffe8f64c25da F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2 -F src/test5.c 862784cd7a68e7d36f00287aac6e413ca996eaf8 +F src/test5.c 13ac1db35b03acbc197ceb245fe862da5ebf2369 F src/tokenize.c 183c5d7da11affab5d70d903d33409c8c0ce6c5b F src/trigger.c d1a4d7a59b34c811bf6070d64d0497baa0140dcf F src/update.c 168b6d523087ca4545b74ec9f3102b1f3c6b1e38 -F src/utf.c c2c8e445bfea724f3502609d6389fe66651f02ab -F src/util.c e8629f04d920ae968fced709dc7a3a2c62b65ac4 +F src/utf.c e16737b3fc4201bf7ce9bd8ced5250596aa31b76 +F src/util.c 90375fa253137562d536ccdd40b297f0fd7413fc F src/vacuum.c b921eb778842592e1fb48a9d4cef7e861103878f -F src/vdbe.c 56a97efecedecff984599763552a96cacce86319 +F src/vdbe.c 73b2c3d0de81a97f7a0d210c9374f4ba6a17a20c F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde F src/vdbeInt.h 57b7001bc18de348f2180c5fa8a85b687592a19b -F src/vdbeapi.c bcf5821ed09070d586898374b905861c4dd73d0b -F src/vdbeaux.c 117d0d0a3178c203a0093d6fd7c26b69c34e9ed5 -F src/vdbemem.c 6407b5dcd6cae43ee1342d49bcd574f0f23f5beb +F src/vdbeapi.c d7803664ea8bacc109ddb4b96ce8c5785ff60138 +F src/vdbeaux.c fefea411bd41ac46fada191d017a414817f7d86b +F src/vdbemem.c 26cd5419a9c9e7a8959618376f04afdb433b77a3 F src/where.c dda77afaa593cd54e5955ec433076de18faf62f6 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/attach.test aed659e52635662bcd5069599aaca823533edf5a @@ -194,7 +194,7 @@ F www/arch2.gif 49c6bb36160f03ca2b89eaa5bfb1f560c7d68ee7 F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0 F www/c_interface.tcl 2176519fc2bd2d2cf6fe74fd806fc2d8362de2c8 F www/capi3.tcl a940c5ca0b0ebafd5acfe2ceca5a388bd8cfb468 -F www/capi3ref.tcl 2cb0861c5219c6e44298c217a6c904464b4403bc +F www/capi3ref.tcl 7a6e81eebe20b960aed02cb33e369b3645acceec F www/changes.tcl cbe942607b2b9e5dc995395f37042dbb5a629c7f F www/common.tcl f786e6be86fb2627ceb30e770e9efa83b9c67a3a F www/conflict.tcl fb8a2ba83746c7fdfd9e52fa7f6aaf5c422b8246 @@ -223,7 +223,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 13cf1ba8256bf8cee0195dbaeac71a20cd2c2fc2 -R a74bbada06c34f6b3745d14293026d8d -U drh -Z 5456fa4d6b2f147027153ff7013c301f +P 022075517cc0edc5f21de4b92ef188bda2034c98 +R abf75eaed31f2acb34d4cd05657f47f8 +U danielk1977 +Z d06de6886101bf9e57ad7761153b77ce diff --git a/manifest.uuid b/manifest.uuid index 21652c9517..7fefd055e3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -022075517cc0edc5f21de4b92ef188bda2034c98 \ No newline at end of file +9b84f2f488e1d37ba1a4c4cf31490bcbba0f6edd \ No newline at end of file diff --git a/src/build.c b/src/build.c index 09aa751b7d..5823b24774 100644 --- a/src/build.c +++ b/src/build.c @@ -23,7 +23,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.216 2004/06/10 14:01:08 danielk1977 Exp $ +** $Id: build.c,v 1.217 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -879,11 +879,11 @@ static CollSeq * findCollSeqEntry( pColl = sqliteMalloc( 3*sizeof(*pColl) + nName + 1 ); if( pColl ){ pColl[0].zName = (char*)&pColl[3]; - pColl[0].enc = TEXT_Utf8; + pColl[0].enc = SQLITE_UTF8; pColl[1].zName = (char*)&pColl[3]; - pColl[1].enc = TEXT_Utf16le; + pColl[1].enc = SQLITE_UTF16LE; pColl[2].zName = (char*)&pColl[3]; - pColl[2].enc = TEXT_Utf16be; + pColl[2].enc = SQLITE_UTF16BE; memcpy(pColl[0].zName, zName, nName); pColl[0].zName[nName] = 0; sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl); @@ -909,12 +909,12 @@ CollSeq *sqlite3FindCollSeq( ){ CollSeq *pColl = findCollSeqEntry(db, zName, nName, create); if( pColl ) switch( enc ){ - case TEXT_Utf8: + case SQLITE_UTF8: break; - case TEXT_Utf16le: + case SQLITE_UTF16LE: pColl = &pColl[1]; break; - case TEXT_Utf16be: + case SQLITE_UTF16BE: pColl = &pColl[2]; break; default: @@ -957,27 +957,27 @@ static int synthCollSeq(Parse *pParse, CollSeq *pColl){ char *z = pColl->zName; int n = strlen(z); switch( pParse->db->enc ){ - case TEXT_Utf16le: - pColl2 = sqlite3FindCollSeq(pParse->db, TEXT_Utf16be, z, n, 0); + case SQLITE_UTF16LE: + pColl2 = sqlite3FindCollSeq(pParse->db, SQLITE_UTF16BE, z, n, 0); assert( pColl2 ); if( pColl2->xCmp ) break; - pColl2 = sqlite3FindCollSeq(pParse->db, TEXT_Utf8, z, n, 0); + pColl2 = sqlite3FindCollSeq(pParse->db, SQLITE_UTF8, z, n, 0); assert( pColl2 ); break; - case TEXT_Utf16be: - pColl2 = sqlite3FindCollSeq(pParse->db,TEXT_Utf16le, z, n, 0); + case SQLITE_UTF16BE: + pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF16LE, z, n, 0); assert( pColl2 ); if( pColl2->xCmp ) break; - pColl2 = sqlite3FindCollSeq(pParse->db,TEXT_Utf8, z, n, 0); + pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF8, z, n, 0); assert( pColl2 ); break; - case TEXT_Utf8: - pColl2 = sqlite3FindCollSeq(pParse->db,TEXT_Utf16be, z, n, 0); + case SQLITE_UTF8: + pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF16BE, z, n, 0); assert( pColl2 ); if( pColl2->xCmp ) break; - pColl2 = sqlite3FindCollSeq(pParse->db,TEXT_Utf16le, z, n, 0); + pColl2 = sqlite3FindCollSeq(pParse->db,SQLITE_UTF16LE, z, n, 0); assert( pColl2 ); break; } diff --git a/src/date.c b/src/date.c index e304d70aaa..51ffb3410d 100644 --- a/src/date.c +++ b/src/date.c @@ -16,7 +16,7 @@ ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: date.c,v 1.27 2004/05/31 18:51:58 drh Exp $ +** $Id: date.c,v 1.28 2004/06/12 00:42:35 danielk1977 Exp $ ** ** NOTES: ** @@ -321,7 +321,7 @@ static int parseDateOrTime(const char *zDate, DateTime *p){ return 0; } return 1; - }else if( sqlite3IsNumber(zDate, 0, TEXT_Utf8) ){ + }else if( sqlite3IsNumber(zDate, 0, SQLITE_UTF8) ){ p->rJD = sqlite3AtoF(zDate, 0); p->validJD = 1; return 0; diff --git a/src/expr.c b/src/expr.c index 7b4768f9a4..4c80f4400f 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.139 2004/06/11 10:51:27 danielk1977 Exp $ +** $Id: expr.c,v 1.140 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -1012,7 +1012,7 @@ int sqlite3ExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){ int nId; /* Number of characters in function name */ const char *zId; /* The function name. */ FuncDef *pDef; - int iPrefEnc = (pParse->db->enc==TEXT_Utf8)?0:1; + int iPrefEnc = (pParse->db->enc==SQLITE_UTF8)?0:1; getFunctionName(pExpr, &zId, &nId); pDef = sqlite3FindFunction(pParse->db, zId, nId, n, iPrefEnc, 0); @@ -1280,7 +1280,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){ const char *zId; int p2 = 0; int i; - int iPrefEnc = (pParse->db->enc==TEXT_Utf8)?0:1; + int iPrefEnc = (pParse->db->enc==SQLITE_UTF8)?0:1; CollSeq *pColl = 0; getFunctionName(pExpr, &zId, &nId); pDef = sqlite3FindFunction(pParse->db, zId, nId, nExpr, iPrefEnc, 0); @@ -1724,7 +1724,7 @@ int sqlite3ExprAnalyzeAggregates(Parse *pParse, Expr *pExpr){ } } if( i>=pParse->nAgg ){ - int iPrefEnc = (pParse->db->enc==TEXT_Utf8)?0:1; + int iPrefEnc = (pParse->db->enc==SQLITE_UTF8)?0:1; i = appendAggInfo(pParse); if( i<0 ) return 1; pParse->aAgg[i].isAgg = 1; diff --git a/src/func.c b/src/func.c index 0563351c23..394f7f173e 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.66 2004/06/11 10:51:32 danielk1977 Exp $ +** $Id: func.c,v 1.67 2004/06/12 00:42:35 danielk1977 Exp $ */ #include #include @@ -397,7 +397,7 @@ LikePattern *compileLike(sqlite3_value *pPattern, u8 enc){ int offset = 0; const char *zLike; - if( enc==TEXT_Utf8 ){ + if( enc==SQLITE_UTF8 ){ zLike = sqlite3_value_text(pPattern); n = sqlite3_value_bytes(pPattern) + 1; }else{ @@ -488,11 +488,11 @@ static void likeFunc( /* If the user-data pointer is NULL, use UTF-8. Otherwise UTF-16. */ if( sqlite3_user_data(context) ){ - enc = TEXT_Utf16; + enc = SQLITE_UTF16NATIVE; zString = (const unsigned char *)sqlite3_value_text16(argv[1]); assert(0); }else{ - enc = TEXT_Utf8; + enc = SQLITE_UTF8; zString = sqlite3_value_text(argv[1]); } @@ -509,7 +509,7 @@ static void likeFunc( pState = aState; do { - if( enc==TEXT_Utf8 ){ + if( enc==SQLITE_UTF8 ){ c = zString[offset++]; if( c&0x80 ){ offset--; diff --git a/src/main.c b/src/main.c index d3967b9a16..17fdb93f51 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.215 2004/06/11 10:51:32 danielk1977 Exp $ +** $Id: main.c,v 1.216 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -223,14 +223,14 @@ static int sqlite3InitOne(sqlite *db, int iDb, char **pzErrMsg){ ** meta[1] File format of schema layer. ** meta[2] Size of the page cache. ** meta[3] Synchronous setting. 1:off, 2:normal, 3:full - ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16 LE 3:UTF-16 BE + ** meta[4] Db text encoding. 1:UTF-8 3:UTF-16 LE 4:UTF-16 BE ** meta[5] Pragma temp_store value. See comments on BtreeFactory ** meta[6] ** meta[7] ** meta[8] ** meta[9] ** - ** Note: The hash defined TEXT_Utf* symbols in sqliteInt.h correspond to + ** Note: The hash defined SQLITE_UTF* symbols in sqliteInt.h correspond to ** the possible values of meta[4]. */ if( rc==SQLITE_OK ){ @@ -1054,7 +1054,7 @@ static int openDatabase( db->magic = SQLITE_MAGIC_BUSY; db->nDb = 2; db->aDb = db->aDbStatic; - db->enc = TEXT_Utf8; + db->enc = SQLITE_UTF8; db->autoCommit = 1; /* db->flags |= SQLITE_ShortColNames; */ sqlite3HashInit(&db->aFunc, SQLITE_HASH_STRING, 0); diff --git a/src/pragma.c b/src/pragma.c index bc1e313e33..0781957c7a 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.42 2004/06/10 10:50:25 danielk1977 Exp $ +** $Id: pragma.c,v 1.43 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -769,14 +769,14 @@ void sqlite3Pragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){ char *zName; u8 enc; } encnames[] = { - { "UTF-8", TEXT_Utf8 }, - { "UTF-16le", TEXT_Utf16le }, - { "UTF-16be", TEXT_Utf16be }, - { "UTF-16", TEXT_Utf16 }, - { "UTF8", TEXT_Utf8 }, - { "UTF16le", TEXT_Utf16le }, - { "UTF16be", TEXT_Utf16be }, - { "UTF16", TEXT_Utf16 }, + { "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 }, { 0, 0 } }; struct EncName *pEnc; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e3dbe2cad5..c95d9387dc 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -12,7 +12,7 @@ ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.98 2004/06/11 17:48:03 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.99 2004/06/12 00:42:35 danielk1977 Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ @@ -968,9 +968,9 @@ void sqlite3_result_value(sqlite3_context*, sqlite3_value*); ** sqlite3_create_collation and sqlite3_create_function. */ #define SQLITE_UTF8 1 -#define SQLITE_UTF16 2 /* Use native byte order */ -#define SQLITE_UTF16LE 3 -#define SQLITE_UTF16BE 4 +#define SQLITE_UTF16LE 2 +#define SQLITE_UTF16BE 3 +#define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 45a4fc283a..7cf1a4b282 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.282 2004/06/11 10:51:35 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.283 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "config.h" #include "sqlite3.h" @@ -320,6 +320,7 @@ struct Db { #define DB_SchemaLoaded 0x0004 /* The schema has been loaded */ #define DB_UnresetViews 0x0008 /* Some views have defined column names */ +#if 0 /* ** Possible values for the Db.textEnc field. */ @@ -327,6 +328,9 @@ struct Db { #define TEXT_Utf16le 2 #define TEXT_Utf16be 3 #define TEXT_Utf16 (SQLITE_BIGENDIAN?TEXT_Utf16be:TEXT_Utf16le) +#endif + +#define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) /* ** An instance of the following structure is used to store the busy-handler diff --git a/src/test5.c b/src/test5.c index ec1ea0ddb4..525716be19 100644 --- a/src/test5.c +++ b/src/test5.c @@ -15,7 +15,7 @@ ** is used for testing the SQLite routines for converting between ** the various supported unicode encodings. ** -** $Id: test5.c,v 1.9 2004/06/09 09:55:19 danielk1977 Exp $ +** $Id: test5.c,v 1.10 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -270,7 +270,7 @@ static int test_value_overhead( val.flags = MEM_Str|MEM_Term|MEM_Static; val.z = "hello world"; val.type = SQLITE_TEXT; - val.enc = TEXT_Utf8; + val.enc = SQLITE_UTF8; for(i=0; i0xDFFF ){ return (int)0xFFFD; @@ -257,7 +257,7 @@ static int readUtf16Bom(UtfString *pStr, int big_endian){ u8 bom = sqlite3UtfReadBom(pStr->pZ, 2); if( bom ){ pStr->c += 2; - return (bom==TEXT_Utf16le)?0:1; + return (bom==SQLITE_UTF16LE)?0:1; } } @@ -267,8 +267,8 @@ static int readUtf16Bom(UtfString *pStr, int big_endian){ /* ** zData is a UTF-16 encoded string, nData bytes in length. This routine ** checks if there is a byte-order mark at the start of zData. If no -** byte order mark is found 0 is returned. Otherwise TEXT_Utf16be or -** TEXT_Utf16le is returned, depending on whether The BOM indicates that +** byte order mark is found 0 is returned. Otherwise SQLITE_UTF16BE or +** SQLITE_UTF16LE is returned, depending on whether The BOM indicates that ** the text is big-endian or little-endian. */ u8 sqlite3UtfReadBom(const void *zData, int nData){ @@ -276,10 +276,10 @@ u8 sqlite3UtfReadBom(const void *zData, int nData){ u8 b1 = *(u8 *)zData; u8 b2 = *(((u8 *)zData) + 1); if( b1==0xFE && b2==0xFF ){ - return TEXT_Utf16be; + return SQLITE_UTF16BE; } if( b1==0xFF && b2==0xFE ){ - return TEXT_Utf16le; + return SQLITE_UTF16LE; } } return 0; @@ -292,7 +292,7 @@ u8 sqlite3UtfReadBom(const void *zData, int nData){ ** strings, the unicode replacement character U+FFFD may be returned. */ static u32 readUtf8(UtfString *pStr){ - u8 enc = TEXT_Utf8; + u8 enc = SQLITE_UTF8; return sqlite3ReadUniChar(pStr->pZ, &pStr->c, &enc, 0); } @@ -687,15 +687,15 @@ int sqlite3utfTranslate( void **zOut, int *nOut, /* Output string */ u8 enc2 /* Desired encoding of output */ ){ - assert( enc1==TEXT_Utf8 || enc1==TEXT_Utf16le || enc1==TEXT_Utf16be ); - assert( enc2==TEXT_Utf8 || enc2==TEXT_Utf16le || enc2==TEXT_Utf16be ); + assert( enc1==SQLITE_UTF8 || enc1==SQLITE_UTF16LE || enc1==SQLITE_UTF16BE ); + assert( enc2==SQLITE_UTF8 || enc2==SQLITE_UTF16LE || enc2==SQLITE_UTF16BE ); assert( - (enc1==TEXT_Utf8 && (enc2==TEXT_Utf16le || enc2==TEXT_Utf16be)) || - (enc2==TEXT_Utf8 && (enc1==TEXT_Utf16le || enc1==TEXT_Utf16be)) + (enc1==SQLITE_UTF8 && (enc2==SQLITE_UTF16LE || enc2==SQLITE_UTF16BE)) || + (enc2==SQLITE_UTF8 && (enc1==SQLITE_UTF16LE || enc1==SQLITE_UTF16BE)) ); - if( enc1==TEXT_Utf8 ){ - if( enc2==TEXT_Utf16le ){ + if( enc1==SQLITE_UTF8 ){ + if( enc2==SQLITE_UTF16LE ){ *zOut = sqlite3utf8to16le(zData, nData); }else{ *zOut = sqlite3utf8to16be(zData, nData); @@ -703,7 +703,7 @@ int sqlite3utfTranslate( if( !(*zOut) ) return SQLITE_NOMEM; *nOut = sqlite3utf16ByteLen(*zOut, -1); }else{ - *zOut = sqlite3utf16to8(zData, nData, enc1==TEXT_Utf16be); + *zOut = sqlite3utf16to8(zData, nData, enc1==SQLITE_UTF16BE); if( !(*zOut) ) return SQLITE_NOMEM; *nOut = strlen(*zOut); } diff --git a/src/util.c b/src/util.c index 9755c6f3ce..80a69912fe 100644 --- a/src/util.c +++ b/src/util.c @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.100 2004/06/09 14:01:53 drh Exp $ +** $Id: util.c,v 1.101 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -565,8 +565,8 @@ int sqlite3StrNICmp(const char *zLeft, const char *zRight, int N){ ** Am empty string is considered non-numeric. */ int sqlite3IsNumber(const char *z, int *realnum, u8 enc){ - int incr = (enc==TEXT_Utf8?1:2); - if( enc==TEXT_Utf16be ) z++; + int incr = (enc==SQLITE_UTF8?1:2); + if( enc==SQLITE_UTF16LE ) z++; if( *z=='-' || *z=='+' ) z += incr; if( !isdigit(*z) ){ return 0; @@ -767,8 +767,8 @@ int sqlite3Compare(const char *atext, const char *btext){ }else if( btext==0 ){ return 1; } - isNumA = sqlite3IsNumber(atext, 0, TEXT_Utf8); - isNumB = sqlite3IsNumber(btext, 0, TEXT_Utf8); + isNumA = sqlite3IsNumber(atext, 0, SQLITE_UTF8); + isNumB = sqlite3IsNumber(btext, 0, SQLITE_UTF8); if( isNumA ){ if( !isNumB ){ result = -1; @@ -859,8 +859,8 @@ int sqlite3SortCompare(const char *a, const char *b){ res = strcmp(&a[1],&b[1]); if( res ) break; }else{ - isNumA = sqlite3IsNumber(&a[1], 0, TEXT_Utf8); - isNumB = sqlite3IsNumber(&b[1], 0, TEXT_Utf8); + isNumA = sqlite3IsNumber(&a[1], 0, SQLITE_UTF8); + isNumB = sqlite3IsNumber(&b[1], 0, SQLITE_UTF8); if( isNumA ){ double rA, rB; if( !isNumB ){ diff --git a/src/vdbe.c b/src/vdbe.c index 55a4e7323e..57ea4929ec 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -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.365 2004/06/11 13:19:21 danielk1977 Exp $ +** $Id: vdbe.c,v 1.366 2004/06/12 00:42:35 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -702,7 +702,7 @@ case OP_Integer: { pTos->flags = MEM_Str|MEM_Static|MEM_Term; pTos->z = pOp->p3; pTos->n = strlen(pTos->z); - pTos->enc = TEXT_Utf8; + pTos->enc = SQLITE_UTF8; Integerify(pTos, 0); } break; @@ -717,7 +717,7 @@ case OP_Real: { pTos->flags = MEM_Str|MEM_Static|MEM_Term; pTos->z = pOp->p3; pTos->n = strlen(pTos->z); - pTos->enc = TEXT_Utf8; + pTos->enc = SQLITE_UTF8; Realify(pTos, 0); break; } @@ -730,8 +730,8 @@ case OP_Real: { case OP_String8: { pOp->opcode = OP_String; - if( db->enc!=TEXT_Utf8 && pOp->p3 ){ - if( db->enc==TEXT_Utf16le ){ + if( db->enc!=SQLITE_UTF8 && pOp->p3 ){ + if( db->enc==SQLITE_UTF16LE ){ pOp->p3 = sqlite3utf8to16le(pOp->p3, -1); }else{ pOp->p3 = sqlite3utf8to16be(pOp->p3, -1); @@ -753,7 +753,7 @@ case OP_String: { if( pOp->p3 ){ pTos->flags = MEM_Str|MEM_Static|MEM_Term; pTos->z = pOp->p3; - if( db->enc==TEXT_Utf8 ){ + if( db->enc==SQLITE_UTF8 ){ pTos->n = strlen(pTos->z); }else{ pTos->n = sqlite3utf16ByteLen(pTos->z, -1); @@ -1061,7 +1061,7 @@ case OP_Concat: { mSep.z = pOp->p3; mSep.n = strlen(mSep.z); mSep.flags = MEM_Str|MEM_Static|MEM_Term; - mSep.enc = TEXT_Utf8; + mSep.enc = SQLITE_UTF8; sqlite3VdbeChangeEncoding(&mSep, db->enc); }else{ mSep.flags = MEM_Null; @@ -1492,16 +1492,16 @@ case OP_MustBeInt: { pTos->i = i; }else if( pTos->flags & MEM_Str ){ i64 v; - if( sqlite3VdbeChangeEncoding(pTos, TEXT_Utf8) + if( sqlite3VdbeChangeEncoding(pTos, SQLITE_UTF8) || sqlite3VdbeMemNulTerminate(pTos) ){ goto no_mem; } if( !sqlite3atoi64(pTos->z, &v) ){ double r; - if( !sqlite3IsNumber(pTos->z, 0, TEXT_Utf8) ){ + if( !sqlite3IsNumber(pTos->z, 0, db->enc) ){ goto mismatch; } - Realify(pTos, TEXT_Utf8); + Realify(pTos, db->enc); v = (int)pTos->r; r = (double)v; if( r!=pTos->r ){ @@ -3929,7 +3929,7 @@ case OP_IntegrityCk: { pTos->n = strlen(z); pTos->flags = MEM_Str | MEM_Dyn | MEM_Term; } - pTos->enc = TEXT_Utf8; + pTos->enc = SQLITE_UTF8; sqlite3VdbeChangeEncoding(pTos, db->enc); sqliteFree(aRoot); break; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index ea69e3e679..a3fc2f03f8 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -58,10 +58,10 @@ long long int sqlite3_value_int64(sqlite3_value *pVal){ return pVal->i; } const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ - return (const char *)sqlite3ValueText(pVal, TEXT_Utf8); + return (const char *)sqlite3ValueText(pVal, SQLITE_UTF8); } const void *sqlite3_value_text16(sqlite3_value* pVal){ - return sqlite3ValueText(pVal, TEXT_Utf16); + return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); } int sqlite3_value_type(sqlite3_value* pVal){ return pVal->type; @@ -85,11 +85,11 @@ void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ } void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ pCtx->isError = 1; - sqlite3VdbeMemSetStr(&pCtx->s, z, n, TEXT_Utf8, 1); + sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, 1); } void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ pCtx->isError = 1; - sqlite3VdbeMemSetStr(&pCtx->s, z, n, TEXT_Utf16, 1); + sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, 1); } void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal); @@ -106,7 +106,7 @@ void sqlite3_result_text( int n, int eCopy ){ - sqlite3VdbeMemSetStr(&pCtx->s, z, n, TEXT_Utf8, eCopy); + sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, eCopy); } void sqlite3_result_text16( sqlite3_context *pCtx, @@ -114,7 +114,7 @@ void sqlite3_result_text16( int n, int eCopy ){ - sqlite3VdbeMemSetStr(&pCtx->s, z, n, TEXT_Utf16, eCopy); + sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, eCopy); } void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ sqlite3VdbeMemCopy(&pCtx->s, pValue); @@ -474,7 +474,7 @@ int sqlite3_bind_text( return rc; } pVar = &p->apVar[i-1]; - rc = sqlite3VdbeMemSetStr(pVar, zData, nData, TEXT_Utf8, eCopy); + rc = sqlite3VdbeMemSetStr(pVar, zData, nData, SQLITE_UTF8, eCopy); if( rc ){ return rc; } @@ -499,7 +499,7 @@ int sqlite3_bind_text16( pVar = &p->apVar[i-1]; /* There may or may not be a byte order mark at the start of the UTF-16. - ** Either way set 'txt_enc' to the TEXT_Utf16* value indicating the + ** Either way set 'txt_enc' to the SQLITE_UTF16* value indicating the ** actual byte order used by this string. If the string does happen ** to contain a BOM, then move zData so that it points to the first ** byte after the BOM. @@ -509,7 +509,7 @@ int sqlite3_bind_text16( zData = (void *)(((u8 *)zData) + 2); nData -= 2; }else{ - txt_enc = SQLITE_BIGENDIAN?TEXT_Utf16be:TEXT_Utf16le; + txt_enc = SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE; } rc = sqlite3VdbeMemSetStr(pVar, zData, nData, txt_enc, eCopy); if( rc ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index cddef5a64e..494ace2c53 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -579,7 +579,7 @@ int sqlite3VdbeList( pMem->z = sqlite3OpcodeNames[pOp->opcode]; /* Opcode */ pMem->n = strlen(pMem->z); pMem->type = SQLITE_TEXT; - pMem->enc = TEXT_Utf8; + pMem->enc = SQLITE_UTF8; pMem++; pMem->flags = MEM_Int; @@ -595,7 +595,7 @@ int sqlite3VdbeList( pMem->flags = MEM_Short|MEM_Str|MEM_Term; /* P3 */ pMem->z = displayP3(pOp, pMem->zShort, sizeof(pMem->zShort)); pMem->type = SQLITE_TEXT; - pMem->enc = TEXT_Utf8; + pMem->enc = SQLITE_UTF8; p->nResColumn = 5; p->pTos = pMem; @@ -1008,9 +1008,9 @@ int sqlite3VdbeSetColName(Vdbe *p, int idx, const char *zName, int N){ pColName = &(p->aColName[idx]); if( N==0 ){ - rc = sqlite3VdbeMemSetStr(pColName, zName, -1, TEXT_Utf8, 1); + rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, 1); }else{ - rc = sqlite3VdbeMemSetStr(pColName, zName, N, TEXT_Utf8, N>0); + rc = sqlite3VdbeMemSetStr(pColName, zName, N, SQLITE_UTF8, N>0); } if( rc==SQLITE_OK && N==P3_DYNAMIC ){ pColName->flags = (pColName->flags&(~MEM_Static))|MEM_Dyn; diff --git a/src/vdbemem.c b/src/vdbemem.c index 1c9e09cec2..b74c84e593 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -41,7 +41,7 @@ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ return SQLITE_OK; } - if( pMem->enc==TEXT_Utf8 || desiredEnc==TEXT_Utf8 ){ + if( pMem->enc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF8 ){ /* If the current encoding does not match the desired encoding, then ** we will need to do some translation between encodings. */ @@ -191,7 +191,7 @@ int sqlite3VdbeMemStringify(Mem *pMem, int enc){ } pMem->n = strlen(z); pMem->z = z; - pMem->enc = TEXT_Utf8; + pMem->enc = SQLITE_UTF8; pMem->flags |= MEM_Str | MEM_Short | MEM_Term; sqlite3VdbeChangeEncoding(pMem, enc); } @@ -219,7 +219,7 @@ int sqlite3VdbeMemIntegerify(Mem *pMem){ }else if( flags & MEM_Real ){ pMem->i = (i64)pMem->r; }else if( flags & (MEM_Str|MEM_Blob) ){ - if( sqlite3VdbeChangeEncoding(pMem, TEXT_Utf8) + if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) || sqlite3VdbeMemNulTerminate(pMem) ){ return SQLITE_NOMEM; } @@ -243,7 +243,7 @@ int sqlite3VdbeMemRealify(Mem *pMem){ }else if( (pMem->flags & MEM_Int) && pMem->type!=SQLITE_TEXT ){ pMem->r = pMem->i; }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ - if( sqlite3VdbeChangeEncoding(pMem, TEXT_Utf8) + if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8) || sqlite3VdbeMemNulTerminate(pMem) ){ return SQLITE_NOMEM; } @@ -332,7 +332,7 @@ int sqlite3VdbeMemSetStr( pMem->flags |= MEM_Blob; break; - case TEXT_Utf8: + case SQLITE_UTF8: pMem->flags |= MEM_Str; if( n<0 ){ pMem->n = strlen(z); @@ -340,8 +340,8 @@ int sqlite3VdbeMemSetStr( } break; - case TEXT_Utf16le: - case TEXT_Utf16be: + case SQLITE_UTF16LE: + case SQLITE_UTF16BE: pMem->flags |= MEM_Str; if( n<0 ){ pMem->n = sqlite3utf16ByteLen(z,-1); @@ -433,8 +433,8 @@ int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){ } assert( pMem1->enc==pMem2->enc ); - assert( pMem1->enc==TEXT_Utf8 || - pMem1->enc==TEXT_Utf16le || pMem1->enc==TEXT_Utf16be ); + assert( pMem1->enc==SQLITE_UTF8 || + pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE ); /* FIX ME: This may fail if the collation sequence is deleted after ** this vdbe program is compiled. We cannot just use BINARY in this @@ -554,14 +554,14 @@ void sqlite3VdbeMemSanity(Mem *pMem, u8 db_enc){ assert( (pMem->flags & MEM_Short)!=0 || pMem->z!=pMem->zShort ); if( (flags & MEM_Str) ){ - assert( pMem->enc==TEXT_Utf8 || - pMem->enc==TEXT_Utf16le || - pMem->enc==TEXT_Utf16be + assert( pMem->enc==SQLITE_UTF8 || + pMem->enc==SQLITE_UTF16BE || + pMem->enc==SQLITE_UTF16LE ); /* If the string is UTF-8 encoded and nul terminated, then pMem->n ** must be the length of the string. */ - if( pMem->enc==TEXT_Utf8 && (flags & MEM_Term) ){ + if( pMem->enc==SQLITE_UTF8 && (flags & MEM_Term) ){ assert( strlen(pMem->z)==pMem->n ); } } diff --git a/www/capi3ref.tcl b/www/capi3ref.tcl index 9c71f549c4..45542921a2 100644 --- a/www/capi3ref.tcl +++ b/www/capi3ref.tcl @@ -1,4 +1,4 @@ -set rcsid {$Id: capi3ref.tcl,v 1.2 2004/06/11 17:48:04 drh Exp $} +set rcsid {$Id: capi3ref.tcl,v 1.3 2004/06/12 00:42:36 danielk1977 Exp $} source common.tcl header {C/C++ Interface For SQLite Version 3} puts { @@ -330,9 +330,9 @@ int sqlite3_create_collation16( int(*xCompare)(void*,int,const void*,int,const void*) ); #define SQLITE_UTF8 1 -#define SQLITE_UTF16 2 -#define SQLITE_UTF16BE 3 -#define SQLITE_UTF16LE 4 +#define SQLITE_UTF16BE 2 +#define SQLITE_UTF16LE 3 +#define SQLITE_UTF16 4 } { These two functions are used to add new collation sequences to the sqlite3 handle specified as the first argument.