diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 32 | ||||
-rw-r--r-- | src/date.c | 4 | ||||
-rw-r--r-- | src/expr.c | 8 | ||||
-rw-r--r-- | src/func.c | 10 | ||||
-rw-r--r-- | src/main.c | 8 | ||||
-rw-r--r-- | src/pragma.c | 18 | ||||
-rw-r--r-- | src/sqlite.h.in | 8 | ||||
-rw-r--r-- | src/sqliteInt.h | 6 | ||||
-rw-r--r-- | src/test5.c | 4 | ||||
-rw-r--r-- | src/utf.c | 42 | ||||
-rw-r--r-- | src/util.c | 14 | ||||
-rw-r--r-- | src/vdbe.c | 22 | ||||
-rw-r--r-- | src/vdbeapi.c | 18 | ||||
-rw-r--r-- | src/vdbeaux.c | 8 | ||||
-rw-r--r-- | src/vdbemem.c | 26 |
15 files changed, 116 insertions, 112 deletions
diff --git a/src/build.c b/src/build.c index 09aa751b7..5823b2477 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 <ctype.h> @@ -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 e304d70aa..51ffb3410 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 7b4768f9a..4c80f4400 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 <ctype.h> @@ -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 0563351c2..394f7f173 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 <ctype.h> #include <math.h> @@ -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 d3967b9a1..17fdb93f5 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 bc1e313e3..0781957c7 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 <ctype.h> @@ -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 e3dbe2cad..c95d9387d 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 45a4fc283..7cf1a4b28 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 ec1ea0ddb..525716be1 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; i<repeat_count; i++){ if( do_calls ){ @@ -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.18 2004/06/06 12:41:50 danielk1977 Exp $ +** $Id: utf.c,v 1.19 2004/06/12 00:42:35 danielk1977 Exp $ ** ** Notes on UTF-8: ** @@ -100,8 +100,8 @@ static unsigned char UpperToLower[91] = { ** reads a single character from the string and returns the codepoint value ** of the character read. ** -** The value of *pEnc is the string encoding. If *pEnc is TEXT_Utf16le or -** TEXT_Utf16be, and the first character read is a byte-order-mark, then +** The value of *pEnc is the string encoding. If *pEnc is SQLITE_UTF16LE or +** SQLITE_UTF16BE, and the first character read is a byte-order-mark, then ** the value of *pEnc is modified if necessary. In this case the next ** character is read and it's code-point value returned. ** @@ -116,7 +116,7 @@ int sqlite3ReadUniChar(const char *zStr, int *pOffset, u8 *pEnc, int fold){ int ret = 0; switch( *pEnc ){ - case TEXT_Utf8: { + case SQLITE_UTF8: { #if 0 static const int initVal[] = { @@ -184,12 +184,12 @@ int sqlite3ReadUniChar(const char *zStr, int *pOffset, u8 *pEnc, int fold){ break; } - case TEXT_Utf16le: - case TEXT_Utf16be: { + case SQLITE_UTF16LE: + case SQLITE_UTF16BE: { u32 code_point; /* the first code-point in the character */ u32 code_point2; /* the second code-point in the character, if any */ - code_point = READ_16(&zStr[*pOffset], (*pEnc==TEXT_Utf16be)); + code_point = READ_16(&zStr[*pOffset], (*pEnc==SQLITE_UTF16BE)); *pOffset += 2; /* If this is a non-surrogate code-point, just cast it to an int and @@ -211,7 +211,7 @@ int sqlite3ReadUniChar(const char *zStr, int *pOffset, u8 *pEnc, int fold){ ** is not enough data left or the next code-point is not a trailing ** surrogate, return the replacement character. */ - code_point2 = READ_16(&zStr[*pOffset], (*pEnc==TEXT_Utf16be)); + code_point2 = READ_16(&zStr[*pOffset], (*pEnc==SQLITE_UTF16BE)); *pOffset += 2; if( code_point2<0xDC00 || code_point>0xDFFF ){ 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 9755c6f3c..80a69912f 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 <stdarg.h> @@ -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 55a4e7323..57ea4929e 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 ea69e3e67..a3fc2f03f 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 cddef5a64..494ace2c5 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 1c9e09cec..b74c84e59 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 ); } } |